forked from upstream-mirrors/OpenTracks
* Added display_settings_screen_key to keys.xml and put it to use in
CheckUnits and SettingsActivity classes for use with intents. * In SettingsActivity split onCreate() code into initActivityCommons() and initActivitySpecifics() methods for easier maintaining of code required for all screens and code require for only some screens.
This commit is contained in:
@@ -53,4 +53,5 @@ limitations under the License.
|
||||
<string name="reset_key">resetToDefaults</string>
|
||||
<string name="sensor_options_key">sensorOptions</string>
|
||||
<string name="ant_options_key">antOptions</string>
|
||||
<string name="display_settings_screen_key">displaySettingsScreen</string>
|
||||
</resources>
|
||||
|
||||
@@ -19,7 +19,7 @@ limitations under the License.
|
||||
|
||||
<!-- Display settings -->
|
||||
<PreferenceScreen android:title="@string/settings_display"
|
||||
android:key="@string/settings_display">
|
||||
android:key="@string/display_settings_screen_key">
|
||||
<CheckBoxPreference
|
||||
android:key="@string/metric_units_key"
|
||||
android:title="@string/settings_metric_units"
|
||||
|
||||
@@ -81,7 +81,7 @@ class CheckUnits {
|
||||
recordCheckPerformed(preferences);
|
||||
Intent startIntent = new Intent(context, SettingsActivity.class);
|
||||
startIntent.putExtra(context.getString(R.string.open_settings_screen),
|
||||
context.getString(R.string.settings_display));
|
||||
context.getString(R.string.display_settings_screen_key));
|
||||
context.startActivity(startIntent);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,11 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* An activity that let's the user see and edit the settings.
|
||||
*
|
||||
*
|
||||
* This activity has two entry points, "root" and "display" preference screen.
|
||||
* If bundle.getString("open_settings_screen") is set to "display_settings_screen_key", then
|
||||
* the "display" preference screen is shown, otherwise, the "root" display preference is shown.
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
@@ -64,6 +68,16 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
initActivityCommons();
|
||||
|
||||
// If we only need the display setting screen nothing else needs to load.
|
||||
if (processIntent())
|
||||
return;
|
||||
|
||||
initActivitySpecifics();
|
||||
}
|
||||
|
||||
private void initActivityCommons() {
|
||||
// The volume we want to control is the Text-To-Speech volume
|
||||
ApiFeatures apiFeatures = ApiFeatures.getInstance();
|
||||
int volumeStream =
|
||||
@@ -93,11 +107,9 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
announcementFrequency.setSummary(
|
||||
R.string.settings_not_available_summary);
|
||||
}
|
||||
|
||||
// If we only need the display setting screen nothing else needs to load.
|
||||
if (processIntent())
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
private void initActivitySpecifics() {
|
||||
// Hook up switching of displayed list entries between metric and imperial
|
||||
// units
|
||||
CheckBoxPreference metricUnitsPreference =
|
||||
@@ -126,7 +138,6 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private boolean processIntent() {
|
||||
|
||||
Reference in New Issue
Block a user