Skip to content

Commit

Permalink
cmparts: Overhaul the performance and power setttings
Browse files Browse the repository at this point in the history
 * Implement a new screen for managing power save and performance
   profiles with a nice slider and descriptions of what everything
   actually does.

Change-Id: I65b1780fbd7a5ca5d4fb882e3a9cf3ef28c0ab81
  • Loading branch information
ryzenforce990 committed Oct 13, 2016
1 parent be40850 commit 01fc9e6
Show file tree
Hide file tree
Showing 10 changed files with 583 additions and 83 deletions.
1 change: 1 addition & 0 deletions Android.mk
Expand Up @@ -12,6 +12,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-v7-appcompat \
android-support-v14-preference \
jsr305 \
uicommon \
org.cyanogenmod.platform.internal

LOCAL_RESOURCE_DIR := \
Expand Down
6 changes: 6 additions & 0 deletions res/anim/ic_perf_profile_needle.xml
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="600"
android:propertyName="rotation"
android:valueTo="-45"
android:valueFrom="-225"/>
34 changes: 34 additions & 0 deletions res/drawable/ic_perf_profile.xml
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="64dp"
android:width="64dp"
android:viewportHeight="48"
android:viewportWidth="48">

<group
android:name="base_gauge">

<path android:pathData="M24,8c8.8,0,16,7.2,16,16s-7.2,16-16,16S8,32.8,8,24S15.2,8,24,8 M24,4C13,4,4,13,4,24s9,20,20,20s20-9,20-20S35,4,24,4
L24,4z M24,20c-2.2,0-4,1.8-4,4s1.8,4,4,4s4-1.8,4-4S26.2,20,24,20z M32.5,13.5c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2
S33.6,13.5,32.5,13.5z M15.5,13.5c-1.1,0-2,0.9-2,2s0.9,2,2,2s2-0.9,2-2S16.6,13.5,15.5,13.5z M15.5,30.5c-1.1,0-2,0.9-2,2
c0,1.1,0.9,2,2,2s2-0.9,2-2C17.5,31.4,16.6,30.5,15.5,30.5z"

android:fillColor="#FFFFFFFF"/>

</group>

<group
android:name="needle"
android:pivotX="24"
android:pivotY="24"
android:rotation="-135">

<path
android:strokeColor="#FFFFFFFF"
android:strokeWidth="4"
android:strokeLineCap="round"
android:pathData="M 24,24 h 12"/>
</group>


</vector>
9 changes: 9 additions & 0 deletions res/drawable/ic_perf_profile_avd.xml
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_perf_profile">

<target
android:name="needle"
android:animation="@anim/ic_perf_profile_needle"/>

</animated-vector>
78 changes: 78 additions & 0 deletions res/layout/preference_slider.xml
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 The Android Open Source Project
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.
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:background="?android:attr/activatedBackgroundIndicator"
android:clipToPadding="false">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="8dip"
android:layout_marginBottom="8dip">

<TextView android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceListItem"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">

<ImageView
android:id="@+id/icon"
android:layout_gravity="center_vertical|start"
android:layout_width="48dp"
android:layout_height="48dp" />

<SeekBar
android:id="@+id/seekbar"
android:layout_marginStart="56dp"
android:layout_marginEnd="16dp"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="48dp"
style="@android:style/Widget.Material.SeekBar.Discrete"
android:tickMarkTint="@android:color/black" />

</FrameLayout>

<TextView
android:id="@android:id/summary"
android:paddingTop="4dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary"
android:gravity="center_vertical"
android:minLines="3"
android:maxLines="4" />

</LinearLayout>

</FrameLayout>
3 changes: 3 additions & 0 deletions res/values/colors.xml
Expand Up @@ -35,4 +35,7 @@

<color name="weather_settings_icon_tint">#B4B9BA</color>

<color name="perf_hot">#ffd10015</color>
<color name="perf_cold">#ff005994</color>

</resources>
21 changes: 12 additions & 9 deletions res/values/strings.xml
Expand Up @@ -532,15 +532,18 @@
<string name="status_bar_show_weather_summary">Display the current temperature on the status bar</string>

<!-- Power: Performance profiles -->
<string name="perf_profile_settings_title">Battery profiles</string>
<string name="perf_profile_settings_summary">Tweak your device\'s performance to suit your needs</string>
<string name="perf_profile_title">Battery profile</string>
<string name="perf_profile_fail_toast">The battery profile is currently unavailable</string>
<string name="power_save_title">Power save mode</string>
<string name="perf_profile_settings_title">Battery saver and performance</string>
<string name="perf_profile_settings_summary">Adjust power saving features and device performance</string>
<string name="perf_profile_overview_summary">Current profile: <xliff:g id="perf_profile_name">%1$s</xliff:g></string>
<string name="perf_profile_category_title">Device performance</string>
<string name="perf_profile_title">Performance profile: <xliff:g id="perf_profile_name">%1$s</xliff:g></string>
<string name="perf_profile_fail_toast">The performance profile is currently unavailable</string>
<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="auto_power_save_title">Battery saver</string>
<string name="auto_power_save_title">Automatic power saver</string>
<string name="auto_power_save_summary_on">Automatically enable power save mode at %d percent battery</string>
<string name="auto_power_save_summary_off">Never enable power save mode automatically</string>
<string name="app_perf_profiles_title">Enable per-app profiles</string>
<string name="app_perf_profiles_summary">Automatically choose an appropriate battery profile for various apps</string>
<string name="auto_power_save_summary_off">Do not enable power save mode automatically</string>
<string name="app_perf_profiles_title">Automatic optimization</string>
<string name="app_perf_profiles_summary">Automatically choose an appropriate performance profile for applications and usage patterns</string>
</resources>
56 changes: 35 additions & 21 deletions res/xml/perf_profile_settings.xml
Expand Up @@ -19,25 +19,39 @@
android:key="perf_profile_settings"
android:title="@string/perf_profile_settings_title" >

<ListPreference
android:key="perf_profile"
android:title="@string/perf_profile_title"
android:persistent="false" />

<SwitchPreference
android:key="power_save"
android:title="@string/power_save_title"
android:summary="@string/power_save_summary"
android:persistent="false" />

<ListPreference
android:key="auto_power_save"
android:title="@string/auto_power_save_title"
android:persistent="false" />

<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="app_perf_profiles_enabled"
android:title="@string/app_perf_profiles_title"
android:summary="@string/app_perf_profiles_summary" />

<PreferenceCategory
android:key="power_save_category"
android:title="@string/power_save_category_title">

<SwitchPreference
android:key="power_save"
android:title="@string/power_save_title"
android:summary="@string/power_save_summary"
android:persistent="false" />

<ListPreference
android:key="auto_power_save"
android:title="@string/auto_power_save_title"
android:persistent="false" />

</PreferenceCategory>

<PreferenceCategory
android:key="perf_profile_category"
android:title="@string/perf_profile_category_title">

<org.cyanogenmod.cmparts.SeekBarPreference
android:key="perf_seekbar"
android:title="@string/perf_profile_title"
android:max="4"
android:defaultValue="1"
android:persistent="false"
android:layout="@layout/preference_slider" />

<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="app_perf_profiles_enabled"
android:title="@string/app_perf_profiles_title"
android:summary="@string/app_perf_profiles_summary" />

</PreferenceCategory>
</PreferenceScreen>

0 comments on commit 01fc9e6

Please sign in to comment.