diff --git a/res/drawable/ic_cloud.xml b/res/drawable/ic_cloud.xml new file mode 100644 index 0000000..2141470 --- /dev/null +++ b/res/drawable/ic_cloud.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/res/drawable/ic_weather.xml b/res/drawable/ic_weather.xml new file mode 100644 index 0000000..1654261 --- /dev/null +++ b/res/drawable/ic_weather.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/res/values/cherish_arrays.xml b/res/values/cherish_arrays.xml index 032d4b6..545aa80 100644 --- a/res/values/cherish_arrays.xml +++ b/res/values/cherish_arrays.xml @@ -448,6 +448,15 @@ 2 + + @string/lockscreen_weather_omni_style_title + @string/lockscreen_weather_pixel_style_title + + + 0 + 1 + + @string/toast_none_animation @@ -914,6 +923,31 @@ 34 35 + + + + @string/lockscreen_date_selection_default + @string/lockscreen_date_selection_str_box + @string/lockscreen_date_selection_str_round + @string/lockscreen_date_selection_qbeta_style + @string/lockscreen_date_selection_str_accent + @string/lockscreen_date_selection_str_accent_transparent + @string/lockscreen_date_selection_str_gradient + @string/lockscreen_date_selection_str_border_accent + @string/lockscreen_date_selection_str_border_gradient + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index bc1099a..102cac6 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -485,6 +485,8 @@ Center Aligned Right Aligned Lockscreen Items Padding + LS Weather Alignment + WeatherView Background Style Data disabled icon @@ -511,6 +513,25 @@ Hide Bottom Shortcuts Hide Left-Right Shortcuts on secure lock screens + + Weather + Show on lockscreen + Show weather information on lockscreen and during doze + Setup weather options + Setup icon pack and weather service + Weather service + System service settings + Header view weather + Enable notification panel header weather display + Condition icon pack + Note\u003a you can install new icon packs from play store by searching for \"Chronus icons\" + Condition icon pack is used in quick settings and lock screen + + + Weather style + Omni style + Pixel style + Animations System Wide Animation Options @@ -808,6 +829,22 @@ Pixel animation Toggle home button animation + + Show city name + Show name of current city on left of image + Show temperature + Show current city temperature on right of image + Show Condition Image + Show weather conditions image + + + LS Weather Temp font + Change the default font of the lockscreen weather temp + Select lock weather temp font + LS Weather City font + Change the default font of the lockscreen weather city + Select lock weather city font + QS footer text Display text at bottom of QS panel diff --git a/res/xml/cherish_settings_lockscreen.xml b/res/xml/cherish_settings_lockscreen.xml index cb353e0..d2e4d10 100644 --- a/res/xml/cherish_settings_lockscreen.xml +++ b/res/xml/cherish_settings_lockscreen.xml @@ -193,6 +193,15 @@ android:summary="%s" android:defaultValue="1" /> + + + + + + + + + + - + diff --git a/res/xml/omnijaws_settings.xml b/res/xml/omnijaws_settings.xml new file mode 100644 index 0000000..73274da --- /dev/null +++ b/res/xml/omnijaws_settings.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/cherish/settings/fragments/LockColors.java b/src/com/cherish/settings/fragments/LockColors.java index 2789d12..051be65 100644 --- a/src/com/cherish/settings/fragments/LockColors.java +++ b/src/com/cherish/settings/fragments/LockColors.java @@ -54,9 +54,9 @@ public class LockColors extends SettingsPreferenceFragment implements Preference private static final String LOCKSCREEN_CLOCK_COLOR = "lockscreen_clock_color"; private static final String LOCKSCREEN_CLOCK_DATE_COLOR = "lockscreen_clock_date_color"; private static final String LOCKSCREEN_OWNER_INFO_COLOR = "lockscreen_owner_info_color"; - /* private static final String LOCKSCREEN_WEATHER_TEMP_COLOR = "lockscreen_weather_temp_color"; + private static final String LOCKSCREEN_WEATHER_TEMP_COLOR = "lockscreen_weather_temp_color"; private static final String LOCKSCREEN_WEATHER_CITY_COLOR = "lockscreen_weather_city_color"; - private static final String LOCKSCREEN_WEATHER_ICON_COLOR = "lockscreen_weather_icon_color";*/ + private static final String LOCKSCREEN_WEATHER_ICON_COLOR = "lockscreen_weather_icon_color"; static final int DEFAULT = 0xffffffff; static final int TRANSPARENT = 0x99FFFFFF; @@ -69,9 +69,9 @@ public class LockColors extends SettingsPreferenceFragment implements Preference private ColorPickerPreference mLockscreenClockColorPicker; private ColorPickerPreference mLockscreenClockDateColorPicker; private ColorPickerPreference mLockscreenOwnerInfoColorPicker; - /*private ColorPickerPreference mWeatherRightTextColorPicker; + private ColorPickerPreference mWeatherRightTextColorPicker; private ColorPickerPreference mWeatherLeftTextColorPicker; - private ColorPickerPreference mWeatherIconColorPicker;*/ + private ColorPickerPreference mWeatherIconColorPicker; @Override public void onCreate(Bundle savedInstanceState) { @@ -132,7 +132,7 @@ public class LockColors extends SettingsPreferenceFragment implements Preference hexColor = String.format("#%08x", (0xffffffff & intColor)); mLockscreenOwnerInfoColorPicker.setSummary(hexColor); mLockscreenOwnerInfoColorPicker.setNewPreviewColor(intColor); -/* + mWeatherRightTextColorPicker = (ColorPickerPreference) findPreference(LOCKSCREEN_WEATHER_TEMP_COLOR); mWeatherRightTextColorPicker.setOnPreferenceChangeListener(this); intColor = Settings.System.getInt(getContentResolver(), @@ -156,7 +156,7 @@ public class LockColors extends SettingsPreferenceFragment implements Preference hexColor = String.format("#%08x", (0x99FFFFFF & intColor)); mWeatherIconColorPicker.setSummary(hexColor); mWeatherIconColorPicker.setNewPreviewColor(intColor); -*/ + setHasOptionsMenu(true); } @@ -210,7 +210,7 @@ public class LockColors extends SettingsPreferenceFragment implements Preference Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(), Settings.System.LOCKSCREEN_OWNER_INFO_COLOR, intHex); return true; - /* } else if (preference == mWeatherRightTextColorPicker) { + } else if (preference == mWeatherRightTextColorPicker) { String hex = ColorPickerPreference.convertToARGB( Integer.valueOf(String.valueOf(newValue))); preference.setSummary(hex); @@ -233,7 +233,7 @@ public class LockColors extends SettingsPreferenceFragment implements Preference int intHex = ColorPickerPreference.convertToColorInt(hex); Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(), Settings.System.LOCK_SCREEN_WEATHER_ICON_COLOR, intHex); - return true;*/ + return true; } return false; } @@ -295,7 +295,7 @@ public class LockColors extends SettingsPreferenceFragment implements Preference Settings.System.LOCKSCREEN_OWNER_INFO_COLOR, DEFAULT); mLockscreenOwnerInfoColorPicker.setNewPreviewColor(DEFAULT); mLockscreenOwnerInfoColorPicker.setSummary(R.string.default_string); - /*Settings.System.putInt(getContentResolver(), + Settings.System.putInt(getContentResolver(), Settings.System.LOCK_SCREEN_WEATHER_TEMP_COLOR, DEFAULT); mWeatherRightTextColorPicker.setNewPreviewColor(DEFAULT); mWeatherRightTextColorPicker.setSummary(R.string.default_string); @@ -306,7 +306,7 @@ public class LockColors extends SettingsPreferenceFragment implements Preference Settings.System.putInt(getContentResolver(), Settings.System.LOCK_SCREEN_WEATHER_ICON_COLOR, DEFAULT); mWeatherIconColorPicker.setNewPreviewColor(DEFAULT); - mWeatherIconColorPicker.setSummary(R.string.default_string);*/ + mWeatherIconColorPicker.setSummary(R.string.default_string); } @Override @@ -319,6 +319,3 @@ public class LockColors extends SettingsPreferenceFragment implements Preference return MetricsProto.MetricsEvent.CHERISH_SETTINGS; } } - - - diff --git a/src/com/cherish/settings/preferences/fragments/OmniJawsSettings.java b/src/com/cherish/settings/preferences/fragments/OmniJawsSettings.java new file mode 100644 index 0000000..54a4890 --- /dev/null +++ b/src/com/cherish/settings/preferences/fragments/OmniJawsSettings.java @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2017 The OmniROM Project + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * +*/ + +package com.cherish.settings.fragments; + +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import androidx.preference.ListPreference; +import androidx.preference.Preference; +import androidx.preference.PreferenceCategory; +import androidx.preference.PreferenceScreen; +import android.provider.SearchIndexableResource; +import android.provider.Settings; +import android.util.Log; + +import com.android.internal.logging.nano.MetricsProto.MetricsEvent; + +import com.android.settings.R; +import com.android.settings.SettingsPreferenceFragment; +import com.android.settings.Utils; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settingslib.search.SearchIndexable; + +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; + +@SearchIndexable +public class OmniJawsSettings 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 DEFAULT_WEATHER_ICON_PREFIX = "outline"; + private static final String WEATHER_SERVICE_PACKAGE = "org.omnirom.omnijaws"; + private static final String CHRONUS_ICON_PACK_INTENT = "com.dvtonder.chronus.ICON_PACK"; + private static final String LOCK_WEATHER_TEMP_FONTS = "lock_weather_temp_fonts"; + private static final String LOCK_WEATHER_CITY_FONTS = "lock_weather_city_fonts"; + + private PreferenceCategory mWeatherCategory; + private ListPreference mWeatherIconPack; + ListPreference mLockTempFonts; + ListPreference mLockCityFonts; + + @Override + public int getMetricsCategory() { + return MetricsEvent.CHERISH_SETTINGS; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.omnijaws_settings); + final PreferenceScreen prefScreen = getPreferenceScreen(); + + mWeatherCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_WEATHER); + if (mWeatherCategory != null) { + prefScreen.removePreference(mWeatherCategory); + } else { + String settingHeaderPackage = Settings.System.getString(getContentResolver(), + Settings.System.OMNIJAWS_WEATHER_ICON_PACK); + if (settingHeaderPackage == null) { + settingHeaderPackage = DEFAULT_WEATHER_ICON_PACKAGE + "." + DEFAULT_WEATHER_ICON_PREFIX; + } + mWeatherIconPack = (ListPreference) findPreference(WEATHER_ICON_PACK); + + List entries = new ArrayList(); + List values = new ArrayList(); + getAvailableWeatherIconPacks(entries, values); + mWeatherIconPack.setEntries(entries.toArray(new String[entries.size()])); + mWeatherIconPack.setEntryValues(values.toArray(new String[values.size()])); + + int valueIndex = mWeatherIconPack.findIndexOfValue(settingHeaderPackage); + if (valueIndex == -1) { + // no longer found + settingHeaderPackage = DEFAULT_WEATHER_ICON_PACKAGE + "." + DEFAULT_WEATHER_ICON_PREFIX; + Settings.System.putString(getContentResolver(), + Settings.System.OMNIJAWS_WEATHER_ICON_PACK, settingHeaderPackage); + valueIndex = mWeatherIconPack.findIndexOfValue(settingHeaderPackage); + } + mWeatherIconPack.setValueIndex(valueIndex >= 0 ? valueIndex : 0); + mWeatherIconPack.setSummary(mWeatherIconPack.getEntry()); + mWeatherIconPack.setOnPreferenceChangeListener(this); + } + + // Lockscren Weather Temp Fonts + mLockTempFonts = (ListPreference) findPreference(LOCK_WEATHER_TEMP_FONTS); + mLockTempFonts.setValue(String.valueOf(Settings.System.getInt( + getContentResolver(), Settings.System.LOCK_WEATHER_TEMP_FONTS, 27))); + mLockTempFonts.setSummary(mLockTempFonts.getEntry()); + mLockTempFonts.setOnPreferenceChangeListener(this); + + // Lockscren Weather City Fonts + mLockCityFonts = (ListPreference) findPreference(LOCK_WEATHER_CITY_FONTS); + mLockCityFonts.setValue(String.valueOf(Settings.System.getInt( + getContentResolver(), Settings.System.LOCK_WEATHER_CITY_FONTS, 27))); + mLockCityFonts.setSummary(mLockCityFonts.getEntry()); + mLockCityFonts.setOnPreferenceChangeListener(this); + } + + public boolean onPreferenceChange(Preference preference, Object objValue) { + if (preference == mWeatherIconPack) { + String value = (String) objValue; + Settings.System.putString(getContentResolver(), + Settings.System.OMNIJAWS_WEATHER_ICON_PACK, value); + int valueIndex = mWeatherIconPack.findIndexOfValue(value); + mWeatherIconPack.setSummary(mWeatherIconPack.getEntries()[valueIndex]); + return true; + } else if (preference == mLockTempFonts) { + Settings.System.putInt(getContentResolver(), Settings.System.LOCK_WEATHER_TEMP_FONTS, + Integer.valueOf((String) objValue)); + mLockTempFonts.setValue(String.valueOf(objValue)); + mLockTempFonts.setSummary(mLockTempFonts.getEntry()); + return true; + } else if (preference == mLockCityFonts) { + Settings.System.putInt(getContentResolver(), Settings.System.LOCK_WEATHER_CITY_FONTS, + Integer.valueOf((String) objValue)); + mLockCityFonts.setValue(String.valueOf(objValue)); + mLockCityFonts.setSummary(mLockCityFonts.getEntry()); + return true; + } + return false; + } + + private void getAvailableWeatherIconPacks(List entries, List values) { + Intent i = new Intent(); + PackageManager packageManager = getPackageManager(); + i.setAction("org.omnirom.WeatherIconPack"); + for (ResolveInfo r : packageManager.queryIntentActivities(i, 0)) { + String packageName = r.activityInfo.packageName; + if (packageName.equals(DEFAULT_WEATHER_ICON_PACKAGE)) { + values.add(0, r.activityInfo.name); + } else { + values.add(r.activityInfo.name); + } + String label = r.activityInfo.loadLabel(getPackageManager()).toString(); + if (label == null) { + label = r.activityInfo.packageName; + } + if (packageName.equals(DEFAULT_WEATHER_ICON_PACKAGE)) { + entries.add(0, label); + } else { + entries.add(label); + } + } + i = new Intent(Intent.ACTION_MAIN); + i.addCategory(CHRONUS_ICON_PACK_INTENT); + for (ResolveInfo r : packageManager.queryIntentActivities(i, 0)) { + String packageName = r.activityInfo.packageName; + values.add(packageName + ".weather"); + String label = r.activityInfo.loadLabel(getPackageManager()).toString(); + if (label == null) { + label = r.activityInfo.packageName; + } + entries.add(label); + } + } + + private boolean isOmniJawsEnabled() { + final Uri SETTINGS_URI + = Uri.parse("content://org.omnirom.omnijaws.provider/settings"); + + final String[] SETTINGS_PROJECTION = new String[] { + "enabled" + }; + + final Cursor c = getContentResolver().query(SETTINGS_URI, SETTINGS_PROJECTION, + null, null, null); + if (c != null) { + int count = c.getCount(); + if (count == 1) { + c.moveToPosition(0); + boolean enabled = c.getInt(0) == 1; + return enabled; + } + } + return true; + } + + public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider() { + + @Override + public List getXmlResourcesToIndex( + Context context, boolean enabled) { + final SearchIndexableResource sir = new SearchIndexableResource(context); + sir.xmlResId = R.xml.omnijaws_settings; + return Arrays.asList(sir); + } + + @Override + public List getNonIndexableKeys(Context context) { + ArrayList result = new ArrayList(); + return result; + } + }; +}