Merge pull request #1901 from ag2s20150909/master

启用新的gradle格式,设置android.nonTransitiveRClass=true
This commit is contained in:
kunfei
2022-05-24 20:36:35 +08:00
committed by GitHub
14 changed files with 119 additions and 66 deletions
@@ -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"
@@ -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
@@ -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) {
@@ -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()
@@ -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")
)
)
}
@@ -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(
@@ -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