Cleanup and fix a few compiler warnings

This commit is contained in:
Jobobby04 2020-09-13 22:03:27 -04:00
parent 73523dbff8
commit 02e6eaae12
24 changed files with 50 additions and 62 deletions

View File

@ -372,4 +372,4 @@ if (!getGradle().getStartParameter().getTaskRequests().toString().contains("Debu
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
// Firebase Crashlytics // Firebase Crashlytics
apply plugin: 'com.google.firebase.crashlytics' apply plugin: 'com.google.firebase.crashlytics'
} }

View File

@ -66,7 +66,7 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) {
db.execSQL(MangaTable.addDateAdded) db.execSQL(MangaTable.addDateAdded)
db.execSQL(MangaTable.backfillDateAdded) db.execSQL(MangaTable.backfillDateAdded)
} }
if (oldVersion < 4) { if (oldVersion < 12) {
db.execSQL(MergedTable.dropTableQuery) db.execSQL(MergedTable.dropTableQuery)
db.execSQL(MergedTable.createTableQuery) db.execSQL(MergedTable.createTableQuery)
db.execSQL(MergedTable.createIndexQuery) db.execSQL(MergedTable.createIndexQuery)

View File

@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import exh.util.asObservable import exh.util.asObservable
import kotlin.jvm.Throws import kotlin.jvm.Throws
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
@ -28,6 +29,7 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param page the page number to retrieve. * @param page the page number to retrieve.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchPopularManga(page: Int): Observable<MangasPage> { final override fun fetchPopularManga(page: Int): Observable<MangasPage> {
return fetchPopularMangaFlow(page).asObservable() return fetchPopularMangaFlow(page).asObservable()
} }
@ -71,6 +73,7 @@ abstract class SuspendHttpSource : HttpSource() {
* @param query the search query. * @param query the search query.
* @param filters the list of filters to apply. * @param filters the list of filters to apply.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> { final override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
return fetchSearchMangaSuspended(page, query, filters).asObservable() return fetchSearchMangaSuspended(page, query, filters).asObservable()
} }
@ -113,6 +116,7 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param page the page number to retrieve. * @param page the page number to retrieve.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchLatestUpdates(page: Int): Observable<MangasPage> { final override fun fetchLatestUpdates(page: Int): Observable<MangasPage> {
return fetchLatestUpdatesFlow(page).asObservable() return fetchLatestUpdatesFlow(page).asObservable()
} }
@ -154,6 +158,7 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param manga the manga to be updated. * @param manga the manga to be updated.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchMangaDetails(manga: SManga): Observable<SManga> { final override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
return fetchMangaDetailsFlow(manga).asObservable() return fetchMangaDetailsFlow(manga).asObservable()
} }
@ -198,6 +203,7 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param manga the manga to look for chapters. * @param manga the manga to look for chapters.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> { final override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
return try { return try {
fetchChapterListFlow(manga).asObservable() fetchChapterListFlow(manga).asObservable()
@ -250,6 +256,7 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param chapter the chapter whose page list has to be fetched. * @param chapter the chapter whose page list has to be fetched.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchPageList(chapter: SChapter): Observable<List<Page>> { final override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
return fetchPageListFlow(chapter).asObservable() return fetchPageListFlow(chapter).asObservable()
} }
@ -294,6 +301,7 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param page the page whose source image has to be fetched. * @param page the page whose source image has to be fetched.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchImageUrl(page: Page): Observable<String> { final override fun fetchImageUrl(page: Page): Observable<String> {
return fetchImageUrlFlow(page).asObservable() return fetchImageUrlFlow(page).asObservable()
} }
@ -337,6 +345,7 @@ abstract class SuspendHttpSource : HttpSource() {
* *
* @param page the page whose source image has to be downloaded. * @param page the page whose source image has to be downloaded.
*/ */
@ExperimentalCoroutinesApi
final override fun fetchImage(page: Page): Observable<Response> { final override fun fetchImage(page: Page): Observable<Response> {
return fetchImageFlow(page).asObservable() return fetchImageFlow(page).asObservable()
} }

View File

@ -149,7 +149,7 @@ class MangaDex(delegate: HttpSource, val context: Context) :
override val needsLogin: Boolean = true override val needsLogin: Boolean = true
override fun getLoginDialog(source: Source, activity: Activity): DialogController { override fun getLoginDialog(source: Source, activity: Activity): DialogController {
return MangadexLoginDialog(source as MangaDex, activity) return MangadexLoginDialog(source as MangaDex)
} }
override fun isLogged(): Boolean { override fun isLogged(): Boolean {

View File

@ -34,13 +34,13 @@ import eu.kanade.tachiyomi.util.lang.launchUI
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import exh.smartsearch.SmartSearchEngine import exh.smartsearch.SmartSearchEngine
import exh.util.RecyclerWindowInsetsListener
import exh.util.await import exh.util.await
import exh.util.executeOnIO import exh.util.executeOnIO
import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicInteger
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
@ -107,7 +107,6 @@ class MigrationListController(bundle: Bundle? = null) :
binding.recycler.adapter = adapter binding.recycler.adapter = adapter
binding.recycler.layoutManager = LinearLayoutManager(view.context) binding.recycler.layoutManager = LinearLayoutManager(view.context)
binding.recycler.setHasFixedSize(true) binding.recycler.setHasFixedSize(true)
binding.recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
adapter?.updateDataSet(newMigratingManga.map { it.toModal() }) adapter?.updateDataSet(newMigratingManga.map { it.toModal() })
@ -118,6 +117,7 @@ class MigrationListController(bundle: Bundle? = null) :
} }
} }
@OptIn(ExperimentalCoroutinesApi::class)
private suspend fun runMigrations(mangas: List<MigratingManga>) { private suspend fun runMigrations(mangas: List<MigratingManga>) {
if (config == null) return if (config == null) return
val useSourceWithMost = preferences.useSourceWithMost().get() val useSourceWithMost = preferences.useSourceWithMost().get()
@ -157,7 +157,7 @@ class MigrationListController(bundle: Bundle? = null) :
val processedSources = AtomicInteger() val processedSources = AtomicInteger()
validSources.map { source -> validSources.map { source ->
async { async async2@{
sourceSemaphore.withPermit { sourceSemaphore.withPermit {
try { try {
val searchResult = if (useSmartSearch) { val searchResult = if (useSmartSearch) {
@ -176,7 +176,7 @@ class MigrationListController(bundle: Bundle? = null) :
try { try {
syncChaptersWithSource(db, chapters, localManga, source) syncChaptersWithSource(db, chapters, localManga, source)
} catch (e: Exception) { } catch (e: Exception) {
return@async null return@async2 null
} }
manga.progress.send(validSources.size to processedSources.incrementAndGet()) manga.progress.send(validSources.size to processedSources.incrementAndGet())
localManga to chapters.size localManga to chapters.size
@ -327,6 +327,7 @@ class MigrationListController(bundle: Bundle? = null) :
} }
} }
@ExperimentalCoroutinesApi
fun useMangaForMigration(manga: Manga, source: Source) { fun useMangaForMigration(manga: Manga, source: Source) {
val firstIndex = selectedPosition ?: return val firstIndex = selectedPosition ?: return
val migratingManga = adapter?.getItem(firstIndex) ?: return val migratingManga = adapter?.getItem(firstIndex) ?: return

View File

@ -255,9 +255,9 @@ class SourceController(bundle: Bundle? = null) :
val sources = preferenceSources.map { it.split("|")[0] } val sources = preferenceSources.map { it.split("|")[0] }
if (source.id.toString() in sources) { if (source.id.toString() in sources) {
val preferenceSources = preferenceSources.map { it.split("|") }.filter { it[0] == source.id.toString() }.map { Pair(it[0], it[1]) }.toMutableList() val preferenceSourcePairs = preferenceSources.map { it.split("|") }.filter { it[0] == source.id.toString() }.map { it[0] to it[1] }.toMutableList()
val preselected = preferenceSources.map { category -> val preselected = preferenceSourcePairs.map { category ->
categories.indexOf(category.second) categories.indexOf(category.second)
}.toTypedArray() }.toTypedArray()

View File

@ -36,7 +36,7 @@ class SettingsMangaDexController :
dialog.targetController = this@SettingsMangaDexController dialog.targetController = this@SettingsMangaDexController
dialog.showDialog(router) dialog.showDialog(router)
} else { } else {
val dialog = MangadexLoginDialog(source, activity) val dialog = MangadexLoginDialog(source)
dialog.targetController = this@SettingsMangaDexController dialog.targetController = this@SettingsMangaDexController
dialog.showDialog(router) dialog.showDialog(router)
} }

View File

@ -81,6 +81,7 @@ object ImageUtil {
} }
// SY --> // SY -->
@Suppress("UNUSED_VARIABLE")
fun autoSetBackground(image: Bitmap?, alwaysUseWhite: Boolean, context: Context): Drawable { fun autoSetBackground(image: Bitmap?, alwaysUseWhite: Boolean, context: Context): Drawable {
val backgroundColor = if (alwaysUseWhite) Color.WHITE else { val backgroundColor = if (alwaysUseWhite) Color.WHITE else {
context.getResourceColor(R.attr.colorPrimary) context.getResourceColor(R.attr.colorPrimary)

View File

@ -50,6 +50,7 @@ class AutoCompleteAdapter(context: Context, resource: Int, var objects: List<Str
override fun publishResults(constraint: CharSequence?, results: FilterResults) { override fun publishResults(constraint: CharSequence?, results: FilterResults) {
objects = if (results.values != null) { objects = if (results.values != null) {
@Suppress("UNCHECKED_CAST")
results.values as List<String>? ?: emptyList() results.values as List<String>? ?: emptyList()
} else { } else {
emptyList() emptyList()

View File

@ -26,6 +26,7 @@ import exh.util.await
import exh.util.cancellable import exh.util.cancellable
import exh.util.jobScheduler import exh.util.jobScheduler
import java.lang.RuntimeException import java.lang.RuntimeException
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.toList import kotlinx.coroutines.flow.toList
@ -34,6 +35,7 @@ import timber.log.Timber
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import xyz.nulldev.ts.api.http.serializer.FilterSerializer import xyz.nulldev.ts.api.http.serializer.FilterSerializer
@OptIn(FlowPreview::class)
object DebugFunctions { object DebugFunctions {
val app: Application by injectLazy() val app: Application by injectLazy()
val db: DatabaseHelper by injectLazy() val db: DatabaseHelper by injectLazy()

View File

@ -1,6 +1,7 @@
package exh.debug package exh.debug
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import kotlinx.coroutines.ExperimentalCoroutinesApi
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
enum class DebugToggles(val default: Boolean) { enum class DebugToggles(val default: Boolean) {
@ -17,6 +18,7 @@ enum class DebugToggles(val default: Boolean) {
val prefKey = "eh_debug_toggle_${name.toLowerCase()}" val prefKey = "eh_debug_toggle_${name.toLowerCase()}"
@OptIn(ExperimentalCoroutinesApi::class)
var enabled: Boolean var enabled: Boolean
get() = prefs.flowPrefs.getBoolean(prefKey, default).get() get() = prefs.flowPrefs.getBoolean(prefKey, default).get()
set(value) { set(value) {

View File

@ -34,6 +34,8 @@ import kotlin.time.days
import kotlin.time.hours import kotlin.time.hours
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.cancelAndJoin import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.asFlow
@ -128,6 +130,7 @@ class EHentaiUpdateWorker : JobService(), CoroutineScope {
return true return true
} }
@OptIn(FlowPreview::class)
private suspend fun startUpdating() { private suspend fun startUpdating() {
logger.d("Update job started!") logger.d("Update job started!")
val startTime = System.currentTimeMillis() val startTime = System.currentTimeMillis()
@ -255,6 +258,7 @@ class EHentaiUpdateWorker : JobService(), CoroutineScope {
} }
// New, current // New, current
@OptIn(ExperimentalCoroutinesApi::class)
private suspend fun updateEntryAndGetChapters(manga: Manga): Pair<List<Chapter>, List<Chapter>> { private suspend fun updateEntryAndGetChapters(manga: Manga): Pair<List<Chapter>, List<Chapter>> {
val source = sourceManager.get(manga.source) as? EHentai val source = sourceManager.get(manga.source) as? EHentai
?: throw GalleryNotUpdatedException(false, IllegalStateException("Missing EH-based source (${manga.source})!")) ?: throw GalleryNotUpdatedException(false, IllegalStateException("Missing EH-based source (${manga.source})!"))

View File

@ -117,7 +117,7 @@ class FavoritesSyncHelper(val context: Context) {
ignore { wifiLock?.release() } ignore { wifiLock?.release() }
wifiLock = ignore { wifiLock = ignore {
context.wifiManager.createWifiLock( context.wifiManager.createWifiLock(
WifiManager.WIFI_MODE_FULL, WifiManager.WIFI_MODE_FULL_HIGH_PERF,
"teh:ExhFavoritesSyncWifi" "teh:ExhFavoritesSyncWifi"
) )
} }

View File

@ -5,6 +5,7 @@ import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import exh.md.utils.MdUtil import exh.md.utils.MdUtil
import kotlinx.serialization.ExperimentalSerializationApi
import okhttp3.CacheControl import okhttp3.CacheControl
import okhttp3.Headers import okhttp3.Headers
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
@ -14,6 +15,7 @@ import rx.Observable
// Unused, kept for reference todo // Unused, kept for reference todo
class PageHandler(val client: OkHttpClient, val headers: Headers, private val imageServer: String, val dataSaver: String?) { class PageHandler(val client: OkHttpClient, val headers: Headers, private val imageServer: String, val dataSaver: String?) {
@ExperimentalSerializationApi
fun fetchPageList(chapter: SChapter): Observable<List<Page>> { fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
if (chapter.scanlator.equals("MangaPlus")) { if (chapter.scanlator.equals("MangaPlus")) {
return client.newCall(pageListRequest(chapter)) return client.newCall(pageListRequest(chapter))

View File

@ -51,11 +51,6 @@ class NHentaiSearchMetadata : RaisedSearchMetadata() {
if (it.isNotEmpty()) manga.artist = it.joinToString(transform = { it.name }) if (it.isNotEmpty()) manga.artist = it.joinToString(transform = { it.name })
} }
var category: String? = null
tags.filter { it.namespace == NHENTAI_CATEGORIES_NAMESPACE }.let {
if (it.isNotEmpty()) category = it.joinToString(transform = { it.name })
}
// Copy tags -> genres // Copy tags -> genres
manga.genre = tagsToGenreString() manga.genre = tagsToGenreString()
@ -70,23 +65,7 @@ class NHentaiSearchMetadata : RaisedSearchMetadata() {
} }
} }
/*val titleDesc = StringBuilder() manga.description = "meta"
englishTitle?.let { titleDesc += "English Title: $it\n" }
japaneseTitle?.let { titleDesc += "Japanese Title: $it\n" }
shortTitle?.let { titleDesc += "Short Title: $it\n" }
val detailsDesc = StringBuilder()
category?.let { detailsDesc += "Category: $it\n" }
uploadDate?.let { detailsDesc += "Upload Date: ${EX_DATE_FORMAT.format(Date(it * 1000))}\n" }
pageImageTypes.size.let { detailsDesc += "Length: $it pages\n" }
favoritesCount?.let { detailsDesc += "Favorited: $it times\n" }
scanlator?.nullIfBlank()?.let { detailsDesc += "Scanlator: $it\n" }
val tagsDesc = tagsToDescription()*/
manga.description = "meta" /*listOf(titleDesc.toString(), detailsDesc.toString(), tagsDesc.toString())
.filter(String::isNotBlank)
.joinToString(separator = "\n")*/
} }
override fun getExtraInfoPairs(context: Context): List<Pair<String, String>> { override fun getExtraInfoPairs(context: Context): List<Pair<String, String>> {

View File

@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.source.model.SManga
import exh.util.await import exh.util.await
import info.debatty.java.stringsimilarity.NormalizedLevenshtein import info.debatty.java.stringsimilarity.NormalizedLevenshtein
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.supervisorScope import kotlinx.coroutines.supervisorScope
import rx.schedulers.Schedulers import rx.schedulers.Schedulers
@ -20,6 +21,7 @@ class SmartSearchEngine(
private val normalizedLevenshtein = NormalizedLevenshtein() private val normalizedLevenshtein = NormalizedLevenshtein()
@OptIn(ExperimentalCoroutinesApi::class)
suspend fun smartSearch(source: CatalogueSource, title: String): SManga? { suspend fun smartSearch(source: CatalogueSource, title: String): SManga? {
val cleanedTitle = cleanSmartSearchTitle(title) val cleanedTitle = cleanSmartSearchTitle(title)
@ -49,6 +51,7 @@ class SmartSearchEngine(
return eligibleManga.maxByOrNull { it.dist }?.manga return eligibleManga.maxByOrNull { it.dist }?.manga
} }
@OptIn(ExperimentalCoroutinesApi::class)
suspend fun normalSearch(source: CatalogueSource, title: String): SManga? { suspend fun normalSearch(source: CatalogueSource, title: String): SManga? {
val eligibleManga = supervisorScope { val eligibleManga = supervisorScope {
val searchQuery = if (extraSearchParams != null) { val searchQuery = if (extraSearchParams != null) {

View File

@ -70,12 +70,14 @@ class BrowserActionActivity : AppCompatActivity() {
} }
} else null } else null
@Suppress("UNCHECKED_CAST")
val headers = ( val headers = (
(source as? HttpSource)?.headers?.toMultimap()?.mapValues { (source as? HttpSource)?.headers?.toMultimap()?.mapValues {
it.value.joinToString(",") it.value.joinToString(",")
} ?: emptyMap() } ?: emptyMap()
) + (intent.getSerializableExtra(HEADERS_EXTRA) as? HashMap<String, String> ?: emptyMap()) ) + (intent.getSerializableExtra(HEADERS_EXTRA) as? HashMap<String, String> ?: emptyMap())
@Suppress("UNCHECKED_CAST")
val cookies: HashMap<String, String>? = val cookies: HashMap<String, String>? =
intent.getSerializableExtra(COOKIES_EXTRA) as? HashMap<String, String> intent.getSerializableExtra(COOKIES_EXTRA) as? HashMap<String, String>
val script: String? = intent.getStringExtra(SCRIPT_EXTRA) val script: String? = intent.getStringExtra(SCRIPT_EXTRA)

View File

@ -44,12 +44,14 @@ class DeferredField<T> {
*/ */
suspend fun get(): T { suspend fun get(): T {
// Check if field is initialized and return immediately if it is // Check if field is initialized and return immediately if it is
@Suppress("UNCHECKED_CAST")
if (initialized) return content as T if (initialized) return content as T
// Wait for field to initialize // Wait for field to initialize
mutex.withLock {} mutex.withLock {}
// Field is initialized, return value // Field is initialized, return value
@Suppress("UNCHECKED_CAST")
return content as T return content as T
} }
} }

View File

@ -1,9 +1,6 @@
package exh.util package exh.util
import android.content.Context import android.content.Context
import android.view.View
import android.view.WindowInsets
import androidx.annotation.Px
import com.google.android.material.chip.Chip import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup import com.google.android.material.chip.ChipGroup
import exh.EH_SOURCE_ID import exh.EH_SOURCE_ID
@ -12,23 +9,6 @@ import exh.metadata.metadata.EHentaiSearchMetadata.Companion.TAG_TYPE_LIGHT
import exh.metadata.metadata.EHentaiSearchMetadata.Companion.TAG_TYPE_NORMAL import exh.metadata.metadata.EHentaiSearchMetadata.Companion.TAG_TYPE_NORMAL
import exh.metadata.metadata.EHentaiSearchMetadata.Companion.TAG_TYPE_WEAK import exh.metadata.metadata.EHentaiSearchMetadata.Companion.TAG_TYPE_WEAK
inline fun View.updatePaddingRelative(
@Px start: Int = paddingStart,
@Px top: Int = paddingTop,
@Px end: Int = paddingEnd,
@Px bottom: Int = paddingBottom
) {
setPaddingRelative(start, top, end, bottom)
}
object RecyclerWindowInsetsListener : View.OnApplyWindowInsetsListener {
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
v.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
// v.updatePaddingRelative(bottom = v.paddingBottom + insets.systemWindowInsetBottom)
return insets
}
}
/** /**
* Replaces chips in a ChipGroup. * Replaces chips in a ChipGroup.
* *

View File

@ -1,6 +1,5 @@
package exh.widget.preference package exh.widget.preference
import android.app.Activity
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
@ -32,7 +31,7 @@ class MangadexLoginDialog(bundle: Bundle? = null) : LoginDialogPreference(bundle
val scope = CoroutineScope(Job() + Dispatchers.Main) val scope = CoroutineScope(Job() + Dispatchers.Main)
constructor(source: MangaDex, activity: Activity? = null) : this( constructor(source: MangaDex) : this(
Bundle().apply { Bundle().apply {
putLong( putLong(
"key", "key",

View File

@ -20,7 +20,7 @@ import kotlin.reflect.KMutableProperty1
import kotlin.reflect.full.isSubclassOf import kotlin.reflect.full.isSubclassOf
class FilterSerializer { class FilterSerializer {
val serializers = listOf<Serializer<*>>( private val serializers = listOf<Serializer<*>>(
// EXH --> // EXH -->
HelpDialogSerializer(this), HelpDialogSerializer(this),
AutoCompleteSerializer(this), AutoCompleteSerializer(this),
@ -37,6 +37,7 @@ class FilterSerializer {
fun serialize(filters: FilterList) = JsonArray().apply { fun serialize(filters: FilterList) = JsonArray().apply {
filters.forEach { filters.forEach {
@Suppress("UNCHECKED_CAST")
add(serialize(it as Filter<Any?>)) add(serialize(it as Filter<Any?>))
} }
} }
@ -46,6 +47,7 @@ class FilterSerializer {
for (serializer in serializers) { for (serializer in serializers) {
if (filter::class.isSubclassOf(serializer.clazz)) { if (filter::class.isSubclassOf(serializer.clazz)) {
// TODO Not sure how to deal with the mess of types here // TODO Not sure how to deal with the mess of types here
@Suppress("UNCHECKED_CAST")
serializer as Serializer<Filter<Any?>> serializer as Serializer<Filter<Any?>>
serializer.serialize(out, filter) serializer.serialize(out, filter)
@ -68,6 +70,7 @@ class FilterSerializer {
fun deserialize(filters: FilterList, json: JsonArray) { fun deserialize(filters: FilterList, json: JsonArray) {
filters.zip(json).forEach { (filter, obj) -> filters.zip(json).forEach { (filter, obj) ->
@Suppress("UNCHECKED_CAST")
deserialize(filter as Filter<Any?>, obj.obj) deserialize(filter as Filter<Any?>, obj.obj)
} }
} }
@ -78,6 +81,7 @@ class FilterSerializer {
} ?: throw IllegalArgumentException("Cannot deserialize this type!") } ?: throw IllegalArgumentException("Cannot deserialize this type!")
// TODO Not sure how to deal with the mess of types here // TODO Not sure how to deal with the mess of types here
@Suppress("UNCHECKED_CAST")
serializer as Serializer<Filter<Any?>> serializer as Serializer<Filter<Any?>>
serializer.deserialize(json, filter) serializer.deserialize(json, filter)
@ -98,6 +102,7 @@ class FilterSerializer {
"null" -> null "null" -> null
else -> throw IllegalArgumentException("Cannot deserialize this type!") else -> throw IllegalArgumentException("Cannot deserialize this type!")
} }
@Suppress("UNCHECKED_CAST")
(it.second as KMutableProperty1<in Filter<Any?>, in Any?>).set(filter, res) (it.second as KMutableProperty1<in Filter<Any?>, in Any?>).set(filter, res)
} }
} }

View File

@ -1,7 +1,6 @@
package xyz.nulldev.ts.api.http.serializer package xyz.nulldev.ts.api.http.serializer
import com.github.salomonbrys.kotson.bool import com.github.salomonbrys.kotson.bool
import com.github.salomonbrys.kotson.forEach
import com.github.salomonbrys.kotson.int import com.github.salomonbrys.kotson.int
import com.github.salomonbrys.kotson.nullArray import com.github.salomonbrys.kotson.nullArray
import com.github.salomonbrys.kotson.nullObj import com.github.salomonbrys.kotson.nullObj
@ -152,6 +151,7 @@ class GroupSerializer(override val serializer: FilterSerializer) : Serializer<Fi
filter.state.forEach { filter.state.forEach {
add( add(
if (it is Filter<*>) { if (it is Filter<*>) {
@Suppress("UNCHECKED_CAST")
serializer.serialize(it as Filter<Any?>) serializer.serialize(it as Filter<Any?>)
} else { } else {
JsonNull.INSTANCE JsonNull.INSTANCE
@ -164,6 +164,7 @@ class GroupSerializer(override val serializer: FilterSerializer) : Serializer<Fi
override fun deserialize(json: JsonObject, filter: Filter.Group<Any?>) { override fun deserialize(json: JsonObject, filter: Filter.Group<Any?>) {
json[STATE].asJsonArray.forEachIndexed { index, jsonElement -> json[STATE].asJsonArray.forEachIndexed { index, jsonElement ->
if (!jsonElement.isJsonNull) { if (!jsonElement.isJsonNull) {
@Suppress("UNCHECKED_CAST")
serializer.deserialize(filter.state[index] as Filter<Any?>, jsonElement.asJsonObject) serializer.deserialize(filter.state[index] as Filter<Any?>, jsonElement.asJsonObject)
} }
} }

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center"> android:gravity="center">

View File

@ -11,9 +11,7 @@
android:id="@+id/image" android:id="@+id/image"
android:layout_width="@dimen/material_component_lists_single_line_with_avatar_height" android:layout_width="@dimen/material_component_lists_single_line_with_avatar_height"
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height" android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
android:paddingLeft="@dimen/material_component_lists_icon_left_padding"
android:paddingStart="@dimen/material_component_lists_icon_left_padding" android:paddingStart="@dimen/material_component_lists_icon_left_padding"
android:paddingRight="0dp"
android:paddingEnd="0dp" android:paddingEnd="0dp"
tools:src="@mipmap/ic_launcher_round"/> tools:src="@mipmap/ic_launcher_round"/>
@ -21,9 +19,7 @@
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/material_component_lists_text_left_padding"
android:layout_marginStart="@dimen/material_component_lists_text_left_padding" android:layout_marginStart="@dimen/material_component_lists_text_left_padding"
android:layout_marginRight="@dimen/material_component_lists_single_line_with_avatar_height"
android:layout_marginEnd="@dimen/material_component_lists_single_line_with_avatar_height" android:layout_marginEnd="@dimen/material_component_lists_single_line_with_avatar_height"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"