diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-10-17 14:28:11 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-10-17 14:28:11 -0700 |
commit | 6802f91bfea4d378c8e27690430a86e1d7efb503 (patch) | |
tree | ee1ad7822dd4e49432648d5cd07bc750e6db4b11 | |
parent | d78618c064085a852a3ebba0064eeb22c83dfc97 (diff) | |
download | dsub-6802f91bfea4d378c8e27690430a86e1d7efb503.tar.gz dsub-6802f91bfea4d378c8e27690430a86e1d7efb503.tar.bz2 dsub-6802f91bfea4d378c8e27690430a86e1d7efb503.zip |
#386 Add new Tasker's options restore logic
-rw-r--r-- | src/github/daneren2005/dsub/activity/EditPlayActionActivity.java | 60 |
1 files changed, 55 insertions, 5 deletions
diff --git a/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java b/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java index 2ec0b6e8..ab17c087 100644 --- a/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java +++ b/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java @@ -53,6 +53,8 @@ public class EditPlayActionActivity extends SubsonicActivity { private EditText endYearBox; private Button genreButton; private Spinner offlineSpinner; + + private String doNothing; @Override public void onCreate(Bundle savedInstanceState) { @@ -60,16 +62,36 @@ public class EditPlayActionActivity extends SubsonicActivity { setTitle(R.string.tasker_start_playing_title); setContentView(R.layout.edit_play_action); final Activity context = this; + doNothing = context.getResources().getString(R.string.tasker_edit_do_nothing); shuffleCheckbox = (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)) { - shuffleCheckbox.setChecked(true); - } + shuffleCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChange(CompoundView view, boolean isChecked) { + startYearCheckbox.setEnabled(isChecked); + endYearCheckbox.setEnabled(isChecked); + genreButton.setEnabled(isChecked); + } + }); startYearCheckbox = (CheckBox) findViewById(R.id.edit_start_year_checkbox); startYearBox = (EditText) findViewById(R.id.edit_start_year); + // Disable/enable number box if checked + startYearCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChange(CompoundView view, boolean isChecked) { + startYearBox.setEnabled(isChecked); + } + }); + endYearCheckbox = (CheckBox) findViewById(R.id.edit_end_year_checkbox); endYearBox = (EditText) findViewById(R.id.edit_end_year); + endYearCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChange(CompoundView view, boolean isChecked) { + endYearBox.setEnabled(isChecked); + } + }); genreButton = (Button) findViewById(R.id.edit_genre_spinner); genreButton.setOnClickListener(new View.OnClickListener() { @@ -85,7 +107,6 @@ public class EditPlayActionActivity extends SubsonicActivity { protected void done(final List<Genre> genres) { List<String> names = new ArrayList<String>(); String blank = context.getResources().getString(R.string.select_genre_blank); - String doNothing = context.getResources().getString(R.string.tasker_edit_do_nothing); names.add(doNothing); names.add(blank); for(Genre genre: genres) { @@ -122,12 +143,41 @@ public class EditPlayActionActivity extends SubsonicActivity { }.execute(); } }); - genreButton.setText("Do Nothing"); + genreButton.setText(doNothing); offlineSpinner = (Spinner) findViewById(R.id.edit_offline_spinner); ArrayAdapter<CharSequence> offlineAdapter = ArrayAdapter.createFromResource(this, R.array.editServerOptions, android.R.layout.simple_spinner_item); offlineAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); offlineSpinner.setAdapter(offlineAdapter); + + // Setup default for everything + Bundle extras = getIntent().getBundleExtra(Constants.TASKER_EXTRA_BUNDLE); + if(extras != null) { + if(extras.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE)) { + shuffleCheckbox.setChecked(true); + } + + String startYear = extras.getString(Constants.PREFERENCES_KEY_START_YEAR, null); + if(startYear != null) { + startYearCheckbox.setEnabled(true); + startYearBox.setText(startYear); + } + String endYear = extras.getString(Constants.PREFERENCES_KEY_END_YEAR, null); + if(endYear != null) { + endYearCheckbox.setEnabled(true); + endYearBox.setText(endYear); + } + + String genre = extras.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, doNothing); + if(genre != null) + genreButton.setText(genre); + } + + short offline = extras.getShort(Constants.PREFERENCES_KEY_OFFLINE, 0); + if(offline != 0) { + offline.setSelection((int) offline); + } + } drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); } |