[SQUASH]Cherish:Status bar weather [2/2]

@hungphan2001:Bring to Android 11

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
LorDClockaN
2020-05-21 15:33:04 +10:00
committed by Hưng Phan
parent 7d79cc9d06
commit 8534a50c8b
6 changed files with 138 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 crDroid Android Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="?android:attr/colorControlNormal"
android:pathData="M22 17C22.5 17 23 17.5 23 18V22C23 22.5 22.5 23 22 23H17C16.5 23 16 22.5 16 22V18C16 17.5 16.5 17 17 17V15.5C17 14.1 18.1 13 19.5 13C20.9 13 22 14.1 22 15.5V17M21 17V15.5C21 14.7 20.3 14 19.5 14C18.7 14 18 14.7 18 15.5V17H21M19.36 9.03C21.95 9.22 24 11.36 24 14L23.94 14.77C23.59 12.63 21.74 11 19.5 11C17 11 15 13 15 15.5L15 15.76C14.39 16.31 14 17.11 14 18V19H6C2.69 19 0 16.31 0 13C0 9.9 2.34 7.36 5.35 7.04C6.6 4.64 9.11 3 12 3C15.64 3 18.67 5.59 19.36 9.03Z" />
</vector>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 crDroid Android Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="80dp"
android:height="80dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="?android:attr/colorControlNormal"
android:pathData="M22 17C22.5 17 23 17.5 23 18V22C23 22.5 22.5 23 22 23H17C16.5 23 16 22.5 16 22V18C16 17.5 16.5 17 17 17V15.5C17 14.1 18.1 13 19.5 13C20.9 13 22 14.1 22 15.5V17M21 17V15.5C21 14.7 20.3 14 19.5 14C18.7 14 18 14.7 18 15.5V17H21M19.36 9.03C21.95 9.22 24 11.36 24 14L23.94 14.77C23.59 12.63 21.74 11 19.5 11C17 11 15 13 15 15.5L15 15.76C14.39 16.31 14 17.11 14 18V19H6C2.69 19 0 16.31 0 13C0 9.9 2.34 7.36 5.35 7.04C6.6 4.64 9.11 3 12 3C15.64 3 18.67 5.59 19.36 9.03Z" />
</vector>

View File

@@ -1322,4 +1322,33 @@
<item>9</item>
<item>10</item>
</string-array>
<!-- StatusBar weather settings -->
<string-array name="status_bar_weather_entries" translatable="false">
<item>@string/status_bar_weather_hidden</item>
<item>@string/status_bar_temperature_image_show_scale</item>
<item>@string/status_bar_temperature_image_hide_scale</item>
<item>@string/status_bar_temperature_show_scale_hide_image</item>
<item>@string/status_bar_temperature_hide_scale_hide_image</item>
<item>@string/status_bar_show_image</item>
</string-array>
<string-array name="status_bar_weather_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</string-array>
<string-array name="weather_entries" translatable="false">
<item>@string/network_traffic_location_statusbar</item>
<item>@string/network_traffic_location_quick_statusbar</item>
</string-array>
<string-array name="weather_values" translatable="false">
<item>0</item>
<item>1</item>
</string-array>
</resources>

View File

@@ -1272,4 +1272,19 @@
<!-- Lockscreen blur -->
<string name="lockscreen_blur_title">Background blur</string>
<string name="lockscreen_blur_disabled">Lock screen Blur cannot be enabled because your current lock screen wallpaper does not match your home screen one, or your device does not support Blur at all.</string>
<!-- StatusBar weather settings -->
<string name="statusbar_weather_title">Status bar weather</string>
<string name="statusbar_weather_summary">Configure from QS settings/Weather.</string>
<string name="statusbar_weather_dialog_title">Status bar weather style</string>
<string name="status_bar_weather_hidden">Hidde weather</string>
<string name="status_bar_temperature_image_show_scale">Show temp with scale and image</string>
<string name="status_bar_temperature_image_hide_scale">Show temp with image without scale</string>
<string name="status_bar_temperature_show_scale_hide_image">Show temp with scale</string>
<string name="status_bar_temperature_hide_scale_hide_image">Show temp without scale</string>
<string name="status_bar_weather_location_title">Location</string>
<string name="status_bar_show_image">Show image</string>
<string name="network_traffic_location_disable">Disabled</string>
<string name="network_traffic_location_statusbar">Statusbar</string>
<string name="network_traffic_location_quick_statusbar">Quick Statusbar</string>
</resources>

View File

@@ -39,6 +39,23 @@
android:summary="@string/clock_style_category_summary"
android:fragment="com.cherish.settings.fragments.ClockSettings" />
<ListPreference
android:key="status_bar_weather"
android:title="@string/statusbar_weather_title"
android:dialogTitle="@string/statusbar_weather_dialog_title"
android:entries="@array/status_bar_weather_entries"
android:icon="@drawable/ic_sb_weather_icon"
android:entryValues="@array/status_bar_weather_values" />
<com.cherish.settings.preferences.SystemSettingListPreference
android:key="status_bar_show_weather_location"
android:icon="@drawable/ic_sb_weather_icon_nav"
android:title="@string/status_bar_weather_location_title"
android:entries="@array/weather_entries"
android:entryValues="@array/weather_values"
android:summary="%s"
android:defaultValue="0" />
<Preference
android:title="@string/statusbar_items_title"
android:icon="@drawable/ic_shortcuts">

View File

@@ -53,6 +53,9 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
private SystemSettingMasterSwitchPreference mStatusBarLogo;
private static final String PREF_KEY_CUTOUT = "cutout_settings";
private static final String PREF_STATUS_BAR_WEATHER = "status_bar_weather";
private ListPreference mStatusBarWeather;
@Override
public void onCreate(Bundle icicle) {
@@ -69,6 +72,19 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
Settings.System.STATUS_BAR_LOGO, 0) == 1));
mStatusBarLogo.setOnPreferenceChangeListener(this);
// Status bar weather
mStatusBarWeather = (ListPreference) findPreference(PREF_STATUS_BAR_WEATHER);
int temperatureShow = Settings.System.getIntForUser(resolver,
Settings.System.STATUS_BAR_SHOW_WEATHER_TEMP, 0,
UserHandle.USER_CURRENT);
mStatusBarWeather.setValue(String.valueOf(temperatureShow));
if (temperatureShow == 0) {
mStatusBarWeather.setSummary(R.string.statusbar_weather_summary);
} else {
mStatusBarWeather.setSummary(mStatusBarWeather.getEntry());
}
mStatusBarWeather.setOnPreferenceChangeListener(this);
Preference mCutoutPref = (Preference) findPreference(PREF_KEY_CUTOUT);
String hasDisplayCutout = getResources().getString(com.android.internal.R.string.config_mainBuiltInDisplayCutout);
@@ -85,6 +101,19 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
Settings.System.putInt(getActivity().getContentResolver(),
Settings.System.STATUS_BAR_LOGO, value ? 1 : 0);
return true;
} else if (preference == mStatusBarWeather) {
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) {
mStatusBarWeather.setSummary(R.string.statusbar_weather_summary);
} else {
mStatusBarWeather.setSummary(
mStatusBarWeather.getEntries()[index]);
}
return true;
}
return false;
}