Skip to content

Commit

Permalink
修复崩溃问题
Browse files Browse the repository at this point in the history
修复崩溃问题
  • Loading branch information
GangJust committed Apr 22, 2023
1 parent b51b58e commit 5d4ca64
Show file tree
Hide file tree
Showing 44 changed files with 570 additions and 510 deletions.
17 changes: 8 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ android {

defaultConfig {
applicationId "com.freegang.fplus"
minSdk 21
minSdk 24
targetSdk 33
versionCode 8
versionName "1.0.7"
versionCode 11
versionName "1.0.8"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand All @@ -38,13 +38,13 @@ android {
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.1.1'
kotlinCompilerExtensionVersion '1.3.2'
}
packagingOptions {
resources {
Expand All @@ -57,11 +57,12 @@ dependencies {
implementation project(":core")
implementation project(":webdav")

implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.4.0'
implementation 'androidx.activity:activity-compose:1.5.1'
implementation "androidx.compose.ui:ui:$compose_ui_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"

implementation 'androidx.compose.material:material:1.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
Expand All @@ -74,7 +75,5 @@ dependencies {
implementation "com.google.accompanist:accompanist-insets:0.28.0"
implementation "com.google.accompanist:accompanist-insets-ui:0.28.0"
implementation "com.google.accompanist:accompanist-systemuicontroller:0.28.0"
implementation 'com.google.accompanist:accompanist-permissions:0.28.0'

implementation "androidx.compose.runtime:runtime-livedata:1.3.3"
}
24 changes: 13 additions & 11 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,20 @@
-keep public class * extends androidx.**
-keep public class * extends android.**

# 保留模块核心, 否则无法生效
-keepclassmembers class com.freegang.xpler.xp.** { *; }
# 关闭警告信息
-dontwarn android.content.res.*
-dontwarn de.robv.android.xposed.**
# 模块核心
-keepclassmembers class com.freegang.xpler.core.** { *; }
-keepclassmembers class * {
@com.freegang.xpler.xp.FieldGet <fields>;
@com.freegang.xpler.xp.OnBefore <methods>;
@com.freegang.xpler.xp.OnAfter <methods>;
@com.freegang.xpler.xp.OnReplace <methods>;
@com.freegang.xpler.xp.OnConstructorBefore <methods>;
@com.freegang.xpler.xp.OnConstructorAfter <methods>;
@com.freegang.xpler.xp.OnConstructorReplace <methods>;
@com.freegang.xpler.core.FieldGet <fields>;
@com.freegang.xpler.core.OnBefore <methods>;
@com.freegang.xpler.core.OnAfter <methods>;
@com.freegang.xpler.core.OnReplace <methods>;
@com.freegang.xpler.core.OnConstructorBefore <methods>;
@com.freegang.xpler.core.OnConstructorAfter <methods>;
@com.freegang.xpler.core.OnConstructorReplace <methods>;
}
# 模块状态
-keep class com.freegang.xpler.HookInit extends * { *; }

# 保留模块状态
-keep class com.freegang.xpler.HookStatus extends * { *; }
4 changes: 0 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>

<meta-data
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/assets/update.log
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ v1.0.7
兼容抖音评论区视频保存(部分机型可能无法使用)
修复Xpler参数args空指针无法hook情况
修复弹窗在Android13偶现多次弹出情况
修复WebDav上传通知栏提示
修复WebDav上传通知栏提示

v1.0.8
修复评论区图片保存造成崩溃
修复评论区图片只能保存第一张情况
修复用户主页图文详情顶部被重构
修复Android11以上部分机型存储权限
minSdk更改为24
致谢@LuckyPray/DexKit
115 changes: 46 additions & 69 deletions app/src/main/java/com/freegang/fplus/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,98 +10,86 @@ import android.provider.Settings
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.*
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.layout.Column
import androidx.compose.material.Text
import androidx.compose.ui.unit.sp
import androidx.core.content.PermissionChecker
import com.freegang.fplus.FreedomTheme
import com.freegang.fplus.Themes
import com.freegang.fplus.component.FMessageDialog
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.rememberMultiplePermissionsState

class MainActivity : ComponentActivity() {

/// 检查是否具有某个权限
private fun checkPermission(permission: String): Boolean {
return PermissionChecker.checkSelfPermission(application, permission) == PermissionChecker.PERMISSION_GRANTED
}

/// 需要的权限列表
private fun getPermissionList(): List<String> {
val permissions = mutableListOf<String>()
//是否具有外置存储器读
if (!checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) {
permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE)
}

//是否具有外置存储器写
if (!checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
}

//是否具有外置存储器管理(特殊权限)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
permissions.add(Manifest.permission.MANAGE_EXTERNAL_STORAGE)
private val requestMultiplePermissions = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { map ->
val denied = map.filterValues { !it }.mapNotNull { it.key }
if (denied.isEmpty()) {
toHomeActivity()
return@registerForActivityResult
}

return permissions
//处理未授予权限
Toast.makeText(applicationContext, "请开启必要权限!", Toast.LENGTH_SHORT).show()
startActivity(
Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.parse("package:${packageName}")
)
)
}

/// 跳转对应权限修改页
private fun requestAgainPermissions(deniedPermissions: List<String>) {
//处理未请求成功的权限
//应用设置页, 开启外部存储读写权限, 跳转
if (deniedPermissions.contains(Manifest.permission.READ_EXTERNAL_STORAGE) || deniedPermissions.contains(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
startActivity(
Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.parse("package:${packageName}")
)
)
return
}
/// 检查是否具有某个权限
private fun checkPermission(permission: String): Boolean {
return PermissionChecker.checkSelfPermission(application, permission) == PermissionChecker.PERMISSION_GRANTED
}

//Android11 必须要的管理外部存储完全管理权限, 跳转
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (deniedPermissions.contains(Manifest.permission.MANAGE_EXTERNAL_STORAGE) && !Environment.isExternalStorageManager()) {
/// 请求权限
private fun requestPermissions() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { //Android11+ 必须要的管理外部存储完全管理权限, 跳转
if (!Environment.isExternalStorageManager()) {
startActivity(
Intent(
Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,
Uri.parse("package:${packageName}")
)
)
return
}
} else { //Android11以下, 必须要的外部存储读写权限
val permissions = arrayOf(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
)
if (!checkPermission(permissions[0]) || !checkPermission(permissions[1])) {
requestMultiplePermissions.launch(permissions)
return
}
return
}
toHomeActivity()
}

/// 进入App
private fun toHomeActivity() {
if (getPermissionList().isEmpty()) {
startActivity(Intent(application, HomeActivity::class.java))
finish()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (!Environment.isExternalStorageManager()) return
} else {
if (!checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) return
}

startActivity(Intent(application, HomeActivity::class.java))
finish()
}

@OptIn(ExperimentalPermissionsApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
toHomeActivity()
super.onCreate(savedInstanceState)
setContent {
val permissionsState = rememberMultiplePermissionsState(getPermissionList())
FreedomTheme(window = window) {
FMessageDialog(
title = "Freedom+需要以下权限才能正常运行",
cancel = "取消",
confirm = "确定",
onCancel = {
finish()
},
onConfirm = {
if (getPermissionList().isNotEmpty()) {
permissionsState.launchMultiplePermissionRequest()
}
},
onCancel = { finish() },
onConfirm = { requestPermissions() },
content = {
Column {
Text(
Expand All @@ -127,19 +115,8 @@ class MainActivity : ComponentActivity() {
}
}

override fun onResume() {
override fun onStart() {
super.onStart()
toHomeActivity()
super.onResume()
}

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
//Log.d("GLog", "requestCode=$requestCode ,resultCode=${permissions.joinToString()} ,grantResults=${grantResults.joinToString()}")
if (getPermissionList().isNotEmpty()) {
Toast.makeText(application, "请开启必要权限", Toast.LENGTH_SHORT).show()
requestAgainPermissions(permissions.filterIndexed { i, _ -> grantResults[i] == -1 })
} else {
toHomeActivity()
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources>
<string name="app_name">Freedom+</string>
<string name="app_module_des">依赖于抖音运行的辅助模块!</string>
<string name="app_module_des">依赖于抖音运行的辅助模块.</string>
</resources>
2 changes: 1 addition & 1 deletion aweme/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ public class UrlModel {
public int height;

public long size;

public UrlModel() {
throw new RuntimeException("sub!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ public class Emoji {
public int width;

public int height;

public Emoji() {
throw new RuntimeException("sub!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class Aweme {

public int awemeType;

public boolean canPlay;

public String city;

public long createTime;
Expand All @@ -31,4 +33,7 @@ public class Aweme {

public List<ImageUrlStruct> images;

public Aweme() {
throw new RuntimeException("sub!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ public class Video {
public int height;

public int width;

private Video() {
throw new RuntimeException("sub!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
import com.ss.android.ugc.aweme.base.model.UrlModel;

public class VideoUrlModel extends UrlModel {
public VideoUrlModel() {
throw new RuntimeException("sub!");
}
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
buildscript {
ext {
compose_ui_version = '1.1.1'
compose_ui_version = '1.3.3'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}
10 changes: 7 additions & 3 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ android {

defaultConfig {
minSdk 21
targetSdk 32
targetSdk 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"

ndk {
abiFilters "armeabi", 'armeabi-v7a', 'armeabi-v8a', 'arm64-v8a', 'x86', "x86_64"
}
}

buildFeatures {
Expand All @@ -30,7 +34,7 @@ android {
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}
}

Expand All @@ -47,8 +51,8 @@ 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 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'

implementation project(":webdav")
implementation 'org.luckypray:DexKit:1.1.4'
}
Loading

0 comments on commit 5d4ca64

Please sign in to comment.