Unverified Commit 990b693b authored by onlymash's avatar onlymash Committed by GitHub

Migrate to Kotlin DSL (#2490)

Co-authored-by: default avatarMygod <contact-git@mygod.be>
parent 141a3076
...@@ -10,7 +10,7 @@ jobs: ...@@ -10,7 +10,7 @@ jobs:
- checkout - checkout
- run: git submodule update --init --recursive - run: git submodule update --init --recursive
- restore_cache: - restore_cache:
key: jars-{{ checksum "build.gradle" }} key: jars-{{ checksum "build.gradle.kts" }}
- run: - run:
name: Run Build and Tests name: Run Build and Tests
command: ./gradlew assembleDebug check -PCARGO_PROFILE=debug command: ./gradlew assembleDebug check -PCARGO_PROFILE=debug
...@@ -18,7 +18,7 @@ jobs: ...@@ -18,7 +18,7 @@ jobs:
paths: paths:
- ~/.gradle - ~/.gradle
- ~/.android/build-cache - ~/.android/build-cache
key: jars-{{ checksum "build.gradle" }} key: jars-{{ checksum "build.gradle.kts" }}
- store_artifacts: - store_artifacts:
path: mobile/build/outputs/apk path: mobile/build/outputs/apk
destination: apk/mobile destination: apk/mobile
......
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.github.ben-manes.versions'
buildscript {
ext {
javaVersion = JavaVersion.VERSION_1_8
kotlinVersion = '1.3.72'
minSdkVersion = 21
sdkVersion = 29
compileSdkVersion = 29
lifecycleVersion = '2.2.0'
desugarLibsVersion = '1.0.5'
junitVersion = '4.13'
androidTestVersion = '1.2.0'
androidEspressoVersion = '3.2.0'
versionCode = 5000650
versionName = '5.0.6-nightly'
resConfigs = ['ar', 'es', 'fa', 'fr', 'ja', 'ko', 'ru', 'tr', 'zh-rCN', 'zh-rTW']
}
repositories {
google()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0-alpha06'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.28.0'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.2'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta04'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.11.1'
classpath 'gradle.plugin.org.mozilla.rust-android-gradle:plugin:0.8.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.github.ben-manes.versions") version "0.28.0"
}
buildscript {
apply(from = "repositories.gradle.kts")
repositories {
google()
jcenter()
maven("https://plugins.gradle.org/m2/")
}
dependencies {
classpath(rootProject.extra.get("androidPlugin").toString())
classpath(kotlin("gradle-plugin", rootProject.extra.get("kotlinVersion").toString()))
classpath("com.google.android.gms:oss-licenses-plugin:0.10.2")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta04")
classpath("com.google.gms:google-services:4.3.3")
classpath("com.vanniktech:gradle-maven-publish-plugin:0.11.1")
classpath("gradle.plugin.org.mozilla.rust-android-gradle:plugin:0.8.3")
}
}
allprojects {
apply(from = "${rootProject.projectDir}/repositories.gradle.kts")
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
plugins {
`kotlin-dsl`
}
apply(from = "../repositories.gradle.kts")
dependencies {
implementation(rootProject.extra.get("androidPlugin").toString())
implementation(kotlin("gradle-plugin", rootProject.extra.get("kotlinVersion").toString()))
}
import com.android.build.VariantOutput
import com.android.build.gradle.AbstractAppExtension
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.internal.api.ApkVariantOutputImpl
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByName
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
import java.util.*
const val lifecycleVersion = "2.2.0"
private val Project.android get() = extensions.getByName<BaseExtension>("android")
private val flavorRegex = "(assemble|generate)\\w*(Release|Debug)".toRegex()
val Project.currentFlavor get() = gradle.startParameter.taskRequests.toString().let { task ->
flavorRegex.matchEntire(task)?.groupValues?.get(2)?.toLowerCase(Locale.ROOT) ?: "debug".also {
println("Warning: No match found for $task")
}
}
fun Project.setupCommon() {
android.apply {
compileSdkVersion(29)
defaultConfig {
minSdkVersion(21)
targetSdkVersion(29)
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
val javaVersion = JavaVersion.VERSION_1_8
compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
(this as ExtensionAware).extensions.getByName<KotlinJvmOptions>("kotlinOptions").jvmTarget =
javaVersion.toString()
}
dependencies {
add("testImplementation", "junit:junit:4.13")
add("androidTestImplementation", "androidx.test:runner:1.2.0")
add("androidTestImplementation", "androidx.test.espresso:espresso-core:3.2.0")
}
}
fun Project.setupCore() {
setupCommon()
android.apply {
defaultConfig {
versionCode = 5000650
versionName = "5.0.6-nightly"
}
compileOptions.isCoreLibraryDesugaringEnabled = true
}
dependencies.add("coreLibraryDesugaring", "com.android.tools:desugar_jdk_libs:1.0.5")
}
private val abiCodes = mapOf("armeabi-v7a" to 1, "arm64-v8a" to 2, "x86" to 3, "x86_64" to 4)
fun Project.setupApp() {
setupCore()
android.apply {
defaultConfig.resConfigs(listOf("ar", "es", "fa", "fr", "ja", "ko", "ru", "tr", "zh-rCN", "zh-rTW"))
buildTypes {
getByName("debug") {
isPseudoLocalesEnabled = true
}
getByName("release") {
isShrinkResources = true
isMinifyEnabled = true
proguardFile(getDefaultProguardFile("proguard-android.txt"))
}
}
packagingOptions {
exclude("**/*.kotlin_*")
}
splits.abi {
isEnable = true
isUniversalApk = true
}
}
dependencies.add("implementation", project(":core"))
if (currentFlavor == "release") (android as AbstractAppExtension).applicationVariants.all {
for (output in outputs) {
abiCodes[(output as ApkVariantOutputImpl).getFilter(VariantOutput.ABI)]?.let { offset ->
output.versionCodeOverride = versionCode + offset
}
}
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
android {
compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.sdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
consumerProguardFiles 'proguard-rules.pro'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
ndkBuild {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
arguments "-j${Runtime.runtime.availableProcessors()}"
}
}
javaCompileOptions.annotationProcessorOptions.arguments = [
"room.incremental": "true",
"room.schemaLocation": "$projectDir/schemas".toString(),
]
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
kotlinOptions.jvmTarget = javaVersion
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
}
androidExtensions {
experimental = true
}
cargo {
module = 'src/main/rust/shadowsocks-rust'
libname = 'sslocal'
targets = ['arm', 'arm64', 'x86', 'x86_64']
profile = findProperty('CARGO_PROFILE') ?: 'release'
targetIncludes = ["lib${libname}.so"]
extraCargoBuildArguments = ['--bin', 'sslocal']
features {
noDefaultBut "sodium", "rc4", "aes-cfb", "aes-ctr", "camellia-cfb", "openssl-vendored", "local-flow-stat", "local-dns-relay"
}
exec { spec, toolchain ->
spec.environment("RUSTFLAGS", "-C lto=no -C link-arg=-o -C link-arg=target/${toolchain.target}/$profile/lib${libname}.so")
}
}
tasks.whenTaskAdded { task ->
if (task.name == 'javaPreCompileDebug' || task.name == 'javaPreCompileRelease') task.dependsOn 'cargoBuild'
}
def coroutinesVersion = '1.3.5'
def roomVersion = '2.2.5'
def workVersion = '2.3.4'
dependencies {
api project(':plugin')
api 'androidx.fragment:fragment-ktx:1.2.4'
api "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
api "androidx.lifecycle:lifecycle-livedata-core-ktx:$lifecycleVersion"
api 'androidx.preference:preference:1.1.1'
api "androidx.room:room-runtime:$roomVersion"
api "androidx.work:work-runtime-ktx:$workVersion"
api "androidx.work:work-gcm:$workVersion"
api 'com.google.android.gms:play-services-oss-licenses:17.0.0'
api 'com.google.code.gson:gson:2.8.6'
api 'com.google.firebase:firebase-analytics-ktx:17.3.0'
api 'com.google.firebase:firebase-config-ktx:19.1.3'
api 'com.google.firebase:firebase-crashlytics:17.0.0-beta04'
api 'com.jakewharton.timber:timber:4.7.1'
api 'dnsjava:dnsjava:3.0.2'
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
api "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion"
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:$desugarLibsVersion"
kapt "androidx.room:room-compiler:$roomVersion"
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.room:room-testing:$roomVersion"
androidTestImplementation "androidx.test:runner:$androidTestVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidEspressoVersion"
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.1'
}
plugins {
id("com.android.library")
id("org.mozilla.rust-android-gradle.rust-android")
kotlin("android")
kotlin("android.extensions")
kotlin("kapt")
}
setupCore()
android {
defaultConfig {
consumerProguardFiles("proguard-rules.pro")
externalNativeBuild.ndkBuild {
abiFilters("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
arguments("-j${Runtime.getRuntime().availableProcessors()}")
}
javaCompileOptions.annotationProcessorOptions.arguments = mapOf(
"room.incremental" to "true",
"room.schemaLocation" to "$projectDir/schemas"
)
}
externalNativeBuild.ndkBuild.path("src/main/jni/Android.mk")
sourceSets.getByName("androidTest") {
assets.setSrcDirs(assets.srcDirs + files("$projectDir/schemas"))
}
}
androidExtensions.isExperimental = true
cargo {
module = "src/main/rust/shadowsocks-rust"
libname = "sslocal"
targets = listOf("arm", "arm64", "x86", "x86_64")
profile = findProperty("CARGO_PROFILE")?.toString() ?: "release"
targetIncludes = arrayOf("lib$libname.so")
extraCargoBuildArguments = listOf("--bin", "sslocal")
features {
noDefaultBut(arrayOf(
"sodium",
"rc4",
"aes-cfb",
"aes-ctr",
"camellia-cfb",
"openssl-vendored",
"local-flow-stat",
"local-dns-relay"))
}
exec = { spec, toolchain ->
spec.environment("RUSTFLAGS",
"-C lto=no -C link-arg=-o -C link-arg=target/${toolchain.target}/$profile/lib$libname.so")
}
}
tasks.whenTaskAdded {
when (name) {
"javaPreCompileDebug", "javaPreCompileRelease" -> dependsOn("cargoBuild")
}
}
dependencies {
val coroutinesVersion = "1.3.5"
val roomVersion = "2.2.5"
val workVersion = "2.3.4"
api(project(":plugin"))
api("androidx.fragment:fragment-ktx:1.2.4")
api("androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion")
api("androidx.lifecycle:lifecycle-livedata-core-ktx:$lifecycleVersion")
api("androidx.preference:preference:1.1.1")
api("androidx.room:room-runtime:$roomVersion")
api("androidx.work:work-runtime-ktx:$workVersion")
api("androidx.work:work-gcm:$workVersion")
api("com.google.android.gms:play-services-oss-licenses:17.0.0")
api("com.google.code.gson:gson:2.8.6")
api("com.google.firebase:firebase-analytics-ktx:17.3.0")
api("com.google.firebase:firebase-config-ktx:19.1.3")
api("com.google.firebase:firebase-crashlytics:17.0.0-beta04")
api("com.jakewharton.timber:timber:4.7.1")
api("dnsjava:dnsjava:3.0.2")
api("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion")
api("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion")
api("org.connectbot.jsocks:jsocks:1.0.0")
kapt("androidx.room:room-compiler:$roomVersion")
androidTestImplementation("androidx.room:room-testing:$roomVersion")
androidTestImplementation("androidx.test.ext:junit-ktx:1.1.1")
}
import com.android.build.OutputFile
import java.util.regex.Matcher
import java.util.regex.Pattern
apply plugin: 'com.android.application'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
def getCurrentFlavor() {
String task = getGradle().getStartParameter().getTaskRequests().toString()
Matcher matcher = Pattern.compile("(assemble|generate)\\w*(Release|Debug)").matcher(task)
if (matcher.find()) return matcher.group(2).toLowerCase() else {
println "Warning: No match found for $task"
return "debug"
}
}
android {
compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
applicationId "com.github.shadowsocks"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.sdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resConfigs rootProject.resConfigs
}
buildTypes {
debug {
pseudoLocalesEnabled true
}
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
kotlinOptions.jvmTarget = javaVersion
packagingOptions.exclude '**/*.kotlin_*'
splits {
abi {
enable true
universalApk true
}
}
sourceSets.main.jniLibs.srcDirs +=
new File(project(':core').buildDir, "intermediates/bundles/${getCurrentFlavor()}/jni")
}
androidExtensions {
experimental = true
}
dependencies {
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:$desugarLibsVersion"
implementation project(':core')
implementation 'androidx.browser:browser:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion"
implementation 'com.google.android.gms:play-services-vision:20.0.0'
implementation 'com.google.firebase:firebase-ads:19.1.0'
implementation 'com.google.zxing:core:3.4.0'
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.1.0'
implementation 'com.twofortyfouram:android-plugin-api-for-locale:1.0.4'
implementation 'me.zhanghai.android.fastscroll:library:1.1.2'
implementation 'xyz.belvi.mobilevision:barcodescanner:2.0.3'
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test:runner:$androidTestVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidEspressoVersion"
}
repositories {
mavenCentral()
}
ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4]
if (getCurrentFlavor() == 'release') android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def offset = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
if (offset != null) output.versionCodeOverride = variant.versionCode + offset
}
}
plugins {
id("com.android.application")
id("com.google.android.gms.oss-licenses-plugin")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
kotlin("android")
kotlin("android.extensions")
}
setupApp()
android.defaultConfig.applicationId = "com.github.shadowsocks"
androidExtensions.isExperimental = true
dependencies {
implementation("androidx.browser:browser:1.2.0")
implementation("androidx.constraintlayout:constraintlayout:2.0.0-beta4")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion")
implementation("com.google.android.gms:play-services-vision:20.0.0")
implementation("com.google.firebase:firebase-ads:19.1.0")
implementation("com.google.zxing:core:3.4.0")
implementation("com.takisoft.preferencex:preferencex-simplemenu:1.1.0")
implementation("com.twofortyfouram:android-plugin-api-for-locale:1.0.4")
implementation("me.zhanghai.android.fastscroll:library:1.1.2")
implementation("xyz.belvi.mobilevision:barcodescanner:2.0.3")
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.vanniktech.maven.publish'
android {
compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.sdkVersion
versionCode Integer.parseInt(VERSION_CODE)
versionName VERSION_NAME
testInstrumentationRunner "androidx.testgetRepositoryPassword().runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
kotlinOptions.jvmTarget = javaVersion
buildTypes {
release {
minifyEnabled false
}
}
}
androidExtensions {
experimental = true
}
mavenPublish {
targets {
uploadArchives {
releaseRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
snapshotRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
repositoryUsername = findProperty('NEXUS_USERNAME') ?: ''
repositoryPassword = findProperty('NEXUS_PASSWORD') ?: ''
}
}
}
dependencies {
api 'androidx.core:core-ktx:1.2.0'
api 'androidx.drawerlayout:drawerlayout:1.1.0-beta01' // https://android-developers.googleblog.com/2019/07/android-q-beta-5-update.html
api 'com.google.android.material:material:1.1.0'
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test:runner:$androidTestVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidEspressoVersion"
}
repositories {
mavenCentral()
}
plugins {
id("com.android.library")
id("com.vanniktech.maven.publish")
kotlin("android")
kotlin("android.extensions")
}
setupCommon()
android {
defaultConfig {
versionCode = findProperty("VERSION_CODE").toString().toInt()
versionName = findProperty("VERSION_NAME").toString()
}
}
androidExtensions.isExperimental = true
mavenPublish.targets.getByName("uploadArchives") {
releaseRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
snapshotRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
repositoryUsername = findProperty("NEXUS_USERNAME").toString()
repositoryPassword = findProperty("NEXUS_PASSWORD").toString()
}
dependencies {
api(kotlin("stdlib-jdk8", rootProject.extra.get("kotlinVersion").toString()))
api("androidx.core:core-ktx:1.2.0")
// https://android-developers.googleblog.com/2019/07/android-q-beta-5-update.html
api("androidx.drawerlayout:drawerlayout:1.1.0-beta01")
api("com.google.android.material:material:1.1.0")
}
rootProject.extra.apply {
set("androidPlugin", "com.android.tools.build:gradle:4.1.0-alpha06")
set("kotlinVersion", "1.3.72")
}
repositories {
google()
jcenter()
}
include ':mobile', ':core', ':plugin', ':tv'
include(":core", ":plugin", ":mobile", ":tv")
import com.android.build.OutputFile
import java.util.regex.Matcher
import java.util.regex.Pattern
apply plugin: 'com.android.application'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
def getCurrentFlavor() {
String task = getGradle().getStartParameter().getTaskRequests().toString()
Matcher matcher = Pattern.compile("(assemble|generate)\\w*(Release|Debug)").matcher(task)
if (matcher.find()) return matcher.group(2).toLowerCase() else {
println "Warning: No match found for $task"
return "debug"
}
}
android {
compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
applicationId "com.github.shadowsocks.tv"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.sdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
resConfigs rootProject.resConfigs
}
buildTypes {
debug {
pseudoLocalesEnabled true
}
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
kotlinOptions.jvmTarget = javaVersion
packagingOptions.exclude '**/*.kotlin_*'
splits {
abi {
enable true
universalApk true
}
}
sourceSets.main.jniLibs.srcDirs +=
new File(project(':core').buildDir, "intermediates/bundles/${getCurrentFlavor()}/jni")
}
dependencies {
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:$desugarLibsVersion"
implementation project(':core')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.leanback:leanback-preference:1.1.0-alpha03'
}
ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4]
if (getCurrentFlavor() == 'release') android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def offset = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
if (offset != null) output.versionCodeOverride = variant.versionCode + offset
}
}
plugins {
id("com.android.application")
id("com.google.android.gms.oss-licenses-plugin")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
kotlin("android")
kotlin("kapt")
}
setupApp()
android.defaultConfig.applicationId = "com.github.shadowsocks.tv"
dependencies {
implementation("androidx.leanback:leanback-preference:1.1.0-alpha03")
}
...@@ -40,7 +40,7 @@ open class LeanbackSingleListPreferenceDialogFragment : LeanbackListPreferenceDi ...@@ -40,7 +40,7 @@ open class LeanbackSingleListPreferenceDialogFragment : LeanbackListPreferenceDi
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val selected = mInitialSelection.get(this) as? String val selected = mInitialSelection.get(this) as? String
val index = (mEntryValues.get(this) as? Array<CharSequence?>)?.indexOfFirst { it == selected } val index = (mEntryValues.get(this) as? Array<*>)?.indexOfFirst { selected == it }
return super.onCreateView(inflater, container, savedInstanceState)!!.also { return super.onCreateView(inflater, container, savedInstanceState)!!.also {
if (index != null) it.findViewById<RecyclerView>(android.R.id.list).layoutManager!!.scrollToPosition(index) if (index != null) it.findViewById<RecyclerView>(android.R.id.list).layoutManager!!.scrollToPosition(index)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment