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

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="io.legado.app">
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<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 com.script.javascript.RhinoScriptEngine
import io.legado.app.BuildConfig
import io.legado.app.R
import splitties.init.appCtx
import java.text.SimpleDateFormat
@ -57,7 +56,9 @@ object AppConst {
)
@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 {
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) {
val v = io.legado.app.lib.prefs.Preference.bindView<ColorPanelView>(
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) {
v.color = mColor

View File

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

View File

@ -19,34 +19,52 @@ import io.legado.app.utils.dpToPx
@ColorInt
fun Context.getPrimaryTextColor(dark: Boolean): Int {
return if (dark) {
ContextCompat.getColor(this, R.color.primary_text_default_material_light)
} else ContextCompat.getColor(this, R.color.primary_text_default_material_dark)
ContextCompat.getColor(this, androidx.appcompat.R.color.primary_text_default_material_light)
} else ContextCompat.getColor(
this,
androidx.appcompat.R.color.primary_text_default_material_dark
)
}
@ColorInt
fun Context.getSecondaryTextColor(dark: Boolean): Int {
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 {
ContextCompat.getColor(this, R.color.secondary_text_default_material_dark)
ContextCompat.getColor(
this,
androidx.appcompat.R.color.secondary_text_default_material_dark
)
}
}
@ColorInt
fun Context.getPrimaryDisabledTextColor(dark: Boolean): Int {
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 {
ContextCompat.getColor(this, R.color.primary_text_disabled_material_dark)
ContextCompat.getColor(this, androidx.appcompat.R.color.primary_text_disabled_material_dark)
}
}
@ColorInt
fun Context.getSecondaryDisabledTextColor(dark: Boolean): Int {
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 {
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(
this,
android.R.attr.elevation,
resources.getDimension(R.dimen.design_appbar_elevation)
resources.getDimension(com.google.android.material.R.dimen.design_appbar_elevation)
)
} else {
AppConfig.elevation.toFloat().dpToPx()

View File

@ -9,7 +9,6 @@ import androidx.annotation.CheckResult
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat
import io.legado.app.R
import io.legado.app.utils.ColorUtils
import splitties.init.appCtx
@ -189,7 +188,11 @@ private constructor(private val mContext: Context) : ThemeStoreInterface {
fun primaryColor(context: Context = appCtx): Int {
return prefs(context).getInt(
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,
ThemeUtils.resolveColor(
context,
R.attr.colorPrimaryDark,
androidx.appcompat.R.attr.colorPrimaryDark,
Color.parseColor("#37474F")
)
)
@ -211,7 +214,11 @@ private constructor(private val mContext: Context) : ThemeStoreInterface {
fun accentColor(context: Context = appCtx): Int {
return prefs(context).getInt(
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
return ContextCompat.getColor(
context, if (useDarkRipple)
R.color.ripple_material_light
androidx.appcompat.R.color.ripple_material_light
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
@SuppressLint("PrivateResource") val unchecked = ContextCompat.getColor(
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 sl = ColorStateList(

View File

@ -17,7 +17,6 @@ import android.widget.ImageView
import android.widget.OverScroller
import android.widget.Scroller
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.OnRotateListener
import io.legado.app.ui.widget.image.photo.RotateGestureDetector
@ -917,7 +916,7 @@ class PhotoView @JvmOverloads constructor(
var viewParent: ViewParent = target.parent
while (viewParent is View) {
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[1] -= view.scrollY
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.
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
//
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'
ext{
kotlin_version = '1.6.10'
agp_version='7.2.0'
}
}
allprojects {
repositories {
//
google()
mavenCentral()
maven { url 'https://jitpack.io' }
//,,
//maven { url 'https://maven.aliyun.com/repository/google' }
//maven { url 'https://maven.aliyun.com/repository/public' }
}
plugins {
id 'com.android.application' version "$agp_version" apply false
id 'com.android.library' version "$agp_version" apply false
id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
id "de.timfreiheit.resourceplaceholders" version "0.4" apply false
id "de.undercouch.download" version "5.1.0" apply false
id "com.google.gms.google-services" version "4.3.10" apply false
}
task clean(type: Delete) {

View File

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

View File

@ -19,8 +19,11 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
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
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
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
zipStorePath=wrapper/dists
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'