Using filled/outlined icons in tab bar + refactoring

This commit is contained in:
Jay 2020-03-15 14:34:28 -07:00
parent e05c374d2c
commit 6ab222bdc8
24 changed files with 222 additions and 233 deletions

View File

@ -121,7 +121,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
*/
override fun onViewCreated(view: View) {
super.onViewCreated(view)
view.applyWindowInsetsForRootController(activity!!.navigationView)
view.applyWindowInsetsForRootController(activity!!.bottom_nav)
adapter = CatalogueAdapter(this)

View File

@ -182,7 +182,6 @@ class LibraryCategoryAdapter(val libraryListener: LibraryListener) :
fun sortCategory(catId: Int, sortBy: Int)
fun selectAll(position: Int)
fun allSelected(position: Int): Boolean
fun showCategories(position: Int, view: View)
fun recyclerIsScrolling(): Boolean
}
}

View File

@ -398,6 +398,5 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
override fun sortCategory(catId: Int, sortBy: Int) { }
override fun selectAll(position: Int) { }
override fun allSelected(position: Int): Boolean = false
override fun showCategories(position: Int, view: View) { }
override fun recyclerIsScrolling() = false
}

View File

@ -12,6 +12,7 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode
import androidx.appcompat.widget.SearchView
@ -175,7 +176,7 @@ open class LibraryController(
override fun onViewCreated(view: View) {
super.onViewCreated(view)
view.applyWindowInsetsForRootController(activity!!.navigationView)
view.applyWindowInsetsForRootController(activity!!.bottom_nav)
mangaPerRow = getColumnsPreferenceForCurrentOrientation().getOrDefault()
if (!::presenter.isInitialized)
presenter = LibraryPresenter(this)
@ -193,7 +194,8 @@ open class LibraryController(
when (it) {
FilterBottomSheet.ACTION_REFRESH -> onRefresh()
FilterBottomSheet.ACTION_FILTER -> onFilterChanged()
FilterBottomSheet.ACTION_HIDE_FILTER_TIP -> activity?.toast(R.string.hide_filters_tip)
FilterBottomSheet.ACTION_HIDE_FILTER_TIP -> activity?.toast(R.string
.hide_filters_tip, Toast.LENGTH_LONG)
}
}

View File

@ -8,13 +8,11 @@ import android.graphics.Rect
import android.os.Build
import android.os.Bundle
import android.util.TypedValue
import android.view.Gravity
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.view.ActionMode
import androidx.appcompat.widget.PopupMenu
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
@ -38,7 +36,6 @@ import eu.kanade.tachiyomi.ui.main.SpinnerTitleInterface
import eu.kanade.tachiyomi.ui.main.SwipeGestureInterface
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.view.inflate
import eu.kanade.tachiyomi.util.view.scrollViewWith
import eu.kanade.tachiyomi.util.view.snack
import eu.kanade.tachiyomi.util.view.updateLayoutParams
@ -47,9 +44,7 @@ import kotlinx.android.synthetic.main.filter_bottom_sheet.*
import kotlinx.android.synthetic.main.library_grid_recycler.*
import kotlinx.android.synthetic.main.library_list_controller.*
import kotlinx.android.synthetic.main.main_activity.*
import kotlinx.android.synthetic.main.spinner_title.view.*
import kotlinx.coroutines.delay
import timber.log.Timber
import java.util.Locale
import kotlin.math.abs
import kotlin.math.max
@ -73,42 +68,29 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
private var updateScroll = true
private var spinnerAdapter: SpinnerAdapter? = null
private var lastItemPosition:Int? = null
private var lastItem:IFlexible<*>? = null
private lateinit var customTitleSpinner: ViewGroup
private lateinit var titlePopupMenu:PopupMenu
private var switchingCategories = false
var startPosX:Float? = null
var startPosY:Float? = null
var moved = false
var lockedRecycler = false
var lockedY = false
var nextCategory:Int? = null
var ogCategory:Int? = null
var prevCategory:Int? = null
private var startPosX:Float? = null
private var startPosY:Float? = null
private var moved = false
private var lockedRecycler = false
private var lockedY = false
private var nextCategory:Int? = null
private var ogCategory:Int? = null
private var prevCategory:Int? = null
private val swipeDistance = 300f
var flinging = false
var isDragging = false
/**
* Recycler view of the list of manga.
*/
// private lateinit var recycler: RecyclerView
private var flinging = false
private var isDragging = false
override fun contentView():View = recycler_layout
override fun getTitle(): String? {
return if (::customTitleSpinner.isInitialized) customTitleSpinner.category_title.text.toString()
return if (view != null && presenter.categories.size > 1) presenter.categories.find {
it.order == activeCategory }?.name ?: super.getTitle()
else super.getTitle()
// when {
// spinnerAdapter?.array?.size ?: 0 > 1 -> null
// spinnerAdapter?.array?.size == 1 -> return spinnerAdapter?.array?.firstOrNull()
// else -> return super.getTitle()
// }
}
private var scrollListener = object : RecyclerView.OnScrollListener () {
@ -118,12 +100,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
if (order != null && order != activeCategory) {
preferences.lastUsedCategory().set(order)
activeCategory = order
val category = presenter.categories.find { it.order == order }
customTitleSpinner.category_title.text = category?.name ?: ""
val isCurrentController = router?.backstack?.lastOrNull()?.controller() ==
this@LibraryListController
if (isCurrentController) setTitle()
setTitle()
}
}
}
@ -151,24 +128,24 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
}
val sheetRect = Rect()
val recyclerRect = Rect()
val appBarRect = Rect()
bottom_sheet.getGlobalVisibleRect(sheetRect)
view?.getGlobalVisibleRect(recyclerRect)
activity?.appbar?.getGlobalVisibleRect(appBarRect)
if (startPosX == null) {
startPosX = event.rawX
startPosY = event.rawY
val position = (recycler.layoutManager as LinearLayoutManager)
.findFirstVisibleItemPosition()
val order = getCategoryOrder()
if (order != null) {
val position =
(recycler.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition()
val order = activeCategory
ogCategory = order
var newOffsetN = order + 1
while (adapter.indexOf(newOffsetN) == -1 && presenter.categories.any { it.order == newOffsetN }) {
newOffsetN += 1
}
if (adapter.indexOf(newOffsetN) != -1)
nextCategory = newOffsetN
if (adapter.indexOf(newOffsetN) != -1) nextCategory = newOffsetN
if (position == 0) prevCategory = null
else {
@ -176,9 +153,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
while (adapter.indexOf(newOffsetP) == -1 && presenter.categories.any { it.order == newOffsetP }) {
newOffsetP -= 1
}
if (adapter.indexOf(newOffsetP) != -1)
prevCategory = newOffsetP
}
if (adapter.indexOf(newOffsetP) != -1) prevCategory = newOffsetP
}
return
}
@ -193,7 +168,8 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
}
if (startPosX != null && startPosY != null &&
(sheetRect.contains(startPosX!!.toInt(), startPosY!!.toInt()) ||
!recyclerRect.contains(startPosX!!.toInt(), startPosY!!.toInt()))) {
!recyclerRect.contains(startPosX!!.toInt(), startPosY!!.toInt())
|| appBarRect.contains(startPosX!!.toInt(), startPosY!!.toInt()))) {
return
}
if (event.actionMasked != MotionEvent.ACTION_UP && startPosX != null) {
@ -330,21 +306,6 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
val tv = TypedValue()
activity!!.theme.resolveAttribute(R.attr.actionBarTintColor, tv, true)
customTitleSpinner = library_layout.inflate(R.layout.spinner_title) as ViewGroup
spinnerAdapter = SpinnerAdapter(
view.context,
R.layout.library_spinner_textview,
arrayOf(resources!!.getString(R.string.label_library))
)
customTitleSpinner.category_title.text = view.resources.getString(R.string.label_library)
titlePopupMenu = PopupMenu(view.context, customTitleSpinner, Gravity.END or Gravity.CENTER)
customTitleSpinner.setOnTouchListener(titlePopupMenu.dragToOpenListener)
titlePopupMenu.setOnMenuItemClickListener { item ->
scrollToHeader(item.itemId)
true
}
scrollViewWith(recycler) { insets ->
fast_scroller.updateLayoutParams<CoordinatorLayout.LayoutParams> {
topMargin = insets.systemWindowInsetTop
@ -396,19 +357,11 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
adapter.setItems(mangaMap)
val categoryNames = presenter.categories.map { it.name }.toTypedArray()
spinnerAdapter = SpinnerAdapter(recyclerLayout.context, R.layout.library_spinner_textview,
if (categoryNames.isNotEmpty()) categoryNames
else arrayOf(recyclerLayout.context.getString(R.string.label_library))
)
val isCurrentController = router?.backstack?.lastOrNull()?.controller() ==
this
/*customTitleSpinner.category_title.text =
presenter.categories[clamp(activeCategory,
0,
presenter.categories.size - 1)].name
if (isCurrentController) setTitle()*/
setTitle()
updateScroll = false
if (!freshStart) {
justStarted = false
@ -432,9 +385,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
null
}
titlePopupMenu.menu.clear()
presenter.categories.forEach { category ->
titlePopupMenu.menu.add(0, category.order, max(0, category.order), category.name)
popupMenu?.menu?.add(0, category.order, max(0, category.order), category.name)
}
@ -442,10 +393,6 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
scrollToHeader(item.itemId)
true
}
customTitleSpinner.setOnClickListener {
titlePopupMenu.show()
}
}
private fun scrollToHeader(pos: Int) {
@ -453,14 +400,12 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
switchingCategories = true
if (headerPosition > -1) {
val appbar = activity?.appbar
//if (headerPosition == 0)
//activity?.appbar?.y = 0f
recycler.suppressLayout(true)
val appbarOffset =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (appbar?.y ?: 0f > -20) 0 else
(appbar?.y?.plus(view?.rootWindowInsets?.systemWindowInsetTop ?: 0)
?: 0f).roundToInt() + 10.dpToPx
?: 0f).roundToInt() + 30.dpToPx
}
else {
0
@ -470,11 +415,10 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
+ appbarOffset
)
val headerItem = adapter.getItem(headerPosition) as? LibraryHeaderItem
/*val headerItem = adapter.getItem(headerPosition) as? LibraryHeaderItem
if (headerItem != null) {
customTitleSpinner.category_title.text = headerItem.category.name
setTitle()
}
}*/
recycler.suppressLayout(false)
}
launchUI {
@ -573,11 +517,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
}
override fun canDrag(): Boolean {
val filterOff = preferences.filterCompleted().getOrDefault() +
preferences.filterTracked().getOrDefault() +
preferences.filterUnread().getOrDefault() +
preferences.filterMangaType().getOrDefault() +
preferences.filterCompleted().getOrDefault() == 0 &&
val filterOff = !bottom_sheet.hasActiveFilters() &&
!preferences.hideCategories().getOrDefault()
return filterOff && adapter.mode != SelectableAdapter.Mode.MULTI
}
@ -775,28 +715,10 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
return items.all { adapter.isSelected(it) }
}
override fun showCategories(position: Int, view: View) {
if (presenter.categories.size <= 1) return
val header = adapter.getSectionHeader(position) as? LibraryHeaderItem ?: return
if (presenter.categories.size <= 1) return
val category = header.category
val popupMenu = PopupMenu(view.context, view)
presenter.categories.forEach {
if (it.id != category.id)
popupMenu.menu.add(0, it.order, it.order, it.name)
}
popupMenu.setOnMenuItemClickListener {
scrollToHeader(it.itemId)
true
}
popupMenu.show()
}
override fun onSwipeBottom(x: Float, y: Float) { }
override fun onSwipeTop(x: Float, y: Float) {
val sheetRect = Rect()
activity!!.navigationView.getGlobalVisibleRect(sheetRect)
activity!!.bottom_nav.getGlobalVisibleRect(sheetRect)
if (sheetRect.contains(x.toInt(), y.toInt())) {
if (bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED)
toggleFilters()
@ -840,9 +762,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
}
override fun onAnimationCancel(animation: Animator?) {}
override fun onAnimationRepeat(animation: Animator?) {}
override fun onAnimationStart(animation: Animator?) {}
})
}

View File

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.library.filter
import android.content.Context
import android.content.res.Configuration
import android.os.Parcelable
import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
@ -14,7 +15,6 @@ import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.inflate
@ -70,25 +70,18 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
var onGroupClicked: (Int) -> Unit = { _ -> }
var pager:View? = null
var phoneLandscape = false
fun onCreate(pagerView:View) {
clearButton = clear_button
filter_layout.removeView(clearButton)
sheetBehavior = BottomSheetBehavior.from(this)
val phoneLandscape = (isLandscape() && !isTablet())
phoneLandscape = (isLandscape() && !isTablet())
sheetBehavior?.isHideable = true
sheetBehavior?.skipCollapsed = phoneLandscape
top_bar.setOnClickListener {
if (sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED) {
sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
} else {
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
}
}
pager = pagerView
val shadow2:View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow2)
val shadow:View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow)
// val snackbarLayout:View = (pagerView.parent as ViewGroup).findViewById(R.id.snackbar_layout)
if (phoneLandscape) {
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
}
@ -96,47 +89,24 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
override fun onSlide(bottomSheet: View, progress: Float) {
top_bar.alpha = 1 - max(0f, progress)
shadow2.alpha = (1 - max(0f, progress)) * 0.25f
if (phoneLandscape)
shadow.alpha = progress
else
shadow.alpha = 1 + min(0f, progress)
//if (progress >= 0)
if (phoneLandscape) shadow.alpha = progress
else shadow.alpha = 1 + min(0f, progress)
updateRootPadding(progress)
}
override fun onStateChanged(p0: View, state: Int) {
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
if (phoneLandscape)
reSortViews()
if (phoneLandscape)
shadow.alpha = 0f
else
shadow.alpha = 1f
pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
}
if (state == BottomSheetBehavior.STATE_EXPANDED) {
top_bar.alpha = 0f
if (phoneLandscape)
shadow.alpha = 1f
}
if (state == BottomSheetBehavior.STATE_HIDDEN) {
reSortViews()
shadow.alpha = 0f
pager?.updatePaddingRelative(bottom = 0)
// snackbarLayout.updatePaddingRelative(bottom = 0)
}
//top_bar.isClickable = state == BottomSheetBehavior.STATE_COLLAPSED
//top_bar.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED
stateChanged(state)
}
})
if (preferences.hideFiltersAtStart().getOrDefault()) {
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
shadow.alpha = 0f
}
else {
pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
// snackbarLayout.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
}
updateRootPadding(when (sheetBehavior?.state) {
BottomSheetBehavior.STATE_HIDDEN -> -1f
BottomSheetBehavior.STATE_EXPANDED -> 1f
else -> 0f
})
shadow.alpha = if (sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN) 0f else 1f
if (phoneLandscape && shadow2.visibility != View.GONE) {
shadow2.gone()
}
@ -150,6 +120,30 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
clearButton.setOnClickListener { clearFilters() }
}
private fun stateChanged(state: Int) {
val shadow = ((pager?.parent as? ViewGroup)?.findViewById(R.id.shadow) as? View)
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
shadow?.alpha = 1f
pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
}
if (state == BottomSheetBehavior.STATE_EXPANDED) {
top_bar.alpha = 0f
if (phoneLandscape)
shadow?.alpha = 1f
}
if (state == BottomSheetBehavior.STATE_HIDDEN) {
reSortViews()
shadow?.alpha = 0f
pager?.updatePaddingRelative(bottom = 0)
}
}
override fun onRestoreInstanceState(state: Parcelable?) {
super.onRestoreInstanceState(state)
val sheetBehavior = BottomSheetBehavior.from(this)
stateChanged(sheetBehavior.state)
}
private fun isLandscape(): Boolean {
return context.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE
}
@ -176,11 +170,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
fun hasActiveFilters() = filterItems.any { it.isActivated }
private fun createTags() {
//categories = inflate(R.layout.filter_buttons) as FilterTagGroup
// categories.setup(this, R.string.action_hide_categories)
// list.add(categories)
hide_categories.isChecked = preferences.hideCategories().getOrDefault()
hide_categories.setOnCheckedChangeListener { _, isChecked ->
preferences.hideCategories().set(isChecked)
@ -212,11 +201,12 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
db.getCategories().executeAsBlocking()
.isNotEmpty()
}
val librryManga = db.getLibraryMangas().executeAsBlocking()
val libraryManga = db.getLibraryMangas().executeAsBlocking()
val types = mutableListOf<Int>()
if (librryManga.any { it.mangaType() == Manga.TYPE_MANHWA }) types.add(R.string.manhwa)
if (librryManga.any { it.mangaType() == Manga.TYPE_MANHUA }) types.add(R.string.manhua)
if (librryManga.any { it.mangaType() == Manga.TYPE_COMIC }) types.add(R.string.comic)
if (libraryManga.any { it.mangaType() == Manga.TYPE_MANHWA }) types.add(R.string.manhwa)
if (libraryManga.any { it.mangaType() == Manga.TYPE_MANHUA }) types.add(R.string.manhua)
if (libraryManga.any { it.mangaType() == Manga.TYPE_COMIC }) types.add(R.string.comic)
val hasTracking = Injekt.get<TrackManager>().hasLoggedServices()
if (types.isNotEmpty()) {
launchUI {
val mangaType = inflate(R.layout.filter_buttons) as FilterTagGroup
@ -230,12 +220,12 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
filter_layout.addView(mangaType)
filterItems.remove(tracked)
filterItems.add(mangaType)
if (hasTracking)
filterItems.add(tracked)
}
}
withContext(Dispatchers.Main) {
hide_categories.visibleIf(showCategoriesCheckBox)
// categories.setState(preferences.hideCategories().getOrDefault())
downloaded.setState(preferences.filterDownloaded())
completed.setState(preferences.filterCompleted())
unread.setState(preferences.filterUnread())
@ -305,10 +295,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
}
private fun clearFilters() {
val action = if (preferences.hideCategories().getOrDefault()) ACTION_REFRESH
else ACTION_FILTER
preferences.hideCategories().set(false)
preferences.filterDownloaded().set(0)
preferences.filterUnread().set(0)
preferences.filterCompleted().set(0)
@ -322,8 +308,10 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
filterItems.forEach {
it.reset()
}
if (trackers != null)
filterItems.remove(trackers!!)
reSortViews()
onGroupClicked(action)
onGroupClicked(ACTION_FILTER)
}
private fun reSortViews() {
@ -339,10 +327,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
filter_scroll.scrollTo(0, 0)
}
fun adjustFiltersMargin(downloading: Boolean) {
filter_scroll.updatePaddingRelative(end = (if (downloading) 80 else 20).dpToPx)
}
companion object {
const val ACTION_REFRESH = 0
const val ACTION_FILTER = 1

View File

@ -139,13 +139,13 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
// tabAnimator = TabsAnimator(tabs)
var continueSwitchingTabs = false
navigationView.setOnNavigationItemSelectedListener { item ->
bottom_nav.setOnNavigationItemSelectedListener { item ->
val id = item.itemId
val currentController = router.backstack.lastOrNull()?.controller()
if (!continueSwitchingTabs && currentController is BottomNavBarInterface) {
if (!currentController.canChangeTabs {
continueSwitchingTabs = true
this@MainActivity.navigationView.selectedItemId = id
this@MainActivity.bottom_nav.selectedItemId = id
}) return@setOnNavigationItemSelectedListener false
}
continueSwitchingTabs = false
@ -175,7 +175,6 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
if (!showRecents) setRoot(RecentChaptersController(), id)
else setRoot(RecentlyReadController(), id)
preferences.showRecentUpdates().set(!showRecents)
updateRecentsIcon()
}
R.id.nav_library -> {
val controller =
@ -190,6 +189,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
}
}
}
updateIcons(id)
true
}
val container: ViewGroup = findViewById(R.id.controller_container)
@ -206,19 +206,18 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
/*dwawerContainer.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION*/
updateRecentsIcon()
content.viewTreeObserver.addOnGlobalLayoutListener {
val heightDiff: Int = content.rootView.height - content.height
if (heightDiff > 200 &&
window.attributes.softInputMode == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) {
//keyboard is open, hide layout
navigationView.gone()
} else if (navigationView.visibility == View.GONE
bottom_nav.gone()
} else if (bottom_nav.visibility == View.GONE
&& window.attributes.softInputMode == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) {
//keyboard is hidden, show layout
// use coroutine to delay so the bottom bar doesn't flash on top of the keyboard
launchUI {
navigationView.visible()
bottom_nav.visible()
}
}
}
@ -272,7 +271,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
appbar.updatePadding(
top = insets.systemWindowInsetTop
)
navigationView.updatePadding(bottom = insets.systemWindowInsetBottom)
bottom_nav.updatePadding(bottom = insets.systemWindowInsetBottom)
/*controller_container.updateLayoutParams<ConstraintLayout.LayoutParams> {
val attrsArray = intArrayOf(android.R.attr.actionBarSize)
@ -308,7 +307,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
if (!router.hasRootController()) {
// Set start screen
if (!handleIntentAction(intent)) {
navigationView.selectedItemId = R.id.nav_library
bottom_nav.selectedItemId = R.id.nav_library
}
}
@ -320,8 +319,8 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
else onBackPressed()
}
navigationView.visibility = if (router.backstackSize > 1) View.GONE else View.VISIBLE
navigationView.alpha = if (router.backstackSize > 1) 0f else 1f
bottom_nav.visibility = if (router.backstackSize > 1) View.GONE else View.VISIBLE
bottom_nav.alpha = if (router.backstackSize > 1) 0f else 1f
router.addChangeListener(object : ControllerChangeHandler.ControllerChangeListener {
override fun onChangeStarted(to: Controller?, from: Controller?, isPush: Boolean,
container: ViewGroup, handler: ControllerChangeHandler) {
@ -369,11 +368,31 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
setExtensionsBadge()
}
fun updateRecentsIcon() {
navigationView.menu.findItem(R.id.nav_recents).icon =
AppCompatResources.getDrawable(this,
if (preferences.showRecentUpdates().getOrDefault()) R.drawable.ic_update_black_24dp
else R.drawable.ic_history_black_24dp)
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
super.onRestoreInstanceState(savedInstanceState)
updateIcons(bottom_nav.selectedItemId)
}
fun updateIcons(id: Int) {
bottom_nav.menu.findItem(R.id.nav_library).icon = AppCompatResources.getDrawable(
this, if (id == R.id.nav_library) R.drawable.library_24dp
else R.drawable.library_outline_24dp
)
bottom_nav.menu.findItem(R.id.nav_recents).icon = AppCompatResources.getDrawable(
this, if (id == R.id.nav_recents) {
if (preferences.showRecentUpdates().getOrDefault()) R.drawable.recent_updates_24dp
else R.drawable.recent_read_24dp
} else {
if (preferences.showRecentUpdates()
.getOrDefault()
) R.drawable.recent_updates_outline_24dp
else R.drawable.recent_read_outline_24dp
}
)
bottom_nav.menu.findItem(R.id.nav_catalogues).icon = AppCompatResources.getDrawable(
this, if (id == R.id.nav_catalogues) R.drawable.browse_24dp
else R.drawable.browse_outline_24dp
)
}
override fun startSupportActionMode(callback: androidx.appcompat.view.ActionMode.Callback): androidx.appcompat.view.ActionMode? {
@ -400,13 +419,13 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
private fun setExtensionsBadge() {
val updates = preferences.extensionUpdatesCount().getOrDefault()
if (updates > 0) {
val badge = navigationView.getOrCreateBadge(R.id.nav_catalogues)
val badge = bottom_nav.getOrCreateBadge(R.id.nav_catalogues)
badge.number = updates
badge.backgroundColor = getResourceColor(R.attr.badgeColor)
badge.badgeTextColor = Color.WHITE
}
else {
navigationView.removeBadge(R.id.nav_catalogues)
bottom_nav.removeBadge(R.id.nav_catalogues)
}
}
@ -443,17 +462,16 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
applicationContext, notificationId, intent.getIntExtra("groupId", 0)
)
when (intent.action) {
SHORTCUT_LIBRARY -> navigationView.selectedItemId = R.id.nav_library
SHORTCUT_LIBRARY -> bottom_nav.selectedItemId = R.id.nav_library
SHORTCUT_RECENTLY_UPDATED, SHORTCUT_RECENTLY_READ -> {
preferences.showRecentUpdates().set(intent.action == SHORTCUT_RECENTLY_UPDATED)
navigationView.selectedItemId = R.id.nav_recents
updateRecentsIcon()
bottom_nav.selectedItemId = R.id.nav_recents
}
SHORTCUT_CATALOGUES -> navigationView.selectedItemId = R.id.nav_catalogues
SHORTCUT_CATALOGUES -> bottom_nav.selectedItemId = R.id.nav_catalogues
SHORTCUT_EXTENSIONS -> {
if (router.backstack.none { it.controller() is ExtensionController }) {
if (router.backstack.isEmpty()) {
navigationView.selectedItemId = R.id.nav_library
bottom_nav.selectedItemId = R.id.nav_library
router.pushController(
RouterTransaction.with(ExtensionController()).pushChangeHandler(
SimpleSwapChangeHandler()
@ -467,14 +485,14 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
SHORTCUT_MANGA -> {
val extras = intent.extras ?: return false
if (router.backstack.isEmpty()) {
navigationView.selectedItemId = R.id.nav_library
bottom_nav.selectedItemId = R.id.nav_library
}
router.pushController(MangaDetailsController(extras).withFadeTransaction())
}
SHORTCUT_DOWNLOADS -> {
if (router.backstack.none { it.controller() is DownloadController }) {
if (router.backstack.isEmpty()) {
navigationView.selectedItemId = R.id.nav_library
bottom_nav.selectedItemId = R.id.nav_library
router.pushController(RouterTransaction.with(DownloadController())
.pushChangeHandler(SimpleSwapChangeHandler())
.popChangeHandler(FadeChangeHandler()))
@ -627,21 +645,21 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
if (to !is SpinnerTitleInterface) toolbar.removeSpinner()
if (to !is DialogController) {
navigationView.visibility = if (router.backstackSize == 0 ||
bottom_nav.visibility = if (router.backstackSize == 0 ||
(router.backstackSize <= 1 && !isPush))
View.VISIBLE else navigationView.visibility
View.VISIBLE else bottom_nav.visibility
animationSet?.cancel()
animationSet = AnimatorSet()
val alphaAnimation = ValueAnimator.ofFloat(
navigationView.alpha,
bottom_nav.alpha,
if (router.backstackSize > 1) 0f else 1f
)
alphaAnimation.addUpdateListener { valueAnimator ->
navigationView.alpha = valueAnimator.animatedValue as Float
bottom_nav.alpha = valueAnimator.animatedValue as Float
}
alphaAnimation.addListener(object : Animator.AnimatorListener {
override fun onAnimationEnd(animation: Animator?) {
navigationView.visibility = if (router.backstackSize > 1) View.GONE else View.VISIBLE
bottom_nav.visibility = if (router.backstackSize > 1) View.GONE else View.VISIBLE
}
override fun onAnimationCancel(animation: Animator?) { }

View File

@ -54,7 +54,7 @@ class SearchActivity: MainActivity() {
} else {
appbar.enableElevation()
}
navigationView.gone()
bottom_nav.gone()
}
override fun handleIntentAction(intent: Intent): Boolean {

View File

@ -54,7 +54,11 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
DownloadQueue.DownloadListener,
LibraryServiceListener {
<<<<<<< Updated upstream
private var scope = CoroutineScope(Job() + Dispatchers.Default)
=======
var scope = CoroutineScope(Job() + Dispatchers.Default)
>>>>>>> Stashed changes
var isLockedFromSearch = false
var hasRequested = false
@ -711,7 +715,11 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
fun trackSearch(query: String, service: TrackService) {
scope.launch(Dispatchers.IO) {
<<<<<<< Updated upstream
val results = try {service.search(query) }
=======
val results = try {service.search(query).toBlocking().single() }
>>>>>>> Stashed changes
catch (e: Exception) {
withContext(Dispatchers.Main) { controller.trackSearchError(e) }
null }
@ -726,7 +734,11 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
item.manga_id = manga.id!!
scope.launch {
<<<<<<< Updated upstream
val binding = try { service.bind(item) }
=======
val binding = try { service.bind(item).toBlocking().single() }
>>>>>>> Stashed changes
catch (e: Exception) {
trackError(e)
null
@ -746,7 +758,11 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
private fun updateRemote(track: Track, service: TrackService) {
scope.launch {
<<<<<<< Updated upstream
val binding = try { service.update(track) }
=======
val binding = try { service.update(track).toBlocking().single() }
>>>>>>> Stashed changes
catch (e: Exception) {
trackError(e)
null

View File

@ -86,7 +86,7 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
*/
override fun onViewCreated(view: View) {
super.onViewCreated(view)
view.applyWindowInsetsForRootController(activity!!.navigationView)
view.applyWindowInsetsForRootController(activity!!.bottom_nav)
view.context.notificationManager.cancel(Notifications.ID_NEW_CHAPTERS)
// Init RecyclerView and adapter
@ -109,7 +109,7 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
LibraryUpdateService.start(view.context)
view.snack(R.string.updating_library) {
anchorView = (this@RecentChaptersController.activity as? MainActivity)
?.navigationView
?.bottom_nav
}
}
// It can be a very long operation, so we disable swipe refresh and show a snackbar.
@ -385,7 +385,7 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
router.setRoot(
RecentlyReadController().withFadeTransaction().tag(R.id.nav_recents.toString()))
Injekt.get<PreferencesHelper>().showRecentUpdates().set(false)
(activity as? MainActivity)?.updateRecentsIcon()
(activity as? MainActivity)?.updateIcons(R.id.nav_recents)
}
}
return super.onOptionsItemSelected(item)

View File

@ -84,7 +84,7 @@ class RecentlyReadController(bundle: Bundle? = null) : BaseController(bundle),
*/
override fun onViewCreated(view: View) {
super.onViewCreated(view)
view.applyWindowInsetsForRootController(activity!!.navigationView)
view.applyWindowInsetsForRootController(activity!!.bottom_nav)
// Initialize adapter
adapter = RecentlyReadAdapter(this)
recycler.adapter = adapter
@ -239,7 +239,7 @@ class RecentlyReadController(bundle: Bundle? = null) : BaseController(bundle),
router.setRoot(
RecentChaptersController().withFadeTransaction().tag(R.id.nav_recents.toString()))
Injekt.get<PreferencesHelper>().showRecentUpdates().set(true)
(activity as? MainActivity)?.updateRecentsIcon()
(activity as? MainActivity)?.updateIcons(R.id.nav_recents)
}
}
return super.onOptionsItemSelected(item)

View File

@ -0,0 +1,8 @@
<!-- drawable/compass_outline.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M7,17L10.2,10.2L17,7L13.8,13.8L7,17M12,11.1A0.9,0.9 0 0,0 11.1,12A0.9,0.9 0 0,0 12,12.9A0.9,0.9 0 0,0 12.9,12A0.9,0.9 0 0,0 12,11.1M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4Z" />
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M4,6L2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6zM20,2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM17,4v5l-1,-0.75L15,9L15,4h2zM20,16L8,16L8,4h5v9l3,-2.25L19,13L19,4h1v12z"/>
</vector>

View File

@ -0,0 +1,8 @@
<!-- drawable/clock.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M16.2,16.2L11,13V7H12.5V12.2L17,14.9L16.2,16.2Z" />
</vector>

View File

@ -0,0 +1,8 @@
<!-- drawable/clock_outline.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z" />
</vector>

View File

@ -0,0 +1,8 @@
<!-- drawable/alert_circle.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
</vector>

View File

@ -0,0 +1,8 @@
<!-- drawable/alert_circle_outline.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M11,15H13V17H11V15M11,7H13V13H11V7M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20Z" />
</vector>

View File

@ -125,13 +125,13 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:orientation="vertical"
android:layout_height="30sp">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/title"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Regular.Body1.Light"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
@ -143,13 +143,12 @@
<com.google.android.material.textview.MaterialTextView
android:id="@+id/subtitle"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Regular.Body1.Secondary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-1dp"
android:ellipsize="end"
android:singleLine="true"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"
tools:text="Sample artist" />
</LinearLayout>

View File

@ -88,7 +88,7 @@
</eu.kanade.tachiyomi.widget.ElevationAppBarLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/navigationView"
android:id="@+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"

View File

@ -18,7 +18,7 @@
<com.google.android.material.textview.MaterialTextView
android:id="@+id/download_text"
style="@style/TextAppearance.MaterialComponents.Caption"
style="@style/TextAppearance.Regular.Caption.Light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/pale_red"
@ -48,7 +48,7 @@
<com.google.android.material.textview.MaterialTextView
android:id="@+id/unread_text"
style="@style/TextAppearance.MaterialComponents.Caption"
style="@style/TextAppearance.Regular.Caption.Light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorAccent"

View File

@ -5,15 +5,15 @@
<item
android:checked="true"
android:id="@+id/nav_library"
android:icon="@drawable/ic_collections_bookmark_white_24dp"
android:icon="@drawable/library_outline_24dp"
android:title="@string/label_library" />
<item
android:id="@+id/nav_recents"
android:icon="@drawable/ic_update_black_24dp"
android:icon="@drawable/recent_updates_outline_24dp"
android:title="@string/short_recents" />
<item
android:id="@+id/nav_catalogues"
android:icon="@drawable/ic_explore_black_24dp"
android:icon="@drawable/browse_outline_24dp"
android:title="@string/short_catalogues" />
</group>
</menu>

View File

@ -17,6 +17,9 @@
<item
android:id="@+id/download_next"
android:title="@string/download_first" />
<item
android:id="@+id/download_next_5"
android:title="@string/download_5" />
<item
android:id="@+id/download_custom"
android:title="@string/download_custom" />