Fixes to android lollipop

Notification icons now has color
Coping title or other text in manga info is now a snackbar, shows the type of text copied
This commit is contained in:
Jay 2019-11-02 23:07:07 -07:00
parent d263f03cc7
commit 6da8c368fa
7 changed files with 26 additions and 18 deletions

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.data.download
import android.content.Context
import android.graphics.BitmapFactory
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.data.download.model.DownloadQueue
@ -219,7 +220,7 @@ internal class DownloadNotifier(private val context: Context) {
clearActions()
setAutoCancel(true)
setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context))
color = context.getResourceColor(R.attr.colorAccent)
color = ContextCompat.getColor(context, R.color.colorAccentLight)
setProgress(0, 0, false)
}
notification.show(Notifications.ID_DOWNLOAD_CHAPTER_ERROR)

View File

@ -10,6 +10,7 @@ import android.os.Build
import android.os.IBinder
import android.os.PowerManager
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Category
@ -90,7 +91,7 @@ class LibraryUpdateService(
.setLargeIcon(notificationBitmap)
.setOngoing(true)
.setOnlyAlertOnce(true)
.setColor(getResourceColor(R.attr.colorAccent))
.setColor(ContextCompat.getColor(this, R.color.colorAccentLight))
.addAction(R.drawable.ic_clear_grey_24dp_img, getString(android.R.string.cancel), cancelIntent)
}
@ -463,7 +464,7 @@ class LibraryUpdateService(
setSmallIcon(R.drawable.ic_book_white_24dp)
setLargeIcon(notificationBitmap)
setContentTitle(getString(R.string.notification_new_chapters))
color = getResourceColor(R.attr.colorAccent)
color = ContextCompat.getColor(applicationContext, R.color.colorAccentLight)
if (newUpdates.size > 1) {
setContentText(getString(R.string.notification_new_chapters_text, newUpdates.size))
setStyle(NotificationCompat.BigTextStyle().bigText(newUpdates.joinToString("\n")))

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.data.updater
import android.app.PendingIntent
import android.content.Intent
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import com.evernote.android.job.Job
import com.evernote.android.job.JobManager
import com.evernote.android.job.JobRequest
@ -28,7 +29,7 @@ class UpdaterJob : Job() {
setContentTitle(context.getString(R.string.app_name))
setContentText(context.getString(R.string.update_check_notification_update_available))
setSmallIcon(android.R.drawable.stat_sys_download_done)
color = context.getResourceColor(R.attr.colorAccent)
color = ContextCompat.getColor(context, R.color.colorAccentLight)
// Download action
addAction(android.R.drawable.stat_sys_download_done,
context.getString(R.string.action_download),

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.data.updater
import android.content.Context
import android.net.Uri
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.notification.NotificationHandler
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
@ -96,7 +97,7 @@ internal class UpdaterNotifier(private val context: Context) {
setSmallIcon(android.R.drawable.stat_sys_warning)
setOnlyAlertOnce(false)
setProgress(0, 0, false)
color = context.getResourceColor(R.attr.colorAccent)
color = ContextCompat.getColor(context, R.color.colorAccentLight)
// Retry action
addAction(R.drawable.ic_refresh_grey_24dp_img,
context.getString(R.string.action_retry),

View File

@ -101,7 +101,8 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
swipe_refresh.refreshes().subscribeUntilDestroy { fetchMangaFromSource() }
manga_full_title.longClicks().subscribeUntilDestroy {
copyToClipboard(view.context.getString(R.string.title), manga_full_title.text.toString())
copyToClipboard(view.context.getString(R.string.title), manga_full_title.text
.toString(), R.string.manga_info_full_title_label)
}
manga_full_title.clicks().subscribeUntilDestroy {
@ -109,7 +110,8 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
}
manga_artist.longClicks().subscribeUntilDestroy {
copyToClipboard(manga_artist_label.text.toString(), manga_artist.text.toString())
copyToClipboard(manga_artist_label.text.toString(), manga_artist.text.toString(), R
.string.manga_info_artist_label)
}
manga_artist.clicks().subscribeUntilDestroy {
@ -117,7 +119,8 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
}
manga_author.longClicks().subscribeUntilDestroy {
copyToClipboard(manga_author.text.toString(), manga_author.text.toString())
copyToClipboard(manga_author.text.toString(), manga_author.text.toString(), R.string
.manga_info_author_label)
}
manga_author.clicks().subscribeUntilDestroy {
@ -125,13 +128,14 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
}
manga_summary.longClicks().subscribeUntilDestroy {
copyToClipboard(view.context.getString(R.string.description), manga_summary.text.toString())
copyToClipboard(view.context.getString(R.string.description), manga_summary.text
.toString(), R.string.description)
}
//manga_genres_tags.setOnTagClickListener { tag -> performGlobalSearch(tag) }
manga_cover.longClicks().subscribeUntilDestroy {
copyToClipboard(view.context.getString(R.string.title), presenter.manga.title)
copyToClipboard(view.context.getString(R.string.title), presenter.manga.title, R.string.manga_info_full_title_label)
}
container = (view as ViewGroup).findViewById(R.id.manga_info_layout) as? View
val bottomM = manga_genres_tags.marginBottom
@ -569,7 +573,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
* @param label Label to show to the user describing the content
* @param content the actual text to copy to the board
*/
private fun copyToClipboard(label: String, content: String) {
private fun copyToClipboard(label: String, content: String, resId: Int) {
if (content.isBlank()) return
val activity = activity ?: return
@ -578,8 +582,8 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
val clipboard = activity.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setPrimaryClip(ClipData.newPlainText(label, content))
activity.toast(view.context.getString(R.string.copied_to_clipboard, content.truncateCenter(20)),
Toast.LENGTH_SHORT)
snack = container?.snack(view.context.getString(R.string.copied_to_clipboard, view.context
.getString(resId)))
}
/**

View File

@ -55,10 +55,10 @@ Unit)? = null): Snackbar {
if (f != null) {
snack.f()
}
snack.view.doOnApplyWindowInsets { v, insets, padding ->
//v.setPadding(padding.left, 0, padding.right, 0)
v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
if (Build.VERSION.SDK_INT < 23) {
if (Build.VERSION.SDK_INT < 23) {
val view = if (this !is CoordinatorLayout) this else snack.view
view.doOnApplyWindowInsets { _, insets, _ ->
snack.view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = 12 + insets.systemWindowInsetBottom
}
}

View File

@ -40,7 +40,7 @@
<item name="icon_color">@color/iconColorLight</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@color/colorPrimary</item>
<item name="android:navigationBarColor">#B3000000</item>
</style>
<style name="Theme.Tachiyomi" parent="Theme.Base"/>