From 633e1baf2be1e3eb4bc7cf8d1066416d0bd8c69e Mon Sep 17 00:00:00 2001 From: Tyler Nijmeh Date: Wed, 31 Mar 2021 00:29:32 -0700 Subject: Clean up and improve UI Signed-off-by: Tyler Nijmeh --- .../BatterySaverProfileRecyclerAdapter.kt | 28 +++++++++--------- .../BatterySaverConstantsConfigProfiles.kt | 11 +------ app/src/main/res/layout/recycler_item_profile.xml | 34 +++++++++++++++------- app/src/main/res/values/strings.xml | 12 ++++---- 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() { 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 @@ -3,15 +3,6 @@ package com.draco.buoy.repositories 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 */ @@ -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 @@ - - + - - \ No newline at end of file + android:layout_height="match_parent" + android:padding="12dp" + android:orientation="vertical"> + + + + \ 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 @@ Could not handle this action - Default - The default configuration provided by the system + Reset + Undo all changes done by the app and restore secure settings to default. Light - The default configuration provided by the system + Marginally conserve battery without impeding the user experience Moderate - The default configuration provided by the system + Apply additional tweaks to save more battery without yet sacrificing performance High - The default configuration provided by the system + Sacrifice significant performance for a significant gain in power Extreme - The default configuration provided by the system + Apply the maximum changes available to save power at the expense of a fluid user experience \ No newline at end of file -- cgit v1.2.3