control media playback
parent
abaa961d3a
commit
0f1a12d28f
@ -0,0 +1,112 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class ActivityManageActionControlMedia extends Activity
|
||||
{
|
||||
RadioButton rbMediaPlayPause, rbMediaPlay, rbMediaPause, rbMediaStop, rbMediaPrevious, rbMediaNext;
|
||||
Button bSaveControlMediaAction;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_control_media);
|
||||
|
||||
rbMediaPlayPause = (RadioButton)findViewById(R.id.rbMediaPlayPause);
|
||||
rbMediaPlay = (RadioButton)findViewById(R.id.rbMediaPlay);
|
||||
rbMediaPause = (RadioButton)findViewById(R.id.rbMediaPause);
|
||||
rbMediaStop = (RadioButton)findViewById(R.id.rbMediaStop);
|
||||
rbMediaPrevious = (RadioButton)findViewById(R.id.rbMediaPrevious);
|
||||
rbMediaNext = (RadioButton)findViewById(R.id.rbMediaNext);
|
||||
|
||||
bSaveControlMediaAction = (Button)findViewById(R.id.bSaveControlMediaAction);
|
||||
|
||||
bSaveControlMediaAction.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
if(checkInput())
|
||||
{
|
||||
Intent answer = new Intent();
|
||||
|
||||
if(rbMediaPlayPause.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "0");
|
||||
else if(rbMediaPlay.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "1");
|
||||
else if(rbMediaPause.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "2");
|
||||
else if(rbMediaStop.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "3");
|
||||
else if(rbMediaPrevious.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "4");
|
||||
else if(rbMediaNext.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "5");
|
||||
|
||||
setResult(RESULT_OK, answer);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Intent input = getIntent();
|
||||
|
||||
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
|
||||
{
|
||||
String existing = input.getStringExtra(ActivityManageRule.intentNameActionParameter2);
|
||||
switch (existing)
|
||||
{
|
||||
case "0":
|
||||
rbMediaPlayPause.setChecked(true);
|
||||
break;
|
||||
case "1":
|
||||
rbMediaPlay.setChecked(true);
|
||||
break;
|
||||
case "2":
|
||||
rbMediaPause.setChecked(true);
|
||||
break;
|
||||
case "3":
|
||||
rbMediaStop.setChecked(true);
|
||||
break;
|
||||
case "4":
|
||||
rbMediaPrevious.setChecked(true);
|
||||
break;
|
||||
case "5":
|
||||
rbMediaNext.setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean checkInput()
|
||||
{
|
||||
if(
|
||||
!rbMediaPlayPause.isChecked()
|
||||
&&
|
||||
!rbMediaPlay.isChecked()
|
||||
&&
|
||||
!rbMediaPause.isChecked()
|
||||
&&
|
||||
!rbMediaStop.isChecked()
|
||||
&&
|
||||
!rbMediaPrevious.isChecked()
|
||||
&&
|
||||
!rbMediaNext.isChecked()
|
||||
)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionControlMedia.this, getResources().getString(R.string.pleaseSelectActionValue), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/default_margin" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_span="2"
|
||||
android:textSize="25dp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/actionMediaControl" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/actionMediaControlNotice" />
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPlayPause"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/playPause" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPlay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/play" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPause"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pause" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaStop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/stop" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPrevious"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/previous" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaNext"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/next" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveControlMediaAction"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -1,6 +1,7 @@
|
||||
* New trigger: screen state (on/off)
|
||||
* New action: Create notification
|
||||
* New action: Close notification(s)
|
||||
* New action: Control media playback
|
||||
* Fixed: Translation bug in dutch variables text
|
||||
* Fixed: Variables were not replaced when sending text messages
|
||||
* Fixed: Service wouldn't always start after device is powered on
|
||||
* Fixed: Service wouldn't always start after device has been powered on
|
Loading…
Reference in New Issue