From 3407e74e99616cb6e6efed64d6c8009b7e57a30d Mon Sep 17 00:00:00 2001 From: Zakhar Timoshenko Date: Wed, 4 May 2022 23:00:44 +0300 Subject: [PATCH 01/10] Fix `FavouriteCategoriesDialog` toolbar in album orientation --- app/src/main/res/layout/dialog_favorite_categories.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/dialog_favorite_categories.xml b/app/src/main/res/layout/dialog_favorite_categories.xml index 2085c72f7..0acdd440e 100644 --- a/app/src/main/res/layout/dialog_favorite_categories.xml +++ b/app/src/main/res/layout/dialog_favorite_categories.xml @@ -10,7 +10,7 @@ From 9166716f2a693d60ebd1bf921732fbaf48268de8 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Thu, 5 May 2022 15:21:10 +0300 Subject: [PATCH 02/10] Update version --- app/build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ff599eb34..b04edbd11 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,8 +14,8 @@ android { applicationId 'org.koitharu.kotatsu' minSdkVersion 21 targetSdkVersion 32 - versionCode 405 - versionName '3.2.1' + versionCode 406 + versionName '3.2.2' generatedDensities = [] testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -86,7 +86,7 @@ dependencies { implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01' implementation 'androidx.preference:preference-ktx:1.2.0' implementation 'androidx.work:work-runtime-ktx:2.7.1' - implementation 'com.google.android.material:material:1.6.0-rc01' + implementation 'com.google.android.material:material:1.6.0' //noinspection LifecycleAnnotationProcessorWithJava8 kapt 'androidx.lifecycle:lifecycle-compiler:2.4.1' @@ -105,7 +105,7 @@ dependencies { implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0' implementation 'com.github.solkin:disk-lru-cache:1.4' - debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1' + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1' testImplementation 'junit:junit:4.13.2' testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1' From c695468aeca80029b0147902bd926613e313fccd Mon Sep 17 00:00:00 2001 From: Koitharu Date: Thu, 5 May 2022 15:43:07 +0300 Subject: [PATCH 03/10] Fix cold launch --- .../koitharu/kotatsu/main/ui/MainActivity.kt | 20 ++++----- .../kotatsu/settings/AppUpdateChecker.kt | 43 +++++++++---------- .../settings/onboard/OnboardDialogFragment.kt | 6 ++- .../settings/onboard/OnboardViewModel.kt | 3 +- 4 files changed, 35 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/org/koitharu/kotatsu/main/ui/MainActivity.kt b/app/src/main/java/org/koitharu/kotatsu/main/ui/MainActivity.kt index 24805aa84..0e8c85fb9 100644 --- a/app/src/main/java/org/koitharu/kotatsu/main/ui/MainActivity.kt +++ b/app/src/main/java/org/koitharu/kotatsu/main/ui/MainActivity.kt @@ -22,7 +22,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.navigation.NavigationView import com.google.android.material.snackbar.Snackbar import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.koin.android.ext.android.get import org.koin.androidx.viewmodel.ext.android.viewModel @@ -385,20 +384,19 @@ class MainActivity : } private fun onFirstStart() { - lifecycleScope.launch(Dispatchers.Default) { - TrackWorker.setup(applicationContext) - SuggestionsWorker.setup(applicationContext) - if (AppUpdateChecker.isUpdateSupported(this@MainActivity)) { + lifecycleScope.launchWhenResumed { + val isUpdateSupported = withContext(Dispatchers.Default) { + TrackWorker.setup(applicationContext) + SuggestionsWorker.setup(applicationContext) + AppUpdateChecker.isUpdateSupported(this@MainActivity) + } + if (isUpdateSupported) { AppUpdateChecker(this@MainActivity).checkIfNeeded() } val settings = get() when { - !settings.isSourcesSelected -> withContext(Dispatchers.Main) { - OnboardDialogFragment.showWelcome(supportFragmentManager) - } - settings.newSources.isNotEmpty() -> withContext(Dispatchers.Main) { - NewSourcesDialogFragment.show(supportFragmentManager) - } + !settings.isSourcesSelected -> OnboardDialogFragment.showWelcome(supportFragmentManager) + settings.newSources.isNotEmpty() -> NewSourcesDialogFragment.show(supportFragmentManager) } } } diff --git a/app/src/main/java/org/koitharu/kotatsu/settings/AppUpdateChecker.kt b/app/src/main/java/org/koitharu/kotatsu/settings/AppUpdateChecker.kt index 12d7f21ce..5b7bc661e 100644 --- a/app/src/main/java/org/koitharu/kotatsu/settings/AppUpdateChecker.kt +++ b/app/src/main/java/org/koitharu/kotatsu/settings/AppUpdateChecker.kt @@ -8,6 +8,15 @@ import android.net.Uri import androidx.activity.ComponentActivity import androidx.annotation.MainThread import com.google.android.material.dialog.MaterialAlertDialogBuilder +import java.io.ByteArrayInputStream +import java.io.InputStream +import java.security.MessageDigest +import java.security.NoSuchAlgorithmException +import java.security.cert.CertificateEncodingException +import java.security.cert.CertificateException +import java.security.cert.CertificateFactory +import java.security.cert.X509Certificate +import java.util.concurrent.TimeUnit import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.koin.android.ext.android.get @@ -19,15 +28,6 @@ import org.koitharu.kotatsu.core.github.VersionId import org.koitharu.kotatsu.core.prefs.AppSettings import org.koitharu.kotatsu.parsers.util.byte2HexFormatted import org.koitharu.kotatsu.utils.FileSize -import java.io.ByteArrayInputStream -import java.io.InputStream -import java.security.MessageDigest -import java.security.NoSuchAlgorithmException -import java.security.cert.CertificateEncodingException -import java.security.cert.CertificateException -import java.security.cert.CertificateFactory -import java.security.cert.X509Certificate -import java.util.concurrent.TimeUnit class AppUpdateChecker(private val activity: ComponentActivity) { @@ -61,25 +61,22 @@ class AppUpdateChecker(private val activity: ComponentActivity) { @MainThread private fun showUpdateDialog(version: AppVersion) { + val message = buildString { + append(activity.getString(R.string.new_version_s, version.name)) + appendLine() + append(activity.getString(R.string.size_s, FileSize.BYTES.format(activity, version.apkSize))) + appendLine() + appendLine() + append(version.description) + } MaterialAlertDialogBuilder(activity) .setTitle(R.string.app_update_available) - .setMessage(buildString { - append(activity.getString(R.string.new_version_s, version.name)) - appendLine() - append( - activity.getString( - R.string.size_s, - FileSize.BYTES.format(activity, version.apkSize), - ) - ) - appendLine() - appendLine() - append(version.description) - }) + .setMessage(message) .setPositiveButton(R.string.download) { _, _ -> activity.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(version.apkUrl))) } .setNegativeButton(R.string.close, null) + .setCancelable(false) .create() .show() } @@ -128,4 +125,4 @@ class AppUpdateChecker(private val activity: ComponentActivity) { } } } -} +} \ No newline at end of file diff --git a/app/src/main/java/org/koitharu/kotatsu/settings/onboard/OnboardDialogFragment.kt b/app/src/main/java/org/koitharu/kotatsu/settings/onboard/OnboardDialogFragment.kt index 92fee1db9..4f695b154 100644 --- a/app/src/main/java/org/koitharu/kotatsu/settings/onboard/OnboardDialogFragment.kt +++ b/app/src/main/java/org/koitharu/kotatsu/settings/onboard/OnboardDialogFragment.kt @@ -18,8 +18,10 @@ import org.koitharu.kotatsu.utils.ext.observeNotNull import org.koitharu.kotatsu.utils.ext.showAllowStateLoss import org.koitharu.kotatsu.utils.ext.withArgs -class OnboardDialogFragment : AlertDialogFragment(), - OnListItemClickListener, DialogInterface.OnClickListener { +class OnboardDialogFragment : + AlertDialogFragment(), + OnListItemClickListener, + DialogInterface.OnClickListener { private val viewModel by viewModel() private var isWelcome: Boolean = false diff --git a/app/src/main/java/org/koitharu/kotatsu/settings/onboard/OnboardViewModel.kt b/app/src/main/java/org/koitharu/kotatsu/settings/onboard/OnboardViewModel.kt index f2a929017..2f1495243 100644 --- a/app/src/main/java/org/koitharu/kotatsu/settings/onboard/OnboardViewModel.kt +++ b/app/src/main/java/org/koitharu/kotatsu/settings/onboard/OnboardViewModel.kt @@ -3,7 +3,6 @@ package org.koitharu.kotatsu.settings.onboard import androidx.collection.ArraySet import androidx.core.os.LocaleListCompat import androidx.lifecycle.MutableLiveData -import java.util.* import org.koitharu.kotatsu.base.ui.BaseViewModel import org.koitharu.kotatsu.core.prefs.AppSettings import org.koitharu.kotatsu.parsers.model.MangaSource @@ -12,6 +11,7 @@ import org.koitharu.kotatsu.parsers.util.toTitleCase import org.koitharu.kotatsu.settings.onboard.model.SourceLocale import org.koitharu.kotatsu.utils.ext.map import org.koitharu.kotatsu.utils.ext.mapToSet +import java.util.* class OnboardViewModel( private val settings: AppSettings, @@ -55,6 +55,7 @@ class OnboardViewModel( settings.hiddenSources = allSources.filterNot { x -> x.locale in selectedLocales }.mapToSet { x -> x.name } + settings.markKnownSources(settings.newSources) } private fun rebuildList() { From fdd4f5abcaee4d2a420550d4bc18b71ead5f5105 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Thu, 5 May 2022 15:51:30 +0300 Subject: [PATCH 04/10] Fix bottom sheet navbar color --- app/src/main/res/values-v27/styles.xml | 7 +++++++ app/src/main/res/values/styles.xml | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/values-v27/styles.xml diff --git a/app/src/main/res/values-v27/styles.xml b/app/src/main/res/values-v27/styles.xml new file mode 100644 index 000000000..0f361cb7f --- /dev/null +++ b/app/src/main/res/values-v27/styles.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 2333f5d68..772a54b02 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -23,7 +23,6 @@ From 23e7aa2aaa80ac848837a4fb0b7d4f3a5d9929e6 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Thu, 5 May 2022 15:57:05 +0300 Subject: [PATCH 05/10] Fix images scale type --- .../org/koitharu/kotatsu/list/ui/adapter/MangaGridItemAD.kt | 2 ++ .../koitharu/kotatsu/list/ui/adapter/MangaListDetailedItemAD.kt | 2 ++ .../org/koitharu/kotatsu/list/ui/adapter/MangaListItemAD.kt | 2 ++ .../java/org/koitharu/kotatsu/tracker/ui/adapter/FeedItemAD.kt | 2 ++ 4 files changed, 8 insertions(+) diff --git a/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaGridItemAD.kt b/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaGridItemAD.kt index ced1697b0..c7196e37c 100644 --- a/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaGridItemAD.kt +++ b/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaGridItemAD.kt @@ -3,6 +3,7 @@ package org.koitharu.kotatsu.list.ui.adapter import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import coil.request.Disposable +import coil.size.Scale import coil.util.CoilUtils import com.google.android.material.badge.BadgeDrawable import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding @@ -43,6 +44,7 @@ fun mangaGridItemAD( .fallback(R.drawable.ic_placeholder) .error(R.drawable.ic_placeholder) .allowRgb565(true) + .scale(Scale.FILL) .lifecycle(lifecycleOwner) .enqueueWith(coil) badge = itemView.bindBadge(badge, item.counter) diff --git a/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListDetailedItemAD.kt b/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListDetailedItemAD.kt index 10e9a473d..b265c0442 100644 --- a/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListDetailedItemAD.kt +++ b/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListDetailedItemAD.kt @@ -3,6 +3,7 @@ package org.koitharu.kotatsu.list.ui.adapter import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import coil.request.Disposable +import coil.size.Scale import coil.util.CoilUtils import com.google.android.material.badge.BadgeDrawable import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding @@ -44,6 +45,7 @@ fun mangaListDetailedItemAD( .placeholder(R.drawable.ic_placeholder) .fallback(R.drawable.ic_placeholder) .error(R.drawable.ic_placeholder) + .scale(Scale.FILL) .allowRgb565(true) .lifecycle(lifecycleOwner) .enqueueWith(coil) diff --git a/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListItemAD.kt b/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListItemAD.kt index 18696de6b..19dc24779 100644 --- a/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListItemAD.kt +++ b/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListItemAD.kt @@ -3,6 +3,7 @@ package org.koitharu.kotatsu.list.ui.adapter import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import coil.request.Disposable +import coil.size.Scale import coil.util.CoilUtils import com.google.android.material.badge.BadgeDrawable import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding @@ -44,6 +45,7 @@ fun mangaListItemAD( .placeholder(R.drawable.ic_placeholder) .fallback(R.drawable.ic_placeholder) .error(R.drawable.ic_placeholder) + .scale(Scale.FILL) .allowRgb565(true) .lifecycle(lifecycleOwner) .enqueueWith(coil) diff --git a/app/src/main/java/org/koitharu/kotatsu/tracker/ui/adapter/FeedItemAD.kt b/app/src/main/java/org/koitharu/kotatsu/tracker/ui/adapter/FeedItemAD.kt index 74e5468b9..000ff5399 100644 --- a/app/src/main/java/org/koitharu/kotatsu/tracker/ui/adapter/FeedItemAD.kt +++ b/app/src/main/java/org/koitharu/kotatsu/tracker/ui/adapter/FeedItemAD.kt @@ -3,6 +3,7 @@ package org.koitharu.kotatsu.tracker.ui.adapter import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import coil.request.Disposable +import coil.size.Scale import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding import org.koitharu.kotatsu.R import org.koitharu.kotatsu.base.ui.list.OnListItemClickListener @@ -34,6 +35,7 @@ fun feedItemAD( .fallback(R.drawable.ic_placeholder) .error(R.drawable.ic_placeholder) .allowRgb565(true) + .scale(Scale.FILL) .lifecycle(lifecycleOwner) .enqueueWith(coil) binding.textViewTitle.text = item.title From b759f8d0a0ac02e75c65d9acda031c6c4e3616a1 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Thu, 5 May 2022 16:46:44 +0300 Subject: [PATCH 06/10] Fix pages filename #151 --- .../kotatsu/base/domain/MangaUtils.kt | 9 ++++ .../kotatsu/reader/ui/PageSaveHelper.kt | 47 +++++++++++++------ 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/koitharu/kotatsu/base/domain/MangaUtils.kt b/app/src/main/java/org/koitharu/kotatsu/base/domain/MangaUtils.kt index 09a970eee..03b0dd53b 100644 --- a/app/src/main/java/org/koitharu/kotatsu/base/domain/MangaUtils.kt +++ b/app/src/main/java/org/koitharu/kotatsu/base/domain/MangaUtils.kt @@ -15,6 +15,7 @@ import org.koitharu.kotatsu.core.parser.MangaRepository import org.koitharu.kotatsu.parsers.model.MangaPage import org.koitharu.kotatsu.parsers.util.await import org.koitharu.kotatsu.parsers.util.medianOrNull +import java.io.File import java.io.InputStream import java.util.zip.ZipFile @@ -59,6 +60,14 @@ object MangaUtils : KoinComponent { } } + suspend fun getImageMimeType(file: File): String? = runInterruptible(Dispatchers.IO) { + val options = BitmapFactory.Options().apply { + inJustDecodeBounds = true + } + BitmapFactory.decodeFile(file.path, options)?.recycle() + options.outMimeType + } + private fun getBitmapSize(input: InputStream?): Size { val options = BitmapFactory.Options().apply { inJustDecodeBounds = true diff --git a/app/src/main/java/org/koitharu/kotatsu/reader/ui/PageSaveHelper.kt b/app/src/main/java/org/koitharu/kotatsu/reader/ui/PageSaveHelper.kt index a2d8f7ac5..3e19c7036 100644 --- a/app/src/main/java/org/koitharu/kotatsu/reader/ui/PageSaveHelper.kt +++ b/app/src/main/java/org/koitharu/kotatsu/reader/ui/PageSaveHelper.kt @@ -2,19 +2,26 @@ package org.koitharu.kotatsu.reader.ui import android.content.Context import android.net.Uri +import android.webkit.MimeTypeMap import androidx.activity.result.ActivityResultLauncher import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runInterruptible import kotlinx.coroutines.suspendCancellableCoroutine +import kotlinx.coroutines.withContext import okhttp3.HttpUrl.Companion.toHttpUrl import okio.IOException +import org.koitharu.kotatsu.base.domain.MangaUtils import org.koitharu.kotatsu.local.data.PagesCache import org.koitharu.kotatsu.parsers.model.MangaPage +import org.koitharu.kotatsu.parsers.util.toFileNameSafe import org.koitharu.kotatsu.reader.domain.PageLoader +import java.io.File import kotlin.coroutines.Continuation -import kotlin.coroutines.coroutineContext import kotlin.coroutines.resume +private const val MAX_FILENAME_LENGTH = 10 +private const val EXTENSION_FALLBACK = "png" + class PageSaveHelper( private val cache: PagesCache, context: Context, @@ -28,22 +35,17 @@ class PageSaveHelper( page: MangaPage, saveLauncher: ActivityResultLauncher, ): Uri { - var pageFile = cache[page.url] - var fileName = pageFile?.name - if (fileName == null) { - fileName = pageLoader.getPageUrl(page).toHttpUrl().pathSegments.last() - } - val cc = coroutineContext - val destination = suspendCancellableCoroutine { cont -> - continuation = cont - Dispatchers.Main.dispatch(cc) { - saveLauncher.launch(fileName) + val pageUrl = pageLoader.getPageUrl(page) + val pageFile = pageLoader.loadPage(page, force = false) + val proposedName = getProposedFileName(pageUrl, pageFile) + val destination = withContext(Dispatchers.Main) { + suspendCancellableCoroutine { cont -> + continuation = cont + saveLauncher.launch(proposedName) + }.also { + continuation = null } } - continuation = null - if (pageFile == null) { - pageFile = pageLoader.loadPage(page, force = false) - } runInterruptible(Dispatchers.IO) { contentResolver.openOutputStream(destination)?.use { output -> pageFile.inputStream().use { input -> @@ -57,4 +59,19 @@ class PageSaveHelper( fun onActivityResult(uri: Uri): Boolean = continuation?.apply { resume(uri) } != null + + private suspend fun getProposedFileName(url: String, file: File): String { + var name = url.toHttpUrl().pathSegments.last() + var extension = name.substringAfterLast('.', "") + name = name.substringBeforeLast('.') + if (extension.length !in 2..4) { + val mimeType = MangaUtils.getImageMimeType(file) + extension = if (mimeType != null) { + MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType) ?: EXTENSION_FALLBACK + } else { + EXTENSION_FALLBACK + } + } + return name.toFileNameSafe().take(MAX_FILENAME_LENGTH) + "." + extension + } } \ No newline at end of file From 45b42ad5bdd369e78bf35b1ff1f3c5c930983142 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Fri, 6 May 2022 12:57:37 +0300 Subject: [PATCH 07/10] Revert "Fix bottom sheet navbar color" This reverts commit fdd4f5abcaee4d2a420550d4bc18b71ead5f5105. --- app/src/main/res/values-v27/styles.xml | 7 ------- app/src/main/res/values/styles.xml | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 app/src/main/res/values-v27/styles.xml diff --git a/app/src/main/res/values-v27/styles.xml b/app/src/main/res/values-v27/styles.xml deleted file mode 100644 index 0f361cb7f..000000000 --- a/app/src/main/res/values-v27/styles.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 772a54b02..2333f5d68 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -23,6 +23,7 @@ From 2709d40fc0a7ce4ff4624529a354e5f54a0e79a1 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Fri, 6 May 2022 13:51:55 +0300 Subject: [PATCH 08/10] Fix BottomSheet edge-to-edge mode --- .idea/deploymentTargetDropDown.xml | 21 ++++++++++++++ .../kotatsu/base/ui/BaseBottomSheet.kt | 7 +++-- .../base/ui/dialog/AppBottomSheetDialog.kt | 29 +++++++++++++++++++ .../utils/BottomSheetToolbarController.kt | 5 ++-- app/src/main/res/values-v27/styles.xml | 7 +++++ app/src/main/res/values/styles.xml | 4 +-- 6 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/org/koitharu/kotatsu/base/ui/dialog/AppBottomSheetDialog.kt create mode 100644 app/src/main/res/values-v27/styles.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 27370aa28..4b6850667 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -13,5 +13,26 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/org/koitharu/kotatsu/base/ui/BaseBottomSheet.kt b/app/src/main/java/org/koitharu/kotatsu/base/ui/BaseBottomSheet.kt index 0672b880f..75503afc5 100644 --- a/app/src/main/java/org/koitharu/kotatsu/base/ui/BaseBottomSheet.kt +++ b/app/src/main/java/org/koitharu/kotatsu/base/ui/BaseBottomSheet.kt @@ -9,11 +9,12 @@ import android.view.ViewGroup.LayoutParams import androidx.appcompat.app.AppCompatDialog import androidx.core.view.updateLayoutParams import androidx.viewbinding.ViewBinding -import com.google.android.material.R as materialR import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment import org.koitharu.kotatsu.R +import org.koitharu.kotatsu.base.ui.dialog.AppBottomSheetDialog +import com.google.android.material.R as materialR abstract class BaseBottomSheet : BottomSheetDialogFragment() { @@ -43,7 +44,9 @@ abstract class BaseBottomSheet : BottomSheetDialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return if (resources.getBoolean(R.bool.is_tablet)) { AppCompatDialog(context, R.style.Theme_Kotatsu_Dialog) - } else super.onCreateDialog(savedInstanceState) + } else { + AppBottomSheetDialog(requireContext(), theme) + } } protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B diff --git a/app/src/main/java/org/koitharu/kotatsu/base/ui/dialog/AppBottomSheetDialog.kt b/app/src/main/java/org/koitharu/kotatsu/base/ui/dialog/AppBottomSheetDialog.kt new file mode 100644 index 000000000..d3b911ace --- /dev/null +++ b/app/src/main/java/org/koitharu/kotatsu/base/ui/dialog/AppBottomSheetDialog.kt @@ -0,0 +1,29 @@ +package org.koitharu.kotatsu.base.ui.dialog + +import android.content.Context +import android.graphics.Color +import android.view.View +import com.google.android.material.bottomsheet.BottomSheetDialog + +class AppBottomSheetDialog(context: Context, theme: Int) : BottomSheetDialog(context, theme) { + + /** + * https://github.com/material-components/material-components-android/issues/2582 + */ + @Suppress("DEPRECATION") + override fun onAttachedToWindow() { + val window = window + val initialSystemUiVisibility = window?.decorView?.systemUiVisibility ?: 0 + super.onAttachedToWindow() + if (window != null) { + // If the navigation bar is translucent at all, the BottomSheet should be edge to edge + val drawEdgeToEdge = edgeToEdgeEnabled && Color.alpha(window.navigationBarColor) < 0xFF + if (drawEdgeToEdge) { + // Copied from super.onAttachedToWindow: + val edgeToEdgeFlags = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE + // Fix super-class's window flag bug by respecting the intial system UI visibility: + window.decorView.systemUiVisibility = edgeToEdgeFlags or initialSystemUiVisibility + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/org/koitharu/kotatsu/utils/BottomSheetToolbarController.kt b/app/src/main/java/org/koitharu/kotatsu/utils/BottomSheetToolbarController.kt index 17d62d3a3..ae40b41f6 100644 --- a/app/src/main/java/org/koitharu/kotatsu/utils/BottomSheetToolbarController.kt +++ b/app/src/main/java/org/koitharu/kotatsu/utils/BottomSheetToolbarController.kt @@ -2,15 +2,16 @@ package org.koitharu.kotatsu.utils import android.view.View import androidx.appcompat.widget.Toolbar -import com.google.android.material.R as materialR import com.google.android.material.bottomsheet.BottomSheetBehavior +import com.google.android.material.R as materialR open class BottomSheetToolbarController( protected val toolbar: Toolbar, ) : BottomSheetBehavior.BottomSheetCallback() { override fun onStateChanged(bottomSheet: View, newState: Int) { - if (newState == BottomSheetBehavior.STATE_EXPANDED) { + val isExpanded = newState == BottomSheetBehavior.STATE_EXPANDED && bottomSheet.top <= 0 + if (isExpanded) { toolbar.setNavigationIcon(materialR.drawable.abc_ic_clear_material) } else { toolbar.navigationIcon = null diff --git a/app/src/main/res/values-v27/styles.xml b/app/src/main/res/values-v27/styles.xml new file mode 100644 index 000000000..88dc7707b --- /dev/null +++ b/app/src/main/res/values-v27/styles.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 2333f5d68..d424cf260 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -22,8 +22,8 @@ - From de9c1017b3f7a7522c74fa84796dfd2f9e384f4c Mon Sep 17 00:00:00 2001 From: Koitharu Date: Fri, 6 May 2022 15:45:20 +0300 Subject: [PATCH 09/10] Update parsers --- .gitignore | 1 + .idea/deploymentTargetDropDown.xml | 38 ------------------------------ app/build.gradle | 2 +- 3 files changed, 2 insertions(+), 39 deletions(-) delete mode 100644 .idea/deploymentTargetDropDown.xml diff --git a/.gitignore b/.gitignore index d4fcf16ce..3ba4daee9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /.idea/navEditor.xml /.idea/assetWizardSettings.xml /.idea/kotlinScripting.xml +/.idea/deploymentTargetDropDown.xml .DS_Store /build /captures diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 4b6850667..000000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index b04edbd11..e899f7b87 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,7 +65,7 @@ android { } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) - implementation('com.github.nv95:kotatsu-parsers:090ad4b256') { + implementation('com.github.nv95:kotatsu-parsers:b495e5e457') { exclude group: 'org.json', module: 'json' } From fa150e45ff65b2f935cb04685b7e5391fc92bd59 Mon Sep 17 00:00:00 2001 From: Zakhar Timoshenko Date: Fri, 6 May 2022 20:15:29 +0300 Subject: [PATCH 10/10] [Issue template] Update version --- .github/ISSUE_TEMPLATE/report_issue.yml | 4 ++-- .github/ISSUE_TEMPLATE/request_feature.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/report_issue.yml b/.github/ISSUE_TEMPLATE/report_issue.yml index 69983d414..97aa936c3 100644 --- a/.github/ISSUE_TEMPLATE/report_issue.yml +++ b/.github/ISSUE_TEMPLATE/report_issue.yml @@ -44,7 +44,7 @@ body: label: Kotatsu version description: You can find your Kotatsu version in **Settings → About**. placeholder: | - Example: "3.2" + Example: "3.2.2" validations: required: true @@ -87,7 +87,7 @@ body: required: true - label: If this is an issue with a source, I should be opening an issue in the [parsers repository](https://github.com/nv95/kotatsu-parsers/issues/new). required: true - - label: I have updated the app to version **[3.2](https://github.com/nv95/Kotatsu/releases/latest)**. + - label: I have updated the app to version **[3.2.2](https://github.com/nv95/Kotatsu/releases/latest)**. required: true - label: I will fill out all of the requested information in this form. required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/request_feature.yml b/.github/ISSUE_TEMPLATE/request_feature.yml index a46a0648f..2077efe27 100644 --- a/.github/ISSUE_TEMPLATE/request_feature.yml +++ b/.github/ISSUE_TEMPLATE/request_feature.yml @@ -33,7 +33,7 @@ body: required: true - label: If this is an issue with a source, I should be opening an issue in the [parsers repository](https://github.com/nv95/kotatsu-parsers/issues/new). required: true - - label: I have updated the app to version **[3.2](https://github.com/nv95/Kotatsu/releases/latest)**. + - label: I have updated the app to version **[3.2.2](https://github.com/nv95/Kotatsu/releases/latest)**. required: true - label: I will fill out all of the requested information in this form. required: true \ No newline at end of file