diff options
4 files changed, 45 insertions, 40 deletions
diff --git a/app/src/main/java/com/draco/buoy/recyclers/BatterySaverProfileRecyclerAdapter.kt b/app/src/main/java/com/draco/buoy/recyclers/BatterySaverProfileRecyclerAdapter.kt index 3e4669b..0957ee7 100644 --- a/app/src/main/java/com/draco/buoy/recyclers/BatterySaverProfileRecyclerAdapter.kt +++ b/app/src/main/java/com/draco/buoy/recyclers/BatterySaverProfileRecyclerAdapter.kt @@ -14,7 +14,7 @@ class BatterySaverProfileRecyclerAdapter( contentResolver: ContentResolver ) : RecyclerView.Adapter<BatterySaverProfileRecyclerAdapter.ViewHolder>() { private val batterySaverProfiles = arrayOf( - BatterySaverConstantsConfigProfiles.DEFAULT, + null, /* Reset */ BatterySaverConstantsConfigProfiles.LIGHT, BatterySaverConstantsConfigProfiles.MODERATE, BatterySaverConstantsConfigProfiles.HIGH, @@ -36,12 +36,10 @@ class BatterySaverProfileRecyclerAdapter( override fun onBindViewHolder(holder: ViewHolder, position: Int) { val profile = batterySaverProfiles[position] - val isDefaultProfile = (profile == BatterySaverConstantsConfigProfiles.DEFAULT) - when (profile) { - BatterySaverConstantsConfigProfiles.DEFAULT -> { - holder.title.setText(R.string.profile_title_default) - holder.description.setText(R.string.profile_description_default) + null -> { + holder.title.setText(R.string.profile_title_reset) + holder.description.setText(R.string.profile_description_reset) } BatterySaverConstantsConfigProfiles.LIGHT -> { @@ -66,13 +64,17 @@ class BatterySaverProfileRecyclerAdapter( } holder.itemView.setOnClickListener { - /* Apply profile */ - batterySaverManager.setConstantsConfig(profile) - /* Enable low power mode */ - batterySaverManager.setLowPower(true) - /* If this is not the default config, set sticky and don't auto disable */ - batterySaverManager.setLowPowerSticky(!isDefaultProfile) - batterySaverManager.setLowPowerStickyAutoDisableEnabled(isDefaultProfile) + if (profile == null) { + batterySaverManager.resetConstants() + batterySaverManager.setLowPower(false) + batterySaverManager.setLowPowerSticky(false) + batterySaverManager.setLowPowerStickyAutoDisableEnabled(true) + } else { + batterySaverManager.setConstantsConfig(profile) + batterySaverManager.setLowPower(true) + batterySaverManager.setLowPowerSticky(true) + batterySaverManager.setLowPowerStickyAutoDisableEnabled(false) + } } } diff --git a/app/src/main/java/com/draco/buoy/repositories/BatterySaverConstantsConfigProfiles.kt b/app/src/main/java/com/draco/buoy/repositories/BatterySaverConstantsConfigProfiles.kt index a935385..75a5228 100644 --- a/app/src/main/java/com/draco/buoy/repositories/BatterySaverConstantsConfigProfiles.kt +++ b/app/src/main/java/com/draco/buoy/repositories/BatterySaverConstantsConfigProfiles.kt @@ -4,15 +4,6 @@ import com.draco.buoy.models.BatterySaverConstantsConfig object BatterySaverConstantsConfigProfiles { /** - * Default battery saver configuration - * Fits between MODERATE and HIGH - * - * @see MODERATE - * @see HIGH - */ - val DEFAULT = BatterySaverConstantsConfig() - - /** * Keep the system running smoothly with some idle tweaks */ val LIGHT = BatterySaverConstantsConfig( @@ -34,8 +25,8 @@ object BatterySaverConstantsConfigProfiles { val MODERATE = BatterySaverConstantsConfig( launchBoostDisabled = false, vibrationDisabled = false, - fireWallDisabled = false, soundTriggerDisabled = false, + fireWallDisabled = false, gpsMode = PowerManagerLocationModes.THROTTLE_SCREEN_OFF, forceAllAppsStandby = false, forceBackgroundCheck = false, diff --git a/app/src/main/res/layout/recycler_item_profile.xml b/app/src/main/res/layout/recycler_item_profile.xml index 25b0cde..6db4ac0 100644 --- a/app/src/main/res/layout/recycler_item_profile.xml +++ b/app/src/main/res/layout/recycler_item_profile.xml @@ -1,14 +1,26 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="200dp" - android:orientation="vertical"> - <TextView + android:layout_height="wrap_content" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_marginHorizontal="12dp" + android:layout_marginTop="12dp" + app:cardCornerRadius="10dp" + app:cardBackgroundColor="@color/green"> + <LinearLayout android:layout_width="match_parent" - android:layout_height="wrap_content" - android:id="@+id/title" /> - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:id="@+id/description" /> -</LinearLayout>
\ No newline at end of file + android:layout_height="match_parent" + android:padding="12dp" + android:orientation="vertical"> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + style="@style/TextAppearance.AppCompat.Display1" + android:id="@+id/title" /> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + style="@style/TextAppearance.AppCompat.Medium" + android:id="@+id/description" /> + </LinearLayout> +</androidx.cardview.widget.CardView>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c2acd83..afd0b7b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -12,18 +12,18 @@ <string name="snackbar_intent_failed">Could not handle this action</string> - <string name="profile_title_default">Default</string> - <string name="profile_description_default">The default configuration provided by the system</string> + <string name="profile_title_reset">Reset</string> + <string name="profile_description_reset">Undo all changes done by the app and restore secure settings to default.</string> <string name="profile_title_light">Light</string> - <string name="profile_description_light">The default configuration provided by the system</string> + <string name="profile_description_light">Marginally conserve battery without impeding the user experience</string> <string name="profile_title_moderate">Moderate</string> - <string name="profile_description_moderate">The default configuration provided by the system</string> + <string name="profile_description_moderate">Apply additional tweaks to save more battery without yet sacrificing performance</string> <string name="profile_title_high">High</string> - <string name="profile_description_high">The default configuration provided by the system</string> + <string name="profile_description_high">Sacrifice significant performance for a significant gain in power</string> <string name="profile_title_extreme">Extreme</string> - <string name="profile_description_extreme">The default configuration provided by the system</string> + <string name="profile_description_extreme">Apply the maximum changes available to save power at the expense of a fluid user experience</string> </resources>
\ No newline at end of file |
