aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-07-22 19:16:52 -0700
committerScott Jackson <daneren2005@gmail.com>2014-07-22 19:16:52 -0700
commita6bdf0783d252174d7fe8ed9b9ab4e85d64dee3a (patch)
tree10c6335005f89c8aba43c4b4ba26110706bd716c
parent856e2829ea93294447bf47a215b8db2c24708142 (diff)
downloaddsub-a6bdf0783d252174d7fe8ed9b9ab4e85d64dee3a.tar.gz
dsub-a6bdf0783d252174d7fe8ed9b9ab4e85d64dee3a.tar.bz2
dsub-a6bdf0783d252174d7fe8ed9b9ab4e85d64dee3a.zip
More work on adding a custom tasker plugin
-rw-r--r--res/menu/tasker_configuration.xml16
-rw-r--r--res/values/strings.xml3
-rw-r--r--src/github/daneren2005/dsub/activity/EditPlayActionActivity.java43
3 files changed, 58 insertions, 4 deletions
diff --git a/res/menu/tasker_configuration.xml b/res/menu/tasker_configuration.xml
new file mode 100644
index 00000000..07613640
--- /dev/null
+++ b/res/menu/tasker_configuration.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:compat="http://schemas.android.com/apk/res-auto">
+
+ <item
+ android:id="@+id/menu_cancel"
+ android:icon="?attr/remove"
+ android:title="@string/common.cancel"
+ compat:showAsAction="always|withText"/>
+
+ <item
+ android:id="@+id/menu_accept"
+ android:icon="?attr/save"
+ android:title="@string/common.ok"
+ compat:showAsAction="always|withText"/>
+</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1de825ea..5d5f832e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -531,7 +531,8 @@
<string name="changelog_version_format" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">Version <xliff:g id="version_name">%s</xliff:g></string>
<string name="tasker.start_playing">Start playing DSub</string>
- <string name="tasker.start_playing_title">Tasker -> Start Playing DSub</string>
+ <string name="tasker.start_playing_shuffled">Start playing DSub in Shuffle Mode</string>
+ <string name="tasker.start_playing_title">Tasker -> Start DSub</string>
<string name="tasker.edit_shuffle_mode">Start in shuffle mode: </string>
<plurals name="select_album_n_songs">
diff --git a/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java b/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java
index 3ae62f5f..b7f9de94 100644
--- a/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java
+++ b/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java
@@ -18,29 +18,66 @@ package github.daneren2005.dsub.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.support.v4.widget.DrawerLayout;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.widget.CheckBox;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.util.Constants;
public class EditPlayActionActivity extends SubsonicActivity {
+ private CheckBox checkBox;
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setTitle(R.string.tasker_start_playing_title);
setContentView(R.layout.edit_play_action);
+
+ checkBox = (CheckBox) findViewById(R.id.edit_shuffle_checkbox);
+ if(getIntent().getBundleExtra(Constants.TASKER_EXTRA_BUNDLE) != null && getIntent().getBundleExtra(Constants.TASKER_EXTRA_BUNDLE).getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE)) {
+ checkBox.setChecked(true);
+ }
+
+ drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater menuInflater = getMenuInflater();
+ menuInflater.inflate(R.menu.tasker_configuration, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if(item.getItemId() == android.R.id.home) {
+ cancel();
+ return true;
+ } else if(item.getItemId() == R.id.menu_accept) {
+ accept();
+ return true;
+ } else if(item.getItemId() == R.id.menu_cancel) {
+ cancel();
+ return true;
+ }
+
+ return false;
}
private void accept() {
Intent intent = new Intent();
- intent.putExtra("com.twofortyfouram.locale.intent.extra.BLURB", "Start DSub");
- CheckBox checkBox = (CheckBox) findViewById(R.id.edit_shuffle_checkbox);
+ String blurb = getResources().getString(checkBox.isChecked() ? R.string.tasker_start_playing_shuffled : R.string.tasker_start_playing);
+ intent.putExtra("com.twofortyfouram.locale.intent.extra.BLURB", blurb);
Bundle data = new Bundle();
data.putBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, checkBox.isChecked());
intent.putExtra(Constants.TASKER_EXTRA_BUNDLE, data);
- setResult(Activity.RESULT_OK);
+ setResult(Activity.RESULT_OK, intent);
finish();
}
private void cancel() {