diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/CenteredToolbar.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/CenteredToolbar.kt index 5b0172b095..db606905f9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/CenteredToolbar.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/CenteredToolbar.kt @@ -4,7 +4,7 @@ import android.content.Context import android.util.AttributeSet import androidx.appcompat.graphics.drawable.DrawerArrowDrawable import com.google.android.material.appbar.MaterialToolbar -import eu.kanade.tachiyomi.util.view.gone +import eu.kanade.tachiyomi.R import kotlinx.android.synthetic.main.main_activity.view.* class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : @@ -14,7 +14,7 @@ class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: Attribut if (navigationIcon is DrawerArrowDrawable) { super.setTitle(resId) toolbar_title.text = null - dropdown?.gone() + hideDropdown() } else { toolbar_title.text = context.getString(resId) super.setTitle(null) @@ -25,10 +25,23 @@ class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: Attribut if (navigationIcon is DrawerArrowDrawable) { super.setTitle(title) toolbar_title.text = "" - dropdown?.gone() + hideDropdown() } else { toolbar_title.text = title super.setTitle(null) } } + + fun showDropdown(down: Boolean = true) { + toolbar_title.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_blank_24dp, 0, + if (down) { + R.drawable.ic_arrow_drop_down_24dp + } else { + R.drawable.ic_arrow_drop_up_24dp + }, 0) + } + + fun hideDropdown() { + toolbar_title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0) + } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index ae68c1d9fb..de4ab9a34a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -621,19 +621,17 @@ class LibraryController( LibraryUpdateService.setListener(this) recycler_cover.isClickable = false recycler_cover.isFocusable = false - if (onRoot) { - activity?.dropdown?.visibleIf(!singleCategory) - } + showDropdown() } else { closeTip() - activity?.dropdown?.gone() + activity?.toolbar?.hideDropdown() } } override fun onChangeEnded(handler: ControllerChangeHandler, type: ControllerChangeType) { super.onChangeEnded(handler, type) if (!type.isEnter) { - activity?.dropdown?.gone() + activity?.toolbar?.hideDropdown() } } @@ -681,9 +679,7 @@ class LibraryController( recycler.itemAnimator = DefaultItemAnimator() } singleCategory = presenter.categories.size <= 1 - if (onRoot) { - activity?.dropdown?.visibleIf(!singleCategory) - } + showDropdown() progress.gone() if (!freshStart) { justStarted = false @@ -712,6 +708,15 @@ class LibraryController( } if (!hasMovedHopper && isAnimatingHopper == null) { showSlideAnimation() + } + } + + private fun showDropdown() { + if (onRoot) { + if (!singleCategory) { + activity?.toolbar?.showDropdown() + } else { + activity?.toolbar?.hideDropdown() } } } diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml index 3716f67741..fa3196c728 100644 --- a/app/src/main/res/layout/main_activity.xml +++ b/app/src/main/res/layout/main_activity.xml @@ -49,22 +49,15 @@ style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:drawableTint="?actionBarTintColor" android:ellipsize="end" android:gravity="start" android:maxLines="1" android:textColor="?actionBarTintColor" android:textSize="20sp" + tools:drawableEnd="@drawable/ic_arrow_drop_down_24dp" + tools:drawableStart="@drawable/ic_blank_24dp" tools:text="Title Text" /> - -