Skip to content

Commit

Permalink
Merge pull request #60 from KieronQuinn/release/1.6
Browse files Browse the repository at this point in the history
1.6
  • Loading branch information
KieronQuinn authored Jul 19, 2022
2 parents 3a4eb17 + 43aa85a commit 1141265
Show file tree
Hide file tree
Showing 29 changed files with 160 additions and 360 deletions.
8 changes: 4 additions & 4 deletions Controls/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ android {
}

dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.lifecycle:lifecycle-common-java8:2.5.0-alpha04"
implementation 'androidx.core:core-ktx:1.8.0'
implementation "androidx.lifecycle:lifecycle-common-java8:2.6.0-alpha01"
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.fragment:fragment-ktx:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.fragment:fragment-ktx:1.5.0'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation "io.insert-koin:koin-android:$koin_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ private class ControlHolderAccessibilityDelegate(
info.className = Switch::class.java.name
}

override fun performAccessibilityAction(host: View?, action: Int, args: Bundle?): Boolean {
override fun performAccessibilityAction(host: View, action: Int, args: Bundle?): Boolean {
if (super.performAccessibilityAction(host, action, args)) {
return true
}
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ Classic Power Menu is a Power Menu Replacement for Android 11+, with the main ai

**[Please read the FAQ before downloading or creating an issue](https://github.com/KieronQuinn/ClassicPowerMenu/blob/main/app/src/main/assets/faq.md)**

[![Crowdin](https://badges.crowdin.net/classicpowermenu/localized.svg)](https://crowdin.com/project/classicpowermenu)

## Features

- Up to 7 power options in the Power Menu, including the non-stock options of Screenshot, Reboot Recovery and Reboot Bootloader
- Up to 10 power options in the Power Menu, including the non-stock options of Screenshot, Reboot Recovery and Reboot Bootloader
- Fully customisable, including rearranging and hiding buttons you don't use

- Quick Access Wallet in the Power Menu, accessible while locked or unlocked
- Optional blurring of card numbers while locked
- Optional showing of loyalty cards, restoring a previous feature from Android 10 which was removed. Loyalty cards' codes can be shown while locked and without needing to open Google Pay, if you wish.
- Optional showing of loyalty cards, restoring a previous feature from Android 10 which was removed. Loyalty cards' codes can be shown while locked and without needing to open Google Wallet, if you wish.

- Device Controls in the Power Menu, accessible while locked or unlocked
- Optional ability to interact with controls while locked, without requiring authentication
Expand Down
30 changes: 10 additions & 20 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ plugins {
id 'kotlin-parcelize'
id 'com.google.android.gms.oss-licenses-plugin'
}
apply plugin: 'kotlin-android'

def version = '1.5.1'
def version = '1.6'

android {
compileSdk 32
Expand All @@ -17,7 +16,7 @@ android {
applicationId "com.kieronquinn.app.classicpowermenu"
minSdk 30
targetSdk 31
versionCode 151
versionCode 160
versionName version

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -46,33 +45,27 @@ android {

protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.0.0'
artifact = "com.google.protobuf:protoc:3.19.2"
}
plugins {
javalite {
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.1'
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
remove java
}
task.plugins {
javalite { }
java {
option 'lite'
}
}
}
}
}

sourceSets{
main.java.srcDirs += "${protobuf.generatedFilesBaseDir}/main/javalite"
}

dependencies {

//AndroidX
def lifecycle_version = "2.4.1"
def lifecycle_version = "2.5.0"
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
Expand All @@ -96,7 +89,7 @@ dependencies {
implementation "io.insert-koin:koin-android:$koin_version"

//Protobuf
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
implementation "com.google.protobuf:protobuf-javalite:3.19.2"

//Guava for hashing code (to match what Gpay uses)
implementation 'com.google.guava:guava:30.1.1-android'
Expand All @@ -118,7 +111,7 @@ dependencies {
implementation 'com.journeyapps:zxing-android-embedded:4.1.0@aar'

//libsu for root operations
def libsuVersion = '4.0.3'
def libsuVersion = '5.0.2'
implementation "com.github.topjohnwu.libsu:core:${libsuVersion}"
implementation "com.github.topjohnwu.libsu:service:${libsuVersion}"
implementation "com.github.topjohnwu.libsu:io:${libsuVersion}"
Expand Down Expand Up @@ -148,7 +141,4 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "androidx.core:core-ktx:+"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 151,
"versionName": "1.5.1",
"versionCode": 160,
"versionName": "1.6",
"outputFile": "app-release.apk"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,18 @@ class ClassicPowerMenu: LifecycleApplication() {
}
}

override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
startKoin {
androidContext(base)
modules(singletonsModule, serviceModule, walletModule, monetModule, viewModelModule)
}
}

override fun onCreate() {
super.onCreate()
Shell.setDefaultBuilder(Shell.Builder.create().setFlags(Shell.FLAG_MOUNT_MASTER));
HiddenApiBypass.addHiddenApiExemptions("")
startKoin {
androidContext(this@ClassicPowerMenu)
modules(singletonsModule, serviceModule, walletModule, monetModule, viewModelModule)
}
setupMonet()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class WalletCardBlurProviderImpl(context: Context, private val settings: Setting
//Don't blur if not locked
if(!keyguardManager.isDeviceLocked && !settings.developerContentCreatorMode) return cardDrawable
if(!settings.quickAccessWalletHideCardNumberWhenLocked && !settings.developerContentCreatorMode) return cardDrawable
val cardBitmap = cardDrawable.bitmap
val cardBitmap = cardDrawable.bitmap.copy(cardDrawable.bitmap.config, true)
//Calculate the position of the last 4 digits of the card number
val cardYTop = (CARD_Y_TOP * cardBitmap.height).roundToInt()
val cardYBottom = (CARD_Y_BOTTOM * cardBitmap.height).roundToInt()
Expand All @@ -57,7 +57,7 @@ class WalletCardBlurProviderImpl(context: Context, private val settings: Setting
val outHeight = cardYBottom - cardYTop
val cropped = Bitmap.createBitmap(cardBitmap, cardXStart, cardYTop, outWidth, outHeight).run {
//Blur the bitmap
blurBitmap(this, 16f)
blurBitmap(this, 20f)
}
//Put the blurred bitmap back on top of the original image in the same position
Canvas(cardBitmap).run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enum class PowerMenuButtonType {
}

enum class PowerMenuButtonId {
EMERGENCY, POWER_OFF, REBOOT, LOCKDOWN, SCREENSHOT, REBOOT_RECOVERY, REBOOT_BOOTLOADER, RESTART_SYSTEMUI;
EMERGENCY, POWER_OFF, REBOOT, LOCKDOWN, SCREENSHOT, REBOOT_RECOVERY, REBOOT_BOOTLOADER, RESTART_SYSTEMUI, REBOOT_FASTBOOTD, REBOOT_DOWNLOAD;

companion object {
val DEFAULT = listOf(EMERGENCY, POWER_OFF, REBOOT, LOCKDOWN, SCREENSHOT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ abstract class PowerMenuViewModel: ViewModel() {
abstract fun onRebootRecoveryClicked()
abstract fun onRebootBootloaderClicked()
abstract fun onRestartSystemUIClicked()
abstract fun onRebootFastbootdClicked()
abstract fun onRebootDownloadClicked()

abstract fun onEmergencyClicked(context: Context)
abstract fun onLockdownClicked()
Expand Down Expand Up @@ -119,6 +121,24 @@ class PowerMenuViewModelImpl(context: Context, private val service: CPMServiceCo
}
}

override fun onRebootFastbootdClicked() {
viewModelScope.launch {
service.runWithService {
it.rebootWithReason("fastboot")
}
navigation.closePowerMenu()
}
}

override fun onRebootDownloadClicked() {
viewModelScope.launch {
service.runWithService {
it.rebootWithReason("download")
}
navigation.closePowerMenu()
}
}

override fun onRestartSystemUIClicked() {
viewModelScope.launch {
service.runWithService {
Expand Down Expand Up @@ -266,6 +286,20 @@ class PowerMenuViewModelImpl(context: Context, private val service: CPMServiceCo
::onRestartSystemUIClicked,
shouldShow = ::shouldShowPowerOption
)
PowerMenuButtonId.REBOOT_FASTBOOTD -> PowerMenuButton.Button(
PowerMenuButtonId.REBOOT_FASTBOOTD,
R.drawable.ic_reboot_fastbootd,
context.getString(R.string.power_menu_button_fastbootd),
::onRebootFastbootdClicked,
shouldShow = ::shouldShowPowerOption
)
PowerMenuButtonId.REBOOT_DOWNLOAD -> PowerMenuButton.Button(
PowerMenuButtonId.REBOOT_DOWNLOAD,
R.drawable.ic_reboot_download,
context.getString(R.string.power_menu_button_download),
::onRebootDownloadClicked,
shouldShow = ::shouldShowPowerOption
)
}

private fun shouldShowPowerOption(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ class SettingsPowerOptionsRearrangeViewModelImpl(private val settings: Settings,
context.getString(R.string.power_menu_button_restart_systemui),
this::emptyClick
)
PowerMenuButtonId.REBOOT_FASTBOOTD -> PowerMenuButton.Button(
PowerMenuButtonId.REBOOT_FASTBOOTD,
R.drawable.ic_reboot_fastbootd,
context.getString(R.string.power_menu_button_fastbootd),
this::emptyClick
)
PowerMenuButtonId.REBOOT_DOWNLOAD -> PowerMenuButton.Button(
PowerMenuButtonId.REBOOT_DOWNLOAD,
R.drawable.ic_reboot_download,
context.getString(R.string.power_menu_button_download),
this::emptyClick
)
}

override fun onBackPressed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import com.kieronquinn.app.classicpowermenu.model.settings.SettingsItem
import com.kieronquinn.app.classicpowermenu.ui.base.AutoExpandOnRotate
import com.kieronquinn.app.classicpowermenu.ui.base.BackAvailable
import com.kieronquinn.app.classicpowermenu.ui.screens.settings.switched.SettingsSwitchedFragment
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import org.koin.androidx.viewmodel.ext.android.viewModel

class SettingsQuickAccessWalletFragment: SettingsSwitchedFragment(), BackAvailable, AutoExpandOnRotate {
Expand Down Expand Up @@ -53,7 +51,7 @@ class SettingsQuickAccessWalletFragment: SettingsSwitchedFragment(), BackAvailab
private val paymentCardsItems by lazy {
listOf(
SettingsItem.Setting(
R.drawable.ic_google_pay,
R.drawable.ic_google_wallet,
getString(R.string.settings_quick_access_wallet_change_settings_in_pay),
getString(R.string.settings_quick_access_wallet_change_settings_in_pay_desc),
tapAction = viewModel::onChangeGooglePaySettingsClicked
Expand All @@ -70,7 +68,7 @@ class SettingsQuickAccessWalletFragment: SettingsSwitchedFragment(), BackAvailab
private val loyaltyCardsUnsupportedItems by lazy {
listOf(
SettingsItem.Setting(
R.drawable.ic_google_pay,
R.drawable.ic_google_wallet,
getString(R.string.settings_quick_access_wallet_loyalty_cards_not_supported),
getString(R.string.settings_quick_access_wallet_loyalty_cards_not_supported_desc),
visible = viewModel::isGooglePayInstalled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class SettingsRootCheckViewModel: ViewModel() {
class SettingsRootCheckViewModelImpl(private val containerNavigation: ContainerNavigation): SettingsRootCheckViewModel() {

private val _state = flow<State> {
val isRooted = Shell.rootAccess()
val isRooted = Shell.cmd("whoami").exec().out.firstOrNull() == "root"
if(isRooted){
emit(State.Result(RootResult.ROOTED))
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class SetupRootCheckViewModel: ViewModel() {
class SetupRootCheckViewModelImpl(private val navigation: ContainerNavigation): SetupRootCheckViewModel(){

private val _state = flow<State> {
val isRooted = Shell.rootAccess()
val isRooted = Shell.cmd("whoami").exec().out.firstOrNull() == "root"
if(isRooted){
emit(State.Result(RootResult.ROOTED))
}else{
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/proto/color.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ syntax = "proto3";

package google.type;

import "wrappers.proto";
import "google/protobuf/wrappers.proto";

option cc_enable_arenas = true;
option go_package = "google.golang.org/genproto/googleapis/type/color;color";
Expand Down
Loading

0 comments on commit 1141265

Please sign in to comment.