Added a tutorial for new location download queue

Using another new tutorial library for it, instead of tooltips
This commit is contained in:
Jay 2020-04-29 00:16:06 -04:00
parent 51b50d8a51
commit 8da4b677ea
7 changed files with 52 additions and 8 deletions

View File

@ -204,6 +204,7 @@ dependencies {
implementation("com.github.chrisbanes:PhotoView:2.3.0")
implementation("com.github.carlosesco:DirectionalViewPager:a844dbca0a")
implementation("com.github.florent37:viewtooltip:1.2.2")
implementation("com.getkeepsafe.taptargetview:taptargetview:1.13.0")
// Conductor
implementation("com.bluelinelabs:conductor:2.1.5")

View File

@ -267,4 +267,6 @@ class PreferencesHelper(val context: Context) {
fun shownFilterTutorial() = flowPrefs.getBoolean("shown_filter_tutorial", false)
fun shownChapterSwipeTutorial() = flowPrefs.getBoolean("shown_swipe_tutorial", false)
fun shownDownloadQueueTutorial() = flowPrefs.getBoolean("shown_download_queue", false)
}

View File

@ -29,6 +29,8 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.getkeepsafe.taptargetview.TapTarget
import com.getkeepsafe.taptargetview.TapTargetView
import com.google.android.material.snackbar.Snackbar
import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.Migrations
@ -38,7 +40,6 @@ import eu.kanade.tachiyomi.data.download.DownloadService
import eu.kanade.tachiyomi.data.download.DownloadServiceListener
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
@ -53,6 +54,7 @@ import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
import eu.kanade.tachiyomi.ui.setting.SettingsController
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
import eu.kanade.tachiyomi.ui.source.SourceController
import eu.kanade.tachiyomi.util.system.contextCompatDrawable
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.hasSideNavBar
import eu.kanade.tachiyomi.util.system.isBottomTappable
@ -69,8 +71,6 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
import java.util.Date
import java.util.concurrent.TimeUnit
@ -91,6 +91,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
private var canDismissSnackBar = false
private var animationSet: AnimatorSet? = null
private val downloadManager: DownloadManager by injectLazy()
fun setUndoSnackBar(snackBar: Snackbar?, extraViewToCheck: View? = null) {
this.snackBar = snackBar
@ -255,6 +256,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
handler: ControllerChangeHandler
) {
appbar.y = 0f
showDLQueueTutorial()
}
})
@ -346,6 +348,32 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
// setting in case someone comes from the search activity to main
getExtensionUpdates()
DownloadService.callListeners()
showDLQueueTutorial()
}
private fun showDLQueueTutorial() {
if (router.backstackSize == 1 && this !is SearchActivity &&
downloadManager.hasQueue() && !preferences.shownDownloadQueueTutorial().get()
) {
val recentsItem = bottom_nav.getItemView(R.id.nav_recents) ?: return
preferences.shownDownloadQueueTutorial().set(true)
TapTargetView.showFor(this,
TapTarget.forView(
recentsItem,
getString(R.string.manage_whats_downloading),
getString(R.string.visit_recents_for_download_queue)
).outerCircleColor(R.color.colorAccent).outerCircleAlpha(0.95f).titleTextSize(20)
.titleTextColor(android.R.color.white).descriptionTextSize(16)
.descriptionTextColor(R.color.md_white_1000_76)
.icon(contextCompatDrawable(R.drawable.ic_recent_read_32dp))
.targetCircleColor(android.R.color.white).targetRadius(45),
object : TapTargetView.Listener() {
override fun onTargetClick(view: TapTargetView) {
super.onTargetClick(view)
bottom_nav.selectedItemId = R.id.nav_recents
}
})
}
}
override fun onPause() {
@ -356,7 +384,6 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
private fun getExtensionUpdates() {
if (Date().time >= preferences.lastExtCheck().getOrDefault() + TimeUnit.HOURS.toMillis(6)) {
GlobalScope.launch(Dispatchers.IO) {
val preferences: PreferencesHelper by injectLazy()
try {
val pendingUpdates = ExtensionGithubApi().checkForUpdates(this@MainActivity)
preferences.extensionUpdatesCount().set(pendingUpdates.size)
@ -529,11 +556,11 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
}
override fun downloadStatusChanged(downloading: Boolean) {
val downloadManager = Injekt.get<DownloadManager>()
val hasQueue = downloading || downloadManager.hasQueue()
launchUI {
if (hasQueue) {
bottom_nav?.getOrCreateBadge(R.id.nav_recents)
showDLQueueTutorial()
} else {
bottom_nav?.removeBadge(R.id.nav_recents)
}

View File

@ -10,6 +10,7 @@ import android.content.IntentFilter
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.content.res.Resources
import android.graphics.drawable.Drawable
import android.net.ConnectivityManager
import android.net.Uri
import android.os.PowerManager
@ -17,6 +18,7 @@ import android.view.View
import android.widget.Toast
import androidx.annotation.AttrRes
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.app.NotificationCompat
@ -101,6 +103,15 @@ fun Context.contextCompatColor(@ColorRes resource: Int): Int {
return ContextCompat.getColor(this, resource)
}
/**
* Returns the color from ContextCompat
*
* @param resource the color.
*/
fun Context.contextCompatDrawable(@DrawableRes resource: Int): Drawable? {
return ContextCompat.getDrawable(this, resource)
}
/**
* Converts to dp.
*/

View File

@ -1,7 +1,7 @@
<!-- drawable/clock.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:height="32dp"
android:width="32dp"
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" />

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_recent_read_24dp" android:state_checked="true" />
<item android:drawable="@drawable/ic_recent_read_32dp" android:state_checked="true" />
<item android:drawable="@drawable/ic_recent_read_outline_24dp" android:state_checked="false" />
</selector>

View File

@ -564,6 +564,9 @@
<string name="download_complete">Download complete</string>
<string name="download_error">Download error</string>
<string name="could_not_download_chapter_can_try_again">Could not download chapters. You can try again in the downloads section</string>
<string name="manage_whats_downloading">Manage what\'s downloading</string>
<string name="visit_recents_for_download_queue">Visit the recents tab to access the download
queue. You can also double tap or press and hold for quicker access</string>
<!-- Download Notification -->
<string name="could_not_download_unexpected_error">Could not download chapter due to unexpected error</string>