mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 01:55:06 +01:00
Download queue option moved to download settings
Also popup menus now us mat menus
This commit is contained in:
parent
98972e76c9
commit
fa5b85e3b2
@ -1,5 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.data.download
|
package eu.kanade.tachiyomi.data.download
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.app.Notification
|
import android.app.Notification
|
||||||
import android.app.Service
|
import android.app.Service
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@ -16,6 +17,7 @@ import com.jakewharton.rxrelay.BehaviorRelay
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.util.lang.plusAssign
|
import eu.kanade.tachiyomi.util.lang.plusAssign
|
||||||
import eu.kanade.tachiyomi.util.system.connectivityManager
|
import eu.kanade.tachiyomi.util.system.connectivityManager
|
||||||
import eu.kanade.tachiyomi.util.system.isServiceRunning
|
import eu.kanade.tachiyomi.util.system.isServiceRunning
|
||||||
@ -46,6 +48,7 @@ class DownloadService : Service() {
|
|||||||
* @param context the application context.
|
* @param context the application context.
|
||||||
*/
|
*/
|
||||||
fun start(context: Context) {
|
fun start(context: Context) {
|
||||||
|
MainActivity.setDownloadBadge(true)
|
||||||
val intent = Intent(context, DownloadService::class.java)
|
val intent = Intent(context, DownloadService::class.java)
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||||
context.startService(intent)
|
context.startService(intent)
|
||||||
@ -60,6 +63,7 @@ class DownloadService : Service() {
|
|||||||
* @param context the application context.
|
* @param context the application context.
|
||||||
*/
|
*/
|
||||||
fun stop(context: Context) {
|
fun stop(context: Context) {
|
||||||
|
MainActivity.setDownloadBadge(false)
|
||||||
context.stopService(Intent(context, DownloadService::class.java))
|
context.stopService(Intent(context, DownloadService::class.java))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +128,7 @@ class DownloadService : Service() {
|
|||||||
* Not used.
|
* Not used.
|
||||||
*/
|
*/
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
return Service.START_NOT_STICKY
|
return START_NOT_STICKY
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.source.SourceManager
|
|||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.source.online.fetchAllImageUrlsFromPageList
|
import eu.kanade.tachiyomi.source.online.fetchAllImageUrlsFromPageList
|
||||||
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.util.lang.RetryWithDelay
|
import eu.kanade.tachiyomi.util.lang.RetryWithDelay
|
||||||
import eu.kanade.tachiyomi.util.lang.plusAssign
|
import eu.kanade.tachiyomi.util.lang.plusAssign
|
||||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||||
@ -90,6 +91,7 @@ class Downloader(
|
|||||||
launchNow {
|
launchNow {
|
||||||
val chapters = async { store.restore() }
|
val chapters = async { store.restore() }
|
||||||
queue.addAll(chapters.await())
|
queue.addAll(chapters.await())
|
||||||
|
MainActivity.setDownloadBadge(queue.isNotEmpty())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.ui.download
|
package eu.kanade.tachiyomi.ui.download
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.ui.library
|
package eu.kanade.tachiyomi.ui.library
|
||||||
|
|
||||||
import android.app.DownloadManager
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
@ -42,7 +41,6 @@ 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.category.CategoryController
|
import eu.kanade.tachiyomi.ui.category.CategoryController
|
||||||
import eu.kanade.tachiyomi.ui.download.DownloadController
|
|
||||||
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.ui.migration.MigrationController
|
import eu.kanade.tachiyomi.ui.migration.MigrationController
|
||||||
@ -438,8 +436,6 @@ class LibraryController(
|
|||||||
val searchView = searchItem.actionView as SearchView
|
val searchView = searchItem.actionView as SearchView
|
||||||
searchView.queryHint = resources?.getString(R.string.search_hint)
|
searchView.queryHint = resources?.getString(R.string.search_hint)
|
||||||
|
|
||||||
menu.findItem(R.id.action_downloads).isVisible = MainActivity.bottomNav &&
|
|
||||||
presenter.hasPendingDownloads()
|
|
||||||
searchItem.collapseActionView()
|
searchItem.collapseActionView()
|
||||||
if (query.isNotEmpty()) {
|
if (query.isNotEmpty()) {
|
||||||
searchItem.expandActionView()
|
searchItem.expandActionView()
|
||||||
@ -486,9 +482,6 @@ class LibraryController(
|
|||||||
R.id.action_edit_categories -> {
|
R.id.action_edit_categories -> {
|
||||||
router.pushController(CategoryController().withFadeTransaction())
|
router.pushController(CategoryController().withFadeTransaction())
|
||||||
}
|
}
|
||||||
R.id.action_downloads -> {
|
|
||||||
router.pushController(DownloadController().withFadeTransaction())
|
|
||||||
}
|
|
||||||
R.id.action_source_migration -> {
|
R.id.action_source_migration -> {
|
||||||
router.pushController(MigrationController().withFadeTransaction())
|
router.pushController(MigrationController().withFadeTransaction())
|
||||||
}
|
}
|
||||||
|
@ -101,8 +101,6 @@ class LibraryPresenter(
|
|||||||
subscribeLibrary()
|
subscribeLibrary()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasPendingDownloads() = downloadManager.hasQueue()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes to library if needed.
|
* Subscribes to library if needed.
|
||||||
*/
|
*/
|
||||||
|
@ -27,9 +27,11 @@ import com.bluelinelabs.conductor.Router
|
|||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
||||||
import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler
|
import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import eu.kanade.tachiyomi.Migrations
|
import eu.kanade.tachiyomi.Migrations
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
@ -48,10 +50,11 @@ import eu.kanade.tachiyomi.ui.library.LibraryController
|
|||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
|
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
|
||||||
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
||||||
|
import eu.kanade.tachiyomi.ui.setting.SettingsDownloadController
|
||||||
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
||||||
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.marginBottom
|
import eu.kanade.tachiyomi.util.view.marginBottom
|
||||||
import eu.kanade.tachiyomi.util.view.marginTop
|
import eu.kanade.tachiyomi.util.view.marginTop
|
||||||
@ -59,13 +62,14 @@ import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
|||||||
import eu.kanade.tachiyomi.util.view.updatePadding
|
import eu.kanade.tachiyomi.util.view.updatePadding
|
||||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
|
||||||
import kotlinx.android.synthetic.main.main_activity.*
|
import kotlinx.android.synthetic.main.main_activity.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
@ -146,9 +150,7 @@ open class MainActivity : BaseActivity() {
|
|||||||
R.id.nav_drawer_recently_read -> setRoot(RecentlyReadController(), id)
|
R.id.nav_drawer_recently_read -> setRoot(RecentlyReadController(), id)
|
||||||
R.id.nav_drawer_catalogues -> setRoot(CatalogueController(), id)
|
R.id.nav_drawer_catalogues -> setRoot(CatalogueController(), id)
|
||||||
R.id.nav_drawer_extensions -> setRoot(ExtensionController(), id)
|
R.id.nav_drawer_extensions -> setRoot(ExtensionController(), id)
|
||||||
R.id.nav_drawer_downloads -> {
|
R.id.nav_drawer_downloads -> setRoot(DownloadController(), id)
|
||||||
router.pushController(DownloadController().withFadeTransaction())
|
|
||||||
}
|
|
||||||
R.id.nav_drawer_settings -> setRoot(SettingsMainController(), id)
|
R.id.nav_drawer_settings -> setRoot(SettingsMainController(), id)
|
||||||
}
|
}
|
||||||
//navigationView.selectedItemId = id
|
//navigationView.selectedItemId = id
|
||||||
@ -197,6 +199,7 @@ open class MainActivity : BaseActivity() {
|
|||||||
|
|
||||||
val content: ViewGroup = findViewById(R.id.main_content)
|
val content: ViewGroup = findViewById(R.id.main_content)
|
||||||
bottomNav = preferences.useBottonNav().getOrDefault()
|
bottomNav = preferences.useBottonNav().getOrDefault()
|
||||||
|
bottomNavView = navigationView
|
||||||
content.fitsSystemWindows = !bottomNav
|
content.fitsSystemWindows = !bottomNav
|
||||||
if (!bottomNav) {
|
if (!bottomNav) {
|
||||||
container.systemUiVisibility =
|
container.systemUiVisibility =
|
||||||
@ -365,7 +368,7 @@ open class MainActivity : BaseActivity() {
|
|||||||
extUpdateText.visible()
|
extUpdateText.visible()
|
||||||
val badge = navigationView.getOrCreateBadge(R.id.nav_drawer_settings)
|
val badge = navigationView.getOrCreateBadge(R.id.nav_drawer_settings)
|
||||||
badge.number = updates
|
badge.number = updates
|
||||||
badge.backgroundColor = getResourceColor(R.attr.colorAccent)
|
badge.backgroundColor = getResourceColor(R.attr.badgeColor)
|
||||||
badge.badgeTextColor = Color.WHITE
|
badge.badgeTextColor = Color.WHITE
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -379,6 +382,8 @@ open class MainActivity : BaseActivity() {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
bottomNav = preferences.useBottonNav().getOrDefault()
|
bottomNav = preferences.useBottonNav().getOrDefault()
|
||||||
getExtensionUpdates()
|
getExtensionUpdates()
|
||||||
|
bottomNavView = navigationView
|
||||||
|
setDownloadBadge(Injekt.get<DownloadManager>().hasQueue())
|
||||||
val useBiometrics = preferences.useBiometrics().getOrDefault()
|
val useBiometrics = preferences.useBiometrics().getOrDefault()
|
||||||
if (useBiometrics && BiometricManager.from(this)
|
if (useBiometrics && BiometricManager.from(this)
|
||||||
.canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS) {
|
.canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS) {
|
||||||
@ -393,6 +398,10 @@ open class MainActivity : BaseActivity() {
|
|||||||
preferences.useBiometrics().set(false)
|
preferences.useBiometrics().set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
bottomNavView = null
|
||||||
|
}
|
||||||
|
|
||||||
private fun getExtensionUpdates() {
|
private fun getExtensionUpdates() {
|
||||||
if (Date().time >= preferences.lastExtCheck().getOrDefault() +
|
if (Date().time >= preferences.lastExtCheck().getOrDefault() +
|
||||||
@ -464,6 +473,7 @@ open class MainActivity : BaseActivity() {
|
|||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
bottomNavView = null
|
||||||
nav_view?.setNavigationItemSelectedListener(null)
|
nav_view?.setNavigationItemSelectedListener(null)
|
||||||
toolbar?.setNavigationOnClickListener(null)
|
toolbar?.setNavigationOnClickListener(null)
|
||||||
}
|
}
|
||||||
@ -529,22 +539,28 @@ open class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.id.nav_drawer_downloads -> {
|
R.id.nav_drawer_downloads -> {
|
||||||
if (router.backstack.isEmpty()) {
|
if (router.backstackSize > 1) {
|
||||||
setRoot(LibraryController(), R.id.nav_drawer_library)
|
router.popToRoot()
|
||||||
router.pushController(RouterTransaction.with(DownloadController())
|
}
|
||||||
.pushChangeHandler(SimpleSwapChangeHandler())
|
|
||||||
.popChangeHandler(FadeChangeHandler()))
|
if (bottomNav) {
|
||||||
|
navigationView.selectedItemId = R.id.nav_drawer_settings
|
||||||
|
val newBackstack = listOf(
|
||||||
|
RouterTransaction.with(SettingsMainController()),
|
||||||
|
RouterTransaction.with(SettingsDownloadController()),
|
||||||
|
RouterTransaction.with(DownloadController()))
|
||||||
|
|
||||||
|
router.setBackstack(newBackstack, FadeChangeHandler())
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
router.pushController(DownloadController().withFadeTransaction())
|
nav_view.setCheckedItem(R.id.nav_drawer_settings)
|
||||||
|
setRoot(DownloadController(), id)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
R.id.nav_drawer_settings -> {
|
R.id.nav_drawer_settings -> {
|
||||||
setRoot(SettingsMainController(), id)
|
setRoot(SettingsMainController(), id)
|
||||||
}
|
}
|
||||||
R.id.nav_drawer_help -> {
|
|
||||||
openInBrowser(URL_HELP)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -650,6 +666,33 @@ open class MainActivity : BaseActivity() {
|
|||||||
|
|
||||||
var bottomNav = false
|
var bottomNav = false
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
|
internal var bottomNavView:BottomNavigationView? = null
|
||||||
|
|
||||||
|
fun setDownloadBadge(downloading: Boolean) {
|
||||||
|
if (!bottomNav) return
|
||||||
|
val badge = bottomNavView?.getOrCreateBadge(R.id.nav_drawer_settings) ?: return
|
||||||
|
val downloadManager = Injekt.get<DownloadManager>()
|
||||||
|
val hasQueue = downloading || downloadManager.hasQueue()
|
||||||
|
if (hasQueue) {
|
||||||
|
badge.clearNumber()
|
||||||
|
badge.backgroundColor = bottomNavView?.context?.getResourceColor(R.attr
|
||||||
|
.badgeColor) ?: Color.BLACK
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
val updates = Injekt.get<PreferencesHelper>().extensionUpdatesCount().getOrDefault()
|
||||||
|
if (updates > 0) {
|
||||||
|
badge.number = updates
|
||||||
|
badge.backgroundColor = bottomNavView?.context?.getResourceColor(R.attr
|
||||||
|
.badgeColor) ?: Color.BLACK
|
||||||
|
badge.badgeTextColor = Color.WHITE
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bottomNavView?.removeBadge(R.id.nav_drawer_settings)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -182,6 +182,7 @@ class SearchActivity: MainActivity() {
|
|||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
bottomNav = false
|
bottomNav = false
|
||||||
|
bottomNavView = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleIntentAction(intent: Intent): Boolean {
|
override fun handleIntentAction(intent: Intent): Boolean {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.ui.manga.chapter
|
package eu.kanade.tachiyomi.ui.manga.chapter
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.ui.migration.manga.process
|
package eu.kanade.tachiyomi.ui.migration.manga.process
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.ui.recent_updates
|
package eu.kanade.tachiyomi.ui.recent_updates
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
|
@ -9,6 +9,7 @@ import com.afollestad.materialdialogs.list.listItems
|
|||||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
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.widget.preference.DownloadQueuePreference
|
||||||
import eu.kanade.tachiyomi.widget.preference.ExtensionPreference
|
import eu.kanade.tachiyomi.widget.preference.ExtensionPreference
|
||||||
import eu.kanade.tachiyomi.widget.preference.IntListMatPreference
|
import eu.kanade.tachiyomi.widget.preference.IntListMatPreference
|
||||||
import eu.kanade.tachiyomi.widget.preference.IntListPreference
|
import eu.kanade.tachiyomi.widget.preference.IntListPreference
|
||||||
@ -34,6 +35,12 @@ inline fun PreferenceGroup.extensionPreference(block: (@DSL Preference).() -> Un
|
|||||||
return initThenAdd(ExtensionPreference(context), block)
|
return initThenAdd(ExtensionPreference(context), block)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun PreferenceGroup.downloadQueuePreference(block: (@DSL Preference).() -> Unit):
|
||||||
|
DownloadQueuePreference {
|
||||||
|
return initThenAdd(DownloadQueuePreference(context), block)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline fun PreferenceGroup.switchPreference(block: (@DSL SwitchPreferenceCompat).() -> Unit): SwitchPreferenceCompat {
|
inline fun PreferenceGroup.switchPreference(block: (@DSL SwitchPreferenceCompat).() -> Unit): SwitchPreferenceCompat {
|
||||||
return initThenAdd(SwitchPreferenceCompat(context), block)
|
return initThenAdd(SwitchPreferenceCompat(context), block)
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,15 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||||
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
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.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
|
import eu.kanade.tachiyomi.ui.download.DownloadController
|
||||||
import eu.kanade.tachiyomi.util.system.getFilePicker
|
import eu.kanade.tachiyomi.util.system.getFilePicker
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
@ -31,6 +34,13 @@ class SettingsDownloadController : SettingsController() {
|
|||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||||
titleRes = R.string.pref_category_downloads
|
titleRes = R.string.pref_category_downloads
|
||||||
|
|
||||||
|
downloadQueuePreference {
|
||||||
|
titleRes = R.string.label_download_queue
|
||||||
|
onClick {
|
||||||
|
router.pushController(DownloadController().withFadeTransaction())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
preference {
|
preference {
|
||||||
key = Keys.downloadsDirectory
|
key = Keys.downloadsDirectory
|
||||||
titleRes = R.string.pref_download_directory
|
titleRes = R.string.pref_download_directory
|
||||||
|
@ -49,7 +49,7 @@ class SettingsMainController : SettingsController() {
|
|||||||
titleRes = R.string.pref_category_reader
|
titleRes = R.string.pref_category_reader
|
||||||
onClick { navigateTo(SettingsReaderController()) }
|
onClick { navigateTo(SettingsReaderController()) }
|
||||||
}
|
}
|
||||||
preference {
|
downloadQueuePreference {
|
||||||
iconRes = R.drawable.ic_file_download_black_24dp
|
iconRes = R.drawable.ic_file_download_black_24dp
|
||||||
iconTint = tintColor
|
iconTint = tintColor
|
||||||
titleRes = R.string.pref_category_downloads
|
titleRes = R.string.pref_category_downloads
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
package eu.kanade.tachiyomi.widget.preference
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.preference.Preference
|
||||||
|
import androidx.preference.PreferenceViewHolder
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
|
import kotlinx.android.synthetic.main.preference_update_text.view.*
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
|
class DownloadQueuePreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
|
Preference(context, attrs) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
widgetLayoutResource = R.layout.preference_update_text
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||||
|
super.onBindViewHolder(holder)
|
||||||
|
|
||||||
|
val extUpdateText = holder.itemView.textView
|
||||||
|
|
||||||
|
val updates = Injekt.get<DownloadManager>().queue.size
|
||||||
|
if (updates > 0) {
|
||||||
|
extUpdateText.text = context.resources.getQuantityString(R.plurals
|
||||||
|
.downloads_pending, updates, updates)
|
||||||
|
extUpdateText.visible()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extUpdateText.text = null
|
||||||
|
extUpdateText.gone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun notifyChanged() {
|
||||||
|
super.notifyChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -51,7 +51,7 @@ class LoginCheckBoxPreference @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make method public
|
// Make method public
|
||||||
override public fun notifyChanged() {
|
public override fun notifyChanged() {
|
||||||
super.notifyChanged()
|
super.notifyChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,12 +17,6 @@
|
|||||||
android:title="@string/action_filter"
|
android:title="@string/action_filter"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_downloads"
|
|
||||||
android:icon="@drawable/ic_file_download_white_24dp"
|
|
||||||
android:title="@string/label_download_queue"
|
|
||||||
app:showAsAction="ifRoom"/>
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_edit_categories"
|
android:id="@+id/action_edit_categories"
|
||||||
android:title="@string/action_edit_categories"
|
android:title="@string/action_edit_categories"
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
<group android:checkableBehavior="single">
|
<group android:checkableBehavior="single"
|
||||||
|
android:id="@+id/menu_top">
|
||||||
<item
|
<item
|
||||||
android:checked="true"
|
android:checked="true"
|
||||||
android:id="@+id/nav_drawer_library"
|
android:id="@+id/nav_drawer_library"
|
||||||
@ -24,6 +25,9 @@
|
|||||||
android:icon="@drawable/ic_extension_black_24dp"
|
android:icon="@drawable/ic_extension_black_24dp"
|
||||||
app:actionLayout="@layout/menu_counter"
|
app:actionLayout="@layout/menu_counter"
|
||||||
android:title="@string/label_extensions"/>
|
android:title="@string/label_extensions"/>
|
||||||
|
</group>
|
||||||
|
<group android:checkableBehavior="single"
|
||||||
|
android:id="@+id/menu_bottom">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_drawer_downloads"
|
android:id="@+id/nav_drawer_downloads"
|
||||||
android:icon="@drawable/ic_file_download_black_24dp"
|
android:icon="@drawable/ic_file_download_black_24dp"
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
<color name="purePrimary">#212121</color>
|
<color name="purePrimary">#212121</color>
|
||||||
<color name="splashBackground">#212121</color>
|
<color name="splashBackground">#212121</color>
|
||||||
<color name="actionModeShadow">@color/md_white_1000_38</color>
|
<color name="actionModeShadow">@color/md_white_1000_38</color>
|
||||||
|
<color name="badgeColor">#3399FF</color>
|
||||||
|
|
||||||
<color name="textColorPrimary">@color/md_white_1000</color>
|
<color name="textColorPrimary">@color/md_white_1000</color>
|
||||||
<color name="textColorSecondary">@color/md_white_1000_70</color>
|
<color name="textColorSecondary">@color/md_white_1000_70</color>
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Tachiyomi">
|
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Tachiyomi">
|
||||||
<item name="colorPrimary">#54759E</item>
|
<item name="colorPrimary">#54759E</item>
|
||||||
<item name="colorPrimaryDark">#54759E</item>
|
<item name="colorPrimaryDark">#54759E</item>
|
||||||
|
<item name="badgeColor">@color/material_red_accent_700</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!--==============-->
|
<!--==============-->
|
||||||
|
@ -31,4 +31,5 @@
|
|||||||
<attr name="icon_color" format="reference|integer"/>
|
<attr name="icon_color" format="reference|integer"/>
|
||||||
<attr name="snackbar_background" format="reference|integer"/>
|
<attr name="snackbar_background" format="reference|integer"/>
|
||||||
<attr name="snackbar_text" format="reference|integer"/>
|
<attr name="snackbar_text" format="reference|integer"/>
|
||||||
|
<attr name="badgeColor" format="reference|integer"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
<color name="textColorHintInverse">@color/md_white_1000_50</color>
|
<color name="textColorHintInverse">@color/md_white_1000_50</color>
|
||||||
<color name="divider">@color/md_black_1000_12</color>
|
<color name="divider">@color/md_black_1000_12</color>
|
||||||
<color name="oldNavBarBackground">#B3FFFFFF</color>
|
<color name="oldNavBarBackground">#B3FFFFFF</color>
|
||||||
|
<color name="badgeColor">@color/material_red_accent_700</color>
|
||||||
|
|
||||||
<color name="preference_fallback_accent_color">@color/colorAccent</color>
|
<color name="preference_fallback_accent_color">@color/colorAccent</color>
|
||||||
<color name="darkPrimaryColor">#212121</color>
|
<color name="darkPrimaryColor">#212121</color>
|
||||||
|
@ -20,13 +20,17 @@
|
|||||||
<string name="label_selected">Selected: %1$d</string>
|
<string name="label_selected">Selected: %1$d</string>
|
||||||
<string name="label_migration">Source migration</string>
|
<string name="label_migration">Source migration</string>
|
||||||
<string name="label_extensions">Extensions</string>
|
<string name="label_extensions">Extensions</string>
|
||||||
|
<string name="label_extension_info">Extension info</string>
|
||||||
|
<string name="label_help">Help</string>
|
||||||
|
<string name="unlock_library">Unlock to access Library</string>
|
||||||
<plurals name="extensions_updates_available">
|
<plurals name="extensions_updates_available">
|
||||||
<item quantity="one">Update available</item>
|
<item quantity="one">Update available</item>
|
||||||
<item quantity="other">%d updates available</item>
|
<item quantity="other">%d updates available</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
<string name="label_extension_info">Extension info</string>
|
<plurals name="downloads_pending">
|
||||||
<string name="label_help">Help</string>
|
<item quantity="one">1 in queue</item>
|
||||||
<string name="unlock_library">Unlock to access Library</string>
|
<item quantity="other">%d in queue</item>
|
||||||
|
</plurals>
|
||||||
|
|
||||||
<!-- Actions -->
|
<!-- Actions -->
|
||||||
<string name="action_filter">Filter</string>
|
<string name="action_filter">Filter</string>
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
<item name="snackbar_background">@color/snackbarBackground</item>
|
<item name="snackbar_background">@color/snackbarBackground</item>
|
||||||
<item name="snackbar_text">@color/textColorPrimaryInverse</item>
|
<item name="snackbar_text">@color/textColorPrimaryInverse</item>
|
||||||
<item name="actionBarTintColor">@color/md_white_1000</item>
|
<item name="actionBarTintColor">@color/md_white_1000</item>
|
||||||
|
<item name="badgeColor">@color/badgeColor</item>
|
||||||
|
|
||||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
<item name="android:navigationBarColor">#B3000000</item>
|
<item name="android:navigationBarColor">#B3000000</item>
|
||||||
@ -66,6 +67,7 @@
|
|||||||
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.DayNight.ActionBar</item>
|
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.DayNight.ActionBar</item>
|
||||||
<item name="tabBarIconColor">@color/colorPrimary</item>
|
<item name="tabBarIconColor">@color/colorPrimary</item>
|
||||||
<item name="tabBarIconInactive">@color/colorPrimaryInactive</item>
|
<item name="tabBarIconInactive">@color/colorPrimaryInactive</item>
|
||||||
|
<item name="badgeColor">@color/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Tachiyomi"/>
|
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Tachiyomi"/>
|
||||||
<style name="Theme.Tachiyomi.Amoled" parent="Theme.Tachiyomi"/>
|
<style name="Theme.Tachiyomi.Amoled" parent="Theme.Tachiyomi"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user