summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2012-12-25 13:33:51 +0100
committerDanny Baumann <dannybaumann@web.de>2012-12-25 13:33:51 +0100
commit3b8fc1fdf7b67dd7caa359f3d064229c219e34ce (patch)
tree13c799a5fe3f48b070afdbf2c61f448113c7aa3c /src
parent0d5eef6f8a963126c8aebff49a563d3bbc8fb435 (diff)
downloadpackages_apps_settings-3b8fc1fdf7b67dd7caa359f3d064229c219e34ce.zip
packages_apps_settings-3b8fc1fdf7b67dd7caa359f3d064229c219e34ce.tar.gz
packages_apps_settings-3b8fc1fdf7b67dd7caa359f3d064229c219e34ce.tar.bz2
Simplify quick pulldown summary logic and improve 'translatability'.
As word ordering on non-English languages does not necessarily match the English word ordering, make quick pulldown summary more flexible. German translation is included as an example for using the new functionality ;) Change-Id: If92ab3d7a1ccc60022e79d22b5b8407bd8fb98ec
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/cyanogenmod/QuickSettings.java57
1 files changed, 23 insertions, 34 deletions
diff --git a/src/com/android/settings/cyanogenmod/QuickSettings.java b/src/com/android/settings/cyanogenmod/QuickSettings.java
index 0a11d2d..070821d 100644
--- a/src/com/android/settings/cyanogenmod/QuickSettings.java
+++ b/src/com/android/settings/cyanogenmod/QuickSettings.java
@@ -19,6 +19,7 @@ package com.android.settings.cyanogenmod;
import android.bluetooth.BluetoothAdapter;
import android.content.ContentResolver;
import android.content.pm.PackageManager;
+import android.content.res.Resources;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
@@ -79,16 +80,16 @@ public class QuickSettings extends SettingsPreferenceFragment implements OnPrefe
PreferenceScreen prefSet = getPreferenceScreen();
PackageManager pm = getPackageManager();
- ContentResolver resolver = getActivity().getApplicationContext().getContentResolver();
+ ContentResolver resolver = getActivity().getContentResolver();
mQuickPulldown = (ListPreference) prefSet.findPreference(QUICK_PULLDOWN);
if (!Utils.isPhone(getActivity())) {
prefSet.removePreference(mQuickPulldown);
} else {
mQuickPulldown.setOnPreferenceChangeListener(this);
- int statusQuickPulldown = Settings.System.getInt(resolver, Settings.System.QS_QUICK_PULLDOWN, 0);
- mQuickPulldown.setValue(String.valueOf(statusQuickPulldown));
- updatePulldownSummary();
+ int quickPulldownValue = Settings.System.getInt(resolver, Settings.System.QS_QUICK_PULLDOWN, 0);
+ mQuickPulldown.setValue(String.valueOf(quickPulldownValue));
+ updatePulldownSummary(quickPulldownValue);
}
mCollapsePanel = (CheckBoxPreference) prefSet.findPreference(COLLAPSE_PANEL);
@@ -96,8 +97,7 @@ public class QuickSettings extends SettingsPreferenceFragment implements OnPrefe
// Add the sound mode
mRingMode = (MultiSelectListPreference) prefSet.findPreference(EXP_RING_MODE);
- String storedRingMode = Settings.System.getString(getActivity()
- .getApplicationContext().getContentResolver(),
+ String storedRingMode = Settings.System.getString(resolver,
Settings.System.EXPANDED_RING_MODE);
if (storedRingMode != null) {
String[] ringModeArray = TextUtils.split(storedRingMode, SEPARATOR);
@@ -138,8 +138,7 @@ public class QuickSettings extends SettingsPreferenceFragment implements OnPrefe
// by the networkmode tile so remove both it and the associated options list
int network_state = -99;
try {
- network_state = Settings.Global.getInt(getActivity()
- .getApplicationContext().getContentResolver(),
+ network_state = Settings.Global.getInt(resolver,
Settings.Global.PREFERRED_NETWORK_MODE);
} catch (Settings.SettingNotFoundException e) {
Log.e(TAG, "Unable to retrieve PREFERRED_NETWORK_MODE", e);
@@ -177,7 +176,7 @@ public class QuickSettings extends SettingsPreferenceFragment implements OnPrefe
}
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- ContentResolver resolver = getActivity().getApplicationContext().getContentResolver();
+ ContentResolver resolver = getActivity().getContentResolver();
if (preference == mDynamicAlarm) {
Settings.System.putInt(resolver, Settings.System.QS_DYNAMIC_ALARM,
mDynamicAlarm.isChecked() ? 1 : 0);
@@ -217,7 +216,7 @@ public class QuickSettings extends SettingsPreferenceFragment implements OnPrefe
}
public boolean onPreferenceChange(Preference preference, Object newValue) {
- ContentResolver resolver = getActivity().getApplicationContext().getContentResolver();
+ ContentResolver resolver = getActivity().getContentResolver();
if (preference == mRingMode) {
ArrayList<String> arrValue = new ArrayList<String>((Set<String>) newValue);
Collections.sort(arrValue, new MultiSelectListPreferenceComparator(mRingMode));
@@ -228,15 +227,15 @@ public class QuickSettings extends SettingsPreferenceFragment implements OnPrefe
} else if (preference == mNetworkMode) {
int value = Integer.valueOf((String) newValue);
int index = mNetworkMode.findIndexOfValue((String) newValue);
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
+ Settings.System.putInt(resolver,
Settings.System.EXPANDED_NETWORK_MODE, value);
mNetworkMode.setSummary(mNetworkMode.getEntries()[index]);
return true;
} else if (preference == mQuickPulldown) {
- int statusQuickPulldown = Integer.valueOf((String) newValue);
+ int quickPulldownValue = Integer.valueOf((String) newValue);
Settings.System.putInt(resolver, Settings.System.QS_QUICK_PULLDOWN,
- statusQuickPulldown);
- updatePulldownSummary();
+ quickPulldownValue);
+ updatePulldownSummary(quickPulldownValue);
return true;
} else if (preference == mScreenTimeoutMode) {
int value = Integer.valueOf((String) newValue);
@@ -272,27 +271,17 @@ public class QuickSettings extends SettingsPreferenceFragment implements OnPrefe
}
}
- private void updatePulldownSummary() {
- ContentResolver resolver = getActivity().getApplicationContext().getContentResolver();
- int summaryId;
- int directionId;
- summaryId = R.string.summary_quick_pulldown;
- String value = Settings.System.getString(resolver, Settings.System.QS_QUICK_PULLDOWN);
- String[] pulldownArray = getResources().getStringArray(R.array.quick_pulldown_values);
- if (pulldownArray[0].equals(value)) {
- directionId = R.string.quick_pulldown_off;
- mQuickPulldown.setValueIndex(0);
- mQuickPulldown.setSummary(getResources().getString(directionId));
- } else if (pulldownArray[1].equals(value)) {
- directionId = R.string.quick_pulldown_right;
- mQuickPulldown.setValueIndex(1);
- mQuickPulldown.setSummary(getResources().getString(directionId)
- + " " + getResources().getString(summaryId));
+ private void updatePulldownSummary(int value) {
+ Resources res = getResources();
+
+ if (value == 0) {
+ /* quick pulldown deactivated */
+ mQuickPulldown.setSummary(res.getString(R.string.quick_pulldown_off));
} else {
- directionId = R.string.quick_pulldown_left;
- mQuickPulldown.setValueIndex(2);
- mQuickPulldown.setSummary(getResources().getString(directionId)
- + " " + getResources().getString(summaryId));
+ String direction = res.getString(value == 2
+ ? R.string.quick_pulldown_summary_left
+ : R.string.quick_pulldown_summary_right);
+ mQuickPulldown.setSummary(res.getString(R.string.summary_quick_pulldown, direction));
}
}