migrate to kts
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
35
build.gradle
35
build.gradle
@@ -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
|
||||
}
|
||||
11
build.gradle.kts
Normal file
11
build.gradle.kts
Normal file
@@ -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
|
||||
}
|
||||
@@ -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]
|
||||
[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" }
|
||||
@@ -1 +0,0 @@
|
||||
include ':app'
|
||||
32
settings.gradle.kts
Normal file
32
settings.gradle.kts
Normal file
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user