Skip to content

Commit

Permalink
Lab:Keyguard weather (2/2)
Browse files Browse the repository at this point in the history
Change-Id: I4aaf55c18ba2e9bd9090facfce538a8e253b99c1
Signed-off-by: AKabhishek <abhishekkaushik.star@gmail.com>
  • Loading branch information
eyosen authored and AKabhishek committed Feb 25, 2018
1 parent d571e7a commit b552203
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
13 changes: 13 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,19 @@
<string name="status_bar_temperature_hide_scale_hide_image">Show temp without scale</string>
<string name="status_bar_show_image">Show image</string>

<!-- Lockscreen Weather -->
<string name="lock_screen_weather_category_title">Lockscreen</string>
<string name="lock_screen_show_weather_title">Weather display</string>
<string name="lock_screen_show_weather_summaryOn">Weather is shown on Lockscreen</string>
<string name="lock_screen_show_weather_summaryOff">Weather is hidden on Lockscreen</string>
<string name="lock_screen_show_location_title">Location display</string>
<string name="lock_screen_show_location_summaryOn">Location is shown on Lockscreen</string>
<string name="lock_screen_show_location_summaryOff">Location is hidden on Lockscreen</string>
<string name="lock_screen_weather_condition_icon_title">Condition icon display</string>
<string name="lock_screen_weather_condition_icon_summaryOn">Condition icon is shown on Lockscreen</string>
<string name="lock_screen_weather_condition_icon_summaryOff">Condition icon is hidden on Lockscreen</string>

</resources>



30 changes: 30 additions & 0 deletions res/xml/weather.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,34 @@
android:dialogTitle="@string/statusbar_weather_dialog_title"
android:entries="@array/status_bar_weather_entries"
android:entryValues="@array/status_bar_weather_values" />

<!-- Lockscreen weather -->
<PreferenceCategory
android:key="lock_screen_weather_category"
android:title="@string/lock_screen_weather_category_title" >

<com.aos.laboratory.preferences.SystemSettingSwitchPreference
android:key="lock_screen_show_weather"
android:title="@string/lock_screen_show_weather_title"
android:summaryOn="@string/lock_screen_show_weather_summaryOn"
android:summaryOff="@string/lock_screen_show_weather_summaryOff"
android:defaultValue="false" />

<com.aos.laboratory.preferences.SystemSettingSwitchPreference
android:key="lock_screen_show_weather_location"
android:title="@string/lock_screen_show_location_title"
android:summaryOn="@string/lock_screen_show_location_summaryOn"
android:summaryOff="@string/lock_screen_show_location_summaryOff"
android:defaultValue="true"
android:dependency="lock_screen_show_weather" />

<com.aos.laboratory.preferences.SystemSettingSwitchPreference
android:key="lock_screen_weather_condition_icon"
android:title="@string/lock_screen_weather_condition_icon_title"
android:summaryOn="@string/lock_screen_weather_condition_icon_summaryOn"
android:summaryOff="@string/lock_screen_weather_condition_icon_summaryOff"
android:defaultValue="true"
android:dependency="lock_screen_show_weather" />

</PreferenceCategory>
</PreferenceScreen>
13 changes: 5 additions & 8 deletions src/com/aos/laboratory/cat/Weather.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.net.Uri;
import android.os.UserHandle;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v7.preference.ListPreference;
Expand All @@ -46,7 +47,6 @@ public class Weather extends SettingsPreferenceFragment
implements Preference.OnPreferenceChangeListener {

private static final String TAG = "OmniJawsSettings";
private static final String CATEGORY_WEATHER = "weather_category";
private static final String WEATHER_ICON_PACK = "weather_icon_pack";
private static final String DEFAULT_WEATHER_ICON_PACKAGE = "org.omnirom.omnijaws";
private static final String WEATHER_SERVICE_PACKAGE = "org.omnirom.omnijaws";
Expand All @@ -69,10 +69,7 @@ public void onCreate(Bundle savedInstanceState) {
final ContentResolver resolver = getActivity().getContentResolver();
final PackageManager pm = getActivity().getPackageManager();

mWeatherCategory = (PreferenceCategory) prefSet.findPreference(CATEGORY_WEATHER);
if (mWeatherCategory != null && (!Utils.isPackageInstalled(WEATHER_SERVICE_PACKAGE, pm))) {
prefSet.removePreference(mWeatherCategory);
} else {
if (Utils.isPackageInstalled(WEATHER_SERVICE_PACKAGE, pm)) {
String settingsJaws = Settings.System.getString(resolver,
Settings.System.OMNIJAWS_WEATHER_ICON_PACK);
if (settingsJaws == null) {
Expand Down Expand Up @@ -131,9 +128,9 @@ public boolean onPreferenceChange(Preference preference, Object objValue) {
int valueIndex = mWeatherIconPack.findIndexOfValue(value);
mWeatherIconPack.setSummary(mWeatherIconPack.getEntries()[valueIndex]);
} else if (preference == mStatusBarWeather) {
int temperatureShow = Integer.valueOf((String) newValue);
int index = mStatusBarWeather.findIndexOfValue((String) newValue);
Settings.System.putIntForUser(resolver,
int temperatureShow = Integer.valueOf((String) objValue);
int index = mStatusBarWeather.findIndexOfValue((String) objValue);
Settings.System.putIntForUser(getActivity().getContentResolver(),
Settings.System.STATUS_BAR_SHOW_WEATHER_TEMP,
temperatureShow, UserHandle.USER_CURRENT);
if (temperatureShow == 0) {
Expand Down

0 comments on commit b552203

Please sign in to comment.