* Changed SettingsActivity and CheckUnits

to use open_settings_screen instead of "Open".

* Cleaned up SettingsActivity by removing the class scoped variable displaySettingsOnly.
This commit is contained in:
Josh Kasten
2011-09-19 17:54:00 -05:00
parent 9bb0ba2953
commit 3029c6d10c
3 changed files with 17 additions and 11 deletions
+1
View File
@@ -49,4 +49,5 @@ limitations under the License.
<!-- Intent actions --> <!-- Intent actions -->
<string name="save_intent_action">android.intent.action.SAVE</string> <string name="save_intent_action">android.intent.action.SAVE</string>
<string name="open_settings_screen">android.intent.action.settings.OPEN</string>
</resources> </resources>
@@ -80,7 +80,8 @@ class CheckUnits {
private static void accept(Context context, SharedPreferences preferences) { private static void accept(Context context, SharedPreferences preferences) {
recordCheckPerformed(preferences); recordCheckPerformed(preferences);
Intent startIntent = new Intent(context, SettingsActivity.class); Intent startIntent = new Intent(context, SettingsActivity.class);
startIntent.putExtra("Open", context.getString(R.string.settings_display)); startIntent.putExtra(context.getString(R.string.open_settings_screen),
context.getString(R.string.settings_display));
context.startActivity(startIntent); context.startActivity(startIntent);
} }
@@ -58,7 +58,6 @@ public class SettingsActivity extends PreferenceActivity {
private BackupPreferencesListener backupListener; private BackupPreferencesListener backupListener;
private SharedPreferences preferences; private SharedPreferences preferences;
private boolean displaySettingsOnly = false;
/** Called when the activity is first created. */ /** Called when the activity is first created. */
@Override @Override
@@ -83,8 +82,6 @@ public class SettingsActivity extends PreferenceActivity {
// Load the preferences to be displayed // Load the preferences to be displayed
addPreferencesFromResource(R.xml.preferences); addPreferencesFromResource(R.xml.preferences);
processIntent();
// Disable TTS announcement preference if not available // Disable TTS announcement preference if not available
if (!apiFeatures.hasTextToSpeech()) { if (!apiFeatures.hasTextToSpeech()) {
@@ -96,9 +93,10 @@ public class SettingsActivity extends PreferenceActivity {
announcementFrequency.setSummary( announcementFrequency.setSummary(
R.string.settings_not_available_summary); R.string.settings_not_available_summary);
} }
if (displaySettingsOnly) // If we only need the display setting screen nothing else needs to load.
return; if (processIntent())
return;
// Hook up switching of displayed list entries between metric and imperial // Hook up switching of displayed list entries between metric and imperial
// units // units
@@ -128,18 +126,24 @@ public class SettingsActivity extends PreferenceActivity {
return true; return true;
} }
}); });
} }
private void processIntent() { private boolean processIntent() {
boolean showDisplaySettings = false;
Bundle bundle = getIntent().getExtras(); Bundle bundle = getIntent().getExtras();
PreferenceScreen preferenceScreen; PreferenceScreen preferenceScreen;
String intentString = getString(R.string.open_settings_screen);
if (bundle != null) { if (bundle != null) {
preferenceScreen = (PreferenceScreen)findPreference(bundle.getString("Open")); preferenceScreen = (PreferenceScreen) findPreference(bundle.getString(intentString));
if (preferenceScreen != null) { if (preferenceScreen != null) {
displaySettingsOnly = true; showDisplaySettings = true;
setPreferenceScreen(preferenceScreen); setPreferenceScreen(preferenceScreen);
} }
} }
return showDisplaySettings;
} }
private void customizeSensorOptionsPreferences() { private void customizeSensorOptionsPreferences() {
@@ -194,7 +198,7 @@ public class SettingsActivity extends PreferenceActivity {
super.onResume(); super.onResume();
// If we only need the display setting screen nothing else needs to load. // If we only need the display setting screen nothing else needs to load.
if (displaySettingsOnly) if (processIntent())
return; return;
configureBluetoothPreferences(); configureBluetoothPreferences();