Update Android Studio

This commit is contained in:
topjohnwu 2022-01-27 01:46:00 -08:00
parent ff5ea1a70d
commit f5e5ab2436
7 changed files with 27 additions and 17 deletions

View File

@ -57,6 +57,7 @@ android {
kotlinOptions { kotlinOptions {
jvmTarget = "11" jvmTarget = "11"
freeCompilerArgs = listOf("-Xjvm-default=enable")
} }
} }
@ -109,19 +110,19 @@ dependencies {
implementation("androidx.room:room-ktx:${vRoom}") implementation("androidx.room:room-ktx:${vRoom}")
kapt("androidx.room:room-compiler:${vRoom}") kapt("androidx.room:room-compiler:${vRoom}")
val vNav = "2.4.0-rc01" val vNav = "2.5.0-alpha01"
implementation("androidx.navigation:navigation-fragment-ktx:${vNav}") implementation("androidx.navigation:navigation-fragment-ktx:${vNav}")
implementation("androidx.navigation:navigation-ui-ktx:${vNav}") implementation("androidx.navigation:navigation-ui-ktx:${vNav}")
implementation("androidx.biometric:biometric:1.1.0") implementation("androidx.biometric:biometric:1.1.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.2") implementation("androidx.constraintlayout:constraintlayout:2.1.3")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("androidx.appcompat:appcompat:1.4.1") implementation("androidx.appcompat:appcompat:1.4.1")
implementation("androidx.preference:preference:1.1.1") implementation("androidx.preference:preference:1.2.0")
implementation("androidx.recyclerview:recyclerview:1.2.1") implementation("androidx.recyclerview:recyclerview:1.2.1")
implementation("androidx.fragment:fragment-ktx:1.4.0") implementation("androidx.fragment:fragment-ktx:1.4.1")
implementation("androidx.transition:transition:1.4.1") implementation("androidx.transition:transition:1.4.1")
implementation("androidx.core:core-ktx:1.7.0") implementation("androidx.core:core-ktx:1.7.0")
implementation("androidx.core:core-splashscreen:1.0.0-beta01") implementation("androidx.core:core-splashscreen:1.0.0-beta01")
implementation("com.google.android.material:material:1.4.0") implementation("com.google.android.material:material:1.5.0")
} }

View File

@ -54,14 +54,14 @@ object ServiceLocator {
object VMFactory : ViewModelProvider.Factory { object VMFactory : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
override fun <T : ViewModel?> create(clz: Class<T>): T { override fun <T : ViewModel> create(modelClass: Class<T>): T {
return when (clz) { return when (modelClass) {
HomeViewModel::class.java -> HomeViewModel(networkService) HomeViewModel::class.java -> HomeViewModel(networkService)
LogViewModel::class.java -> LogViewModel(logRepo) LogViewModel::class.java -> LogViewModel(logRepo)
SuperuserViewModel::class.java -> SuperuserViewModel(policyDB) SuperuserViewModel::class.java -> SuperuserViewModel(policyDB)
InstallViewModel::class.java -> InstallViewModel(networkService) InstallViewModel::class.java -> InstallViewModel(networkService)
SuRequestViewModel::class.java -> SuRequestViewModel(policyDB, timeoutPrefs) SuRequestViewModel::class.java -> SuRequestViewModel(policyDB, timeoutPrefs)
else -> clz.newInstance() else -> modelClass.newInstance()
} as T } as T
} }
} }
@ -69,7 +69,7 @@ object ServiceLocator {
inline fun <reified VM : ViewModel> ViewModelStoreOwner.viewModel() = inline fun <reified VM : ViewModel> ViewModelStoreOwner.viewModel() =
lazy(LazyThreadSafetyMode.NONE) { lazy(LazyThreadSafetyMode.NONE) {
ViewModelProvider(this, ServiceLocator.VMFactory).get(VM::class.java) ViewModelProvider(this, ServiceLocator.VMFactory)[VM::class.java]
} }
private fun createSuLogDatabase(context: Context) = private fun createSuLogDatabase(context: Context) =

View File

@ -121,15 +121,15 @@ class MagiskDialog(
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
super.setContentView(binding.root) super.setContentView(binding.root)
val default = MaterialColors.getColor(context, R.attr.colorSurface, javaClass.canonicalName) val default = MaterialColors.getColor(context, com.google.android.material.R.attr.colorSurface, javaClass.canonicalName)
val surfaceColor = MaterialColors.getColor(context, R.attr.colorSurfaceSurfaceVariant, default) val surfaceColor = MaterialColors.getColor(context, R.attr.colorSurfaceSurfaceVariant, default)
val materialShapeDrawable = MaterialShapeDrawable(context, null, R.attr.alertDialogStyle, R.style.MaterialAlertDialog_MaterialComponents) val materialShapeDrawable = MaterialShapeDrawable(context, null, androidx.appcompat.R.attr.alertDialogStyle, com.google.android.material.R.style.MaterialAlertDialog_MaterialComponents)
materialShapeDrawable.initializeElevationOverlay(context) materialShapeDrawable.initializeElevationOverlay(context)
materialShapeDrawable.fillColor = ColorStateList.valueOf(surfaceColor) materialShapeDrawable.fillColor = ColorStateList.valueOf(surfaceColor)
materialShapeDrawable.elevation = context.resources.getDimension(R.dimen.margin_generic) materialShapeDrawable.elevation = context.resources.getDimension(R.dimen.margin_generic)
materialShapeDrawable.setCornerSize(context.resources.getDimension(R.dimen.l_50)) materialShapeDrawable.setCornerSize(context.resources.getDimension(R.dimen.l_50))
val inset = context.resources.getDimensionPixelSize(R.dimen.appcompat_dialog_background_inset) val inset = context.resources.getDimensionPixelSize(com.google.android.material.R.dimen.appcompat_dialog_background_inset)
window?.apply { window?.apply {
setBackgroundDrawable(InsetDrawable(materialShapeDrawable, inset, inset, inset, inset)) setBackgroundDrawable(InsetDrawable(materialShapeDrawable, inset, inset, inset, inset))
setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)

View File

@ -29,11 +29,11 @@ public class ConcealableBottomNavigationView extends BottomNavigationView {
} }
public ConcealableBottomNavigationView(@NonNull Context context, @Nullable AttributeSet attrs) { public ConcealableBottomNavigationView(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.attr.bottomNavigationStyle); this(context, attrs, com.google.android.material.R.attr.bottomNavigationStyle);
} }
public ConcealableBottomNavigationView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { public ConcealableBottomNavigationView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, R.style.Widget_Design_BottomNavigationView); this(context, attrs, defStyleAttr, com.google.android.material.R.style.Widget_Design_BottomNavigationView);
} }
public ConcealableBottomNavigationView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { public ConcealableBottomNavigationView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {

View File

@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { plugins {
`kotlin-dsl` `kotlin-dsl`
} }
@ -15,10 +17,16 @@ gradlePlugin {
} }
} }
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
}
}
dependencies { dependencies {
implementation(kotlin("gradle-plugin", "1.6.10")) implementation(kotlin("gradle-plugin", "1.6.10"))
implementation("com.android.tools.build:gradle:7.0.4") implementation("com.android.tools.build:gradle:7.1.0")
implementation("androidx.navigation:navigation-safe-args-gradle-plugin:2.4.0-rc01") implementation("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0-alpha01")
implementation("io.michaelrocks:paranoid-gradle-plugin:0.3.7") implementation("io.michaelrocks:paranoid-gradle-plugin:0.3.7")
implementation("org.eclipse.jgit:org.eclipse.jgit:5.12.0.202106070339-r") implementation("org.eclipse.jgit:org.eclipse.jgit:5.12.0.202106070339-r")
} }

View File

@ -29,7 +29,7 @@ fun Project.setupCommon() {
androidBase { androidBase {
compileSdkVersion(31) compileSdkVersion(31)
buildToolsVersion = "31.0.0" buildToolsVersion = "31.0.0"
ndkPath = "${System.getenv("ANDROID_SDK_ROOT")}/ndk/magisk" ndkPath = "$sdkDirectory/ndk/magisk"
defaultConfig { defaultConfig {
minSdk = 21 minSdk = 21

View File

@ -24,6 +24,7 @@ org.gradle.caching=true
android.useAndroidX=true android.useAndroidX=true
android.databinding.incremental=true android.databinding.incremental=true
android.injected.testOnly=false android.injected.testOnly=false
android.nonTransitiveRClass=true
# Magisk # Magisk
magisk.stubVersion=23 magisk.stubVersion=23