diff options
Diffstat (limited to 'subsonic-android')
5 files changed, 60 insertions, 11 deletions
diff --git a/subsonic-android/res/layout/start_timer.xml b/subsonic-android/res/layout/start_timer.xml new file mode 100644 index 00000000..3b607a44 --- /dev/null +++ b/subsonic-android/res/layout/start_timer.xml @@ -0,0 +1,27 @@ +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" + android:layout_width="fill_parent" + android:layout_height="wrap_content"> + + <TextView + android:id="@+id/timer_length_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="4dp" + android:textSize="20dp" + android:text="@string/download.timer_length" /> + <EditText + android:id="@+id/timer_length" + android:inputType="number" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:layout_marginLeft="4dp" + android:hint="@string/download.timer_length" /> + </LinearLayout> +</LinearLayout>
\ No newline at end of file diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index bc8f31f7..6ada14a8 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -135,6 +135,7 @@ <string name="download.jukebox_not_authorized">Remote control is not allowed. Please enable jukebox mode in <b>Users > Settings</b> on your Subsonic server.</string>
<string name="download.show_downloading">Show Downloading</string>
<string name="download.show_now_playing">Show Now Playing</string>
+ <string name="download.timer_length">Timer Length</string>
<string name="download.start_timer">Start Timer</string>
<string name="download.stop_timer">Stop Timer</string>
<string name="download.need_download">Video needs to be downloaded first</string>
diff --git a/subsonic-android/res/xml/settings.xml b/subsonic-android/res/xml/settings.xml index f79063cc..393d7cba 100644 --- a/subsonic-android/res/xml/settings.xml +++ b/subsonic-android/res/xml/settings.xml @@ -155,12 +155,6 @@ android:key="randomSize" android:defaultValue="20" android:digits="0123456789"/> - - <EditTextPreference - android:title="@string/settings.sleep_timer_duration_title" - android:key="sleepTimerDuration" - android:defaultValue="60" - android:digits="0123456789"/> <ListPreference android:title="@string/settings.temp_loss_title" diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index 52ea5b25..8d96499d 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -31,6 +31,7 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.graphics.Color; import android.graphics.Typeface; import android.os.Bundle; @@ -640,10 +641,10 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi case R.id.menu_toggle_timer: if(getDownloadService().getSleepTimer()) { getDownloadService().stopSleepTimer(); + invalidateOptionsMenu(); } else { - getDownloadService().startSleepTimer(); + startTimer(); } - invalidateOptionsMenu(); return true; case R.id.menu_exit: intent = new Intent(this, MainActivity.class); @@ -704,6 +705,35 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi } }.execute(); } + + protected void startTimer() { + View dialogView = getLayoutInflater().inflate(R.layout.start_timer, null); + final EditText lengthBox = (EditText)dialogView.findViewById(R.id.timer_length); + + final SharedPreferences prefs = Util.getPreferences(DownloadActivity.this); + lengthBox.setText(prefs.getString(Constants.PREFERENCES_KEY_SLEEP_TIMER_DURATION, "")); + + AlertDialog.Builder builder = new AlertDialog.Builder(DownloadActivity.this); + builder.setTitle("Set Timer") + .setView(dialogView) + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + String length = lengthBox.getText().toString(); + + SharedPreferences.Editor editor = prefs.edit(); + editor.putString(Constants.PREFERENCES_KEY_SLEEP_TIMER_DURATION, length); + editor.commit(); + + getDownloadService().setSleepTimerDuration(Integer.parseInt(length)); + getDownloadService().startSleepTimer(); + invalidateOptionsMenu(); + } + }) + .setNegativeButton("Cancel", null); + AlertDialog dialog = builder.create(); + dialog.show(); + } private void toggleFullscreenAlbumArt() { scrollToCurrent(); diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java index 086b48ca..97c4c44d 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java @@ -57,7 +57,6 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer private EditTextPreference cacheLocation; private ListPreference preloadCount; private EditTextPreference randomSize; - private EditTextPreference sleepTimerDuration; private ListPreference tempLoss; @Override @@ -73,7 +72,6 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer cacheLocation = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_LOCATION); preloadCount = (ListPreference) findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT); randomSize = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_RANDOM_SIZE); - sleepTimerDuration = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_SLEEP_TIMER_DURATION); tempLoss = (ListPreference) findPreference(Constants.PREFERENCES_KEY_TEMP_LOSS); findPreference("testConnection1").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @@ -162,7 +160,6 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer cacheLocation.setSummary(cacheLocation.getText()); preloadCount.setSummary(preloadCount.getEntry()); randomSize.setSummary(randomSize.getText()); - sleepTimerDuration.setSummary(sleepTimerDuration.getText()); tempLoss.setSummary(tempLoss.getEntry()); for (ServerSettings ss : serverSettings.values()) { ss.update(); |