diff --git a/app/build.gradle b/app/build.gradle index eb3f5e8e..b699df46 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,17 +1,12 @@ -apply plugin: "com.android.application" -apply plugin: "kotlin-android" -apply plugin: "kotlin-kapt" -apply plugin: "kotlin-parcelize" -apply plugin: "kotlinx-serialization" -apply plugin: "com.google.android.gms.oss-licenses-plugin" - -if (file("google-services.json").exists()) { - logger.lifecycle("Firebase Enabled") - apply plugin: "com.google.gms.google-services" - apply plugin: "com.google.firebase.crashlytics" - apply plugin: "com.google.firebase.firebase-perf" -} else { - logger.lifecycle("Firebase Disabled") +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlinx.serialization) + alias(libs.plugins.gms.oss.licenses) + alias(libs.plugins.gms.google.services) + alias(libs.plugins.firebase.crashlytics) + alias(libs.plugins.firebase.perf) + id 'kotlin-parcelize' } android { @@ -105,9 +100,6 @@ dependencies { implementation libs.viewpagerdotsindicator - implementation libs.dirchooser.library - implementation libs.option - implementation libs.patternlockview implementation libs.core diff --git a/app/src/main/java/xyz/quaver/pupil/ui/dialog/DownloadLocationDialogFragment.kt b/app/src/main/java/xyz/quaver/pupil/ui/dialog/DownloadLocationDialogFragment.kt index e6a03cff..ee31f843 100644 --- a/app/src/main/java/xyz/quaver/pupil/ui/dialog/DownloadLocationDialogFragment.kt +++ b/app/src/main/java/xyz/quaver/pupil/ui/dialog/DownloadLocationDialogFragment.kt @@ -21,7 +21,6 @@ package xyz.quaver.pupil.ui.dialog import android.app.Activity import android.app.Dialog import android.content.Intent -import android.os.Build import android.os.Bundle import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AlertDialog @@ -29,8 +28,6 @@ import androidx.core.content.ContextCompat import androidx.core.net.toUri import androidx.fragment.app.DialogFragment import com.google.android.material.snackbar.Snackbar -import net.rdrei.android.dirchooser.DirectoryChooserActivity -import net.rdrei.android.dirchooser.DirectoryChooserConfig import xyz.quaver.io.FileX import xyz.quaver.io.util.toFile import xyz.quaver.pupil.R @@ -56,8 +53,7 @@ class DownloadLocationDialogFragment : DialogFragment() { it.data?.data?.also { uri -> val takeFlags: Int = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) - context.contentResolver.takePersistableUriPermission(uri, takeFlags) + context.contentResolver.takePersistableUriPermission(uri, takeFlags) if (kotlin.runCatching { FileX(context, uri).canWrite() }.getOrDefault(false)) { entries[null]?.locationAvailable?.text = uri.toFile(context)?.canonicalPath @@ -87,32 +83,6 @@ class DownloadLocationDialogFragment : DialogFragment() { } } - private val requestDownloadFolderOldLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { - val context = context ?: return@registerForActivityResult - val dialog = dialog ?: return@registerForActivityResult - - if (it.resultCode == DirectoryChooserActivity.RESULT_CODE_DIR_SELECTED) { - val directory = it.data?.getStringExtra(DirectoryChooserActivity.RESULT_SELECTED_DIR)!! - - if (!File(directory).canWrite()) { - Snackbar.make( - dialog.window!!.decorView.rootView, - R.string.settings_download_folder_not_writable, - Snackbar.LENGTH_LONG - ).show() - - val downloadFolder = DownloadManager.getInstance(context).downloadFolder.canonicalPath - val key = entries.keys.firstOrNull { it?.canonicalPath == downloadFolder } - entries[key]!!.button.isChecked = true - if (key == null) entries[key]!!.locationAvailable.text = downloadFolder - } - else { - entries[null]?.locationAvailable?.text = directory - Preferences["download_folder"] = File(directory).toURI().toString() - } - } - } - private fun initView() { val externalFilesDirs = ContextCompat.getExternalFilesDirs(requireContext(), null) @@ -147,24 +117,11 @@ class DownloadLocationDialogFragment : DialogFragment() { } button.performClick() - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).apply { - putExtra("android.content.extra.SHOW_ADVANCED", true) - } - - requestDownloadFolderLauncher.launch(intent) - } else { // Can't use SAF on old Androids! - val config = DirectoryChooserConfig.builder() - .newDirectoryName("Pupil") - .allowNewDirectoryNameModification(true) - .build() - - val intent = Intent(context, DirectoryChooserActivity::class.java).apply { - putExtra(DirectoryChooserActivity.EXTRA_CONFIG, config) - } - - requestDownloadFolderOldLauncher.launch(intent) + val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).apply { + putExtra("android.content.extra.SHOW_ADVANCED", true) } + + requestDownloadFolderLauncher.launch(intent) } entries[null] = this } diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 83d44c2c..00000000 --- a/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - google() - mavenCentral() - } - dependencies { - classpath libs.gradle - classpath libs.kotlin.gradle.plugin - classpath libs.kotlin.android.extensions - classpath libs.kotlin.serialization - classpath libs.google.services - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - classpath libs.firebase.crashlytics.gradle - classpath libs.perf.plugin - classpath libs.oss.licenses.plugin - } -} - -allprojects { - repositories { - google() - mavenCentral() - jcenter() - maven { url "https://jitpack.io" } - maven { url "https://guardian.github.io/maven/repo-releases/" } - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..740c7fe9 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,11 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.kotlin.compose) apply false + alias(libs.plugins.kotlinx.serialization) apply false + alias(libs.plugins.gms.oss.licenses) apply false + alias(libs.plugins.gms.google.services) apply false + alias(libs.plugins.firebase.crashlytics) apply false + alias(libs.plugins.firebase.perf) apply false +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c192d785..e99ada6f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,4 +1,6 @@ [versions] +agp = "8.8.1" +kotlin = "2.0.0" activityKtx = "1.10.0" appcompat = "1.7.0" bigimageviewer = "1.8.1" @@ -32,7 +34,6 @@ library = "1.2.0" libraryVersion = "3.2" material = "1.12.0" okhttp = "3.12.12" -option = "1.3" ossLicensesPlugin = "0.10.6" patternlockview = "1.0.0" perfPlugin = "1.4.2" @@ -86,7 +87,6 @@ ktor-network = { module = "io.ktor:ktor-network", version.ref = "ktorNetwork" } library = { module = "com.daimajia.swipelayout:library", version.ref = "library" } material = { module = "com.google.android.material:material", version.ref = "material" } okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } -option = { module = "com.gu:option", version.ref = "option" } oss-licenses-plugin = { module = "com.google.android.gms:oss-licenses-plugin", version.ref = "ossLicensesPlugin" } patternlockview = { module = "com.andrognito.patternlockview:patternlockview", version.ref = "patternlockview" } perf-plugin = { module = "com.google.firebase:perf-plugin", version.ref = "perfPlugin" } @@ -100,4 +100,12 @@ runner = { module = "androidx.test:runner", version.ref = "runner" } viewpagerdotsindicator = { module = "com.tbuonomo.andrui:viewpagerdotsindicator", version.ref = "viewpagerdotsindicator" } work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "workRuntimeKtx" } -[plugins] \ No newline at end of file +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +gms-oss-licenses = { id = "com.google.android.gms.oss-licenses-plugin", version.ref = "ossLicensesPlugin" } +gms-google-services = { id = "com.google.gms.google-services", version.ref = "googleServices" } +firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsGradle" } +firebase-perf = { id = "com.google.firebase.firebase-perf", version.ref = "perfPlugin" } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e7b4def4..00000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..2208e57b --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + gradlePluginPortal() + } + resolutionStrategy { + eachPlugin { + if (requested.id.id == "com.google.android.gms.oss-licenses-plugin") { + useModule("com.google.android.gms:oss-licenses-plugin:${requested.version}") + } + } + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + jcenter() + } +} + +rootProject.name = "Pupil" +include(":app") +