From 2c66edda6830b2dc9406fe88fe9f1afe04d3624f Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sat, 28 Mar 2020 12:28:03 +0200 Subject: [PATCH] Update database schema: foreign keys and indices --- .idea/codeStyles | 120 ----------- .idea/codeStyles/Project.xml | 186 ++++++++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 + app/src/main/AndroidManifest.xml | 8 +- .../java/org/koitharu/kotatsu/KotatsuApp.kt | 3 +- .../koitharu/kotatsu/core/db/MangaDatabase.kt | 2 +- .../kotatsu/core/db/entity/FavouriteEntity.kt | 22 ++- .../kotatsu/core/db/entity/HistoryEntity.kt | 36 ++-- .../core/db/entity/MangaPrefsEntity.kt | 11 +- .../kotatsu/core/db/entity/MangaTagsEntity.kt | 22 ++- .../core/db/migrations/Migration1To2.kt | 54 +++++ .../koitharu/kotatsu/core/local/CbzFetcher.kt | 1 + .../local/cookies/cache/SetCookieCache.kt | 2 +- .../persistence/SharedPrefsCookiePersistor.kt | 9 +- .../core/parser/LocalMangaRepository.kt | 1 + .../categories/FavouriteCategoriesDialog.kt | 2 +- .../koitharu/kotatsu/ui/reader/PageLoader.kt | 1 + .../kotatsu/ui/reader/base/GroupedList.kt | 2 +- .../ui/reader/standard/PagerReaderFragment.kt | 2 +- .../ui/reader/wetoon/WebtoonReaderFragment.kt | 2 +- .../org/koitharu/kotatsu/utils/ext/DateExt.kt | 1 + .../kotatsu/utils/ext/NotificationExt.kt | 6 +- .../res/layout-w600dp/fragment_details.xml | 3 +- app/src/main/res/layout/fragment_details.xml | 3 +- app/src/main/res/values-ru/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- .../org/koitharu/kotatsu/utils/AssertX.kt | 4 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 28 files changed, 353 insertions(+), 163 deletions(-) delete mode 100644 .idea/codeStyles create mode 100755 .idea/codeStyles/Project.xml create mode 100755 .idea/codeStyles/codeStyleConfig.xml create mode 100644 app/src/main/java/org/koitharu/kotatsu/core/db/migrations/Migration1To2.kt diff --git a/.idea/codeStyles b/.idea/codeStyles deleted file mode 100644 index 88f911756..000000000 --- a/.idea/codeStyles +++ /dev/null @@ -1,120 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100755 index 000000000..87bd3a768 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100755 index 000000000..79ee123c2 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 82c42aa8e..338d25c9f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ @@ -18,7 +19,8 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" - android:usesCleartextTraffic="true"> + android:usesCleartextTraffic="true" + tools:ignore="UnusedAttribute"> @@ -54,7 +56,9 @@ + android:authorities="${applicationId}.MangaSuggestionsProvider" + android:exported="false" /> + { + @Suppress("BlockingMethodInNonBlockingContext") override suspend fun fetch( pool: BitmapPool, data: Uri, diff --git a/app/src/main/java/org/koitharu/kotatsu/core/local/cookies/cache/SetCookieCache.kt b/app/src/main/java/org/koitharu/kotatsu/core/local/cookies/cache/SetCookieCache.kt index b776b0b33..b18e0fa0f 100644 --- a/app/src/main/java/org/koitharu/kotatsu/core/local/cookies/cache/SetCookieCache.kt +++ b/app/src/main/java/org/koitharu/kotatsu/core/local/cookies/cache/SetCookieCache.kt @@ -37,7 +37,7 @@ class SetCookieCache : CookieCache { override fun iterator(): MutableIterator = SetCookieCacheIterator() - private inner class SetCookieCacheIterator internal constructor() : MutableIterator { + private inner class SetCookieCacheIterator() : MutableIterator { private val iterator = cookies.iterator() diff --git a/app/src/main/java/org/koitharu/kotatsu/core/local/cookies/persistence/SharedPrefsCookiePersistor.kt b/app/src/main/java/org/koitharu/kotatsu/core/local/cookies/persistence/SharedPrefsCookiePersistor.kt index f20b8ff3e..044180bb4 100644 --- a/app/src/main/java/org/koitharu/kotatsu/core/local/cookies/persistence/SharedPrefsCookiePersistor.kt +++ b/app/src/main/java/org/koitharu/kotatsu/core/local/cookies/persistence/SharedPrefsCookiePersistor.kt @@ -41,27 +41,24 @@ class SharedPrefsCookiePersistor(private val sharedPreferences: SharedPreference return cookies } - @SuppressLint("ApplySharedPref") override fun saveAll(cookies: Collection) { val editor = sharedPreferences.edit() for (cookie in cookies) { editor.putString(createCookieKey(cookie), SerializableCookie().encode(cookie)) } - editor.commit() + editor.apply() } - @SuppressLint("ApplySharedPref") override fun removeAll(cookies: Collection) { val editor = sharedPreferences.edit() for (cookie in cookies) { editor.remove(createCookieKey(cookie)) } - editor.commit() + editor.apply() } - @SuppressLint("ApplySharedPref") override fun clear() { - sharedPreferences.edit().clear().commit() + sharedPreferences.edit().clear().apply() } private companion object { diff --git a/app/src/main/java/org/koitharu/kotatsu/core/parser/LocalMangaRepository.kt b/app/src/main/java/org/koitharu/kotatsu/core/parser/LocalMangaRepository.kt index c39189a70..b7bfddd96 100644 --- a/app/src/main/java/org/koitharu/kotatsu/core/parser/LocalMangaRepository.kt +++ b/app/src/main/java/org/koitharu/kotatsu/core/parser/LocalMangaRepository.kt @@ -38,6 +38,7 @@ class LocalMangaRepository : MangaRepository, KoinComponent { getFromFile(Uri.parse(manga.url).toFile()) } else manga + @Suppress("BlockingMethodInNonBlockingContext") override suspend fun getPages(chapter: MangaChapter): List { val file = Uri.parse(chapter.url).toFile() val zip = ZipFile(file) diff --git a/app/src/main/java/org/koitharu/kotatsu/ui/main/list/favourites/categories/FavouriteCategoriesDialog.kt b/app/src/main/java/org/koitharu/kotatsu/ui/main/list/favourites/categories/FavouriteCategoriesDialog.kt index ac821aa6c..e7ccee533 100644 --- a/app/src/main/java/org/koitharu/kotatsu/ui/main/list/favourites/categories/FavouriteCategoriesDialog.kt +++ b/app/src/main/java/org/koitharu/kotatsu/ui/main/list/favourites/categories/FavouriteCategoriesDialog.kt @@ -15,7 +15,7 @@ import org.koitharu.kotatsu.ui.common.dialog.TextInputDialog import org.koitharu.kotatsu.utils.ext.getDisplayMessage import org.koitharu.kotatsu.utils.ext.withArgs -class FavouriteCategoriesDialog() : BaseBottomSheet(R.layout.dialog_favorite_categories), +class FavouriteCategoriesDialog : BaseBottomSheet(R.layout.dialog_favorite_categories), FavouriteCategoriesView, OnCategoryCheckListener { diff --git a/app/src/main/java/org/koitharu/kotatsu/ui/reader/PageLoader.kt b/app/src/main/java/org/koitharu/kotatsu/ui/reader/PageLoader.kt index 1d6fb6f71..badbe52d2 100644 --- a/app/src/main/java/org/koitharu/kotatsu/ui/reader/PageLoader.kt +++ b/app/src/main/java/org/koitharu/kotatsu/ui/reader/PageLoader.kt @@ -23,6 +23,7 @@ class PageLoader : KoinComponent, CoroutineScope, DisposableHandle { override val coroutineContext: CoroutineContext get() = Dispatchers.Main + job + @Suppress("BlockingMethodInNonBlockingContext") suspend fun loadFile(url: String, force: Boolean): File { if (!force) { cache[url]?.let { diff --git a/app/src/main/java/org/koitharu/kotatsu/ui/reader/base/GroupedList.kt b/app/src/main/java/org/koitharu/kotatsu/ui/reader/base/GroupedList.kt index 3b11a1a48..fea6700b3 100644 --- a/app/src/main/java/org/koitharu/kotatsu/ui/reader/base/GroupedList.kt +++ b/app/src/main/java/org/koitharu/kotatsu/ui/reader/base/GroupedList.kt @@ -55,7 +55,7 @@ class GroupedList { lruGroup = entry.second lruGroupKey = entry.first lruGroupFirstIndex = lastIndex - entry.second.size - return entry.second.get(index - lruGroupFirstIndex) + return entry.second[index - lruGroupFirstIndex] } lastIndex -= entry.second.size } diff --git a/app/src/main/java/org/koitharu/kotatsu/ui/reader/standard/PagerReaderFragment.kt b/app/src/main/java/org/koitharu/kotatsu/ui/reader/standard/PagerReaderFragment.kt index 88df58917..1aba85851 100644 --- a/app/src/main/java/org/koitharu/kotatsu/ui/reader/standard/PagerReaderFragment.kt +++ b/app/src/main/java/org/koitharu/kotatsu/ui/reader/standard/PagerReaderFragment.kt @@ -12,7 +12,7 @@ import org.koitharu.kotatsu.ui.reader.ReaderState import org.koitharu.kotatsu.utils.ext.doOnPageChanged import org.koitharu.kotatsu.utils.ext.withArgs -class PagerReaderFragment() : AbstractReader(R.layout.fragment_reader_standard) { +class PagerReaderFragment : AbstractReader(R.layout.fragment_reader_standard) { private var paginationListener: PagerPaginationListener? = null diff --git a/app/src/main/java/org/koitharu/kotatsu/ui/reader/wetoon/WebtoonReaderFragment.kt b/app/src/main/java/org/koitharu/kotatsu/ui/reader/wetoon/WebtoonReaderFragment.kt index 1551d9b0c..015e69276 100644 --- a/app/src/main/java/org/koitharu/kotatsu/ui/reader/wetoon/WebtoonReaderFragment.kt +++ b/app/src/main/java/org/koitharu/kotatsu/ui/reader/wetoon/WebtoonReaderFragment.kt @@ -20,7 +20,7 @@ import org.koitharu.kotatsu.utils.ext.withArgs class WebtoonReaderFragment : AbstractReader(R.layout.fragment_reader_webtoon) { private val scrollInterpolator = AccelerateDecelerateInterpolator() - protected var paginationListener: ListPaginationListener? = null + private var paginationListener: ListPaginationListener? = null override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/app/src/main/java/org/koitharu/kotatsu/utils/ext/DateExt.kt b/app/src/main/java/org/koitharu/kotatsu/utils/ext/DateExt.kt index 51c1caf41..830ff2fa7 100644 --- a/app/src/main/java/org/koitharu/kotatsu/utils/ext/DateExt.kt +++ b/app/src/main/java/org/koitharu/kotatsu/utils/ext/DateExt.kt @@ -3,6 +3,7 @@ package org.koitharu.kotatsu.utils.ext import android.annotation.SuppressLint import java.text.SimpleDateFormat import java.util.* +import java.util.concurrent.TimeUnit @SuppressLint("SimpleDateFormat") fun Date.format(pattern: String): String = SimpleDateFormat(pattern).format(this) diff --git a/app/src/main/java/org/koitharu/kotatsu/utils/ext/NotificationExt.kt b/app/src/main/java/org/koitharu/kotatsu/utils/ext/NotificationExt.kt index 3e9a53b7b..c0bf4a70f 100644 --- a/app/src/main/java/org/koitharu/kotatsu/utils/ext/NotificationExt.kt +++ b/app/src/main/java/org/koitharu/kotatsu/utils/ext/NotificationExt.kt @@ -1,8 +1,12 @@ package org.koitharu.kotatsu.utils.ext +import android.annotation.SuppressLint import androidx.core.app.NotificationCompat +@SuppressLint("RestrictedApi") fun NotificationCompat.Builder.clearActions(): NotificationCompat.Builder { - mActions.clear() + safe { + mActions.clear() + } return this } \ No newline at end of file diff --git a/app/src/main/res/layout-w600dp/fragment_details.xml b/app/src/main/res/layout-w600dp/fragment_details.xml index 332778cc9..38929fa66 100644 --- a/app/src/main/res/layout-w600dp/fragment_details.xml +++ b/app/src/main/res/layout-w600dp/fragment_details.xml @@ -120,7 +120,8 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/imageView_cover" app:layout_constraintTop_toBottomOf="@id/chips_tags" - tools:text="@tools:sample/lorem/random" /> + tools:text="@tools:sample/lorem/random" + tools:ignore="UnusedAttribute" /> + tools:text="@tools:sample/lorem/random" + tools:ignore="UnusedAttribute" /> Настройки Онлайн каталоги Загрузка… - Глава %d из %d + Глава %1$d из %2$d Закрыть Повторить Очистить историю diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 89883acc6..a94b43445 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -16,7 +16,7 @@ Settings Remote sources Loading… - Chapter %d of %d + Chapter %1$d of %2$d Close Try again Clear history diff --git a/app/src/test/java/org/koitharu/kotatsu/utils/AssertX.kt b/app/src/test/java/org/koitharu/kotatsu/utils/AssertX.kt index bec4a5844..30ec1aeef 100644 --- a/app/src/test/java/org/koitharu/kotatsu/utils/AssertX.kt +++ b/app/src/test/java/org/koitharu/kotatsu/utils/AssertX.kt @@ -13,7 +13,9 @@ object AssertX { cn.connect() when (val code = cn.responseCode) { HttpURLConnection.HTTP_MOVED_PERM, - HttpURLConnection.HTTP_MOVED_TEMP -> assertContentType(cn.getHeaderField("Location"), *types) + HttpURLConnection.HTTP_MOVED_TEMP -> { + assertContentType(cn.getHeaderField("Location"), *types) + } HttpURLConnection.HTTP_OK -> { val ct = cn.contentType.substringBeforeLast(';').split("/") Assert.assertTrue(types.any { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 396a79d0a..19bece88e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Mar 08 18:35:17 EET 2020 +#Sat Mar 28 11:01:15 EET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip