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

Commit

Permalink
R3.8.8
Browse files Browse the repository at this point in the history
修复Wear OS上点击帮助的链接崩溃的问题
  • Loading branch information
ryuunoakaihitomi committed Jun 3, 2021
1 parent fc2981d commit b90dc1e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
10 changes: 6 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.time.LocalDateTime

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
//apply plugin: 'AndResGuard'
Expand All @@ -15,9 +17,9 @@ android {
//targetSdkVersion compileSdkVersion
targetSdkVersion 30
// 版本号:发布日期
versionCode 20210601
versionCode 20210603
// 版本名说明: R3.x.y.z (R3:Refactoring 第三次重构,z:Quick Fix序号)
versionName 'R3.8.7.2'
versionName 'R3.8.8'
resConfigs "en", "zh-rCN"

buildConfigField 'String', 'BUILD_TIME', '\"' + new Date() + '\"'
Expand Down Expand Up @@ -45,7 +47,7 @@ android {
signingConfig signingConfigs.release
}
debug {
versionNameSuffix '-debug' +/* 精确判断是不是刚才编译的debug版本 */LocalTime.now().format("(HHmmss)")
versionNameSuffix '-debug' +/* 精确判断是不是刚才编译的debug版本 */LocalDateTime.now().format("(dHHmmss)")
}
}
flavorDimensions "version"
Expand Down Expand Up @@ -78,7 +80,7 @@ dependencies {
// ZXing需要method sort(Ljava/util/Comparator;)V in class Ljava/util/List;
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.2.0'

def lifecycle_version = "2.3.1"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<!-- 来自CM平台SDK文档 -->
<uses-permission android:name="cyanogenmod.permission.PUBLISH_CUSTOM_TILE" />

<!-- Shizuku的minSdkVersion是23,因此在使用相关API前必须判断Build.VERSION.SDK_INT -->
<uses-sdk tools:overrideLibrary="rikka.shizuku.shared,rikka.shizuku.provider,rikka.shizuku.api,rikka.shizuku.aidl" />

<!-- TV -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import android.text.style.StyleSpan
import android.text.style.TypefaceSpan
import android.view.View
import android.view.ViewGroup
import android.view.WindowInsets
import android.view.WindowInsetsController
import android.view.Window
import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo
import android.widget.AdapterView
Expand All @@ -31,6 +30,9 @@ import androidx.core.graphics.drawable.IconCompat
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
import androidx.core.graphics.drawable.toBitmap
import androidx.core.text.set
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.ViewModelProvider
Expand All @@ -46,7 +48,9 @@ import github.ryuunoakaihitomi.powerpanel.ui.OpenSourceLibDependencyActivity
import github.ryuunoakaihitomi.powerpanel.ui.ShortcutActivity
import github.ryuunoakaihitomi.powerpanel.ui.tile.CmCustomTileService
import github.ryuunoakaihitomi.powerpanel.util.*
import io.noties.markwon.AbstractMarkwonPlugin
import io.noties.markwon.Markwon
import io.noties.markwon.MarkwonConfiguration
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin
import io.noties.markwon.image.ImagesPlugin
import org.apache.commons.io.IOUtils
Expand Down Expand Up @@ -239,22 +243,22 @@ class MainActivity : AppCompatActivity() {
return@OnItemLongClickListener true
}
mainDialog.window?.run {
// TODO Android 12发布后加入
//setHideOverlayWindows(true)
decorView.run {
alpha = DIALOG_ALPHA
emptyAccessibilityDelegate()
// 在初次resume时,dialog还未show。所以无效,还需要在这里调用
hideSysUi()
}
// 在初次resume时,dialog还未show。所以无效,还需要在这里调用
hideSysUi()
// TODO Android 12发布后加入
//setHideOverlayWindows(true)
}
}
lifecycle.addObserver(LifecycleEventObserver { _, event ->
mainDialog.run {
when (event) {
Lifecycle.Event.ON_DESTROY -> dismiss()
// 在添加shortcut取消返回时重做
Lifecycle.Event.ON_RESUME -> window?.decorView?.hideSysUi()
Lifecycle.Event.ON_RESUME -> window?.hideSysUi()
else -> if (BuildConfig.DEBUG) Timber.d("Unimplemented lifecycle ${event.name}")
}
}
Expand Down Expand Up @@ -329,27 +333,19 @@ private fun Context.markwon() = Markwon.builder(this)
}
}
})
// 防止打开链接的崩溃
.usePlugin(object : AbstractMarkwonPlugin() {
override fun configureConfiguration(builder: MarkwonConfiguration.Builder) {
builder.linkResolver { _, link -> openUrlInBrowser(link) }
}
})
.build()

/**
* 隐藏导航栏和状态栏
* TODO 用core-ktx将要出的下一个正式版本代替
*/
private fun View.hideSysUi() = apply {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
windowInsetsController?.run {
hide(WindowInsets.Type.systemBars())
// 作用同ui flag的immersive
systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
} else {
@Suppress("DEPRECATION") // 假阳性
systemUiVisibility =
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_FULLSCREEN or
// immersive 取消激活导航栏的步骤,原来的行为是在此之后才响应dialog
// sticky 让状态栏在手动呼出之后一段时间自动隐藏
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
}
private fun Window.hideSysUi() = WindowCompat.getInsetsController(this, decorView)?.run {
hide(WindowInsetsCompat.Type.systemBars())
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
//endregion

0 comments on commit b90dc1e

Please sign in to comment.