diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 3058433..d7f17a5 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index ac4e73b..a96a5fe 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -12,6 +12,6 @@ - + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 526b4c2..7b46144 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -7,13 +7,13 @@ - diff --git a/.idea/misc.xml b/.idea/misc.xml index d5d35ec..ef61796 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 08c9a28..7a5f953 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,18 +2,18 @@ apply plugin: 'com.android.application' apply plugin: 'org.greenrobot.greendao' apply plugin: 'androidx.navigation.safeargs' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 30 + compileSdkVersion 32 defaultConfig { applicationId "com.zane.smapiinstaller" minSdkVersion 19 + //noinspection ExpiringTargetSdkVersion targetSdkVersion 30 - versionCode 72 - versionName "3.7.6.10" + versionCode 73 + versionName "3.7.6.11" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true @@ -53,6 +53,7 @@ android { buildFeatures { viewBinding true } + namespace 'com.zane.smapiinstaller' } greendao { @@ -62,22 +63,23 @@ greendao { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'com.google.android.material:material:1.2.1' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' - implementation "androidx.navigation:navigation-fragment:2.3.1" - implementation "androidx.navigation:navigation-ui:2.3.1" + implementation 'com.google.android.material:material:1.6.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation "androidx.navigation:navigation-fragment-ktx:2.5.2" + implementation "androidx.navigation:navigation-ui-ktx:2.5.2" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - implementation 'androidx.webkit:webkit:1.3.0' + //noinspection GradleDynamicVersion,GradleDependency + implementation 'androidx.webkit:webkit:1.4.+' implementation "androidx.documentfile:documentfile:1.0.1" // https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on - implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.65.01' + implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.67' implementation 'com.afollestad.material-dialogs:core:3.3.0' implementation 'com.afollestad.material-dialogs:input:3.3.0' implementation 'com.afollestad.material-dialogs:lifecycle:3.3.0' implementation 'com.lmntrx.android.library.livin.missme:missme:0.1.5' - implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'androidx.recyclerview:recyclerview:1.2.1' // https://mvnrepository.com/artifact/com.google.guava/guava implementation group: 'com.google.guava', name: 'guava', version: '30.1-android' // https://mvnrepository.com/artifact/org.zeroturnaround/zt-zip @@ -93,6 +95,7 @@ dependencies { implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.12.1' // https://mvnrepository.com/artifact/org.lz4/lz4-pure-java implementation group: 'org.lz4', name: 'lz4-pure-java', version: '1.7.0' + implementation 'com.github.getActivity:XXPermissions:16.2' implementation 'com.github.didikee:AndroidDonate:0.1.0' implementation 'com.hjq:language:6.0' @@ -101,8 +104,8 @@ dependencies { api 'org.greenrobot:greendao-generator:3.3.0' testImplementation 'junit:junit:4.13.1' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' implementation 'com.android.support:multidex:1.0.3' def appCenterSdkVersion = '3.0.0' @@ -111,5 +114,5 @@ dependencies { compileOnly 'org.projectlombok:lombok:1.18.16' annotationProcessor 'org.projectlombok:lombok:1.18.16' - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.0' + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.6' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7688709..b2d675d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,15 +1,14 @@ + android:installLocation="auto"> - + @@ -30,7 +29,6 @@ android:configChanges="orientation|keyboard|screenSize" android:networkSecurityConfig="@xml/network_security_config" android:theme="@style/AppTheme" - android:preserveLegacyExternalStorage="true" android:requestLegacyExternalStorage="true" tools:ignore="UnusedAttribute" android:largeHeap="true"> diff --git a/app/src/main/java/com/zane/smapiinstaller/MainActivity.java b/app/src/main/java/com/zane/smapiinstaller/MainActivity.java index 9ac7fd2..c273906 100644 --- a/app/src/main/java/com/zane/smapiinstaller/MainActivity.java +++ b/app/src/main/java/com/zane/smapiinstaller/MainActivity.java @@ -15,6 +15,9 @@ import android.view.View; import android.widget.Toast; import com.hjq.language.MultiLanguages; +import com.hjq.permissions.OnPermissionCallback; +import com.hjq.permissions.Permission; +import com.hjq.permissions.XXPermissions; import com.lmntrx.android.library.livin.missme.ProgressDialog; import com.lzy.okgo.OkGo; import com.lzy.okgo.model.Response; @@ -43,6 +46,7 @@ import com.zane.smapiinstaller.utils.TranslateUtil; import org.apache.commons.lang3.StringUtils; import java.io.File; +import java.util.List; import java.util.Locale; import androidx.annotation.NonNull; @@ -73,10 +77,10 @@ public class MainActivity extends AppCompatActivity { if (!haveInstallPermission) { DialogUtils.showConfirmDialog(MainActivity.instance, R.string.confirm, R.string.request_unknown_source_permission, ((dialog, dialogAction) -> { if (dialogAction == DialogAction.POSITIVE) { - Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES); - intent.setData(Uri.parse("package:" + this.getPackageName())); - ActivityResultHandler.registerListener(ActivityResultHandler.REQUEST_CODE_APP_INSTALL, (resultCode, data) -> this.requestPermissions()); - MainActivity.instance.startActivityForResult(intent, ActivityResultHandler.REQUEST_CODE_APP_INSTALL); + XXPermissions.with(this).permission(Permission.REQUEST_INSTALL_PACKAGES) + .request(getPermissionCallback()); + } else { + this.finish(); } })); return; @@ -87,14 +91,8 @@ public class MainActivity extends AppCompatActivity { if (!Environment.isExternalStorageManager()) { DialogUtils.showConfirmDialog(MainActivity.instance, R.string.confirm, R.string.request_all_files_access_permission, ((dialog, dialogAction) -> { if (dialogAction == DialogAction.POSITIVE) { - ActivityResultHandler.registerListener(ActivityResultHandler.REQUEST_CODE_ALL_FILES_ACCESS_PERMISSION, (resultCode, data) -> { - if (!Environment.isExternalStorageManager()) { - this.finish(); - } else { - requestPermissions(); - } - }); - CommonLogic.openPermissionSetting(this); + XXPermissions.with(this).permission(Permission.MANAGE_EXTERNAL_STORAGE) + .request(getPermissionCallback()); } else { this.finish(); } @@ -102,13 +100,44 @@ public class MainActivity extends AppCompatActivity { return; } } - if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions(MainActivity.this, - new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0); - } else { - initView(); - } + XXPermissions.with(this) + .permission(Permission.MANAGE_EXTERNAL_STORAGE) + .permission(Permission.REQUEST_INSTALL_PACKAGES) + .request(new OnPermissionCallback() { + @Override + public void onGranted(List permissions, boolean all) { + if (!all) { + requestPermissions(); + return; + } + initView(); + } + @Override + public void onDenied(List permissions, boolean never) { + if (never) { + XXPermissions.startPermissionActivity(instance, permissions); + } + requestPermissions(); + } + }); + } + + @NonNull + private OnPermissionCallback getPermissionCallback() { + return new OnPermissionCallback() { + @Override + public void onGranted(List permissions, boolean all) { + requestPermissions(); + } + + @Override + public void onDenied(List permissions, boolean never) { + if (never) { + XXPermissions.startPermissionActivity(instance, permissions); + } + requestPermissions(); + } + }; } @Override @@ -118,6 +147,7 @@ public class MainActivity extends AppCompatActivity { } else { this.finish(); } + super.onRequestPermissionsResult(requestCode, permissions, grantResults); } @Override @@ -284,7 +314,7 @@ public class MainActivity extends AppCompatActivity { appConfig.setValue(String.valueOf(item.isChecked())); ConfigUtils.saveConfig((MainApplication) getApplication(), appConfig); startActivity(new Intent(this, MainActivity.class)); - overridePendingTransition(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit); +// overridePendingTransition(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit); finish(); } else { return super.onOptionsItemSelected(item); @@ -370,7 +400,7 @@ public class MainActivity extends AppCompatActivity { if (restart) { // 我们可以充分运用 Activity 跳转动画,在跳转的时候设置一个渐变的效果 startActivity(new Intent(this, MainActivity.class)); - overridePendingTransition(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit); +// overridePendingTransition(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit); finish(); } }); diff --git a/app/src/main/java/com/zane/smapiinstaller/utils/DialogUtils.java b/app/src/main/java/com/zane/smapiinstaller/utils/DialogUtils.java index d4f26ee..54dd8a6 100644 --- a/app/src/main/java/com/zane/smapiinstaller/utils/DialogUtils.java +++ b/app/src/main/java/com/zane/smapiinstaller/utils/DialogUtils.java @@ -329,7 +329,7 @@ public class DialogUtils { public static void showSingleChoiceDialog(View view, int title, int items, int index, BiConsumer callback) { CommonLogic.runOnUiThread(CommonLogic.getActivityFromView(view), (activity) -> { MaterialDialog materialDialog = new MaterialDialog(activity, MaterialDialog.getDEFAULT_BEHAVIOR()).title(title, null); - materialDialog = DialogSingleChoiceExtKt.listItemsSingleChoice(materialDialog, items, null, null, index, false, (dialog, position, text) -> { + materialDialog = DialogSingleChoiceExtKt.listItemsSingleChoice(materialDialog, items, null, null, index, false, -1, -1, (dialog, position, text) -> { callback.accept(dialog, position); return null; }); diff --git a/build.gradle b/build.gradle index bdd09c6..7c34a61 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,15 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { - repositories { google() - jcenter() + maven { url 'https://maven.aliyun.com/repository/public/' } + maven { url 'https://jitpack.io' } mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72" - classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.1" + classpath 'com.android.tools.build:gradle:7.3.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10" + classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.2" classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' // NOTE: Do not place your application dependencies here; they belong @@ -18,15 +17,6 @@ buildscript { } } -allprojects { - repositories { - google() - jcenter() - maven { url 'https://jitpack.io' } - - } -} - task clean(type: Delete) { delete rootProject.buildDir } diff --git a/gradle.properties b/gradle.properties index d546dea..1d77e86 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,12 +6,17 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -android.enableJetifier=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx1536m +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true - - +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app"s APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +android.enableJetifier=true +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f6b961f..e708b1c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9fe1473..92ddd36 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Feb 01 14:39:47 CST 2021 +#Sun Oct 09 22:26:32 CST 2022 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip +zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index 803ab3c..3e5eb1e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,20 @@ +pluginManagement { + repositories { + gradlePluginPortal() + google() + maven { url 'https://maven.aliyun.com/repository/public/' } + maven { url 'https://jitpack.io' } + mavenCentral() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + maven { url 'https://maven.aliyun.com/repository/public/' } + maven { url 'https://jitpack.io' } + mavenCentral() + } +} rootProject.name='SMAPI Installer' include ':app'