Modify support Android 7.0

This commit is contained in:
2023-01-15 02:39:03 +08:00
parent c6d5f07b8c
commit aeda0f183e
14 changed files with 38 additions and 13 deletions

View File

@@ -18,7 +18,7 @@
应用发生崩溃的错误日志对开发者来说是无价的财富,若你不是开发者,你依然可以安装此模块,以便给开发者提供更多异常信息快速解决问题。 应用发生崩溃的错误日志对开发者来说是无价的财富,若你不是开发者,你依然可以安装此模块,以便给开发者提供更多异常信息快速解决问题。
> 最低支持 Android 8.1 > 最低支持 Android 7.0
## 项目缘由 ## 项目缘由

View File

@@ -20,7 +20,7 @@ any installed apps, so as to quickly locate the problem.
The error log of apps crashing is an invaluable asset for developers. If you are not a developer, you can still install this module to provide The error log of apps crashing is an invaluable asset for developers. If you are not a developer, you can still install this module to provide
developers with more exception information to quickly solve problems. developers with more exception information to quickly solve problems.
> Minimum support Android 8.1 > Minimum support Android 7.0
## Project Reason ## Project Reason

View File

@@ -21,7 +21,7 @@ android {
defaultConfig { defaultConfig {
applicationId "com.fankes.apperrorstracking" applicationId "com.fankes.apperrorstracking"
minSdk 27 minSdk 24
targetSdk 33 targetSdk 33
versionCode rootProject.ext.appVersionCode versionCode rootProject.ext.appVersionCode
versionName rootProject.ext.appVersionName versionName rootProject.ext.appVersionName

View File

@@ -27,7 +27,10 @@
android:value="@string/xposed_desc" /> android:value="@string/xposed_desc" />
<meta-data <meta-data
android:name="xposedminversion" android:name="xposedminversion"
android:value="93" /> android:value="89" />
<meta-data
android:name="xposedsharedprefs"
android:value="true" />
<meta-data <meta-data
android:name="xposedscope" android:name="xposedscope"
android:resource="@array/module_scope" /> android:resource="@array/module_scope" />

View File

@@ -23,6 +23,8 @@
package com.fankes.apperrorstracking.ui.activity.base package com.fankes.apperrorstracking.ui.activity.base
import android.app.ActivityManager
import android.content.Intent
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
@@ -67,6 +69,24 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
/** 回调 [onCreate] 方法 */ /** 回调 [onCreate] 方法 */
abstract fun onCreate() abstract fun onCreate()
/**
* 在旧版的 Android 系统中使用了 activity-alias 标签从启动器启动 Activity 会造成其组件名称 (完整类名) 为代理名称
*
* 为了获取真实的顶层 Activity 组件名称 (完整类名) - 如果名称不正确将自动执行一次结束并重新打开当前 Activity
*/
fun checkingTopComponentName() {
/** 当前顶层的 Activity 组件名称 (完整类名) */
val topComponentName = runCatching {
@Suppress("DEPRECATION")
(getSystemService(ACTIVITY_SERVICE) as? ActivityManager?)
?.getRunningTasks(9999)?.firstOrNull()?.topActivity?.className ?: ""
}.getOrNull() ?: ""
if (topComponentName.isNotBlank() && topComponentName != javaClass.name) {
finish()
startActivity(Intent(this, javaClass))
}
}
/** /**
* 弹出提示并退出 * 弹出提示并退出
* @param name 名称 * @param name 名称

View File

@@ -52,6 +52,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
} }
override fun onCreate() { override fun onCreate() {
checkingTopComponentName()
binding.mainTextVersion.text = LocaleString.moduleVersion(BuildConfig.VERSION_NAME) binding.mainTextVersion.text = LocaleString.moduleVersion(BuildConfig.VERSION_NAME)
binding.mainTextSystemVersion.text = LocaleString.systemVersion(systemVersion) binding.mainTextSystemVersion.text = LocaleString.systemVersion(systemVersion)
binding.onlyShowErrorsInFrontSwitch.bind(ConfigData.ENABLE_ONLY_SHOW_ERRORS_IN_FRONT) binding.onlyShowErrorsInFrontSwitch.bind(ConfigData.ENABLE_ONLY_SHOW_ERRORS_IN_FRONT)

View File

@@ -19,7 +19,7 @@
* *
* This file is Created by fankes on 2022/5/7. * This file is Created by fankes on 2022/5/7.
*/ */
@file:Suppress("unused") @file:Suppress("unused", "NotificationPermission")
package com.fankes.apperrorstracking.utils.factory package com.fankes.apperrorstracking.utils.factory
@@ -261,7 +261,8 @@ fun Context.snake(msg: String, actionText: String = "", callback: () -> Unit = {
*/ */
fun Context.pushNotify(channelId: String, channelName: String, title: String, content: String, icon: IconCompat, color: Int, intent: Intent) { fun Context.pushNotify(channelId: String, channelName: String, title: String, content: String, icon: IconCompat, color: Int, intent: Intent) {
getSystemService<NotificationManager>()?.apply { getSystemService<NotificationManager>()?.apply {
createNotificationChannel(NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_HIGH)) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
createNotificationChannel(NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_HIGH))
notify((0..999).random(), NotificationCompat.Builder(this@pushNotify, channelId).apply { notify((0..999).random(), NotificationCompat.Builder(this@pushNotify, channelId).apply {
this.color = color this.color = color
setAutoCancel(true) setAutoCancel(true)

View File

@@ -6,7 +6,7 @@
android:background="@color/colorThemeBackground" android:background="@color/colorThemeBackground"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ui.activity.debug.LoggerActivity" tools:context=".ui.activity.debug.LoggerActivity"
tools:ignore="ContentDescription,UseCompoundDrawables"> tools:ignore="ContentDescription,UseCompoundDrawables,UnusedAttribute">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -8,7 +8,7 @@
android:background="@color/colorThemeBackground" android:background="@color/colorThemeBackground"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ui.activity.errors.AppErrorsDetailActivity" tools:context=".ui.activity.errors.AppErrorsDetailActivity"
tools:ignore="ContentDescription,UseCompoundDrawables,SmallSp"> tools:ignore="ContentDescription,UseCompoundDrawables,SmallSp,UnusedAttribute">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -6,7 +6,7 @@
android:background="@color/colorThemeBackground" android:background="@color/colorThemeBackground"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ui.activity.errors.AppErrorsRecordActivity" tools:context=".ui.activity.errors.AppErrorsRecordActivity"
tools:ignore="ContentDescription,UseCompoundDrawables"> tools:ignore="ContentDescription,UseCompoundDrawables,UnusedAttribute">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -6,7 +6,7 @@
android:background="@color/colorThemeBackground" android:background="@color/colorThemeBackground"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ui.activity.errors.AppErrorsRecordActivity" tools:context=".ui.activity.errors.AppErrorsRecordActivity"
tools:ignore="ContentDescription,UseCompoundDrawables"> tools:ignore="ContentDescription,UseCompoundDrawables,UnusedAttribute">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -6,7 +6,7 @@
android:background="@color/colorThemeBackground" android:background="@color/colorThemeBackground"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ui.activity.main.ConfigureActivity" tools:context=".ui.activity.main.ConfigureActivity"
tools:ignore="ContentDescription,UseCompoundDrawables"> tools:ignore="ContentDescription,UseCompoundDrawables,UnusedAttribute">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -7,7 +7,7 @@
android:background="@color/colorThemeBackground" android:background="@color/colorThemeBackground"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ui.activity.main.MainActivity" tools:context=".ui.activity.main.MainActivity"
tools:ignore="UseCompoundDrawables,ContentDescription,SmallSp"> tools:ignore="UseCompoundDrawables,ContentDescription,SmallSp,UnusedAttribute">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -20,7 +20,7 @@ android {
} }
defaultConfig { defaultConfig {
minSdk 27 minSdk 24
targetSdk 33 targetSdk 33
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"