Commit 09b1f161 authored by Romain Hunault's avatar Romain Hunault
Browse files

Add a default OWM key during build

parent abb8ff53
......@@ -6,6 +6,7 @@ stages:
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
- sed -i -e 's/<string name="default_key"><\/string>/<string name="default_key">'${DEFAULT_OWM_KEY}'<\/string>/g' app/src/main/res/values/strings.xml
cache:
key: ${CI_PROJECT_ID}
......
......@@ -68,7 +68,7 @@ public class OpenWeatherMapProviderService extends WeatherProviderService
final SharedPreferences preferences
= PreferenceManager.getDefaultSharedPreferences(this);
preferences.registerOnSharedPreferenceChangeListener(this);
final String mApiId = preferences.getString(API_KEY, null);
final String mApiId = preferences.getString(API_KEY, getString(R.string.default_key));
mOpenWeatherMapService.setApiKey(mApiId);
}
......@@ -146,7 +146,7 @@ public class OpenWeatherMapProviderService extends WeatherProviderService
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(API_KEY)) {
Logging.logd("API key has changed");
final String mApiKey = sharedPreferences.getString(key, null);
final String mApiKey = sharedPreferences.getString(key, getString(R.string.default_key));
mOpenWeatherMapService.setApiKey(mApiKey);
}
}
......
......@@ -37,4 +37,6 @@
<string name="prefscreen_disclaimer_summary">The information provided by this application is provided for general information purposes only</string>
<string name="copyright_title">Copyright</string>
<string name="copyright_summary">OpenWeatherMap is a registered trademark of OpenWeatherMap Inc, both in the United States and internationally</string>
<string name="default_key"></string>
</resources>
\ No newline at end of file
......@@ -41,4 +41,4 @@
android:title="@string/copyright_title"
android:summary="@string/copyright_summary" />
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
</PreferenceScreen>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment