Cherish:Statusbar weather [2/2]
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -1339,4 +1339,33 @@
|
||||
<item>@string/monet_5</item>
|
||||
<item>@string/monet_6</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>
|
||||
|
||||
<!-- StatusBar Weather location -->
|
||||
<string-array name="sb_weather_location_entries">
|
||||
<item>@string/traffic_statusbar</item>
|
||||
<item>@string/traffic_expanded_statusbar</item>
|
||||
</string-array>
|
||||
<string-array name="sb_weather_location_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -1386,4 +1386,18 @@
|
||||
<string name="status_bar_carrier_color">Carrier label color</string>
|
||||
<string name="status_bar_carrier_size">Carrier label size</string>
|
||||
<string name="status_bar_carrier_font_style_title">Carrier Label Font</string>
|
||||
|
||||
<!-- StatusBar weather settings -->
|
||||
<string name="sb_weather_title">StatusBar Weather</string>
|
||||
<string name="sb_weather_summary">config statusBar and qs weather</string>
|
||||
<string name="status_bar_weather_location_title">Weather Placement</string>
|
||||
<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">Hide 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_show_image">Show image</string>
|
||||
</resources>
|
||||
|
||||
36
res/xml/cherish_sb_weather.xml
Normal file
36
res/xml/cherish_sb_weather.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 The CherishOS 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.
|
||||
-->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||
android:title="@string/sb_weather_title">
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||
android:key="status_bar_show_weather_temp"
|
||||
android:title="@string/statusbar_weather_title"
|
||||
android:dialogTitle="@string/statusbar_weather_dialog_title"
|
||||
android:entries="@array/status_bar_weather_entries"
|
||||
android:entryValues="@array/status_bar_weather_values"
|
||||
android:summary="%s"
|
||||
android:defaultValue="0" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||
android:key="status_bar_show_weather_location"
|
||||
android:title="@string/status_bar_weather_location_title"
|
||||
android:entries="@array/sb_weather_location_entries"
|
||||
android:entryValues="@array/sb_weather_location_values"
|
||||
android:summary="%s"
|
||||
android:defaultValue="0" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -38,6 +38,14 @@
|
||||
android:title="@string/clock_style_category_title"
|
||||
android:summary="@string/clock_style_category_summary"
|
||||
android:fragment="com.cherish.settings.fragments.ClockSettings" />
|
||||
|
||||
<!-- Status Bar Weather -->
|
||||
<Preference
|
||||
android:key="status_bar_weather"
|
||||
android:icon="@drawable/ic_weather"
|
||||
android:title="@string/sb_weather_title"
|
||||
android:summary="@string/sb_weather_summary"
|
||||
android:fragment="com.cherish.settings.fragments.SBWeather" />
|
||||
|
||||
<Preference
|
||||
android:title="@string/statusbar_items_title"
|
||||
|
||||
95
src/com/cherish/settings/fragments/SBWeather.java
Normal file
95
src/com/cherish/settings/fragments/SBWeather.java
Normal file
@@ -0,0 +1,95 @@
|
||||
package com.cherish.settings.fragments;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.content.Context;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.content.res.Resources;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.SwitchPreference;
|
||||
import android.provider.Settings;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import java.util.Locale;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class SBWeather extends SettingsPreferenceFragment implements
|
||||
OnPreferenceChangeListener {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
addPreferencesFromResource(R.xml.cherish_sb_weather);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object objValue) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Search.
|
||||
*/
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
ArrayList<SearchIndexableResource> result =
|
||||
new ArrayList<SearchIndexableResource>();
|
||||
SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.cherish_sb_weather;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
List<String> keys = super.getNonIndexableKeys(context);
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user