From 38aaced5d8044e01d51005cb3029e481ffba6641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C6=B0ng=20Phan?= Date: Sat, 3 Jul 2021 13:12:50 +0700 Subject: [PATCH] Revert "Cherish: Keyguard Batterybar & Color Modes [2/2]" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 36218a35f43b12d71e5c8dc4af3afc868700fbb3. Signed-off-by: Hưng Phan --- res/values/cherish_arrays.xml | 15 --- res/values/cherish_strings.xml | 13 -- res/xml/cherish_keyguard_battery_bar.xml | 55 --------- res/xml/cherish_settings_lockscreen.xml | 8 -- .../fragments/KeygaurdBatteryBar.java | 114 ------------------ 5 files changed, 205 deletions(-) delete mode 100644 res/xml/cherish_keyguard_battery_bar.xml delete mode 100644 src/com/cherish/settings/preferences/fragments/KeygaurdBatteryBar.java diff --git a/res/values/cherish_arrays.xml b/res/values/cherish_arrays.xml index 0988f2f..b0cbb88 100644 --- a/res/values/cherish_arrays.xml +++ b/res/values/cherish_arrays.xml @@ -1089,21 +1089,6 @@ 2 3 - - - - @string/keyguard_battery_bar_color_gradient - @string/keyguard_battery_bar_color_accent - @string/keyguard_battery_bar_color_random - @string/keyguard_battery_bar_color_custom - - - - 0 - 1 - 2 - 3 - diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index c70f584..96c1d04 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -1027,19 +1027,6 @@ Only in DND mode Always - - Battery bar - Show a battery bar on the ambient display when charging - Always show battery bar - Always show a battery bar on the ambient display - Color - AOD - Color mode - Gradient - Accent - Random - Custom - Tint the active volume bar Use a color gradient to tint the active volume bar diff --git a/res/xml/cherish_keyguard_battery_bar.xml b/res/xml/cherish_keyguard_battery_bar.xml deleted file mode 100644 index 40c3e4c..0000000 --- a/res/xml/cherish_keyguard_battery_bar.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/res/xml/cherish_settings_lockscreen.xml b/res/xml/cherish_settings_lockscreen.xml index 5c429b8..0cfc5cd 100644 --- a/res/xml/cherish_settings_lockscreen.xml +++ b/res/xml/cherish_settings_lockscreen.xml @@ -269,13 +269,6 @@ android:entryValues="@array/lockscreen_albumart_filter_values" android:dependency="lockscreen_media_metadata" android:defaultValue="0" /> - - - diff --git a/src/com/cherish/settings/preferences/fragments/KeygaurdBatteryBar.java b/src/com/cherish/settings/preferences/fragments/KeygaurdBatteryBar.java deleted file mode 100644 index 72dd9cf..0000000 --- a/src/com/cherish/settings/preferences/fragments/KeygaurdBatteryBar.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2021 TenX-OS - * - * 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. - */ -package com.cherish.settings.fragments; - -import android.app.Activity; -import android.content.ContentResolver; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.os.SystemProperties; -import android.os.UserHandle; -import android.provider.Settings; -import androidx.preference.*; - -import com.android.internal.logging.nano.MetricsProto; - -import com.android.settings.R; -import com.android.settings.SettingsPreferenceFragment; - -import com.cherish.settings.preferences.SystemSettingListPreference; -import net.margaritov.preference.colorpicker.ColorPickerPreference; - -public class KeygaurdBatteryBar extends SettingsPreferenceFragment - implements Preference.OnPreferenceChangeListener { - - private static final String BATTERY_BAR_COLOR_MODE = "keygaurd_battery_bar_color_mode"; - private static final String BATTERY_BAR_COLOR_CUSTOM = "keygaurd_battery_bar_color_custom"; - - private SystemSettingListPreference mColor; - private ColorPickerPreference mColorCustom; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.cherish_keyguard_battery_bar); - PreferenceScreen prefScreen = getPreferenceScreen(); - ContentResolver resolver = getActivity().getContentResolver(); - - mColor = (SystemSettingListPreference) findPreference(BATTERY_BAR_COLOR_MODE); - mColor.setOnPreferenceChangeListener(this); - int color = Settings.System.getIntForUser(resolver, - Settings.System.KEYGAURD_BATTERY_BAR_COLOR_MODE, 0, UserHandle.USER_CURRENT); - mColor.setValue(String.valueOf(color)); - mColor.setSummary(mColor.getEntry()); - - mColorCustom = (ColorPickerPreference) findPreference(BATTERY_BAR_COLOR_CUSTOM); - mColorCustom.setOnPreferenceChangeListener(this); - int custom = Settings.System.getInt(getContentResolver(), - Settings.System.KEYGAURD_BATTERY_BAR_COLOR_CUSTOM, 0xFFFFFFFF); - String hex = String.format("#%08x", (0xFFFFFFFF & custom)); - if (hex.equals("#ffffffff")) { - mColorCustom.setSummary(R.string.default_string); - } else { - mColorCustom.setSummary(hex); - } - mColorCustom.setNewPreviewColor(custom); - - updateColorPrefs(color); - } - - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - ContentResolver resolver = getActivity().getContentResolver(); - if (preference == mColor) { - int color = Integer.parseInt(((String) newValue).toString()); - Settings.System.putIntForUser(resolver, - Settings.System.KEYGAURD_BATTERY_BAR_COLOR_MODE, color, UserHandle.USER_CURRENT); - int index = mColor.findIndexOfValue((String) newValue); - mColor.setSummary( - mColor.getEntries()[index]); - updateColorPrefs(color); - return true; - } else if (preference == mColorCustom) { - String hex = ColorPickerPreference.convertToARGB( - Integer.valueOf(String.valueOf(newValue))); - if (hex.equals("#ffffffff")) { - preference.setSummary(R.string.default_string); - } else { - preference.setSummary(hex); - } - int intHex = ColorPickerPreference.convertToColorInt(hex); - Settings.System.putInt(getContentResolver(), - Settings.System.KEYGAURD_BATTERY_BAR_COLOR_CUSTOM, intHex); - return true; - } - return false; - } - - private void updateColorPrefs(int color) { - if (color == 3) { - mColorCustom.setEnabled(true); - } else { - mColorCustom.setEnabled(false); - } - } - - @Override - public int getMetricsCategory() { - return MetricsProto.MetricsEvent.CHERISH_SETTINGS; - } -}