* 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 -->
<string name="save_intent_action">android.intent.action.SAVE</string>
<string name="open_settings_screen">android.intent.action.settings.OPEN</string>
</resources>
@@ -80,7 +80,8 @@ class CheckUnits {
private static void accept(Context context, SharedPreferences preferences) {
recordCheckPerformed(preferences);
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);
}
@@ -58,7 +58,6 @@ public class SettingsActivity extends PreferenceActivity {
private BackupPreferencesListener backupListener;
private SharedPreferences preferences;
private boolean displaySettingsOnly = false;
/** Called when the activity is first created. */
@Override
@@ -83,8 +82,6 @@ public class SettingsActivity extends PreferenceActivity {
// Load the preferences to be displayed
addPreferencesFromResource(R.xml.preferences);
processIntent();
// Disable TTS announcement preference if not available
if (!apiFeatures.hasTextToSpeech()) {
@@ -96,9 +93,10 @@ public class SettingsActivity extends PreferenceActivity {
announcementFrequency.setSummary(
R.string.settings_not_available_summary);
}
if (displaySettingsOnly)
return;
// If we only need the display setting screen nothing else needs to load.
if (processIntent())
return;
// Hook up switching of displayed list entries between metric and imperial
// units
@@ -128,18 +126,24 @@ public class SettingsActivity extends PreferenceActivity {
return true;
}
});
}
private void processIntent() {
private boolean processIntent() {
boolean showDisplaySettings = false;
Bundle bundle = getIntent().getExtras();
PreferenceScreen preferenceScreen;
String intentString = getString(R.string.open_settings_screen);
if (bundle != null) {
preferenceScreen = (PreferenceScreen)findPreference(bundle.getString("Open"));
preferenceScreen = (PreferenceScreen) findPreference(bundle.getString(intentString));
if (preferenceScreen != null) {
displaySettingsOnly = true;
showDisplaySettings = true;
setPreferenceScreen(preferenceScreen);
}
}
return showDisplaySettings;
}
private void customizeSensorOptionsPreferences() {
@@ -194,7 +198,7 @@ public class SettingsActivity extends PreferenceActivity {
super.onResume();
// If we only need the display setting screen nothing else needs to load.
if (displaySettingsOnly)
if (processIntent())
return;
configureBluetoothPreferences();