update gradle to new format

turn on nonTransitiveRClass
This commit is contained in:
ag2s20150909 2022-05-23 23:45:37 +08:00
parent 7f1a6e6ef0
commit 2e107e7356
14 changed files with 119 additions and 68 deletions

View File

@ -1,9 +1,11 @@
apply plugin: 'com.android.application' plugins {
apply plugin: 'kotlin-android' id "com.android.application"
apply plugin: 'kotlin-parcelize' id 'org.jetbrains.kotlin.android'
apply plugin: 'kotlin-kapt' id 'kotlin-parcelize'
apply plugin: 'de.timfreiheit.resourceplaceholders' id 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services' id "de.timfreiheit.resourceplaceholders"
id "com.google.gms.google-services"
}
apply from: 'download.gradle' apply from: 'download.gradle'
static def releaseTime() { static def releaseTime() {
@ -16,11 +18,15 @@ def gitCommits = Integer.parseInt('git rev-list HEAD --count'.execute().text.tri
android { android {
compileSdkVersion 32 compileSdkVersion 32
buildToolsVersion '32.0.0' buildToolsVersion "32.0.0"
namespace 'io.legado.app'
kotlinOptions { kotlinOptions {
jvmTarget = "11" jvmTarget = "11"
} }
namespace 'io.legado.app' lintOptions{
checkDependencies true
}
signingConfigs { signingConfigs {
if (project.hasProperty("RELEASE_STORE_FILE")) { if (project.hasProperty("RELEASE_STORE_FILE")) {
myConfig { myConfig {

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools">
package="io.legado.app">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />

View File

@ -5,7 +5,6 @@ import android.content.pm.PackageManager
import android.provider.Settings import android.provider.Settings
import com.script.javascript.RhinoScriptEngine import com.script.javascript.RhinoScriptEngine
import io.legado.app.BuildConfig import io.legado.app.BuildConfig
import io.legado.app.R
import splitties.init.appCtx import splitties.init.appCtx
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
@ -57,7 +56,9 @@ object AppConst {
) )
@SuppressLint("PrivateResource") @SuppressLint("PrivateResource")
val sysElevation = appCtx.resources.getDimension(R.dimen.design_appbar_elevation).toInt() val sysElevation =
appCtx.resources.getDimension(com.google.android.material.R.dimen.design_appbar_elevation)
.toInt()
val androidId: String by lazy { val androidId: String by lazy {
Settings.System.getString(appCtx.contentResolver, Settings.Secure.ANDROID_ID) ?: "null" Settings.System.getString(appCtx.contentResolver, Settings.Secure.ANDROID_ID) ?: "null"

View File

@ -120,7 +120,7 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex
override fun onBindViewHolder(holder: PreferenceViewHolder) { override fun onBindViewHolder(holder: PreferenceViewHolder) {
val v = io.legado.app.lib.prefs.Preference.bindView<ColorPanelView>( val v = io.legado.app.lib.prefs.Preference.bindView<ColorPanelView>(
context, holder, icon, title, summary, widgetLayoutResource, context, holder, icon, title, summary, widgetLayoutResource,
io.legado.app.R.id.cpv_preference_preview_color_panel, 30, 30 com.jaredrummler.android.colorpicker.R.id.cpv_preference_preview_color_panel, 30, 30
) )
if (v is ColorPanelView) { if (v is ColorPanelView) {
v.color = mColor v.color = mColor

View File

@ -30,7 +30,7 @@ class SwitchPreference(context: Context, attrs: AttributeSet) :
title, title,
summary, summary,
widgetLayoutResource, widgetLayoutResource,
R.id.switchWidget, androidx.preference.R.id.switchWidget,
isBottomBackground = isBottomBackground isBottomBackground = isBottomBackground
) )
if (v is SwitchCompat && !v.isInEditMode) { if (v is SwitchCompat && !v.isInEditMode) {

View File

@ -19,34 +19,52 @@ import io.legado.app.utils.dpToPx
@ColorInt @ColorInt
fun Context.getPrimaryTextColor(dark: Boolean): Int { fun Context.getPrimaryTextColor(dark: Boolean): Int {
return if (dark) { return if (dark) {
ContextCompat.getColor(this, R.color.primary_text_default_material_light) ContextCompat.getColor(this, androidx.appcompat.R.color.primary_text_default_material_light)
} else ContextCompat.getColor(this, R.color.primary_text_default_material_dark) } else ContextCompat.getColor(
this,
androidx.appcompat.R.color.primary_text_default_material_dark
)
} }
@ColorInt @ColorInt
fun Context.getSecondaryTextColor(dark: Boolean): Int { fun Context.getSecondaryTextColor(dark: Boolean): Int {
return if (dark) { return if (dark) {
ContextCompat.getColor(this, R.color.secondary_text_default_material_light) ContextCompat.getColor(
this,
androidx.appcompat.R.color.secondary_text_default_material_light
)
} else { } else {
ContextCompat.getColor(this, R.color.secondary_text_default_material_dark) ContextCompat.getColor(
this,
androidx.appcompat.R.color.secondary_text_default_material_dark
)
} }
} }
@ColorInt @ColorInt
fun Context.getPrimaryDisabledTextColor(dark: Boolean): Int { fun Context.getPrimaryDisabledTextColor(dark: Boolean): Int {
return if (dark) { return if (dark) {
ContextCompat.getColor(this, R.color.primary_text_disabled_material_light) ContextCompat.getColor(
this,
androidx.appcompat.R.color.primary_text_disabled_material_light
)
} else { } else {
ContextCompat.getColor(this, R.color.primary_text_disabled_material_dark) ContextCompat.getColor(this, androidx.appcompat.R.color.primary_text_disabled_material_dark)
} }
} }
@ColorInt @ColorInt
fun Context.getSecondaryDisabledTextColor(dark: Boolean): Int { fun Context.getSecondaryDisabledTextColor(dark: Boolean): Int {
return if (dark) { return if (dark) {
ContextCompat.getColor(this, R.color.secondary_text_disabled_material_light) ContextCompat.getColor(
this,
androidx.appcompat.R.color.secondary_text_disabled_material_light
)
} else { } else {
ContextCompat.getColor(this, R.color.secondary_text_disabled_material_dark) ContextCompat.getColor(
this,
androidx.appcompat.R.color.secondary_text_disabled_material_dark
)
} }
} }
@ -124,7 +142,7 @@ val Context.elevation: Float
ThemeUtils.resolveFloat( ThemeUtils.resolveFloat(
this, this,
android.R.attr.elevation, android.R.attr.elevation,
resources.getDimension(R.dimen.design_appbar_elevation) resources.getDimension(com.google.android.material.R.dimen.design_appbar_elevation)
) )
} else { } else {
AppConfig.elevation.toFloat().dpToPx() AppConfig.elevation.toFloat().dpToPx()

View File

@ -9,7 +9,6 @@ import androidx.annotation.CheckResult
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
import androidx.annotation.ColorRes import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import io.legado.app.R
import io.legado.app.utils.ColorUtils import io.legado.app.utils.ColorUtils
import splitties.init.appCtx import splitties.init.appCtx
@ -189,7 +188,11 @@ private constructor(private val mContext: Context) : ThemeStoreInterface {
fun primaryColor(context: Context = appCtx): Int { fun primaryColor(context: Context = appCtx): Int {
return prefs(context).getInt( return prefs(context).getInt(
ThemeStorePrefKeys.KEY_PRIMARY_COLOR, ThemeStorePrefKeys.KEY_PRIMARY_COLOR,
ThemeUtils.resolveColor(context, R.attr.colorPrimary, Color.parseColor("#455A64")) ThemeUtils.resolveColor(
context,
androidx.appcompat.R.attr.colorPrimary,
Color.parseColor("#455A64")
)
) )
} }
@ -200,7 +203,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface {
ThemeStorePrefKeys.KEY_PRIMARY_COLOR_DARK, ThemeStorePrefKeys.KEY_PRIMARY_COLOR_DARK,
ThemeUtils.resolveColor( ThemeUtils.resolveColor(
context, context,
R.attr.colorPrimaryDark, androidx.appcompat.R.attr.colorPrimaryDark,
Color.parseColor("#37474F") Color.parseColor("#37474F")
) )
) )
@ -211,7 +214,11 @@ private constructor(private val mContext: Context) : ThemeStoreInterface {
fun accentColor(context: Context = appCtx): Int { fun accentColor(context: Context = appCtx): Int {
return prefs(context).getInt( return prefs(context).getInt(
ThemeStorePrefKeys.KEY_ACCENT_COLOR, ThemeStorePrefKeys.KEY_ACCENT_COLOR,
ThemeUtils.resolveColor(context, R.attr.colorAccent, Color.parseColor("#263238")) ThemeUtils.resolveColor(
context,
androidx.appcompat.R.attr.colorAccent,
Color.parseColor("#263238")
)
) )
} }

View File

@ -31,9 +31,9 @@ object TintHelper {
// Light ripple is actually translucent black, and vice versa // Light ripple is actually translucent black, and vice versa
return ContextCompat.getColor( return ContextCompat.getColor(
context, if (useDarkRipple) context, if (useDarkRipple)
R.color.ripple_material_light androidx.appcompat.R.color.ripple_material_light
else else
R.color.ripple_material_dark androidx.appcompat.R.color.ripple_material_dark
) )
} }
@ -170,7 +170,7 @@ object TintHelper {
val rd = view.background as RippleDrawable val rd = view.background as RippleDrawable
@SuppressLint("PrivateResource") val unchecked = ContextCompat.getColor( @SuppressLint("PrivateResource") val unchecked = ContextCompat.getColor(
view.context, view.context,
if (isDark) R.color.ripple_material_dark else R.color.ripple_material_light if (isDark) androidx.appcompat.R.color.ripple_material_dark else androidx.appcompat.R.color.ripple_material_light
) )
val checked = ColorUtils.adjustAlpha(color, 0.4f) val checked = ColorUtils.adjustAlpha(color, 0.4f)
val sl = ColorStateList( val sl = ColorStateList(

View File

@ -17,7 +17,6 @@ import android.widget.ImageView
import android.widget.OverScroller import android.widget.OverScroller
import android.widget.Scroller import android.widget.Scroller
import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.AppCompatImageView
import io.legado.app.R
import io.legado.app.ui.widget.image.photo.Info import io.legado.app.ui.widget.image.photo.Info
import io.legado.app.ui.widget.image.photo.OnRotateListener import io.legado.app.ui.widget.image.photo.OnRotateListener
import io.legado.app.ui.widget.image.photo.RotateGestureDetector import io.legado.app.ui.widget.image.photo.RotateGestureDetector
@ -917,7 +916,7 @@ class PhotoView @JvmOverloads constructor(
var viewParent: ViewParent = target.parent var viewParent: ViewParent = target.parent
while (viewParent is View) { while (viewParent is View) {
val view: View = viewParent val view: View = viewParent
if (view.id == R.id.content) return if (view.id == androidx.constraintlayout.widget.R.id.content) return
position[0] -= view.scrollX position[0] -= view.scrollX
position[1] -= view.scrollY position[1] -= view.scrollY
position[0] += view.left position[0] += view.left

View File

@ -1,36 +1,22 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.6.10' ext{
repositories { kotlin_version = '1.6.10'
// agp_version='7.2.0'
google()
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
//,,
//maven { url 'https://maven.aliyun.com/repository/google' }
//maven { url 'https://maven.aliyun.com/repository/public' }
//maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'de.timfreiheit.resourceplaceholders:placeholders:0.4'
classpath 'de.undercouch:gradle-download-task:5.0.1'
classpath 'com.google.gms:google-services:4.3.10'
} }
} }
allprojects {
repositories {
// plugins {
google() id 'com.android.application' version "$agp_version" apply false
mavenCentral() id 'com.android.library' version "$agp_version" apply false
maven { url 'https://jitpack.io' } id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
//,, id "de.timfreiheit.resourceplaceholders" version "0.4" apply false
//maven { url 'https://maven.aliyun.com/repository/google' } id "de.undercouch.download" version "5.1.0" apply false
//maven { url 'https://maven.aliyun.com/repository/public' } id "com.google.gms.google-services" version "4.3.10" apply false
}
} }
task clean(type: Delete) { task clean(type: Delete) {

View File

@ -3,12 +3,15 @@ plugins {
} }
android { android {
compileSdkVersion 31 compileSdkVersion 32
buildToolsVersion '31.0.0' buildToolsVersion '32.0.0'
namespace 'me.ag2s.epublib' namespace 'me.ag2s.epublib'
lintOptions{
checkDependencies true
}
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 31 targetSdkVersion 32
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro" consumerProguardFiles "consumer-rules.pro"
@ -19,8 +22,7 @@ android {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
android {
}
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8

View File

@ -19,8 +19,11 @@ android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete": # Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official kotlin.code.style=official
android.enableResourceOptimizations=true android.enableResourceOptimizations=true
android.enableNewResourceShrinker=true
android.experimental.enableNewResourceShrinker.preciseShrinking=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
#https://chromiumdash.appspot.com/releases?platform=Android #https://chromiumdash.appspot.com/releases?platform=Android
CronetVersion=101.0.4951.61 CronetVersion=101.0.4951.61

View File

@ -1,6 +1,6 @@
#Fri May 07 15:24:46 CST 2021 #Mon May 23 22:07:39 CST 2022
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@ -1 +1,31 @@
pluginManagement {
repositories {
//
gradlePluginPortal()
google()
mavenCentral()
//,,
//maven {url"https://maven-central-asia.storage-download.googleapis.com/maven2/"}
//maven { url 'https://maven.aliyun.com/repository/google' }
//maven { url 'https://maven.aliyun.com/repository/public' }
//maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
//
google()
mavenCentral()
maven { url 'https://jitpack.io' }
//,,
//maven {url"https://maven-central-asia.storage-download.googleapis.com/maven2/"}
//maven { url 'https://maven.aliyun.com/repository/google' }
//maven { url 'https://maven.aliyun.com/repository/public' }
}
}
rootProject.name = 'legado'
include ':app',':epublib' include ':app',':epublib'