2017-10-21 09:10:23 -04:00
|
|
|
From a1e8c666a77d575c8d78a0d1269b3d06a7cb5d41 Mon Sep 17 00:00:00 2001
|
2017-10-20 15:31:04 -04:00
|
|
|
From: Tad <tad@spotco.us>
|
2017-10-21 09:10:23 -04:00
|
|
|
Date: Sat, 21 Oct 2017 09:05:09 -0400
|
2017-10-20 15:31:04 -04:00
|
|
|
Subject: [PATCH] Reduced Resolution Feature 1/2
|
|
|
|
|
2017-10-21 09:10:23 -04:00
|
|
|
Change-Id: I925a23e61ebf3ce06dc78898952085d87ad10410
|
2017-10-20 15:31:04 -04:00
|
|
|
---
|
2017-10-21 09:10:23 -04:00
|
|
|
res/values/strings.xml | 3 +++
|
|
|
|
res/xml/perf_profile_settings.xml | 6 ++++++
|
|
|
|
.../cyanogenmod/cmparts/power/PerfProfileSettings.java | 17 +++++++++++++++++
|
|
|
|
3 files changed, 26 insertions(+)
|
2017-10-20 15:31:04 -04:00
|
|
|
|
|
|
|
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
2017-10-20 16:54:46 -04:00
|
|
|
index 21b8b78..1fee482 100644
|
2017-10-20 15:31:04 -04:00
|
|
|
--- a/res/values/strings.xml
|
|
|
|
+++ b/res/values/strings.xml
|
2017-10-20 16:54:46 -04:00
|
|
|
@@ -576,6 +576,9 @@
|
2017-10-20 15:31:04 -04:00
|
|
|
<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>
|
2017-10-20 16:54:46 -04:00
|
|
|
+ <string name="reduce_resolution_fail_toast">Unable to set a lower screen resolution</string>
|
2017-10-20 15:31:04 -04:00
|
|
|
<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
|
2017-10-21 09:10:23 -04:00
|
|
|
index 3585cb7..ce99c6c 100644
|
2017-10-20 15:31:04 -04:00
|
|
|
--- a/res/xml/perf_profile_settings.xml
|
|
|
|
+++ b/res/xml/perf_profile_settings.xml
|
2017-10-21 09:10:23 -04:00
|
|
|
@@ -34,6 +34,12 @@
|
|
|
|
android:title="@string/auto_power_save_title"
|
2017-10-20 15:31:04 -04:00
|
|
|
android:persistent="false" />
|
|
|
|
|
|
|
|
+ <SwitchPreference
|
|
|
|
+ android:key="reduce_resolution"
|
|
|
|
+ android:title="@string/reduce_resolution_title"
|
2017-10-21 09:10:23 -04:00
|
|
|
+ android:summary="@string/reduce_resolution_summary"
|
|
|
|
+ android:persistent="false" />
|
2017-10-20 15:31:04 -04:00
|
|
|
+
|
2017-10-21 09:10:23 -04:00
|
|
|
</PreferenceCategory>
|
|
|
|
|
|
|
|
<PreferenceCategory
|
2017-10-20 15:31:04 -04:00
|
|
|
diff --git a/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java b/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
|
2017-10-21 09:10:23 -04:00
|
|
|
index ec2138d..5fdc8f1 100644
|
2017-10-20 15:31:04 -04:00
|
|
|
--- 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);
|
2017-10-21 09:10:23 -04:00
|
|
|
@@ -124,6 +127,8 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
|
2017-10-20 15:31:04 -04:00
|
|
|
updateAutoPowerSaveValue();
|
|
|
|
mAutoPowerSavePref.setOnPreferenceChangeListener(this);
|
|
|
|
mPowerSavePref.setOnPreferenceChangeListener(this);
|
|
|
|
+ mReduceResolutionPref.setOnPreferenceChangeListener(this);
|
2017-10-21 09:10:23 -04:00
|
|
|
+ updateReduceResolutionValue();
|
2017-10-20 15:31:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-21 09:10:23 -04:00
|
|
|
@@ -245,6 +250,14 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
|
2017-10-20 15:31:04 -04:00
|
|
|
final int level = Integer.parseInt((String) newValue);
|
|
|
|
Global.putInt(getContentResolver(), Global.LOW_POWER_MODE_TRIGGER_LEVEL, level);
|
|
|
|
updateAutoPowerSaveSummary(level);
|
2017-10-21 00:39:22 -04:00
|
|
|
+ } else if (preference == mReduceResolutionPref) {
|
2017-10-20 15:31:04 -04:00
|
|
|
+ if (!mPowerManager.setReducedResolution((boolean) newValue)) {
|
|
|
|
+ // Don't just fail silently, inform the user as well
|
|
|
|
+ Toast.makeText(getActivity(),
|
2017-10-20 16:54:46 -04:00
|
|
|
+ R.string.reduce_resolution_fail_toast, Toast.LENGTH_SHORT).show();
|
2017-10-20 15:31:04 -04:00
|
|
|
+ return false;
|
|
|
|
+ }
|
2017-10-21 00:39:22 -04:00
|
|
|
+ updateReduceResolutionValue();
|
2017-10-20 15:31:04 -04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-21 09:10:23 -04:00
|
|
|
@@ -262,6 +275,10 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
|
2017-10-20 15:31:04 -04:00
|
|
|
PartsUpdater.notifyChanged(getActivity(), getPreferenceScreen().getKey());
|
|
|
|
}
|
|
|
|
|
|
|
|
+ private void updateReduceResolutionValue() {
|
2017-10-21 00:39:22 -04:00
|
|
|
+ mReduceResolutionPref.setChecked(mPowerManager.isReducedResolution());
|
2017-10-20 15:31:04 -04:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
private void updateAutoPowerSaveValue() {
|
|
|
|
final int level = Global.getInt(
|
|
|
|
getContentResolver(), Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
|
|
|
|
--
|
|
|
|
2.14.2
|
|
|
|
|