Skip to content

Commit 001d66b

Browse files
committed
1.3
- Fixed background blur on Android 12 (#13) - Added toggles for auto rotation & full sensor rotation (including upside down). Rotation is enabled by default, full sensor is not. (#15)
1 parent 12ce41b commit 001d66b

14 files changed

+89
-25
lines changed

.idea/modules.xml

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
id 'com.google.android.gms.oss-licenses-plugin'
88
}
99

10-
def version = '1.2'
10+
def version = '1.3'
1111

1212
android {
1313
compileSdk 31
@@ -16,7 +16,7 @@ android {
1616
applicationId "com.kieronquinn.app.classicpowermenu"
1717
minSdk 30
1818
targetSdk 31
19-
versionCode 12
19+
versionCode 13
2020
versionName version
2121

2222
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -71,8 +71,8 @@ sourceSets{
7171
dependencies {
7272

7373
//AndroidX
74-
def lifecycle_version = "2.4.0-rc01"
75-
implementation 'androidx.core:core-ktx:1.6.0'
74+
def lifecycle_version = "2.4.0"
75+
implementation 'androidx.core:core-ktx:1.7.0'
7676
implementation 'androidx.appcompat:appcompat:1.3.1'
7777
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
7878
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
@@ -95,7 +95,7 @@ dependencies {
9595
implementation "io.insert-koin:koin-android:$koin_version"
9696

9797
//Protobuf
98-
implementation 'com.google.protobuf:protobuf-lite:3.0.0'
98+
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
9999

100100
//Guava for hashing code (to match what Gpay uses)
101101
implementation 'com.google.guava:guava:30.1.1-android'
@@ -138,7 +138,7 @@ dependencies {
138138

139139
//Other third party
140140
implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:2.0'
141-
implementation 'com.airbnb.android:lottie:4.1.0'
141+
implementation 'com.airbnb.android:lottie:4.2.0'
142142
implementation 'com.jakewharton:process-phoenix:2.1.2'
143143
implementation 'me.saket:better-link-movement-method:2.2.0'
144144
implementation "io.noties.markwon:core:4.6.2"

app/release/output-metadata.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"type": "SINGLE",
1212
"filters": [],
1313
"attributes": [],
14-
"versionCode": 12,
15-
"versionName": "1.2",
14+
"versionCode": 13,
15+
"versionName": "1.3",
1616
"outputFile": "app-release.apk"
1717
}
1818
],

app/src/main/AndroidManifest.xml

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<activity android:name=".ui.activities.PowerMenuActivity"
3030
android:theme="@style/Theme.ClassicPowerMenu.Fullscreen"
3131
android:noHistory="true"
32-
android:screenOrientation="fullSensor"
3332
android:launchMode="singleInstance"
3433
android:excludeFromRecents="true"/>
3534

app/src/main/java/com/kieronquinn/app/classicpowermenu/ClassicPowerMenu.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class ClassicPowerMenu: LifecycleApplication() {
143143
viewModel<MainActivityViewModel> { MainActivityViewModelImpl(get(), get()) }
144144
viewModel<DecisionViewModel> { DecisionViewModelImpl(get(), get()) }
145145
viewModel<PowerMenuViewModel> { PowerMenuViewModelImpl(get(), get(), get(), get(), get(), get()) }
146-
viewModel<PowerMenuActivityViewModel> { PowerMenuActivityViewModelImpl(get(), get()) }
146+
viewModel<PowerMenuActivityViewModel> { PowerMenuActivityViewModelImpl(get(), get(), get()) }
147147
viewModel<SafeModeTopSheetViewModel> { SafeModeTopSheetViewModelImpl(get(), get()) }
148148
viewModel<SetupLandingViewModel> { SetupLandingViewModelImpl(get()) }
149149
viewModel<SetupRootCheckViewModel> { SetupRootCheckViewModelImpl(get()) }

app/src/main/java/com/kieronquinn/app/classicpowermenu/components/blur/BlurProvider31.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.kieronquinn.app.classicpowermenu.components.blur
33
import android.content.res.Resources
44
import android.os.Build
55
import android.view.Window
6+
import android.view.WindowManager
67
import androidx.annotation.RequiresApi
78
import com.kieronquinn.app.classicpowermenu.R
89

@@ -23,7 +24,7 @@ class BlurProvider31(resources: Resources): BlurProvider() {
2324

2425
override fun applyBlurToWindow(window: Window, ratio: Float) {
2526
val radius = blurRadiusOfRatio(ratio)
26-
window.attributes.blurBehindRadius = radius
27+
window.setBackgroundBlurRadius(radius)
2728
}
2829

2930
}

app/src/main/java/com/kieronquinn/app/classicpowermenu/components/settings/Settings.kt

+10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ abstract class Settings {
2020
abstract var monetColor: Int?
2121
abstract var powerOptionsHideWhenLocked: Boolean
2222
abstract var powerOptionsOpenCollapsed: Boolean
23+
abstract var allowRotation: Boolean
24+
abstract var allowFullRotation: Boolean
2325
abstract var powerMenuButtons: List<PowerMenuButtonId>
2426
abstract var quickAccessWalletShow: Boolean
2527
abstract val quickAccessWalletShowFlow: Flow<Boolean>
@@ -65,6 +67,12 @@ class SettingsImpl(context: Context): Settings() {
6567
private const val KEY_POWER_MENU_BUTTONS = "power_options"
6668
private val DEFAULT_POWER_MENU_BUTTONS = PowerMenuButtonId.DEFAULT
6769

70+
private const val KEY_ALLOW_ROTATION = "allow_rotation"
71+
private const val DEFAULT_ALLOW_ROTATION = true
72+
73+
private const val KEY_ALLOW_FULL_ROTATION = "allow_full_rotation"
74+
private const val DEFAULT_ALLOW_FULL_ROTATION = false
75+
6876
//Quick Access Wallet
6977
private const val KEY_QUICK_ACCESS_WALLET_SHOW = "quick_access_wallet_show"
7078
private const val DEFAULT_QUICK_ACCESS_WALLET_SHOW = true
@@ -115,6 +123,8 @@ class SettingsImpl(context: Context): Settings() {
115123
override var powerOptionsHideWhenLocked by shared(KEY_POWER_OPTIONS_HIDE_WHEN_LOCKED, DEFAULT_POWER_OPTIONS_HIDE_WHEN_LOCKED)
116124
override var powerOptionsOpenCollapsed by shared(KEY_POWER_OPTIONS_OPEN_COLLAPSED, DEFAULT_POWER_OPTIONS_OPEN_COLLAPSED)
117125
override var powerMenuButtons by sharedList(KEY_POWER_MENU_BUTTONS, DEFAULT_POWER_MENU_BUTTONS, this::powerMenuButtonTypeConverter, this::powerMenuButtonTypeReverseConverter)
126+
override var allowRotation by shared(KEY_ALLOW_ROTATION, DEFAULT_ALLOW_ROTATION)
127+
override var allowFullRotation by shared(KEY_ALLOW_FULL_ROTATION, DEFAULT_ALLOW_FULL_ROTATION)
118128

119129
override var quickAccessWalletShow by shared(KEY_QUICK_ACCESS_WALLET_SHOW, DEFAULT_QUICK_ACCESS_WALLET_SHOW)
120130
override var quickAccessWalletShowLoyaltyCards by shared(KEY_QUICK_ACCESS_WALLET_SHOW_LOYALTY_CARDS, DEFAULT_QUICK_ACCESS_WALLET_SHOW_LOYALTY_CARDS)

app/src/main/java/com/kieronquinn/app/classicpowermenu/ui/activities/PowerMenuActivity.kt

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ package com.kieronquinn.app.classicpowermenu.ui.activities
22

33
import android.graphics.Color
44
import android.os.Bundle
5-
import android.util.Log
6-
import android.view.View
7-
import android.view.ViewTreeObserver
5+
import android.transition.Fade
86
import android.view.Window
97
import android.view.WindowManager
108
import androidx.core.view.WindowCompat
@@ -32,9 +30,14 @@ class PowerMenuActivity : MonetCompatActivity(), PowerMenuStarter.PowerMenuStart
3230
private val starter by inject<PowerMenuStarter>()
3331

3432
override fun onCreate(savedInstanceState: Bundle?) {
35-
overridePendingTransition(R.anim.activity_fade_in, 0)
33+
window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS)
34+
window.exitTransition = Fade()
35+
window.returnTransition = Fade()
36+
window.enterTransition = Fade()
37+
window.reenterTransition = Fade()
3638
window.setupWindowFlags()
3739
super.onCreate(savedInstanceState)
40+
requestedOrientation = viewModel.getRequestedOrientation()
3841
hideStatusBar()
3942
lifecycleScope.launchWhenCreated {
4043
setContentView(R.layout.activity_power_menu)
@@ -61,11 +64,6 @@ class PowerMenuActivity : MonetCompatActivity(), PowerMenuStarter.PowerMenuStart
6164
}
6265
}
6366

64-
override fun finish() {
65-
super.finish()
66-
overridePendingTransition(0, R.anim.activity_fade_out)
67-
}
68-
6967
override fun onResume() {
7068
super.onResume()
7169
starter.setEventListener(this)

app/src/main/java/com/kieronquinn/app/classicpowermenu/ui/activities/PowerMenuActivityViewModel.kt

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package com.kieronquinn.app.classicpowermenu.ui.activities
22

33
import android.content.Context
44
import android.content.Intent
5+
import android.content.pm.ActivityInfo
56
import androidx.lifecycle.ViewModel
67
import androidx.lifecycle.viewModelScope
8+
import com.kieronquinn.app.classicpowermenu.components.settings.Settings
79
import com.kieronquinn.app.classicpowermenu.service.container.CPMServiceContainer
810
import com.kieronquinn.app.classicpowermenu.utils.extensions.*
911
import kotlinx.coroutines.delay
@@ -12,17 +14,26 @@ import kotlinx.coroutines.launch
1214

1315
abstract class PowerMenuActivityViewModel: ViewModel() {
1416

17+
abstract fun getRequestedOrientation(): Int
1518
abstract val closeBroadcast: Flow<Unit>
1619
abstract fun sendCloseBroadcast(context: Context, ignoreSelf: Boolean)
1720

1821
}
1922

20-
class PowerMenuActivityViewModelImpl(context: Context, private val service: CPMServiceContainer): PowerMenuActivityViewModel() {
23+
class PowerMenuActivityViewModelImpl(context: Context, private val service: CPMServiceContainer, private val settings: Settings): PowerMenuActivityViewModel() {
2124

2225
private companion object {
2326
private val CLOSE_ACTIONS = arrayOf(Intent.ACTION_SCREEN_OFF, Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
2427
}
2528

29+
override fun getRequestedOrientation(): Int {
30+
return when {
31+
settings.allowFullRotation && settings.allowRotation -> ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
32+
settings.allowRotation -> ActivityInfo.SCREEN_ORIENTATION_SENSOR
33+
else -> ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
34+
}
35+
}
36+
2637
override val closeBroadcast = context.broadcastReceiverAsFlow(*CLOSE_ACTIONS).mapNotNull {
2738
if(it.isFromSelf()) null
2839
else Unit

app/src/main/java/com/kieronquinn/app/classicpowermenu/ui/screens/settings/poweroptions/SettingsPowerOptionsFragment.kt

+19
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,27 @@ class SettingsPowerOptionsFragment : SettingsGenericFragment(), BackAvailable, A
3131
getString(R.string.settings_power_options_open_collapsed),
3232
getText(R.string.settings_power_options_open_collapsed_desc),
3333
viewModel::openCollapsed
34+
),
35+
SettingsItem.SwitchSetting(
36+
R.drawable.ic_power_options_allow_rotation,
37+
getString(R.string.settings_power_options_allow_rotate),
38+
getText(R.string.settings_power_options_allow_rotate_desc),
39+
viewModel::allowRotation,
40+
tapAction = this::refreshItems
41+
),
42+
SettingsItem.SwitchSetting(
43+
R.drawable.ic_power_options_allow_full_rotation,
44+
getString(R.string.settings_power_options_allow_rotate_full),
45+
getText(R.string.settings_power_options_allow_rotate_full_desc),
46+
viewModel::allowFullRotation,
47+
enabled = { viewModel.allowRotation }
3448
)
3549
)
3650
}
3751

52+
private fun refreshItems(isChecked: Boolean): Boolean {
53+
recyclerView.invoke().adapter?.notifyDataSetChanged()
54+
return true
55+
}
56+
3857
}

app/src/main/java/com/kieronquinn/app/classicpowermenu/ui/screens/settings/poweroptions/SettingsPowerOptionsViewModel.kt

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ abstract class SettingsPowerOptionsViewModel: ViewModel() {
1212

1313
abstract var hideWhenLocked: Boolean
1414
abstract var openCollapsed: Boolean
15+
abstract var allowRotation: Boolean
16+
abstract var allowFullRotation: Boolean
1517

1618
abstract fun onRearrangeClicked()
1719

@@ -21,6 +23,8 @@ class SettingsPowerOptionsViewModelImpl(settings: Settings, private val containe
2123

2224
override var hideWhenLocked by settings::powerOptionsHideWhenLocked
2325
override var openCollapsed by settings::powerOptionsOpenCollapsed
26+
override var allowRotation by settings::allowRotation
27+
override var allowFullRotation by settings::allowFullRotation
2428

2529
override fun onRearrangeClicked() {
2630
viewModelScope.launch {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="?android:textColorPrimary"
8+
android:pathData="M20.34,7.79C18.52,5.26 15.76,4.01 13,4.01V2.21c0,-0.45 -0.54,-0.67 -0.85,-0.35L9.35,4.65c-0.2,0.2 -0.2,0.51 0,0.71l2.79,2.79C12.46,8.46 13,8.24 13,7.79V6.03c2.2,0 4.4,1 5.81,3.07c1.6,2.36 1.63,5.36 0.05,7.73c-1.99,2.99 -5.62,3.86 -8.58,2.62c-0.38,-0.16 -0.81,-0.1 -1.1,0.19l-0.05,0.05c-0.47,0.47 -0.34,1.29 0.27,1.56c3.63,1.58 8.09,0.66 10.74,-2.79C22.54,15.37 22.62,10.96 20.34,7.79z"/>
9+
<path
10+
android:fillColor="?android:textColorPrimary"
11+
android:pathData="M1.71,12.29c-0.39,0.39 -0.39,1.02 0,1.41l4.59,4.59c0.39,0.39 1.02,0.39 1.41,0l4.59,-4.59c0.39,-0.39 0.39,-1.02 0,-1.41L7.71,7.71c-0.39,-0.39 -1.02,-0.39 -1.41,0L1.71,12.29z"/>
12+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="?android:textColorPrimary"
8+
android:pathData="M11.65,4.58C11.26,4.2 10.75,4 10.23,4C9.72,4 9.21,4.2 8.82,4.59L4.59,8.82c-0.78,0.78 -0.78,2.04 0,2.82l7.77,7.77c0.39,0.39 0.9,0.59 1.41,0.59s1.02,-0.2 1.41,-0.59l4.24,-4.24c0.78,-0.78 0.78,-2.04 0,-2.82L11.65,4.58zM13.77,18L6,10.24L10.23,6L18,13.76L13.77,18zM13.04,0.05C12.7,0.02 12.35,0 12,0c-0.6,0 -1.2,0.05 -1.77,0.14C9.82,0.2 9.66,0.7 9.95,0.99l3.2,3.16C13.46,4.47 14,4.25 14,3.8V2.2c4.28,0.87 7.57,4.48 7.96,8.92c0.04,0.5 0.48,0.88 0.99,0.88h0c0.6,0 1.05,-0.52 1,-1.12C23.42,5.12 18.81,0.55 13.04,0.05zM10,21.8c-4.28,-0.87 -7.57,-4.48 -7.96,-8.92C1.99,12.38 1.56,12 1.05,12h0c-0.6,0 -1.05,0.52 -1,1.12c0.53,5.76 5.14,10.34 10.91,10.83C11.3,23.98 11.65,24 12,24c0.59,0 1.16,-0.05 1.72,-0.13c0.41,-0.06 0.59,-0.56 0.29,-0.85l-3.16,-3.16C10.54,19.54 10,19.76 10,20.21V21.8z"/>
9+
</vector>

app/src/main/res/values/strings.xml

+5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@
6666
<string name="settings_power_options_drag_to_rearrange">Tap &amp; hold to drag to add, remove or re-arrange</string>
6767
<string name="settings_power_options_cannot_remove">You must have at least one Power Option in the Power Menu</string>
6868
<string name="settings_power_options_rearrange_no_items">No more buttons to add</string>
69+
<string name="settings_power_options_allow_rotate">Allow Rotation</string>
70+
<string name="settings_power_options_allow_rotate_desc">Allows the screen to be orientated in either portrait or landscape</string>
71+
<string name="settings_power_options_allow_rotate_full">Allow Full Rotation</string>
72+
<string name="settings_power_options_allow_rotate_full_desc">Allows full rotation, including reverse portrait (upside down)</string>
73+
6974
<string name="settings_quick_access_wallet_switch">Show Quick Access Wallet</string>
7075
<string name="settings_quick_access_wallet_header_payment">Payment Cards</string>
7176
<string name="settings_quick_access_wallet_loyalty_cards">Loyalty Cards</string>

0 commit comments

Comments
 (0)