diff options
| author | Ali B <abittin@gmail.com> | 2021-05-07 23:46:57 +0300 |
|---|---|---|
| committer | Ali B <abittin@gmail.com> | 2021-05-10 14:10:47 +0300 |
| commit | 7beb8c491d646af65ab2d00b64f78d70837b8b95 (patch) | |
| tree | 2d1d8472d57e9c75d67fe1a4f812a5837cc00f24 | |
| parent | 49449f11137c4a0bed6cd417c94b26dfde2ef5c6 (diff) | |
PartsBin: partially revert RefreshRate commits
Includes partial reverts to
I415a58 PartsBin: add Refreshrate switching and QS tile
I660989 PartsBin 1/2: Make Refreshrate switching use integer values
and also some code cleanup in DeviceSettings
Change-Id: Ib801c21c00464728513beb0ab2c9f479c1dac1e8
| -rw-r--r-- | AndroidManifest.xml | 11 | ||||
| -rw-r--r-- | res/values/config.xml | 5 | ||||
| -rw-r--r-- | res/xml/main.xml | 11 | ||||
| -rw-r--r-- | src/com/aicp/device/AutoRefreshRateSwitch.java | 54 | ||||
| -rw-r--r-- | src/com/aicp/device/DeviceSettings.java | 21 | ||||
| -rw-r--r-- | src/com/aicp/device/RefreshRateSwitch.java | 61 | ||||
| -rw-r--r-- | src/com/aicp/device/RefreshRateTileService.java | 95 |
7 files changed, 4 insertions, 254 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 48a18f9..7b44fbf 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -115,17 +115,6 @@ android:name="android.service.quicksettings.action.QS_TILE"/> </intent-filter> </service> - <service - android:name="com.aicp.device.RefreshRateTileService" - android:icon="@drawable/ic_refresh" - android:label="@string/tile_refresh_rate" - android:enabled="@bool/enableRefreshrateTile" - android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> - <intent-filter> - <action - android:name="android.service.quicksettings.action.QS_TILE"/> - </intent-filter> - </service> </application> </manifest> diff --git a/res/values/config.xml b/res/values/config.xml index e102e44..d4d7b2c 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -20,8 +20,6 @@ <bool name="config_device_has_hw_nav_buttons">false</bool> <bool name="config_device_supports_switch_refreshrate">false</bool> - <integer name="BaseRefresh"></integer> - <integer name="PeakRefresh"></integer> <bool name="config_device_supports_soundtuner">false</bool> @@ -126,9 +124,6 @@ <!-- Show/hide the QS tile, if device supports DC Dimming or not --> <bool name="enableDCDTile">false</bool> - <!-- Show/hide the QS tile, if device supports refreshrate switching or not --> - <bool name="enableRefreshrateTile">false</bool> - <!-- Show/hide the QS tile, if device supports switching Displaymodes or not --> <bool name="enablePanelModeTile">false</bool> diff --git a/res/xml/main.xml b/res/xml/main.xml index c441994..a15be3e 100644 --- a/res/xml/main.xml +++ b/res/xml/main.xml @@ -72,17 +72,6 @@ <PreferenceCategory android:key="category_refresh" android:title="@string/refresh_title"> - <SwitchPreference - android:key="auto_refresh_rate" - android:title="@string/auto_refresh_rate_title" - android:icon="@drawable/ic_refresh" - android:summary="@string/auto_refresh_rate_summary" - android:persistent="true" /> - <SwitchPreference - android:key="refresh_rate" - android:title="@string/refresh_rate_title" - android:summary="@string/refresh_rate_summary" - android:persistent="false" /> <ListPreference android:key="peakrefreshrate" diff --git a/src/com/aicp/device/AutoRefreshRateSwitch.java b/src/com/aicp/device/AutoRefreshRateSwitch.java deleted file mode 100644 index 213c1a5..0000000 --- a/src/com/aicp/device/AutoRefreshRateSwitch.java +++ /dev/null @@ -1,54 +0,0 @@ -/* -* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>. -* -*/ -package com.aicp.device; - -import android.content.Context; -import android.content.SharedPreferences; -import android.provider.Settings; -import androidx.preference.Preference; -import androidx.preference.Preference.OnPreferenceChangeListener; - -public class AutoRefreshRateSwitch implements OnPreferenceChangeListener { - - public static final String SETTINGS_KEY = DeviceSettings.KEY_SETTINGS_PREFIX + DeviceSettings.KEY_AUTO_REFRESH_RATE; - - private Context mContext; - protected static float mBaseRefresh; - protected static float mPeakRefresh; - - public AutoRefreshRateSwitch(Context context) { - mContext = context; - mBaseRefresh = (float) context.getResources().getInteger(R.integer.BaseRefresh); - mPeakRefresh = (float) context.getResources().getInteger(R.integer.PeakRefresh); - } - - public static boolean isCurrentlyEnabled(Context context) { - return Settings.System.getInt(context.getContentResolver(), SETTINGS_KEY, 1) == 1; - } - - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - Boolean enabled = (Boolean) newValue; - Settings.System.putFloat(mContext.getContentResolver(), - Settings.System.PEAK_REFRESH_RATE, mPeakRefresh); - Settings.System.putFloat(mContext.getContentResolver(), - Settings.System.MIN_REFRESH_RATE, mBaseRefresh); - Settings.System.putInt(mContext.getContentResolver(), SETTINGS_KEY, enabled ? 1 : 0); - return true; - } -} diff --git a/src/com/aicp/device/DeviceSettings.java b/src/com/aicp/device/DeviceSettings.java index c402156..82b0a1a 100644 --- a/src/com/aicp/device/DeviceSettings.java +++ b/src/com/aicp/device/DeviceSettings.java @@ -99,8 +99,6 @@ public class DeviceSettings extends PreferenceFragment implements public static final String KEY_S2S_SWITCH = "sweep_to_sleep"; public static final String KEY_S2W_SWITCH = "sweep_to_wake"; public static final String KEY_FASTCHARGE_SWITCH = "fastcharge"; - public static final String KEY_REFRESH_RATE = "refresh_rate"; - public static final String KEY_AUTO_REFRESH_RATE = "auto_refresh_rate"; private static final String KEY_PEAK_REFRESH_RATE = "peakrefreshrate"; private static final String KEY_MIN_REFRESH_RATE = "minrefreshrate"; private static final String KEY_ENABLE_DOLBY_ATMOS = "enable_dolby_atmos"; @@ -134,8 +132,6 @@ public class DeviceSettings extends PreferenceFragment implements private static TwoStatePreference mDoubleTapToWakeSwitch; private static TwoStatePreference mSweepToSleepSwitch; private static TwoStatePreference mSweepToWakeSwitch; - private static TwoStatePreference mRefreshRate; - private static TwoStatePreference mAutoRefreshRate; private SwitchPreference mEnableDolbyAtmos; @Override @@ -268,14 +264,10 @@ public class DeviceSettings extends PreferenceFragment implements if (graphicsRemoved == 3) graphicsCategory.getParent().removePreference(graphicsCategory); if (supportsRefreshrate) { - mAutoRefreshRate = (TwoStatePreference) findPreference(KEY_AUTO_REFRESH_RATE); - mAutoRefreshRate.setChecked(AutoRefreshRateSwitch.isCurrentlyEnabled(this.getContext())); - mAutoRefreshRate.setOnPreferenceChangeListener(new AutoRefreshRateSwitch(getContext())); - - mRefreshRate = (TwoStatePreference) findPreference(KEY_REFRESH_RATE); - mRefreshRate.setEnabled(!AutoRefreshRateSwitch.isCurrentlyEnabled(this.getContext())); - mRefreshRate.setChecked(RefreshRateSwitch.isCurrentlyEnabled(this.getContext())); - mRefreshRate.setOnPreferenceChangeListener(new RefreshRateSwitch(getContext())); + mPeakRefreshRatePref = findPreference(KEY_PEAK_REFRESH_RATE); + initRefreshRatePreference(mPeakRefreshRatePref, PEAK_REFRESH_RATE); + mMinRefreshRatePref = findPreference(KEY_MIN_REFRESH_RATE); + initRefreshRatePreference(mMinRefreshRatePref, MIN_REFRESH_RATE); } else { PreferenceCategory refreshCategory = (PreferenceCategory) findPreference(KEY_CATEGORY_REFRESH); refreshCategory.getParent().removePreference(refreshCategory); @@ -348,11 +340,6 @@ public class DeviceSettings extends PreferenceFragment implements countVibRemoved += 1; } if (countVibRemoved == 3) vibratorCategory.getParent().removePreference(vibratorCategory); - - mPeakRefreshRatePref = findPreference(KEY_PEAK_REFRESH_RATE); - initRefreshRatePreference(mPeakRefreshRatePref, PEAK_REFRESH_RATE); - mMinRefreshRatePref = findPreference(KEY_MIN_REFRESH_RATE); - initRefreshRatePreference(mMinRefreshRatePref, MIN_REFRESH_RATE); } private void initRefreshRatePreference(ListPreference preference, String key) { diff --git a/src/com/aicp/device/RefreshRateSwitch.java b/src/com/aicp/device/RefreshRateSwitch.java deleted file mode 100644 index 33ab336..0000000 --- a/src/com/aicp/device/RefreshRateSwitch.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>. -* -*/ -package com.aicp.device; - -import android.content.Context; -import android.content.SharedPreferences; -import android.provider.Settings; -import androidx.preference.Preference; -import androidx.preference.Preference.OnPreferenceChangeListener; - -public class RefreshRateSwitch implements OnPreferenceChangeListener { - - public static final String SETTINGS_KEY = DeviceSettings.KEY_SETTINGS_PREFIX + DeviceSettings.KEY_REFRESH_RATE; - - private Context mContext; - protected static float mBaseRefresh; - protected static float mPeakRefresh; - - public RefreshRateSwitch(Context context) { - mContext = context; - mBaseRefresh = (float) context.getResources().getInteger(R.integer.BaseRefresh); - mPeakRefresh = (float) context.getResources().getInteger(R.integer.PeakRefresh); - } - - public static boolean isCurrentlyEnabled(Context context) { - return Settings.System.getFloat(context.getContentResolver(), - Settings.System.PEAK_REFRESH_RATE, mPeakRefresh) == mPeakRefresh; - } - - public static void setPeakRefresh (Context context, boolean enabled) { - Settings.System.putFloat(context.getContentResolver(), - Settings.System.PEAK_REFRESH_RATE, enabled ? mPeakRefresh : mBaseRefresh); - Settings.System.putFloat(context.getContentResolver(), - Settings.System.MIN_REFRESH_RATE, enabled ? mPeakRefresh : mBaseRefresh); - } - - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - Boolean enabled = (Boolean) newValue; - Settings.System.putFloat(mContext.getContentResolver(), - Settings.System.PEAK_REFRESH_RATE, enabled ? mPeakRefresh : mBaseRefresh); - Settings.System.putFloat(mContext.getContentResolver(), - Settings.System.MIN_REFRESH_RATE, enabled ? mPeakRefresh : mBaseRefresh); - return true; - } -} diff --git a/src/com/aicp/device/RefreshRateTileService.java b/src/com/aicp/device/RefreshRateTileService.java deleted file mode 100644 index e407340..0000000 --- a/src/com/aicp/device/RefreshRateTileService.java +++ /dev/null @@ -1,95 +0,0 @@ -/* -* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. -* -*/ -package com.aicp.device; - -import android.annotation.TargetApi; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.drawable.Icon; -import android.provider.Settings; -import android.service.quicksettings.Tile; -import android.service.quicksettings.TileService; -import androidx.preference.PreferenceManager; - - -@TargetApi(24) -public class RefreshRateTileService extends TileService { - private boolean enabled = false; - private boolean autoRefreshEnabled; - protected static float mBaseRefresh; - protected static float mPeakRefresh; - - @Override - public void onDestroy() { - super.onDestroy(); - } - - @Override - public void onTileAdded() { - super.onTileAdded(); - } - - @Override - public void onTileRemoved() { - super.onTileRemoved(); - } - - @Override - public void onStartListening() { - super.onStartListening(); - mBaseRefresh = (float) this.getResources().getInteger(R.integer.BaseRefresh); - mPeakRefresh = (float) this.getResources().getInteger(R.integer.PeakRefresh); - autoRefreshEnabled = Settings.System.getInt(this.getContentResolver(), - AutoRefreshRateSwitch.SETTINGS_KEY, 1) == 1; - if (autoRefreshEnabled) { - getQsTile().setState(Tile.STATE_UNAVAILABLE); - } else { - enabled = RefreshRateSwitch.isCurrentlyEnabled(this); - RefreshRateSwitch.setPeakRefresh(this, enabled); - - getQsTile().setIcon(Icon.createWithResource(this, - enabled ? R.drawable.ic_refresh_tile_peak : R.drawable.ic_refresh_tile_base)); - getQsTile().setState(enabled ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE); - } - getQsTile().updateTile(); - } - - @Override - public void onStopListening() { - super.onStopListening(); - } - - @Override - public void onClick() { - super.onClick(); - if (!autoRefreshEnabled) { - SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); - enabled = RefreshRateSwitch.isCurrentlyEnabled(this); - RefreshRateSwitch.setPeakRefresh(this, enabled); - sharedPrefs.edit().putBoolean(DeviceSettings.KEY_REFRESH_RATE, enabled ? false : true).commit(); - Settings.System.putFloat(this.getContentResolver(), - Settings.System.PEAK_REFRESH_RATE, enabled ? mBaseRefresh : mPeakRefresh); - Settings.System.putFloat(this.getContentResolver(), - Settings.System.MIN_REFRESH_RATE, enabled ? mBaseRefresh : mPeakRefresh); - getQsTile().setIcon(Icon.createWithResource(this, - enabled ? R.drawable.ic_refresh_tile_base : R.drawable.ic_refresh_tile_peak)); - getQsTile().setState(enabled ? Tile.STATE_INACTIVE : Tile.STATE_ACTIVE); - getQsTile().updateTile(); - } - } -} |
