|
@@ -15,8 +15,6 @@ import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.appcompat.view.ActionMode
|
|
import androidx.appcompat.view.ActionMode
|
|
import androidx.appcompat.widget.SearchView
|
|
import androidx.appcompat.widget.SearchView
|
|
import androidx.core.graphics.drawable.DrawableCompat
|
|
import androidx.core.graphics.drawable.DrawableCompat
|
|
-import androidx.core.view.GravityCompat
|
|
|
|
-import androidx.drawerlayout.widget.DrawerLayout
|
|
|
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
|
import com.bluelinelabs.conductor.ControllerChangeType
|
|
import com.bluelinelabs.conductor.ControllerChangeType
|
|
import com.f2prateek.rx.preferences.Preference
|
|
import com.f2prateek.rx.preferences.Preference
|
|
@@ -33,19 +31,16 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
|
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
|
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
|
-import eu.kanade.tachiyomi.ui.base.controller.SecondaryDrawerController
|
|
|
|
import eu.kanade.tachiyomi.ui.base.controller.TabbedController
|
|
import eu.kanade.tachiyomi.ui.base.controller.TabbedController
|
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
|
import eu.kanade.tachiyomi.util.system.toast
|
|
import eu.kanade.tachiyomi.util.system.toast
|
|
-import eu.kanade.tachiyomi.util.view.inflate
|
|
|
|
import java.io.IOException
|
|
import java.io.IOException
|
|
import kotlinx.android.synthetic.main.library_controller.action_toolbar
|
|
import kotlinx.android.synthetic.main.library_controller.action_toolbar
|
|
import kotlinx.android.synthetic.main.library_controller.empty_view
|
|
import kotlinx.android.synthetic.main.library_controller.empty_view
|
|
import kotlinx.android.synthetic.main.library_controller.library_pager
|
|
import kotlinx.android.synthetic.main.library_controller.library_pager
|
|
-import kotlinx.android.synthetic.main.main_activity.drawer
|
|
|
|
import kotlinx.android.synthetic.main.main_activity.tabs
|
|
import kotlinx.android.synthetic.main.main_activity.tabs
|
|
import rx.Subscription
|
|
import rx.Subscription
|
|
import timber.log.Timber
|
|
import timber.log.Timber
|
|
@@ -58,7 +53,6 @@ class LibraryController(
|
|
) : NucleusController<LibraryPresenter>(bundle),
|
|
) : NucleusController<LibraryPresenter>(bundle),
|
|
RootController,
|
|
RootController,
|
|
TabbedController,
|
|
TabbedController,
|
|
- SecondaryDrawerController,
|
|
|
|
ActionMode.Callback,
|
|
ActionMode.Callback,
|
|
ChangeMangaCategoriesDialog.Listener,
|
|
ChangeMangaCategoriesDialog.Listener,
|
|
DeleteLibraryMangasDialog.Listener {
|
|
DeleteLibraryMangasDialog.Listener {
|
|
@@ -118,14 +112,9 @@ class LibraryController(
|
|
private var adapter: LibraryAdapter? = null
|
|
private var adapter: LibraryAdapter? = null
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Navigation view containing filter/sort/display items.
|
|
|
|
|
|
+ * Sheet containing filter/sort/display items.
|
|
*/
|
|
*/
|
|
- private var navView: LibraryNavigationView? = null
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Drawer listener to allow swipe only for closing the drawer.
|
|
|
|
- */
|
|
|
|
- private var drawerListener: DrawerLayout.DrawerListener? = null
|
|
|
|
|
|
+ private var settingsSheet: LibrarySettingsSheet? = null
|
|
|
|
|
|
private var tabsVisibilityRelay: BehaviorRelay<Boolean> = BehaviorRelay.create(false)
|
|
private var tabsVisibilityRelay: BehaviorRelay<Boolean> = BehaviorRelay.create(false)
|
|
|
|
|
|
@@ -169,6 +158,15 @@ class LibraryController(
|
|
if (selectedMangas.isNotEmpty()) {
|
|
if (selectedMangas.isNotEmpty()) {
|
|
createActionModeIfNeeded()
|
|
createActionModeIfNeeded()
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ settingsSheet = LibrarySettingsSheet(activity!!) { group ->
|
|
|
|
+ when (group) {
|
|
|
|
+ is LibrarySettingsSheet.Settings.FilterGroup -> onFilterChanged()
|
|
|
|
+ is LibrarySettingsSheet.Settings.SortGroup -> onSortChanged()
|
|
|
|
+ is LibrarySettingsSheet.Settings.DisplayGroup -> reattachAdapter()
|
|
|
|
+ is LibrarySettingsSheet.Settings.BadgeGroup -> onDownloadBadgeChanged()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
|
@@ -184,32 +182,12 @@ class LibraryController(
|
|
action_toolbar.destroy()
|
|
action_toolbar.destroy()
|
|
adapter?.onDestroy()
|
|
adapter?.onDestroy()
|
|
adapter = null
|
|
adapter = null
|
|
|
|
+ settingsSheet = null
|
|
tabsVisibilitySubscription?.unsubscribe()
|
|
tabsVisibilitySubscription?.unsubscribe()
|
|
tabsVisibilitySubscription = null
|
|
tabsVisibilitySubscription = null
|
|
super.onDestroyView(view)
|
|
super.onDestroyView(view)
|
|
}
|
|
}
|
|
|
|
|
|
- override fun createSecondaryDrawer(drawer: DrawerLayout): ViewGroup {
|
|
|
|
- val view = drawer.inflate(R.layout.library_drawer) as LibraryNavigationView
|
|
|
|
- navView = view
|
|
|
|
- drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, GravityCompat.END)
|
|
|
|
-
|
|
|
|
- navView?.onGroupClicked = { group ->
|
|
|
|
- when (group) {
|
|
|
|
- is LibraryNavigationView.FilterGroup -> onFilterChanged()
|
|
|
|
- is LibraryNavigationView.SortGroup -> onSortChanged()
|
|
|
|
- is LibraryNavigationView.DisplayGroup -> reattachAdapter()
|
|
|
|
- is LibraryNavigationView.BadgeGroup -> onDownloadBadgeChanged()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return view
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- override fun cleanupSecondaryDrawer(drawer: DrawerLayout) {
|
|
|
|
- navView = null
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
override fun configureTabs(tabs: TabLayout) {
|
|
override fun configureTabs(tabs: TabLayout) {
|
|
with(tabs) {
|
|
with(tabs) {
|
|
tabGravity = TabLayout.GRAVITY_CENTER
|
|
tabGravity = TabLayout.GRAVITY_CENTER
|
|
@@ -231,6 +209,10 @@ class LibraryController(
|
|
tabsVisibilitySubscription = null
|
|
tabsVisibilitySubscription = null
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ fun showSettingsSheet() {
|
|
|
|
+ settingsSheet?.show()
|
|
|
|
+ }
|
|
|
|
+
|
|
fun onNextLibraryUpdate(categories: List<Category>, mangaMap: Map<Int, List<LibraryItem>>) {
|
|
fun onNextLibraryUpdate(categories: List<Category>, mangaMap: Map<Int, List<LibraryItem>>) {
|
|
val view = view ?: return
|
|
val view = view ?: return
|
|
val adapter = adapter ?: return
|
|
val adapter = adapter ?: return
|
|
@@ -364,12 +346,12 @@ class LibraryController(
|
|
}
|
|
}
|
|
|
|
|
|
override fun onPrepareOptionsMenu(menu: Menu) {
|
|
override fun onPrepareOptionsMenu(menu: Menu) {
|
|
- val navView = navView ?: return
|
|
|
|
|
|
+ val settingsSheet = settingsSheet ?: return
|
|
|
|
|
|
val filterItem = menu.findItem(R.id.action_filter)
|
|
val filterItem = menu.findItem(R.id.action_filter)
|
|
|
|
|
|
// Tint icon if there's a filter active
|
|
// Tint icon if there's a filter active
|
|
- if (navView.hasActiveFilters()) {
|
|
|
|
|
|
+ if (settingsSheet.hasActiveFilters()) {
|
|
val filterColor = activity!!.getResourceColor(R.attr.colorFilterActive)
|
|
val filterColor = activity!!.getResourceColor(R.attr.colorFilterActive)
|
|
DrawableCompat.setTint(filterItem.icon, filterColor)
|
|
DrawableCompat.setTint(filterItem.icon, filterColor)
|
|
}
|
|
}
|
|
@@ -378,9 +360,7 @@ class LibraryController(
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
when (item.itemId) {
|
|
when (item.itemId) {
|
|
R.id.action_search -> expandActionViewFromInteraction = true
|
|
R.id.action_search -> expandActionViewFromInteraction = true
|
|
- R.id.action_filter -> {
|
|
|
|
- navView?.let { activity?.drawer?.openDrawer(GravityCompat.END) }
|
|
|
|
- }
|
|
|
|
|
|
+ R.id.action_filter -> showSettingsSheet()
|
|
R.id.action_update_library -> {
|
|
R.id.action_update_library -> {
|
|
activity?.let { LibraryUpdateService.start(it) }
|
|
activity?.let { LibraryUpdateService.start(it) }
|
|
}
|
|
}
|