Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
os
android_packages_apps_OpenWeatherMapProvider
Commits
09b1f161
Commit
09b1f161
authored
Nov 02, 2018
by
Romain Hunault
Browse files
Add a default OWM key during build
parent
abb8ff53
Changes
4
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
09b1f161
...
...
@@ -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}
...
...
app/src/main/java/org/lineageos/openweathermapprovider/OpenWeatherMapProviderService.java
View file @
09b1f161
...
...
@@ -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
);
}
}
...
...
app/src/main/res/values/strings.xml
View file @
09b1f161
...
...
@@ -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
app/src/main/res/xml/preferences.xml
View file @
09b1f161
...
...
@@ -41,4 +41,4 @@
android:title=
"@string/copyright_title"
android:summary=
"@string/copyright_summary"
/>
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
</PreferenceScreen>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment