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

Commit

Permalink
R3.11.3
Browse files Browse the repository at this point in the history
手表界面适应:启用夜间模式禁用透明度
捐赠界面增加提示
  • Loading branch information
ryuunoakaihitomi committed Aug 28, 2021
1 parent 1ecbe9a commit 4f7dc3f
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 11 deletions.
5 changes: 3 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 31
// 版本号:发布日期
versionCode 20210828
versionCode 20210829
// 版本名说明: R3.x.y.z (R3:Refactoring 第三次重构,z:Quick Fix序号)
versionName 'R3.11.2'
versionName 'R3.11.3'
resConfigs "en", "zh-rCN"

buildConfigField 'String', 'BUILD_TIME', '\"' + new Date() + '\"'
Expand Down Expand Up @@ -107,6 +107,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.android.material:material:1.4.0'

def lifecycle_version = "2.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import github.ryuunoakaihitomi.poweract.ExternalUtils
import github.ryuunoakaihitomi.powerpanel.receiver.ShutdownReceiver
import github.ryuunoakaihitomi.powerpanel.stat.Statistics
import github.ryuunoakaihitomi.powerpanel.util.MyLogTree
import github.ryuunoakaihitomi.powerpanel.util.isWatch
import org.lsposed.hiddenapibypass.HiddenApiBypass
import timber.log.Timber

Expand Down Expand Up @@ -44,7 +45,7 @@ class MyApplication : MultiDexApplication() {
// 留下PowerAct核心日志用以发布后的调试
ExternalUtils.enableLog(true)

/* KitKat系统主题为黑色,因此使用夜间模式作为搭配 */
/* KitKat和手表系统主题为黑色,因此使用夜间模式作为搭配 */
/**
* WONT FIX 无法使用values-night资源
*
Expand All @@ -53,7 +54,7 @@ class MyApplication : MultiDexApplication() {
*
* @see [android.app.UiModeManager.setNightMode](https://developer.android.google.cn/reference/android/app/UiModeManager#setNightMode(int))
*/
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || isWatch())
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ package github.ryuunoakaihitomi.powerpanel.ui

import android.graphics.BitmapFactory
import android.os.Bundle
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.snackbar.Snackbar
import com.google.zxing.BinaryBitmap
import com.google.zxing.RGBLuminanceSource
import com.google.zxing.common.HybridBinarizer
import com.google.zxing.qrcode.QRCodeReader
import github.ryuunoakaihitomi.powerpanel.R
import github.ryuunoakaihitomi.powerpanel.databinding.ActivityDonateBinding
import github.ryuunoakaihitomi.powerpanel.util.isWatch
import github.ryuunoakaihitomi.powerpanel.util.openUrlInBrowser
import timber.log.Timber

Expand All @@ -34,5 +38,16 @@ class DonateActivity : AppCompatActivity() {
}.onFailure { Timber.e(it) }
}
}
if (!isWatch()) {
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
Snackbar.make(binding.root, R.string.snack_donate_guide, Snackbar.LENGTH_LONG)
.addCallback(object : Snackbar.Callback() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
transientBottomBar?.removeCallback(this)
}
})
.show()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package github.ryuunoakaihitomi.powerpanel.ui.main

import android.app.Activity
import android.app.AlertDialog
import android.app.UiModeManager
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.content.res.Resources
import android.graphics.Typeface
import android.os.Build
Expand Down Expand Up @@ -68,15 +66,16 @@ class MainActivity : AppCompatActivity() {

private fun checkCompatibility() {
if (myApp().hasShownCompatibilityWarning) return
val modeType = getSystemService<UiModeManager>()?.currentModeType
?: Configuration.UI_MODE_TYPE_UNDEFINED
val isCompatible =
// KitKat无法长期维护,这次只不过是临时接触了这类设备才给稍微适配
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
// Wear OS存在界面元素无法显示问题
modeType != Configuration.UI_MODE_TYPE_WATCH &&
!isWatch() &&
// Android TV部分功能无法使用
modeType != Configuration.UI_MODE_TYPE_TELEVISION &&
!packageManager.hasSystemFeature(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
PackageManager.FEATURE_LEANBACK else PackageManager.FEATURE_TELEVISION
) &&
// 工作资料之类的
getSystemService<UserManager>()!!.userProfiles[0].equals(Process.myUserHandle())
if (!isCompatible) {
Expand Down Expand Up @@ -279,7 +278,7 @@ class MainActivity : AppCompatActivity() {
checkScrollableListView(lv)
mainDialog.window?.run {
decorView.run {
alpha = 0.85f // 窗口透明度
if (!isWatch()) alpha = 0.85f // 窗口透明度,在手表上不仅没有透明效果还会使内容暗淡并出现奇怪的重影效果
emptyAccessibilityDelegate()
}
BlackMagic.collapseStatusBarPanels(application)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package github.ryuunoakaihitomi.powerpanel.util

import android.app.UiModeManager
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.net.Uri
import android.os.Build
import android.provider.Browser
import android.service.quicksettings.Tile
import android.text.Spannable
import androidx.annotation.RequiresApi
import androidx.core.content.getSystemService
import androidx.core.content.res.ResourcesCompat
import androidx.core.text.set
import es.dmoral.toasty.Toasty
Expand Down Expand Up @@ -36,4 +39,10 @@ fun Tile.updateState(state: Int) {

operator fun Spannable.set(range: IntRange, spans: Array<Any>) {
for (span in spans) this[range] = span
}

fun Context.isWatch() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
Configuration.UI_MODE_TYPE_WATCH == getSystemService<UiModeManager>()?.currentModeType
} else {
false
}
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
<string name="url_aosp_home" tools:ignore="Untranslatable">https://source.android.google.cn</string>
<string name="url_aosp_license" tools:ignore="Untranslatable">https://source.android.google.cn/setup/start/licenses</string>
<string name="toast_list_scrollable">列表视图是<b>可滚动的</b>,请检查是否有<b>尚未可见</b>的项目。</string>
<string name="snack_donate_guide">♥ <b>感谢你的好意!</b>\n只需点击图片,无需截屏。</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
<string name="url_aosp_home" translatable="false">https://source.android.com</string>
<string name="url_aosp_license" translatable="false">https://source.android.com/setup/start/licenses</string>
<string name="toast_list_scrollable">The ListView is <b>SCROLLABLE</b>, please check if there are any items that are <b>not yet visible</b>.</string>
<string name="snack_donate_guide">♥ <b>Thanks for your kindness!</b>\nJust click the picture, no need to take screenshots.</string>
</resources>

0 comments on commit 4f7dc3f

Please sign in to comment.