Updated settings to show the status of the typed-in location.
This commit is contained in:
@@ -95,10 +95,28 @@ public class SettingsActivity extends PreferenceActivity
|
||||
if (prefIndex >= 0) {
|
||||
preference.setSummary(listPreference.getEntries()[prefIndex]);
|
||||
}
|
||||
} else if (key.equals(getString(R.string.pref_location_key))) {
|
||||
@SunshineSyncAdapter.LocationStatus int status = Utility.getLocationStatus(this);
|
||||
switch (status) {
|
||||
case SunshineSyncAdapter.LOCATION_STATUS_OK:
|
||||
preference.setSummary(stringValue);
|
||||
break;
|
||||
case SunshineSyncAdapter.LOCATION_STATUS_UNKNOWN:
|
||||
preference.setSummary(getString(R.string.pref_location_unknown_description, value.toString()));
|
||||
break;
|
||||
case SunshineSyncAdapter.LOCATION_STATUS_INVALID:
|
||||
preference.setSummary(getString(R.string.pref_location_error_description, value.toString()));
|
||||
break;
|
||||
default:
|
||||
// Note --- if the server is down we still assume the value
|
||||
// is valid
|
||||
preference.setSummary(stringValue);
|
||||
}
|
||||
} else {
|
||||
// For other preferences, set the summary to the value's simple string representation.
|
||||
preference.setSummary(stringValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// This gets called before the preference is changed
|
||||
@@ -120,6 +138,10 @@ public class SettingsActivity extends PreferenceActivity
|
||||
} else if ( key.equals(getString(R.string.pref_units_key)) ) {
|
||||
// units have changed. update lists of weather entries accordingly
|
||||
getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
|
||||
} else if ( key.equals(getString(R.string.pref_location_status_key)) ) {
|
||||
// our location status has changed. Update the summary accordingly
|
||||
Preference locationPreference = findPreference(getString(R.string.pref_location_key));
|
||||
bindPreferenceSummaryToValue(locationPreference);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
<!-- Default postal code for location preference [CHAR LIMIT=NONE] -->
|
||||
<string name="pref_location_default" translatable="false">94043</string>
|
||||
|
||||
<!-- Strings used when displaying the state of the Location in settings -->
|
||||
<string name="pref_location_error_description">Invalid Location (<xliff:g id="location_setting">%1$s</xliff:g>)"</string>
|
||||
<string name="pref_location_unknown_description">Validating Location... (<xliff:g id="location_setting">%1$s</xliff:g>)"</string>
|
||||
|
||||
<!-- Strings related to Notification Enabled preference -->
|
||||
<string name="pref_enable_notifications_key" translatable="false">enable_notifications</string>
|
||||
<string name="pref_enable_notifications_label">Weather Notifications</string>
|
||||
|
||||
Reference in New Issue
Block a user