From 5fec956ce6ed5fd1e4eb24158fb3f93893c49114 Mon Sep 17 00:00:00 2001 From: len Date: Sat, 17 Jun 2017 12:34:46 +0200 Subject: [PATCH] Main activity now uses single task. Fixes #850. Actually use new support library --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 4 ++- .../kanade/tachiyomi/ui/main/MainActivity.kt | 35 ++++++++++++++----- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index cce2cb6368..c4a9d06172 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -237,7 +237,7 @@ configurations.all { def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { - details.useVersion '25.3.1' + details.useVersion '25.4.0' } } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b83ac43069..427c03e832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,7 +23,9 @@ android:label="@string/app_name" android:largeHeap="true" android:theme="@style/Theme.Tachiyomi"> - + diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index b50d2a5a4a..d6bf1d2331 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.ui.main import android.animation.ObjectAnimator +import android.content.Intent import android.graphics.Color import android.os.Bundle import android.support.v4.view.GravityCompat @@ -105,15 +106,8 @@ class MainActivity : BaseActivity() { router = Conductor.attachRouter(this, container, savedInstanceState) if (!router.hasRootController()) { // Set start screen - when (intent.action) { - SHORTCUT_LIBRARY -> setSelectedDrawerItem(R.id.nav_drawer_library) - SHORTCUT_RECENTLY_UPDATED -> setSelectedDrawerItem(R.id.nav_drawer_recent_updates) - SHORTCUT_RECENTLY_READ -> setSelectedDrawerItem(R.id.nav_drawer_recently_read) - SHORTCUT_CATALOGUES -> setSelectedDrawerItem(R.id.nav_drawer_catalogues) - SHORTCUT_MANGA -> router.setRoot( - RouterTransaction.with(MangaController(intent.extras))) - SHORTCUT_DOWNLOADS -> setSelectedDrawerItem(R.id.nav_drawer_downloads) - else -> setSelectedDrawerItem(startScreenId) + if (!handleIntentAction(intent)) { + setSelectedDrawerItem(startScreenId) } } @@ -149,6 +143,29 @@ class MainActivity : BaseActivity() { } } + override fun onNewIntent(intent: Intent) { + if (!handleIntentAction(intent)) { + super.onNewIntent(intent) + } + } + + private fun handleIntentAction(intent: Intent): Boolean { + when (intent.action) { + SHORTCUT_LIBRARY -> setSelectedDrawerItem(R.id.nav_drawer_library) + SHORTCUT_RECENTLY_UPDATED -> setSelectedDrawerItem(R.id.nav_drawer_recent_updates) + SHORTCUT_RECENTLY_READ -> setSelectedDrawerItem(R.id.nav_drawer_recently_read) + SHORTCUT_CATALOGUES -> setSelectedDrawerItem(R.id.nav_drawer_catalogues) + SHORTCUT_MANGA -> router.setRoot(RouterTransaction.with(MangaController(intent.extras))) + SHORTCUT_DOWNLOADS -> { + if (router.backstack.none { it.controller() is DownloadController }) { + setSelectedDrawerItem(R.id.nav_drawer_downloads) + } + } + else -> return false + } + return true + } + override fun onDestroy() { super.onDestroy() nav_view?.setNavigationItemSelectedListener(null)