Theme refactoring again

This commit is contained in:
Jay 2020-03-23 17:18:18 -04:00
parent 6ee80d2a2b
commit 776c85a954
19 changed files with 84 additions and 63 deletions

View File

@ -19,7 +19,7 @@ import eu.kanade.tachiyomi.util.view.setEdgeToEdge
import kotlinx.android.synthetic.main.catalogue_drawer_content.*
import uy.kohesive.injekt.injectLazy
class CatalogueSearchSheet(private val activity: Activity) :
class CatalogueSearchSheet(activity: Activity) :
BottomSheetDialog(activity, R.style.BottomSheetDialogThemeCovered) {
/**

View File

@ -8,7 +8,6 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.AbstractHeaderItem
import eu.davidea.flexibleadapter.items.IFlexible
import eu.davidea.viewholders.FlexibleViewHolder
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.util.system.getResourceColor
@ -26,7 +25,7 @@ class HeaderItem(val filter: Filter.Header) : AbstractHeaderItem<HeaderItem.Hold
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>, holder: Holder, position: Int, payloads: MutableList<Any?>?) {
val view = holder.itemView as TextView
view.text = filter.name
view.setTextColor(view.context.getResourceColor(R.attr.actionBarTintColor))
view.setTextColor(view.context.getResourceColor(android.R.attr.textColorPrimary))
}
override fun equals(other: Any?): Boolean {

View File

@ -211,12 +211,12 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
}
// if in landscape with 2/3 button mode, fully opaque nav bar
else if (v.rootWindowInsets.systemWindowInsetLeft > 0 || v.rootWindowInsets.systemWindowInsetRight > 0) {
getResourceColor(android.R.attr.colorPrimary)
getResourceColor(R.attr.colorPrimaryVariant)
}
// if in portrait with 2/3 button mode, translucent nav bar
else {
ColorUtils.setAlphaComponent(
getResourceColor(android.R.attr.colorPrimary), 179
getResourceColor(R.attr.colorPrimaryVariant), 179
)
}
val contextView = window?.decorView?.findViewById<View>(R.id.action_mode_bar)
@ -316,7 +316,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
}
override fun startSupportActionMode(callback: androidx.appcompat.view.ActionMode.Callback): androidx.appcompat.view.ActionMode? {
window?.statusBarColor = getResourceColor(R.attr.colorPrimary)
window?.statusBarColor = getResourceColor(R.attr.colorPrimaryVariant)
return super.startSupportActionMode(callback)
}

View File

@ -243,7 +243,7 @@ class MangaDetailsController : BaseController,
return
}
val color =
coverColor ?: activity!!.getResourceColor(android.R.attr.colorPrimary)
coverColor ?: activity!!.getResourceColor(R.attr.colorPrimaryVariant)
val colorFrom =
if (colorAnimator?.isRunning == true) activity?.window?.statusBarColor
?: color
@ -360,14 +360,14 @@ class MangaDetailsController : BaseController,
}
colorAnimator?.cancel()
val colorOnPrimary = activity?.getResourceColor(
R.attr.colorOnPrimary
val colorSecondary = activity?.getResourceColor(
R.attr.colorSecondary
) ?: Color.BLACK
(activity as MainActivity).appbar.setBackgroundColor(colorOnPrimary)
(activity as MainActivity).toolbar.setBackgroundColor(colorOnPrimary)
(activity as MainActivity).appbar.setBackgroundColor(colorSecondary)
(activity as MainActivity).toolbar.setBackgroundColor(colorSecondary)
activity?.window?.statusBarColor = activity?.getResourceColor(android.R.attr
.statusBarColor) ?: colorOnPrimary
.statusBarColor) ?: colorSecondary
}
}
@ -517,22 +517,22 @@ class MangaDetailsController : BaseController,
fun toggleReadChapter(position: Int) {
val item = adapter?.getItem(position) as? ChapterItem ?: return
if (!item.read) markAsRead(listOf(item), false)
else markAsUnread(listOf(item), false)
if (!item.read) markAsRead(listOf(item))
else markAsUnread(listOf(item))
}
private fun bookmarkChapters(chapters: List<ChapterItem>, bookmarked: Boolean) {
presenter.bookmarkChapters(chapters, bookmarked)
}
private fun markAsRead(chapters: List<ChapterItem>, refresh: Boolean = true) {
private fun markAsRead(chapters: List<ChapterItem>) {
presenter.markChaptersRead(chapters, read = true)
if (presenter.preferences.removeAfterMarkedAsRead()) {
presenter.deleteChapters(chapters)
}
}
private fun markAsUnread(chapters: List<ChapterItem>, refresh: Boolean = true) {
private fun markAsUnread(chapters: List<ChapterItem>) {
presenter.markChaptersRead(chapters, read = false)
}
@ -1248,25 +1248,25 @@ class MangaDetailsController : BaseController,
expandedImageView.setOnClickListener {
currentAnimator?.cancel()
val rect = Rect()
thumbView.getGlobalVisibleRect(rect)
val rect2 = Rect()
thumbView.getGlobalVisibleRect(rect2)
expandedImageView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
height = thumbView.height
width = thumbView.width
topMargin = rect.top
leftMargin = rect.left
rightMargin = rect.right
bottomMargin = rect.bottom
topMargin = rect2.top
leftMargin = rect2.left
rightMargin = rect2.right
bottomMargin = rect2.bottom
}
// Zoom out back to tc thumbnail
val transitionSet = TransitionSet()
val bound = ChangeBounds()
transitionSet.addTransition(bound)
val changeImageTransform = ChangeImageTransform()
transitionSet.addTransition(changeImageTransform)
transitionSet.duration = shortAnimationDuration.toLong()
TransitionManager.beginDelayedTransition(frame_layout, transitionSet)
val transitionSet2 = TransitionSet()
val bound2 = ChangeBounds()
transitionSet2.addTransition(bound2)
val changeImageTransform2 = ChangeImageTransform()
transitionSet2.addTransition(changeImageTransform2)
transitionSet2.duration = shortAnimationDuration.toLong()
TransitionManager.beginDelayedTransition(frame_layout, transitionSet2)
// Animation to remove backdrop and hide the full cover
currentAnimator = AnimatorSet().apply {

View File

@ -42,7 +42,7 @@ class SettingsTrackingController : SettingsController(),
trackPreference(trackManager.aniList) {
onClick {
val tabsIntent = CustomTabsIntent.Builder()
.setToolbarColor(context.getResourceColor(R.attr.colorPrimary))
.setToolbarColor(context.getResourceColor(R.attr.colorPrimaryVariant))
.build()
tabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
tabsIntent.launchUrl(activity!!, AnilistApi.authUrl())
@ -58,7 +58,7 @@ class SettingsTrackingController : SettingsController(),
trackPreference(trackManager.shikimori) {
onClick {
val tabsIntent = CustomTabsIntent.Builder()
.setToolbarColor(context.getResourceColor(R.attr.colorPrimary))
.setToolbarColor(context.getResourceColor(R.attr.colorPrimaryVariant))
.build()
tabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
tabsIntent.launchUrl(activity!!, ShikimoriApi.authUrl())
@ -67,7 +67,7 @@ class SettingsTrackingController : SettingsController(),
trackPreference(trackManager.bangumi) {
onClick {
val tabsIntent = CustomTabsIntent.Builder()
.setToolbarColor(context.getResourceColor(R.attr.colorPrimary))
.setToolbarColor(context.getResourceColor(R.attr.colorPrimaryVariant))
.build()
tabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
tabsIntent.launchUrl(activity!!, BangumiApi.authUrl())

View File

@ -96,7 +96,7 @@ class WebViewActivity : BaseActivity() {
}
window.statusBarColor = ColorUtils.setAlphaComponent(getResourceColor(R.attr
.colorOnPrimary), 255)
.colorSecondary), 255)
content.setOnApplyWindowInsetsListener { v, insets ->
// if pure white theme on a device that does not support dark status bar
@ -104,7 +104,7 @@ class WebViewActivity : BaseActivity() {
window.statusBarColor = Color.BLACK
else window.statusBarColor = getResourceColor(R.attr.colorPrimary)*/
window.navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
val colorPrimary = getResourceColor(android.R.attr.colorPrimary)
val colorPrimary = getResourceColor(R.attr.colorPrimaryVariant)
if (colorPrimary == Color.WHITE) Color.BLACK
else getResourceColor(android.R.attr.colorPrimary)
}
@ -191,8 +191,8 @@ class WebViewActivity : BaseActivity() {
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
val lightMode = currentNightMode == Configuration.UI_MODE_NIGHT_NO
window.statusBarColor = ColorUtils.setAlphaComponent(getResourceColor(R.attr
.colorOnPrimary), 255)
toolbar.setBackgroundColor(getResourceColor(R.attr.colorOnPrimary))
.colorSecondary), 255)
toolbar.setBackgroundColor(getResourceColor(R.attr.colorSecondary))
toolbar.popupTheme = if (lightMode) R.style.ThemeOverlay_MaterialComponents else R
.style.ThemeOverlay_MaterialComponents_Dark
val tintColor = getResourceColor(R.attr.actionBarTintColor)
@ -202,7 +202,7 @@ class WebViewActivity : BaseActivity() {
toolbar.overflowIcon?.setTint(tintColor)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
window.navigationBarColor = getResourceColor(android.R.attr.colorPrimary)
window.navigationBarColor = getResourceColor(R.attr.colorPrimaryVariant)
else if (window.navigationBarColor != getColor(android.R.color.transparent))
window.navigationBarColor = getResourceColor(android.R.attr.colorBackground)

View File

@ -176,7 +176,7 @@ fun Context.openInBrowser(url: String) {
try {
val parsedUrl = Uri.parse(url)
val intent = CustomTabsIntent.Builder()
.setToolbarColor(getResourceColor(R.attr.colorPrimary))
.setToolbarColor(getResourceColor(R.attr.colorPrimaryVariant))
.build()
intent.launchUrl(this, parsedUrl)
} catch (e: Exception) {

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
The regular version uses ?attr/colorPrimary when focused, which doesn't work well with our themes.
https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/textfield/res/color/mtrl_filled_stroke_color.xml
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorAccent" android:state_focused="true" />
<item android:alpha="0.87" android:color="?android:attr/textColorPrimary" android:state_hovered="true" />
<item android:alpha="0.12" android:color="?android:attr/textColorPrimary" android:state_enabled="false" />
<item android:alpha="0.38" android:color="?android:attr/textColorPrimary" />
</selector>

View File

@ -2,7 +2,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:bottom="5dp">
<shape>
<solid android:color="?attr/colorPrimary"/>
<solid android:color="?attr/colorPrimaryVariant"/>
</shape>
</item>
<item android:height="5dp" android:gravity="bottom">

View File

@ -5,6 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_bottom_sheet_primary"
android:backgroundTint="?android:attr/colorBackground"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
@ -21,6 +22,7 @@
android:layout_height="?attr/actionBarSize"
android:layout_gravity="top"
android:background="@drawable/bg_bottom_sheet_primary"
android:backgroundTint="?attr/colorSecondary"
android:clickable="true"
android:elevation="0dp"
android:focusable="true"
@ -30,6 +32,7 @@
android:id="@+id/reset_btn"
style="@style/Theme.Widget.Button.TextButton"
android:layout_width="wrap_content"
android:textColor="?attr/tabBarIconColor"
android:layout_height="match_parent"
android:text="@string/action_reset"
app:layout_constraintBottom_toBottomOf="parent"
@ -60,7 +63,7 @@
android:layout_gravity="end"
android:layout_marginEnd="12dp"
android:src="@drawable/ic_expand_more_white_24dp"
android:tint="?android:attr/textColorPrimary"
android:tint="?attr/actionBarTintColor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

View File

@ -18,7 +18,7 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/bg_bottom_sheet_dialog_fragment"
android:backgroundTint="?android:attr/colorPrimary"
android:backgroundTint="?attr/colorPrimaryVariant"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View File

@ -25,7 +25,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="?attr/actionBarTheme"
android:background="?attr/colorOnPrimary"
android:background="?attr/colorSecondary"
android:stateListAnimator="@null"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
@ -35,7 +35,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorOnPrimary">
android:background="?attr/colorSecondary">
<LinearLayout
android:id="@+id/title_layout"
@ -44,8 +44,7 @@
android:layout_gravity="center"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
tools:background="?colorPrimary">
android:orientation="horizontal">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/toolbar_title"
@ -92,7 +91,7 @@
android:id="@+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:background="?colorPrimaryVariant"
app:itemIconTint="@drawable/bottom_nav_item_selector"
app:itemRippleColor="@color/rippleColor"
app:itemTextColor="@drawable/bottom_nav_item_selector"
@ -101,7 +100,6 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_navigation"
app:tabBackground="@color/rippleColor"
app:tabRippleColor="@color/rippleColor"
app:tabTextColor="?attr/tabBarIconColor" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeightSmall"
android:background="?colorPrimary"
android:background="?colorPrimaryVariant"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingStart="?attr/listPreferredItemPaddingStart"

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="?attr/listPreferredItemPaddingStart"
android:paddingEnd="?attr/listPreferredItemPaddingEnd"
android:background="?attr/selectableItemBackground"
android:focusable="true">
android:focusable="true"
android:paddingStart="?attr/listPreferredItemPaddingStart"
android:paddingEnd="?attr/listPreferredItemPaddingEnd">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/nav_view_item_wrapper"
style="@style/Theme.Widget.TextInputLayout.OutlinedBox.Dense"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -19,9 +19,9 @@
android:id="@+id/nav_view_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:inputType="text"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Body2" />
</com.google.android.material.textfield.TextInputLayout>

View File

@ -19,7 +19,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorOnPrimary"
android:background="?attr/colorSecondary"
android:theme="?attr/actionBarTheme"
app:navigationIcon="@drawable/ic_close_white_24dp"
app:layout_scrollFlags="scroll|enterAlways|snap" />

View File

@ -3,6 +3,7 @@
<style name="Theme.Tachiyomi" parent="Theme.Base">
<item name="android:windowLightStatusBar">false</item>
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
</style>
<style name="Theme.Base.Reader" parent="Theme.Base">
@ -19,6 +20,8 @@
<!--==============-->
<style name="Theme.Tachiyomi.Amoled" parent="Theme.Tachiyomi">
<item name="colorPrimary">@color/colorAmoledPrimary</item>
<item name="colorSecondary">@color/colorAmoledPrimary</item>
<item name="colorPrimaryVariant">@color/colorAmoledPrimary</item>
<item name="colorOnPrimary">@color/colorAmoledPrimary</item>
<item name="colorPrimaryDark">@color/colorAmoledPrimary</item>
<item name="android:colorBackground">@color/md_black_1000</item>

View File

@ -54,7 +54,7 @@
<string name="action_filter_tracked">Tracked</string>
<string name="action_filter_not_tracked">Not tracked</string>
<string name="action_hide_categories">Hide categories</string>
<string name="action_start_filters_hidden">Hide filters on startup</string>
<string name="action_start_filters_hidden">Start hidden</string>
<string name="hiding_categories">Hiding categories</string>
<string name="manga_only">Manga only</string>
<string name="manhwa_only">Manhwa only</string>

View File

@ -220,6 +220,12 @@
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
<style name="Theme.Widget.TextInputLayout.OutlinedBox.Dense" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
<item name="boxStrokeColor">@color/text_input_stroke</item>
<item name="hintTextColor">?colorAccent</item>
<item name="android:textColorHint">?android:attr/textColorHint</item>
</style>
<!--==============-->
<!--Widgets.Button-->
<!--==============-->

View File

@ -9,9 +9,11 @@
<style name="Theme.Base" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:forceDarkAllowed" tools:targetApi="29">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnPrimary">@color/background</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorPrimary">@color/bluePrimary</item>
<item name="colorPrimaryVariant">@color/colorPrimary</item>
<item name="colorSecondary">@color/background</item>
<item name="colorPrimaryDark">@color/bluePrimary</item>
<item name="colorControlActivated">@color/colorAccent</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="android:textColorSecondary">@color/textColorSecondary</item>
@ -64,9 +66,8 @@
<style name="Theme.Tachiyomi" parent="Theme.Base"/>
<style name="Theme.Tachiyomi.AllBlue" parent="Theme.Tachiyomi">
<item name="colorPrimary">@color/bluePrimary</item>
<item name="colorPrimaryDark">@color/bluePrimary</item>
<item name="colorOnPrimary">@color/bluePrimary</item>
<item name="colorPrimaryVariant">@color/bluePrimary</item>
<item name="colorSecondary">@color/bluePrimary</item>
<item name="tabBarIconColor">@color/md_white_1000</item>
<item name="tabBarIconInactive">@color/md_white_1000_50</item>
<item name="android:statusBarColor">@color/blueStatus</item>