mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 02:21:51 +01:00
Fixed Download intent + help button in settings
This commit is contained in:
parent
becf936d48
commit
ff71b96703
@ -18,11 +18,10 @@ object NotificationHandler {
|
||||
* @param context context of application
|
||||
*/
|
||||
internal fun openDownloadManagerPendingActivity(context: Context): PendingIntent {
|
||||
val intent = Intent(context, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
|
||||
action = MainActivity.SHORTCUT_DOWNLOADS
|
||||
}
|
||||
return PendingIntent.getActivity(context, 0, intent, 0)
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
intent.action = MainActivity.SHORTCUT_DOWNLOADS
|
||||
return PendingIntent.getActivity(context, -201, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,8 @@ import com.bluelinelabs.conductor.Controller
|
||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||
import com.bluelinelabs.conductor.Router
|
||||
import com.bluelinelabs.conductor.RouterTransaction
|
||||
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
||||
import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import eu.kanade.tachiyomi.Migrations
|
||||
import eu.kanade.tachiyomi.R
|
||||
@ -169,7 +171,10 @@ open class MainActivity : BaseActivity() {
|
||||
R.id.nav_drawer_catalogues -> setRoot(CatalogueController(), id)
|
||||
R.id.nav_drawer_extensions -> setRoot(ExtensionController(), id)
|
||||
R.id.nav_drawer_downloads -> {
|
||||
setRoot(DownloadController(), id)
|
||||
if (router.backstack.isEmpty()) {
|
||||
setRoot(LibraryController(), R.id.nav_drawer_library)
|
||||
}
|
||||
router.pushController(DownloadController().withFadeTransaction())
|
||||
}
|
||||
R.id.nav_drawer_settings -> {
|
||||
setRoot(SettingsMainController(), id)
|
||||
@ -453,8 +458,49 @@ open class MainActivity : BaseActivity() {
|
||||
if (!isFinishing) {
|
||||
nav_view.setCheckedItem(itemId)
|
||||
navigationView.selectedItemId = itemId
|
||||
nav_view.menu.performIdentifierAction(itemId, 0)
|
||||
//navigationView.menu.performIdentifierAction(itemId, 0)
|
||||
jumpToController(itemId)
|
||||
}
|
||||
}
|
||||
|
||||
fun jumpToController(id: Int) {
|
||||
|
||||
val currentRoot = router.backstack.firstOrNull()
|
||||
if (currentRoot?.tag()?.toIntOrNull() != id) {
|
||||
when (id) {
|
||||
R.id.nav_drawer_library -> setRoot(LibraryController(), id)
|
||||
R.id.nav_drawer_recent_updates -> setRoot(RecentChaptersController(), id)
|
||||
R.id.nav_drawer_recently_read -> setRoot(RecentlyReadController(), id)
|
||||
R.id.nav_drawer_catalogues -> setRoot(CatalogueController(), id)
|
||||
R.id.nav_drawer_extensions -> {
|
||||
if (router.backstack.isEmpty()) {
|
||||
navigationView.selectedItemId = R.id.nav_drawer_settings
|
||||
setRoot(SettingsMainController(), R.id.nav_drawer_settings)
|
||||
router.pushController(RouterTransaction.with(ExtensionController())
|
||||
.pushChangeHandler(SimpleSwapChangeHandler())
|
||||
.popChangeHandler(FadeChangeHandler()))
|
||||
}
|
||||
else {
|
||||
router.pushController(ExtensionController().withFadeTransaction())
|
||||
}
|
||||
}
|
||||
R.id.nav_drawer_downloads -> {
|
||||
if (router.backstack.isEmpty()) {
|
||||
setRoot(LibraryController(), R.id.nav_drawer_library)
|
||||
router.pushController(RouterTransaction.with(DownloadController())
|
||||
.pushChangeHandler(SimpleSwapChangeHandler())
|
||||
.popChangeHandler(FadeChangeHandler()))
|
||||
}
|
||||
else {
|
||||
router.pushController(DownloadController().withFadeTransaction())
|
||||
}
|
||||
}
|
||||
R.id.nav_drawer_settings -> {
|
||||
setRoot(SettingsMainController(), id)
|
||||
}
|
||||
R.id.nav_drawer_help -> {
|
||||
openInBrowser(URL_HELP)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,22 @@
|
||||
package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||
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.data.updater.UpdaterJob
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.ui.extension.ExtensionController
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||
|
||||
class SettingsMainController : SettingsController() {
|
||||
|
||||
init {
|
||||
setHasOptionsMenu(true)
|
||||
}
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||
titleRes = R.string.label_settings
|
||||
|
||||
@ -75,8 +78,23 @@ class SettingsMainController : SettingsController() {
|
||||
onClick { navigateTo(SettingsAboutController()) }
|
||||
}
|
||||
}
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.settings_main, menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_help -> activity?.openInBrowser(URL_HELP)
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun navigateTo(controller: Controller) {
|
||||
router.pushController(controller.withFadeTransaction())
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val URL_HELP = "https://tachiyomi.org/help/"
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,8 @@
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?attr/actionBarTintColor">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"/>
|
||||
|
@ -14,11 +14,6 @@
|
||||
android:visible="false"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item android:title="@string/action_cancel_all"
|
||||
android:id="@+id/clear_queue"
|
||||
android:visible="false"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/reorder"
|
||||
android:title="@string/action_reorganize_by"
|
||||
@ -34,4 +29,10 @@
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
|
||||
<item android:title="@string/action_cancel_all"
|
||||
android:id="@+id/clear_queue"
|
||||
android:visible="false"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
</menu>
|
9
app/src/main/res/menu/settings_main.xml
Normal file
9
app/src/main/res/menu/settings_main.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_help"
|
||||
android:title="@string/label_help"
|
||||
android:icon="@drawable/ic_help_black_24dp"
|
||||
app:showAsAction="always"/>
|
||||
</menu>
|
Loading…
Reference in New Issue
Block a user