From 38000652306e866e0ad50e380a840120774872da Mon Sep 17 00:00:00 2001 From: Midyan Hamdoun Date: Mon, 18 Oct 2021 16:57:52 +0300 Subject: [PATCH 01/15] Fix crashing when clicking the search icon (#6128) --- .../tachiyomi/ui/setting/SettingsSecurityController.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt index 195ab4d21..dcdaf4fb4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt @@ -31,9 +31,9 @@ class SettingsSecurityController : SettingsController() { defaultValue = false requireAuthentication( - activity as? FragmentActivity, - activity!!.getString(R.string.lock_with_biometrics), - activity!!.getString(R.string.confirm_lock_change), + context as? FragmentActivity, + context!!.getString(R.string.lock_with_biometrics), + context.getString(R.string.confirm_lock_change), ) } From 9352e249ee7cfbfefe66aab6856ebb0b0410c403 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 18 Oct 2021 09:49:58 -0400 Subject: [PATCH 02/15] Make tapping library update and backup restore error notifications open log --- .../tachiyomi/data/backup/BackupNotifier.kt | 4 +++- .../data/library/LibraryUpdateNotifier.kt | 17 ++--------------- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt index faf7fc92f..f0c9873a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt @@ -139,10 +139,12 @@ class BackupNotifier(private val context: Context) { val destFile = File(path, file) val uri = destFile.getUriCompat(context) + val errorLogIntent = NotificationReceiver.openErrorLogPendingActivity(context, uri) + setContentIntent(errorLogIntent) addAction( R.drawable.ic_folder_24dp, context.getString(R.string.action_show_errors), - NotificationReceiver.openErrorLogPendingActivity(context, uri) + errorLogIntent, ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt index ac9a7618e..bb8608f91 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt @@ -117,23 +117,10 @@ class LibraryUpdateNotifier(private val context: Context) { Notifications.ID_LIBRARY_ERROR, context.notificationBuilder(Notifications.CHANNEL_LIBRARY_ERROR) { setContentTitle(context.resources.getQuantityString(R.plurals.notification_update_error, errors.size, errors.size)) - setStyle( - NotificationCompat.BigTextStyle().bigText( - errors.joinToString("\n") { - it.chop(NOTIF_TITLE_MAX_LEN) - } - ) - ) + setContentText(context.getString(R.string.action_show_errors)) setSmallIcon(R.drawable.ic_tachi) - val errorLogIntent = NotificationReceiver.openErrorLogPendingActivity(context, uri) - - setContentIntent(errorLogIntent) - addAction( - R.drawable.ic_folder_24dp, - context.getString(R.string.action_show_errors), - errorLogIntent - ) + setContentIntent(NotificationReceiver.openErrorLogPendingActivity(context, uri)) } .build() ) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c1fc99237..1ef9c7bb4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -119,7 +119,7 @@ Reset Undo Open log - Show errors + See full error details Create Restore Back From 9e2ef82902369908503e860af12e8536a004bd43 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 18 Oct 2021 09:54:09 -0400 Subject: [PATCH 03/15] Remove global update intervals below 12 hours, add every 3 day interval Users with smaller libraries have a lower change of getting updates frequently. "Power users" are actively hurting sources by updating frequently. --- app/build.gradle.kts | 2 +- app/src/main/java/eu/kanade/tachiyomi/Migrations.kt | 8 ++++++++ .../tachiyomi/ui/setting/SettingsLibraryController.kt | 7 ++----- app/src/main/res/values/strings.xml | 4 +--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cdd2f5c9f..f38093944 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -29,7 +29,7 @@ android { minSdk = AndroidConfig.minSdk targetSdk = AndroidConfig.targetSdk testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - versionCode = 70 + versionCode = 71 versionName = "0.12.3" buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"") diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index a68762fa8..fe4d13a51 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -235,6 +235,14 @@ object Migrations { preferences.enabledLanguages() += "all" } } + if (oldVersion < 71) { + // Handle removed every 3, 4, 6, and 8 hour library updates + val updateInterval = preferences.libraryUpdateInterval().get() + if (updateInterval in listOf(3, 4, 6, 8)) { + preferences.libraryUpdateInterval().set(12) + LibraryUpdateJob.setupTask(context, 12) + } + } return true } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index 6e4fd5c8c..a8e98b323 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -139,16 +139,13 @@ class SettingsLibraryController : SettingsController() { titleRes = R.string.pref_library_update_interval entriesRes = arrayOf( R.string.update_never, - R.string.update_3hour, - R.string.update_4hour, - R.string.update_6hour, - R.string.update_8hour, R.string.update_12hour, R.string.update_24hour, R.string.update_48hour, + R.string.update_72hour, R.string.update_weekly ) - entryValues = arrayOf("0", "3", "4", "6", "8", "12", "24", "48", "168") + entryValues = arrayOf("0", "12", "24", "48", "72", "168") defaultValue = "24" summary = "%s" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1ef9c7bb4..d87ecd186 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -211,13 +211,11 @@ Global update Update frequency Manual - Every 3 hours - Every 4 hours Every 6 hours - Every 8 hours Every 12 hours Daily Every 2 days + Every 3 days Weekly Update order Update restrictions From bfe7aa1ed21e1fd789db5a330dba51c622666377 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 18 Oct 2021 10:02:25 -0400 Subject: [PATCH 04/15] Minor cleanup --- .../kanade/tachiyomi/ui/setting/SettingsBrowseController.kt | 4 ++-- .../kanade/tachiyomi/ui/setting/SettingsSecurityController.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt index 0ce909d81..b927e6fbd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt @@ -58,8 +58,8 @@ class SettingsBrowseController : SettingsController() { if (context.isAuthenticationSupported() && activity != null) { requireAuthentication( activity as? FragmentActivity, - activity!!.getString(R.string.pref_category_nsfw_content), - activity!!.getString(R.string.confirm_lock_change), + context.getString(R.string.pref_category_nsfw_content), + context.getString(R.string.confirm_lock_change), ) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt index dcdaf4fb4..e0e5e4c39 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt @@ -31,8 +31,8 @@ class SettingsSecurityController : SettingsController() { defaultValue = false requireAuthentication( - context as? FragmentActivity, - context!!.getString(R.string.lock_with_biometrics), + activity as? FragmentActivity, + context.getString(R.string.lock_with_biometrics), context.getString(R.string.confirm_lock_change), ) } From f453236840dc3cb1599cf15dd8e362d8418e49f5 Mon Sep 17 00:00:00 2001 From: Platiplus Date: Mon, 18 Oct 2021 11:05:54 -0300 Subject: [PATCH 05/15] [6068] - Use semibold text for Browse items primary text (#6087) * Changing the text on source title (browse items) to semibold and fixing the color of the subtitle on global search * Updated history_item, updates_item and global_search to not have bold titles * Changing global_search_controller_card * Changing back history_item --- app/src/main/res/layout/global_search_controller_card.xml | 3 ++- app/src/main/res/layout/updates_item.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/global_search_controller_card.xml b/app/src/main/res/layout/global_search_controller_card.xml index 1ede433d3..a1794195d 100644 --- a/app/src/main/res/layout/global_search_controller_card.xml +++ b/app/src/main/res/layout/global_search_controller_card.xml @@ -17,7 +17,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="16dp" - android:textAppearance="?attr/textAppearanceSubtitle2" + android:textAppearance="?attr/textAppearanceBody2" app:layout_constraintBottom_toTopOf="@+id/subtitle" app:layout_constraintEnd_toStartOf="@+id/title_more_icon" app:layout_constraintStart_toStartOf="parent" @@ -34,6 +34,7 @@ android:textAppearance="?attr/textAppearanceBody2" android:textSize="12sp" android:visibility="gone" + android:textColor="?android:attr/textColorSecondary" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/title_more_icon" app:layout_constraintStart_toStartOf="parent" diff --git a/app/src/main/res/layout/updates_item.xml b/app/src/main/res/layout/updates_item.xml index 0064745b8..4547d16e2 100644 --- a/app/src/main/res/layout/updates_item.xml +++ b/app/src/main/res/layout/updates_item.xml @@ -29,7 +29,7 @@ android:layout_marginStart="16dp" android:ellipsize="end" android:maxLines="1" - android:textAppearance="?attr/textAppearanceSubtitle2" + android:textAppearance="?attr/textAppearanceBody2" app:layout_constraintBottom_toTopOf="@+id/chapter_title" app:layout_constraintEnd_toStartOf="@+id/download" app:layout_constraintStart_toEndOf="@+id/manga_cover" From 538dd60580f1b97993620b05d353db883e44b552 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 18 Oct 2021 10:46:07 -0400 Subject: [PATCH 06/15] Adjust update/download warnings - Uses toasts now - Adjusted wording to emphasize effect on sources - Download warning has a different threshold (15 chapters per source, vs. 60 entries per source for library update) --- .../tachiyomi/data/download/DownloadNotifier.kt | 2 +- .../kanade/tachiyomi/data/download/Downloader.kt | 15 +++++++++------ .../data/library/LibraryUpdateNotifier.kt | 14 -------------- .../data/library/LibraryUpdateService.kt | 8 +++++--- .../tachiyomi/data/notification/Notifications.kt | 1 - app/src/main/res/values/strings.xml | 3 ++- 6 files changed, 17 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt index d3c7b46a8..e73acf1f1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt @@ -187,7 +187,7 @@ internal class DownloadNotifier(private val context: Context) { */ fun onWarning(reason: String) { with(errorNotificationBuilder) { - setContentTitle(context.getString(R.string.label_warning)) + setContentTitle(context.getString(R.string.download_notifier_downloader_title)) setStyle(NotificationCompat.BigTextStyle().bigText(reason)) setSmallIcon(R.drawable.ic_warning_white_24dp) setAutoCancel(true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index 8cd520cbf..e58f386dd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.data.download import android.content.Context import android.webkit.MimeTypeMap +import android.widget.Toast import com.hippo.unifile.UniFile import com.jakewharton.rxrelay.BehaviorRelay import com.jakewharton.rxrelay.PublishRelay @@ -11,7 +12,6 @@ import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.download.model.DownloadQueue -import eu.kanade.tachiyomi.data.library.PER_SOURCE_QUEUE_WARNING_THRESHOLD import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.online.HttpSource @@ -24,6 +24,7 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.saveTo import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.system.logcat +import eu.kanade.tachiyomi.util.system.toast import kotlinx.coroutines.async import logcat.LogPriority import okhttp3.Response @@ -265,8 +266,8 @@ class Downloader( // Start downloader if needed if (autoStart && wasEmpty) { val maxDownloadsFromSource = queue.groupBy { it.source }.maxOf { it.value.size } - if (maxDownloadsFromSource > PER_SOURCE_QUEUE_WARNING_THRESHOLD) { - notifier.onWarning(context.getString(R.string.notification_size_warning)) + if (maxDownloadsFromSource > CHAPTERS_PER_SOURCE_QUEUE_WARNING_THRESHOLD) { + context.toast(R.string.download_queue_size_warning, Toast.LENGTH_LONG) } DownloadService.start(context) } @@ -506,8 +507,10 @@ class Downloader( companion object { const val TMP_DIR_SUFFIX = "_tmp" - - // Arbitrary minimum required space to start a download: 50 MB - const val MIN_DISK_SPACE = 50 * 1024 * 1024 } } + +private const val CHAPTERS_PER_SOURCE_QUEUE_WARNING_THRESHOLD = 15 + +// Arbitrary minimum required space to start a download: 50 MB +private const val MIN_DISK_SPACE = 50 * 1024 * 1024 diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt index bb8608f91..991ae3011 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt @@ -88,20 +88,6 @@ class LibraryUpdateNotifier(private val context: Context) { ) } - fun showQueueSizeWarningNotification() { - val notification = context.notificationBuilder(Notifications.CHANNEL_LIBRARY_PROGRESS) { - setContentTitle(context.getString(R.string.label_warning)) - setSmallIcon(R.drawable.ic_warning_white_24dp) - setStyle(NotificationCompat.BigTextStyle().bigText(context.getString(R.string.notification_size_warning))) - } - .build() - - context.notificationManager.notify( - Notifications.ID_LIBRARY_SIZE_WARNING, - notification, - ) - } - /** * Shows notification containing update entries that failed with action to open full log. * diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index 16ceb85d4..8540038b8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -5,6 +5,7 @@ import android.content.Context import android.content.Intent import android.os.IBinder import android.os.PowerManager +import android.widget.Toast import androidx.core.content.ContextCompat import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.cache.CoverCache @@ -38,6 +39,7 @@ import eu.kanade.tachiyomi.util.system.acquireWakeLock import eu.kanade.tachiyomi.util.system.createFileInCacheDir import eu.kanade.tachiyomi.util.system.isServiceRunning import eu.kanade.tachiyomi.util.system.logcat +import eu.kanade.tachiyomi.util.system.toast import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -267,8 +269,8 @@ class LibraryUpdateService( // Warn when excessively checking a single source val maxUpdatesFromSource = mangaToUpdate.groupBy { it.source }.maxOf { it.value.size } - if (maxUpdatesFromSource > PER_SOURCE_QUEUE_WARNING_THRESHOLD) { - notifier.showQueueSizeWarningNotification() + if (maxUpdatesFromSource > MANGA_PER_SOURCE_QUEUE_WARNING_THRESHOLD) { + toast(R.string.notification_size_warning, Toast.LENGTH_LONG) } } @@ -574,4 +576,4 @@ class LibraryUpdateService( } } -const val PER_SOURCE_QUEUE_WARNING_THRESHOLD = 60 +private const val MANGA_PER_SOURCE_QUEUE_WARNING_THRESHOLD = 60 diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt index 753701a7b..c6403a25c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt @@ -27,7 +27,6 @@ object Notifications { private const val GROUP_LIBRARY = "group_library" const val CHANNEL_LIBRARY_PROGRESS = "library_progress_channel" const val ID_LIBRARY_PROGRESS = -101 - const val ID_LIBRARY_SIZE_WARNING = -103 const val CHANNEL_LIBRARY_ERROR = "library_errors_channel" const val ID_LIBRARY_ERROR = -102 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d87ecd186..5e8d7c8cb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -701,11 +701,12 @@ Couldn\'t download chapters. You can try again in the downloads section Couldn\'t download chapters due to low storage space + Warning: large bulk downloads may lead to sources becoming slower and/or blocking Tachiyomi Checking for new chapters Updating library… (%1$d/%2$d) - Large updates may lead to increased battery usage and sources becoming slower + Warning: large updates harm sources and may lead to slower updates and also increased battery usage New chapters found For 1 title From bf1b7f44b641686b012e1d28ca46ed222162df87 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 18 Oct 2021 11:03:27 -0400 Subject: [PATCH 07/15] Change tablet UI threshold to w720dp (closes #6054) Was previously sw720dp. Now matches J2K. --- .../tachiyomi/util/system/ContextExtensions.kt | 12 ++++++------ .../main_activity.xml | 0 .../manga_controller.xml | 0 .../manga_info_header.xml | 0 4 files changed, 6 insertions(+), 6 deletions(-) rename app/src/main/res/{layout-sw720dp => layout-w720dp}/main_activity.xml (100%) rename app/src/main/res/{layout-sw720dp => layout-w720dp}/manga_controller.xml (100%) rename app/src/main/res/{layout-sw720dp => layout-w720dp}/manga_info_header.xml (100%) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt index f02bef0e1..b97e2f6b6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt @@ -307,10 +307,10 @@ fun Context.createFileInCacheDir(name: String): File { } /** - * We consider anything with a width of >= 720dp as a tablet, i.e. with layouts in layout-sw720dp. + * We consider anything with a width of >= 720dp as a tablet, i.e. with layouts in layout-w720dp. */ fun Context.isTablet(): Boolean { - return resources.configuration.smallestScreenWidthDp >= TABLET_UI_MIN_SCREEN_WIDTH_DP + return resources.configuration.screenWidthDp >= TABLET_UI_MIN_SCREEN_WIDTH_DP } fun Context.prepareTabletUiContext(): Context { @@ -320,13 +320,13 @@ fun Context.prepareTabletUiContext(): Context { PreferenceValues.TabletUiMode.LANDSCAPE -> configuration.orientation == Configuration.ORIENTATION_LANDSCAPE PreferenceValues.TabletUiMode.NEVER -> false } - if (configuration.smallestScreenWidthDp >= TABLET_UI_MIN_SCREEN_WIDTH_DP != expected) { + if (configuration.screenWidthDp >= TABLET_UI_MIN_SCREEN_WIDTH_DP != expected) { val overrideConf = Configuration() overrideConf.setTo(configuration) - overrideConf.smallestScreenWidthDp = if (expected) { - overrideConf.smallestScreenWidthDp.coerceAtLeast(TABLET_UI_MIN_SCREEN_WIDTH_DP) + overrideConf.screenWidthDp = if (expected) { + overrideConf.screenWidthDp.coerceAtLeast(TABLET_UI_MIN_SCREEN_WIDTH_DP) } else { - overrideConf.smallestScreenWidthDp.coerceAtMost(TABLET_UI_MIN_SCREEN_WIDTH_DP - 1) + overrideConf.screenWidthDp.coerceAtMost(TABLET_UI_MIN_SCREEN_WIDTH_DP - 1) } return createConfigurationContext(overrideConf) } diff --git a/app/src/main/res/layout-sw720dp/main_activity.xml b/app/src/main/res/layout-w720dp/main_activity.xml similarity index 100% rename from app/src/main/res/layout-sw720dp/main_activity.xml rename to app/src/main/res/layout-w720dp/main_activity.xml diff --git a/app/src/main/res/layout-sw720dp/manga_controller.xml b/app/src/main/res/layout-w720dp/manga_controller.xml similarity index 100% rename from app/src/main/res/layout-sw720dp/manga_controller.xml rename to app/src/main/res/layout-w720dp/manga_controller.xml diff --git a/app/src/main/res/layout-sw720dp/manga_info_header.xml b/app/src/main/res/layout-w720dp/manga_info_header.xml similarity index 100% rename from app/src/main/res/layout-sw720dp/manga_info_header.xml rename to app/src/main/res/layout-w720dp/manga_info_header.xml From 5b3bd3f47001de32c42babbb3bc2dcba73f6cbff Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 18 Oct 2021 12:39:41 -0400 Subject: [PATCH 08/15] Remove jcenter usage (closes #4387) --- app/build.gradle.kts | 4 ++-- build.gradle.kts | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f38093944..ee8296dd4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -231,8 +231,8 @@ dependencies { // UI libraries implementation("com.google.android.material:material:1.5.0-alpha04") implementation("com.github.dmytrodanylyk.android-process-button:library:1.0.4") - implementation("eu.davidea:flexible-adapter:5.1.0") - implementation("eu.davidea:flexible-adapter-ui:1.0.0") + implementation("com.github.arkon.FlexibleAdapter:flexible-adapter:c8013533") + implementation("com.github.arkon.FlexibleAdapter:flexible-adapter-ui:c8013533") implementation("com.nightlynexus.viewstatepageradapter:viewstatepageradapter:1.1.0") implementation("com.github.chrisbanes:PhotoView:2.3.0") implementation("com.github.tachiyomiorg:DirectionalViewPager:1.0.0") { diff --git a/build.gradle.kts b/build.gradle.kts index 634a4fb04..c5607aa82 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,6 @@ allprojects { mavenCentral() google() maven { setUrl("https://www.jitpack.io") } - jcenter() } } From ccd7c8df53a6d14af44b3973aa5f68fafb5fd591 Mon Sep 17 00:00:00 2001 From: Midyan Hamdoun Date: Thu, 21 Oct 2021 03:10:55 +0300 Subject: [PATCH 09/15] Fix double increment when updating covers (#6138) * Fix double increment when updating covers * Remove redundant block --- .../kanade/tachiyomi/data/library/LibraryUpdateService.kt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index 8540038b8..8acc0d4c5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -445,14 +445,6 @@ class LibraryUpdateService( logcat(LogPriority.ERROR, e) } } - - currentlyUpdatingManga.remove(manga) - progressCount.andIncrement - notifier.showProgressNotification( - currentlyUpdatingManga, - progressCount.get(), - mangaToUpdate.size - ) } } } From 7cd54dc8f0e541f41bec1a8662f0f2a691257b6f Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 23 Oct 2021 17:05:22 -0400 Subject: [PATCH 10/15] Launch the download warning toast in the UI thread Co-authored-by: jobobby04 --- .../java/eu/kanade/tachiyomi/data/download/Downloader.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index e58f386dd..7a75e633b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.util.lang.RetryWithDelay import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchNow import eu.kanade.tachiyomi.util.lang.plusAssign +import eu.kanade.tachiyomi.util.lang.withUIContext import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.saveTo import eu.kanade.tachiyomi.util.system.ImageUtil @@ -267,7 +268,9 @@ class Downloader( if (autoStart && wasEmpty) { val maxDownloadsFromSource = queue.groupBy { it.source }.maxOf { it.value.size } if (maxDownloadsFromSource > CHAPTERS_PER_SOURCE_QUEUE_WARNING_THRESHOLD) { - context.toast(R.string.download_queue_size_warning, Toast.LENGTH_LONG) + withUIContext { + context.toast(R.string.download_queue_size_warning, Toast.LENGTH_LONG) + } } DownloadService.start(context) } From 93e2b88d41143b7485172a29bb40b7ed5478a0ac Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 23 Oct 2021 17:29:13 -0400 Subject: [PATCH 11/15] Minor cleanup --- .../data/updater/AppUpdateChecker.kt | 24 +++++---- .../extension/api/ExtensionGithubApi.kt | 6 +++ .../ui/base/controller/ConductorExtensions.kt | 4 ++ .../kanade/tachiyomi/ui/main/MainActivity.kt | 54 +++++++------------ 4 files changed, 43 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt index 37488a753..2e638fcc7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt @@ -10,24 +10,22 @@ import eu.kanade.tachiyomi.network.parseAs import eu.kanade.tachiyomi.util.lang.withIOContext import uy.kohesive.injekt.injectLazy import java.util.Date +import java.util.concurrent.TimeUnit class AppUpdateChecker { private val networkService: NetworkHelper by injectLazy() private val preferences: PreferencesHelper by injectLazy() - private val repo: String by lazy { - if (BuildConfig.PREVIEW) { - "tachiyomiorg/tachiyomi-preview" - } else { - "tachiyomiorg/tachiyomi" - } - } - suspend fun checkForUpdate(context: Context): AppUpdateResult { + // Limit checks to once a day at most + if (Date().time < preferences.lastAppCheck().get() + TimeUnit.DAYS.toMillis(1)) { + return AppUpdateResult.NoNewUpdate + } + return withIOContext { val result = networkService.client - .newCall(GET("https://api.github.com/repos/$repo/releases/latest")) + .newCall(GET("https://api.github.com/repos/$GITHUB_REPO/releases/latest")) .await() .parseAs() .let { @@ -64,3 +62,11 @@ class AppUpdateChecker { } } } + +val GITHUB_REPO: String by lazy { + if (BuildConfig.PREVIEW) { + "tachiyomiorg/tachiyomi-preview" + } else { + "tachiyomiorg/tachiyomi" + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt index d712a564d..308b3782d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt @@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.util.lang.withIOContext import kotlinx.serialization.Serializable import uy.kohesive.injekt.injectLazy import java.util.Date +import java.util.concurrent.TimeUnit internal class ExtensionGithubApi { @@ -30,6 +31,11 @@ internal class ExtensionGithubApi { } suspend fun checkForUpdates(context: Context): List { + // Limit checks to once a day at most + if (Date().time < preferences.lastExtCheck().get() + TimeUnit.DAYS.toMillis(1)) { + return emptyList() + } + val extensions = findExtensions() preferences.lastExtCheck().set(Date().time) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt index d225bec56..bc7ef0b6f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt @@ -9,6 +9,10 @@ import com.bluelinelabs.conductor.RouterTransaction import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.util.system.openInBrowser +fun Router.setRoot(controller: Controller, id: Int) { + setRoot(controller.withFadeTransaction().tag(id.toString())) +} + fun Router.popControllerWithTag(tag: String): Boolean { val controller = getControllerWithTag(tag) if (controller != null) { 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 19d9e2126..70e5e83db 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 @@ -45,6 +45,7 @@ import eu.kanade.tachiyomi.ui.base.controller.FabController import eu.kanade.tachiyomi.ui.base.controller.NoAppBarElevationController import eu.kanade.tachiyomi.ui.base.controller.RootController import eu.kanade.tachiyomi.ui.base.controller.TabbedController +import eu.kanade.tachiyomi.ui.base.controller.setRoot import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.browse.BrowseController import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController @@ -69,8 +70,6 @@ import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import logcat.LogPriority -import java.util.Date -import java.util.concurrent.TimeUnit class MainActivity : BaseViewBindingActivity() { @@ -153,11 +152,11 @@ class MainActivity : BaseViewBindingActivity() { val currentRoot = router.backstack.firstOrNull() if (currentRoot?.tag()?.toIntOrNull() != id) { when (id) { - R.id.nav_library -> setRoot(LibraryController(), id) - R.id.nav_updates -> setRoot(UpdatesController(), id) - R.id.nav_history -> setRoot(HistoryController(), id) - R.id.nav_browse -> setRoot(BrowseController(), id) - R.id.nav_more -> setRoot(MoreController(), id) + R.id.nav_library -> router.setRoot(LibraryController(), id) + R.id.nav_updates -> router.setRoot(UpdatesController(), id) + R.id.nav_history -> router.setRoot(HistoryController(), id) + R.id.nav_browse -> router.setRoot(BrowseController(), id) + R.id.nav_more -> router.setRoot(MoreController(), id) } } else if (!isHandlingShortcut) { when (id) { @@ -322,37 +321,24 @@ class MainActivity : BaseViewBindingActivity() { override fun onResume() { super.onResume() - checkForExtensionUpdates() - if (BuildConfig.INCLUDE_UPDATER) { - checkForAppUpdates() - } + checkForUpdates() } - private fun checkForAppUpdates() { - // Limit checks to once a day at most - if (Date().time < preferences.lastAppCheck().get() + TimeUnit.DAYS.toMillis(1)) { - return - } - + private fun checkForUpdates() { lifecycleScope.launchIO { - try { - val result = AppUpdateChecker().checkForUpdate(this@MainActivity) - if (result is AppUpdateResult.NewUpdate) { - NewUpdateDialogController(result).showDialog(router) + // App updates + if (BuildConfig.INCLUDE_UPDATER) { + try { + val result = AppUpdateChecker().checkForUpdate(this@MainActivity) + if (result is AppUpdateResult.NewUpdate) { + NewUpdateDialogController(result).showDialog(router) + } + } catch (e: Exception) { + logcat(LogPriority.ERROR, e) } - } catch (e: Exception) { - logcat(LogPriority.ERROR, e) } - } - } - private fun checkForExtensionUpdates() { - // Limit checks to once a day at most - if (Date().time < preferences.lastExtCheck().get() + TimeUnit.DAYS.toMillis(1)) { - return - } - - lifecycleScope.launchIO { + // Extension updates try { val pendingUpdates = ExtensionGithubApi().checkForUpdates(this@MainActivity) preferences.extensionUpdatesCount().set(pendingUpdates.size) @@ -502,10 +488,6 @@ class MainActivity : BaseViewBindingActivity() { } } - private fun setRoot(controller: Controller, id: Int) { - router.setRoot(controller.withFadeTransaction().tag(id.toString())) - } - private fun syncActivityViewWithController(to: Controller?, from: Controller? = null, isPush: Boolean = true) { if (from is DialogController || to is DialogController) { return From 22ed163c8f97136f3b7679ae48adba7e6b7c727c Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 23 Oct 2021 17:29:27 -0400 Subject: [PATCH 12/15] Fix what's new link in dialog --- .../kanade/tachiyomi/data/updater/AppUpdateChecker.kt | 10 ++++++++++ .../tachiyomi/ui/main/WhatsNewDialogController.kt | 3 ++- .../eu/kanade/tachiyomi/ui/more/AboutController.kt | 8 ++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt index 2e638fcc7..7a202a9ea 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt @@ -70,3 +70,13 @@ val GITHUB_REPO: String by lazy { "tachiyomiorg/tachiyomi" } } + +val RELEASE_TAG: String by lazy { + if (BuildConfig.PREVIEW) { + "r${BuildConfig.COMMIT_COUNT}" + } else { + "v${BuildConfig.VERSION_NAME}" + } +} + +val RELEASE_URL = "https://github.com/$GITHUB_REPO/releases/tag/$RELEASE_TAG" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/WhatsNewDialogController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/WhatsNewDialogController.kt index 9cedc6c2c..f69eb34c9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/WhatsNewDialogController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/WhatsNewDialogController.kt @@ -5,6 +5,7 @@ import android.os.Bundle import com.google.android.material.dialog.MaterialAlertDialogBuilder import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.data.updater.RELEASE_URL import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.openInBrowser @@ -16,7 +17,7 @@ class WhatsNewDialogController(bundle: Bundle? = null) : DialogController(bundle .setTitle(activity!!.getString(R.string.updated_version, BuildConfig.VERSION_NAME)) .setPositiveButton(android.R.string.ok, null) .setNeutralButton(R.string.whats_new) { _, _ -> - openInBrowser("https://github.com/tachiyomiorg/tachiyomi/releases/tag/v${BuildConfig.VERSION_NAME}") + openInBrowser(RELEASE_URL) } .create() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt index 162cb90d4..81794456a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt @@ -5,6 +5,7 @@ import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.updater.AppUpdateChecker import eu.kanade.tachiyomi.data.updater.AppUpdateResult +import eu.kanade.tachiyomi.data.updater.RELEASE_URL import eu.kanade.tachiyomi.ui.base.controller.NoAppBarElevationController import eu.kanade.tachiyomi.ui.base.controller.openInBrowser import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction @@ -73,12 +74,7 @@ class AboutController : SettingsController(), NoAppBarElevationController { titleRes = R.string.whats_new onClick { - val url = if (BuildConfig.PREVIEW) { - "https://github.com/tachiyomiorg/tachiyomi-preview/releases/tag/r${BuildConfig.COMMIT_COUNT}" - } else { - "https://github.com/tachiyomiorg/tachiyomi/releases/tag/v${BuildConfig.VERSION_NAME}" - } - openInBrowser(url) + openInBrowser(RELEASE_URL) } } } From 593091a5e304eff771604ff2a91cdc0c886c4d68 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 23 Oct 2021 17:30:56 -0400 Subject: [PATCH 13/15] Sync view state with controller on activity resume Hopefully fixes some weird states where the bottom nav shows up when it shouldn't. --- .../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 70e5e83db..07ce03a59 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 @@ -215,7 +215,7 @@ class MainActivity : BaseViewBindingActivity() { } ) - syncActivityViewWithController(router.backstack.lastOrNull()?.controller) + syncActivityViewWithController() if (savedInstanceState == null) { // Reset Incognito Mode on relaunch @@ -320,6 +320,7 @@ class MainActivity : BaseViewBindingActivity() { override fun onResume() { super.onResume() + syncActivityViewWithController() checkForUpdates() } @@ -488,7 +489,11 @@ class MainActivity : BaseViewBindingActivity() { } } - private fun syncActivityViewWithController(to: Controller?, from: Controller? = null, isPush: Boolean = true) { + private fun syncActivityViewWithController( + to: Controller? = router.backstack.lastOrNull()?.controller, + from: Controller? = null, + isPush: Boolean = true, + ) { if (from is DialogController || to is DialogController) { return } From 6129519e5a0a2cf88ce5c3faebcc69f9807565c3 Mon Sep 17 00:00:00 2001 From: Soitora Date: Sun, 24 Oct 2021 16:21:13 +0200 Subject: [PATCH 14/15] More sensical string for 'pref_hide_threshold' (#6157) --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5e8d7c8cb..708b1dd83 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -374,7 +374,7 @@ 15% 20% 25% - Auto hide menu on scroll sensitivity + Sensitivity for hiding menu on scroll Highest High Low From 8f00d34b0b3a5dc30f12ff5a22fd242ade84defe Mon Sep 17 00:00:00 2001 From: Andreas Date: Thu, 28 Oct 2021 05:33:36 +0200 Subject: [PATCH 15/15] Change zoom from 3x to 5x (#6164) Because some people actually read images with really small text *I hope they have some extreme high quality pictures else I don't know how they read the raster images* --- .../kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt index 8806bd09e..975505f45 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt @@ -141,7 +141,7 @@ open class ReaderPageImageView @JvmOverloads constructor( setOnImageEventListener( object : SubsamplingScaleImageView.DefaultOnImageEventListener() { override fun onReady() { - // 3x zoom + // 5x zoom maxScale = scale * MAX_ZOOM_SCALE setDoubleTapZoomScale(scale * 2) @@ -261,4 +261,4 @@ open class ReaderPageImageView @JvmOverloads constructor( } } -private const val MAX_ZOOM_SCALE = 3F +private const val MAX_ZOOM_SCALE = 5F