diff --git a/app/build.gradle b/app/build.gradle
index 19167f951..f7ffae8fd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -17,6 +17,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
+ buildTypes.each {
+ it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', MyOpenWeatherMapApiKey
+ }
}
dependencies {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 64a14ce2b..99c059290 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -27,6 +27,14 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.android.sunshine.app.MainActivity" />
+
+ * See
+ * Android Design: Settings for design guidelines and the Settings
+ * API Guide for more information on developing a Settings UI.
+ */
+public class SettingsActivity extends PreferenceActivity
+ implements Preference.OnPreferenceChangeListener {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // Add 'general' preferences, defined in the XML file
+ // TODO: Add preferences from XML
+
+ // For all preferences, attach an OnPreferenceChangeListener so the UI summary can be
+ // updated when the preference changes.
+ // TODO: Add preference
+ }
+
+ /**
+ * Attaches a listener so the summary is always updated with the preference value.
+ * Also fires the listener once, to initialize the summary (so it shows up before the value
+ * is changed.)
+ */
+ private void bindPreferenceSummaryToValue(Preference preference) {
+ // Set the listener to watch for value changes.
+ preference.setOnPreferenceChangeListener(this);
+
+ // Trigger the listener immediately with the preference's
+ // current value.
+ onPreferenceChange(preference,
+ PreferenceManager
+ .getDefaultSharedPreferences(preference.getContext())
+ .getString(preference.getKey(), ""));
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object value) {
+ String stringValue = value.toString();
+
+ if (preference instanceof ListPreference) {
+ // For list preferences, look up the correct display value in
+ // the preference's 'entries' list (since they have separate labels/values).
+ ListPreference listPreference = (ListPreference) preference;
+ int prefIndex = listPreference.findIndexOfValue(stringValue);
+ if (prefIndex >= 0) {
+ preference.setSummary(listPreference.getEntries()[prefIndex]);
+ }
+ } else {
+ // For other preferences, set the summary to the value's simple string representation.
+ preference.setSummary(stringValue);
+ }
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml
index 45e7df4b2..70bef316d 100644
--- a/app/src/main/res/layout/fragment_detail.xml
+++ b/app/src/main/res/layout/fragment_detail.xml
@@ -6,7 +6,7 @@
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.android.sunshine.app.DetailActivity.DetailFragment">
-