aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-11-28 19:38:48 -0800
committerScott Jackson <daneren2005@gmail.com>2012-11-28 19:38:48 -0800
commitb476e18389ae4b7a7cbde091f372c4e88f2d01bf (patch)
treef957c425b77af331eb046fc1f97be6182f01ed1f /subsonic-android/src
parentb75e4654a818cd4109d6411a8ea08a44e50b2cf0 (diff)
downloaddsub-b476e18389ae4b7a7cbde091f372c4e88f2d01bf.tar.gz
dsub-b476e18389ae4b7a7cbde091f372c4e88f2d01bf.tar.bz2
dsub-b476e18389ae4b7a7cbde091f372c4e88f2d01bf.zip
Moved timer length from a setting to a cached input when starting timer
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java34
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java3
2 files changed, 32 insertions, 5 deletions
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();