Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
R3.8.13
Browse files Browse the repository at this point in the history
将Shizuku图标资源转化成Webp,减小体积
PowerViewModel缓存Application对象,提升性能
删除多余代码
  • Loading branch information
ryuunoakaihitomi committed Jul 9, 2021
1 parent e94c447 commit a3e77da
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ android {
//targetSdkVersion compileSdkVersion
targetSdkVersion 30
// 版本号:发布日期
versionCode 20210628
versionCode 20210709
// 版本名说明: R3.x.y.z (R3:Refactoring 第三次重构,z:Quick Fix序号)
versionName 'R3.8.12.1'
versionName 'R3.8.13'
resConfigs "en", "zh-rCN"

buildConfigField 'String', 'BUILD_TIME', '\"' + new Date() + '\"'
Expand Down
Binary file removed app/src/main/assets/shizuku_logo.png
Binary file not shown.
Binary file added app/src/main/assets/shizuku_logo.webp
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class ShutdownReceiver : BroadcastReceiver() {
}

override fun onReceive(context: Context?, intent: Intent?) {
Intent.ACTION_GTALK_SERVICE_CONNECTED
if (intent?.action == Intent.ACTION_SHUTDOWN) {
Timber.d("Shutdown broadcast received.")
// 偶尔收到Caused by android.os.DeadObjectException的Unable to reach IQSService异常
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private fun Context.markwon() = Markwon.builder(this)
* 在文档中保留网址,不使用file:///android/asset。然后在errorHandler中匹配网址返回特定assets图像资源。
*/
"https://shizuku.rikka.app/logo.png" ->
RoundedBitmapDrawableFactory.create(resources, assets.open("shizuku_logo.png"))
RoundedBitmapDrawableFactory.create(resources, assets.open("shizuku_logo.webp"))
else ->
RC.getDrawable(Resources.getSystem(), android.R.drawable.ic_menu_gallery, null)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import timber.log.Timber
// AndroidViewModel 因为魔法问题不可用了
class PowerViewModel : ViewModel() {

private val app = BlackMagic.getGlobalApp()

/* Root模式:分隔开受限模式 */
val rootMode: LiveData<Boolean>
get() = _rootMode
Expand Down Expand Up @@ -73,9 +75,9 @@ class PowerViewModel : ViewModel() {
fun reverseForceMode() {
forceMode.value = getForceMode().not()
if (forceMode.value == true) {
Toasty.warning(app(), R.string.toast_switch_to_force_mode).show()
Toasty.warning(app, R.string.toast_switch_to_force_mode).show()
} else {
Toasty.normal(app(), R.string.toast_switch_to_privileged_mode).show()
Toasty.normal(app, R.string.toast_switch_to_privileged_mode).show()
}
changeInfo()
}
Expand Down Expand Up @@ -106,15 +108,15 @@ class PowerViewModel : ViewModel() {
lockScreenPrivileged
)

val rawTitle = app().getString(R.string.app_name)
val rawTitle = app.getString(R.string.app_name)
if (rootMode.value == true) {
_title.value = rawTitle

/* 在Android 11中,为特权模式添加打开系统电源菜单的选项以访问设备控制器(使用Shizuku实现) */
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R &&
Shizuku.pingBinder() &&
Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED &&
app().packageManager.hasSystemFeature(PackageManager.FEATURE_CONTROLS)
app.packageManager.hasSystemFeature(PackageManager.FEATURE_CONTROLS)
) {
Timber.d("add showSysPowerDialog for device controls")
val size = privilegedActions.size
Expand All @@ -131,7 +133,7 @@ class PowerViewModel : ViewModel() {
_title.value = String.format(
"%s %s",
rawTitle,
app().getString(R.string.title_dialog_restricted_mode)
app.getString(R.string.title_dialog_restricted_mode)
)
_infoArray.value = restrictedActions
_shortcutInfoArray.value = restrictedActions
Expand Down Expand Up @@ -189,14 +191,12 @@ class PowerViewModel : ViewModel() {
}
else -> powerInfo
}.apply {
label = colorForceLabel(app().getString(labelResId), this)
label = colorForceLabel(app.getString(labelResId), this)
this.labelResId = labelResId
}
}
//</editor-fold>

private fun app() = BlackMagic.getGlobalApp()

fun getForceMode() = forceMode.value ?: false

fun isOnForceMode(info: PowerInfo) = getForceMode() and info.hasForceMode
Expand All @@ -213,7 +213,7 @@ class PowerViewModel : ViewModel() {
if (isOnForceMode(info)) {
val range = 0..forceLabel.length
forceLabel[range] = ForegroundColorSpan(
ResourcesCompat.getColor(app().resources, R.color.colorForceModeItem, null)
ResourcesCompat.getColor(app.resources, R.color.colorForceModeItem, null)
)
forceLabel[range] = StyleSpan(Typeface.BOLD)
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter() // AndResGuard 1.2.20
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

/* Crashlytics */
Expand Down

0 comments on commit a3e77da

Please sign in to comment.