mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-10-01 01:35:54 -04:00
b6575a362e
Signed-off-by: Tad <tad@spotco.us>
105 lines
5.2 KiB
Diff
105 lines
5.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Tad <tad@spotco.us>
|
|
Date: Sat, 21 Oct 2017 09:05:09 -0400
|
|
Subject: [PATCH] Reduced Resolution Feature 1/2
|
|
|
|
Change-Id: I925a23e61ebf3ce06dc78898952085d87ad10410
|
|
---
|
|
res/values/strings.xml | 3 +++
|
|
res/xml/perf_profile_settings.xml | 6 ++++++
|
|
.../cmparts/power/PerfProfileSettings.java | 17 +++++++++++++++++
|
|
3 files changed, 26 insertions(+)
|
|
|
|
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
|
index 9cba5f2..e05168f 100644
|
|
--- a/res/values/strings.xml
|
|
+++ b/res/values/strings.xml
|
|
@@ -574,6 +574,9 @@
|
|
<string name="power_save_category_title">Battery saving</string>
|
|
<string name="power_save_title">Extreme power saver</string>
|
|
<string name="power_save_summary">Restrict device performance and background activity to save power</string>
|
|
+ <string name="reduce_resolution_title">Reduce screen resolution</string>
|
|
+ <string name="reduce_resolution_summary">Lowers the screen resolution to save power</string>
|
|
+ <string name="reduce_resolution_fail_toast">Unable to set a lower screen resolution</string>
|
|
<string name="auto_power_save_title">Automatic power saver</string>
|
|
<string name="auto_power_save_summary_on">Automatically enable power save mode at %s battery</string>
|
|
<string name="auto_power_save_summary_off">Do not enable power save mode automatically</string>
|
|
diff --git a/res/xml/perf_profile_settings.xml b/res/xml/perf_profile_settings.xml
|
|
index 3585cb7..ce99c6c 100644
|
|
--- a/res/xml/perf_profile_settings.xml
|
|
+++ b/res/xml/perf_profile_settings.xml
|
|
@@ -34,6 +34,12 @@
|
|
android:title="@string/auto_power_save_title"
|
|
android:persistent="false" />
|
|
|
|
+ <SwitchPreference
|
|
+ android:key="reduce_resolution"
|
|
+ android:title="@string/reduce_resolution_title"
|
|
+ android:summary="@string/reduce_resolution_summary"
|
|
+ android:persistent="false" />
|
|
+
|
|
</PreferenceCategory>
|
|
|
|
<PreferenceCategory
|
|
diff --git a/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java b/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
|
|
index ec2138d..5fdc8f1 100644
|
|
--- a/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
|
|
+++ b/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
|
|
@@ -56,11 +56,13 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
|
|
private static final String KEY_PERF_PROFILE_CATEGORY = "perf_profile_category";
|
|
private static final String KEY_AUTO_POWER_SAVE = "auto_power_save";
|
|
private static final String KEY_POWER_SAVE = "power_save";
|
|
+ private static final String KEY_REDUCE_RESOLUTION = "reduce_resolution";
|
|
private static final String KEY_PER_APP_PROFILES = "app_perf_profiles_enabled";
|
|
private static final String KEY_PERF_SEEKBAR = "perf_seekbar";
|
|
|
|
private ListPreference mAutoPowerSavePref;
|
|
private SwitchPreference mPowerSavePref;
|
|
+ private SwitchPreference mReduceResolutionPref;
|
|
|
|
private SeekBarPreference mPerfSeekBar;
|
|
private StopMotionVectorDrawable mPerfDrawable;
|
|
@@ -90,6 +92,7 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
|
|
mPerfSeekBar = (SeekBarPreference) findPreference(KEY_PERF_SEEKBAR);
|
|
mAutoPowerSavePref = (ListPreference) findPreference(KEY_AUTO_POWER_SAVE);
|
|
mPowerSavePref = (SwitchPreference) findPreference(KEY_POWER_SAVE);
|
|
+ mReduceResolutionPref = (SwitchPreference) findPreference(KEY_REDUCE_RESOLUTION);
|
|
mPerAppProfilesPref = (SwitchPreference) findPreference(KEY_PER_APP_PROFILES);
|
|
|
|
mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
|
@@ -124,6 +127,8 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
|
|
updateAutoPowerSaveValue();
|
|
mAutoPowerSavePref.setOnPreferenceChangeListener(this);
|
|
mPowerSavePref.setOnPreferenceChangeListener(this);
|
|
+ mReduceResolutionPref.setOnPreferenceChangeListener(this);
|
|
+ updateReduceResolutionValue();
|
|
}
|
|
|
|
|
|
@@ -245,6 +250,14 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
|
|
final int level = Integer.parseInt((String) newValue);
|
|
Global.putInt(getContentResolver(), Global.LOW_POWER_MODE_TRIGGER_LEVEL, level);
|
|
updateAutoPowerSaveSummary(level);
|
|
+ } else if (preference == mReduceResolutionPref) {
|
|
+ if (!mPowerManager.setReducedResolution((boolean) newValue)) {
|
|
+ // Don't just fail silently, inform the user as well
|
|
+ Toast.makeText(getActivity(),
|
|
+ R.string.reduce_resolution_fail_toast, Toast.LENGTH_SHORT).show();
|
|
+ return false;
|
|
+ }
|
|
+ updateReduceResolutionValue();
|
|
}
|
|
return true;
|
|
}
|
|
@@ -262,6 +275,10 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
|
|
PartsUpdater.notifyChanged(getActivity(), getPreferenceScreen().getKey());
|
|
}
|
|
|
|
+ private void updateReduceResolutionValue() {
|
|
+ mReduceResolutionPref.setChecked(mPowerManager.isReducedResolution());
|
|
+ }
|
|
+
|
|
private void updateAutoPowerSaveValue() {
|
|
final int level = Global.getInt(
|
|
getContentResolver(), Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
|