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="reset_key">resetToDefaults</string>
|
||||||
<string name="sensor_options_key">sensorOptions</string>
|
<string name="sensor_options_key">sensorOptions</string>
|
||||||
<string name="ant_options_key">antOptions</string>
|
<string name="ant_options_key">antOptions</string>
|
||||||
|
<string name="display_settings_screen_key">displaySettingsScreen</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ limitations under the License.
|
|||||||
|
|
||||||
<!-- Display settings -->
|
<!-- Display settings -->
|
||||||
<PreferenceScreen android:title="@string/settings_display"
|
<PreferenceScreen android:title="@string/settings_display"
|
||||||
android:key="@string/settings_display">
|
android:key="@string/display_settings_screen_key">
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/metric_units_key"
|
android:key="@string/metric_units_key"
|
||||||
android:title="@string/settings_metric_units"
|
android:title="@string/settings_metric_units"
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class CheckUnits {
|
|||||||
recordCheckPerformed(preferences);
|
recordCheckPerformed(preferences);
|
||||||
Intent startIntent = new Intent(context, SettingsActivity.class);
|
Intent startIntent = new Intent(context, SettingsActivity.class);
|
||||||
startIntent.putExtra(context.getString(R.string.open_settings_screen),
|
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);
|
context.startActivity(startIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* An activity that let's the user see and edit the settings.
|
* 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 Leif Hendrik Wilden
|
||||||
* @author Rodrigo Damazio
|
* @author Rodrigo Damazio
|
||||||
*/
|
*/
|
||||||
@@ -64,6 +68,16 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
super.onCreate(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
|
// The volume we want to control is the Text-To-Speech volume
|
||||||
ApiFeatures apiFeatures = ApiFeatures.getInstance();
|
ApiFeatures apiFeatures = ApiFeatures.getInstance();
|
||||||
int volumeStream =
|
int volumeStream =
|
||||||
@@ -93,11 +107,9 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
announcementFrequency.setSummary(
|
announcementFrequency.setSummary(
|
||||||
R.string.settings_not_available_summary);
|
R.string.settings_not_available_summary);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we only need the display setting screen nothing else needs to load.
|
private void initActivitySpecifics() {
|
||||||
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
|
||||||
CheckBoxPreference metricUnitsPreference =
|
CheckBoxPreference metricUnitsPreference =
|
||||||
@@ -126,7 +138,6 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean processIntent() {
|
private boolean processIntent() {
|
||||||
|
|||||||
Reference in New Issue
Block a user