Switch to non-transitive R classes.

This commit is contained in:
Isira Seneviratne 2023-04-18 06:08:40 +05:30
parent 7b4e3fd121
commit cf179fd7e9
8 changed files with 24 additions and 11 deletions

View File

@ -132,7 +132,7 @@ object ThemeHelper {
* Get the styled app name
*/
fun getStyledAppName(context: Context): Spanned {
val colorPrimary = getThemeColor(context, R.attr.colorPrimaryDark)
val colorPrimary = getThemeColor(context, androidx.appcompat.R.attr.colorPrimaryDark)
val hexColor = String.format("#%06X", (0xFFFFFF and colorPrimary))
return "Libre<span style='color:$hexColor';>Tube</span>"
.parseAsHtml(HtmlCompat.FROM_HTML_MODE_COMPACT)

View File

@ -237,8 +237,14 @@ class MainActivity : BaseActivity() {
if (lastSeenVideoIndex < 1) return@observe
binding.bottomNav.getOrCreateBadge(R.id.subscriptionsFragment).apply {
number = lastSeenVideoIndex
backgroundColor = ThemeHelper.getThemeColor(this@MainActivity, R.attr.colorPrimary)
badgeTextColor = ThemeHelper.getThemeColor(this@MainActivity, R.attr.colorOnPrimary)
backgroundColor = ThemeHelper.getThemeColor(
this@MainActivity,
androidx.appcompat.R.attr.colorPrimary
)
badgeTextColor = ThemeHelper.getThemeColor(
this@MainActivity,
com.google.android.material.R.attr.colorOnPrimary
)
}
}
}

View File

@ -91,7 +91,10 @@ class CommentsAdapter(
// highlight the comment that is being replied to
if (comment == comments.firstOrNull()) {
root.setBackgroundColor(
ThemeHelper.getThemeColor(root.context, R.attr.colorSurface)
ThemeHelper.getThemeColor(
root.context,
com.google.android.material.R.attr.colorSurface
)
)
root.updatePadding(top = 20)
root.updateLayoutParams<MarginLayoutParams> { bottomMargin = 20 }

View File

@ -40,7 +40,8 @@ class PlaylistsAdapter(
// set imageview drawable as empty playlist if imageview empty
if (playlist.thumbnail.orEmpty().split("/").size <= 4) {
playlistThumbnail.setImageResource(R.drawable.ic_empty_playlist)
playlistThumbnail.setBackgroundColor(R.attr.colorSurface)
playlistThumbnail
.setBackgroundColor(com.google.android.material.R.attr.colorSurface)
} else {
ImageHelper.loadImage(playlist.thumbnail, playlistThumbnail)
}

View File

@ -21,7 +21,7 @@ class ErrorDialog : DialogFragment() {
.setTitle(R.string.error_occurred)
.setMessage(errorLog)
.setNegativeButton(R.string.okay, null)
.setPositiveButton(R.string.copy) { _, _ ->
.setPositiveButton(androidx.preference.R.string.copy) { _, _ ->
ClipboardHelper.save(requireContext(), errorLog)
Toast.makeText(context, R.string.copied, Toast.LENGTH_SHORT).show()
}

View File

@ -7,7 +7,6 @@ import android.view.MotionEvent
import android.view.MotionEvent.ACTION_MOVE
import android.view.ViewConfiguration
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.github.libretube.R
import com.github.libretube.helpers.ThemeHelper
import com.google.android.material.elevation.SurfaceColors
import kotlin.math.abs
@ -18,7 +17,9 @@ class CustomSwipeToRefresh(context: Context?, attrs: AttributeSet?) :
private var mPrevX = 0f
init {
setColorSchemeColors(ThemeHelper.getThemeColor(this.context, R.attr.colorPrimary))
setColorSchemeColors(
ThemeHelper.getThemeColor(this.context, androidx.appcompat.R.attr.colorPrimary)
)
setProgressBackgroundColorSchemeColor(
SurfaceColors.getColorForElevation(this.context, 20f)
)

View File

@ -7,7 +7,6 @@ import android.graphics.Rect
import android.util.AttributeSet
import android.view.View
import androidx.core.view.marginLeft
import com.github.libretube.R
import com.github.libretube.api.obj.Segment
import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.extensions.dpToPx
@ -56,7 +55,10 @@ class MarkableTimeBar(
canvas.height - marginY
),
Paint().apply {
color = ThemeHelper.getThemeColor(context, R.attr.colorOnSecondary)
color = ThemeHelper.getThemeColor(
context,
com.google.android.material.R.attr.colorOnSecondary
)
}
)
}

View File

@ -16,5 +16,5 @@ kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonTransitiveRClass=true
android.nonFinalResIds=true