aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-11-12 20:09:17 -0800
committerScott Jackson <daneren2005@gmail.com>2013-11-12 20:09:17 -0800
commitc989c3973c3a947b5054bb0451aa44cedb941981 (patch)
treea04544d131c894a1ca6b90e79a4463c93feb1a64 /src/github
parentcaf1b6c523eb350467ea2cb4777e9d304586bc75 (diff)
downloaddsub-c989c3973c3a947b5054bb0451aa44cedb941981.tar.gz
dsub-c989c3973c3a947b5054bb0451aa44cedb941981.tar.bz2
dsub-c989c3973c3a947b5054bb0451aa44cedb941981.zip
Added up button to SettingsActivity
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/activity/SettingsActivity.java42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/github/daneren2005/dsub/activity/SettingsActivity.java b/src/github/daneren2005/dsub/activity/SettingsActivity.java
index 12ee7694..4dac82bd 100644
--- a/src/github/daneren2005/dsub/activity/SettingsActivity.java
+++ b/src/github/daneren2005/dsub/activity/SettingsActivity.java
@@ -18,11 +18,13 @@
*/
package github.daneren2005.dsub.activity;
+import android.annotation.TargetApi;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
@@ -33,6 +35,8 @@ import android.preference.PreferenceScreen;
import android.provider.SearchRecentSuggestions;
import android.text.InputType;
import android.util.Log;
+import android.view.MenuItem;
+
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.provider.DSubSearchProvider;
import github.daneren2005.dsub.service.DownloadService;
@@ -78,6 +82,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
private int serverCount = 3;
private SharedPreferences settings;
+ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
@Override
public void onCreate(Bundle savedInstanceState) {
applyTheme();
@@ -145,23 +150,23 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
});
addServerPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
serverCount++;
- String instance = String.valueOf(serverCount);
+ String instance = String.valueOf(serverCount);
+
+ Preference addServerPreference = findPreference(Constants.PREFERENCES_KEY_SERVER_ADD);
+ serversCategory.addPreference(addServer(serverCount));
- Preference addServerPreference = findPreference(Constants.PREFERENCES_KEY_SERVER_ADD);
- serversCategory.addPreference(addServer(serverCount));
-
SharedPreferences.Editor editor = settings.edit();
editor.putInt(Constants.PREFERENCES_KEY_SERVER_COUNT, serverCount);
editor.commit();
-
+
serverSettings.put(instance, new ServerSettings(instance));
-
- return true;
- }
- });
+
+ return true;
+ }
+ });
serversCategory.setOrderingAsAdded(false);
for (int i = 1; i <= serverCount; i++) {
@@ -174,6 +179,11 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
prefs.registerOnSharedPreferenceChangeListener(this);
update();
+
+ if(Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ getActionBar().setHomeButtonEnabled(true);
+ }
}
@Override
@@ -184,6 +194,16 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
prefs.unregisterOnSharedPreferenceChangeListener(this);
}
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if(item.getItemId() == android.R.id.home) {
+ onBackPressed();
+ return true;
+ }
+
+ return false;
+ }
+
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Log.d(TAG, "Preference changed: " + key);