diff --git a/app/src/main/java/com/example/android/sunshine/app/SettingsActivity.java b/app/src/main/java/com/example/android/sunshine/app/SettingsActivity.java
index 5487595..162c9a0 100644
--- a/app/src/main/java/com/example/android/sunshine/app/SettingsActivity.java
+++ b/app/src/main/java/com/example/android/sunshine/app/SettingsActivity.java
@@ -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);
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 87d92e0..8b3a6bb 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -48,6 +48,10 @@
94043
+
+ Invalid Location (%1$s)"
+ Validating Location... (%1$s)"
+
enable_notifications
Weather Notifications