Implement Mihon's spotless PR (#1257)
* Remove detekt (mihonapp/mihon#1130) Annoying. More annoying in this project. (cherry picked from commit 777ae2461e1eb277a3aa0c998ff69e4f100387a1) * Add spotless (with ktlint) (mihonapp/mihon#1136) (cherry picked from commit 5ae8095ef1ed2ae9f98486f9148e933c77a28692) * Address spotless lint errors (mihonapp/mihon#1138) * Add spotless (with ktlint) * Run spotlessApply * screaming case screaming case screaming case * Update PagerViewerAdapter.kt * Update ReaderTransitionView.kt (cherry picked from commit d6252ab7703d52ecf9f43de3ee36fd63e665a31f) * Generate locales_config.xml in build dir (cherry picked from commit ac41bffdc97b4cfed923de6b9e8e01cccf3eb6eb) * Address more spotless lint errors in SY * some more missed * more missed * still missing, not sure while it won't report error when running locally * one more * more * more * correct comment --------- Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
@@ -46,11 +46,13 @@ class GalleryAdder(
|
||||
return sourceManager.getVisibleCatalogueSources()
|
||||
.mapNotNull { it.getMainSource<UrlImportableSource>() }
|
||||
.filter {
|
||||
it.lang in filters.enabledLangs && it.id !in filters.disabledSources && try {
|
||||
it.matchesUri(uri)
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
it.lang in filters.enabledLangs &&
|
||||
it.id !in filters.disabledSources &&
|
||||
try {
|
||||
it.matchesUri(uri)
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,11 +84,13 @@ class GalleryAdder(
|
||||
sourceManager.getVisibleCatalogueSources()
|
||||
.mapNotNull { it.getMainSource<UrlImportableSource>() }
|
||||
.find {
|
||||
it.lang in filters.enabledLangs && it.id !in filters.disabledSources && try {
|
||||
it.matchesUri(uri)
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
it.lang in filters.enabledLangs &&
|
||||
it.id !in filters.disabledSources &&
|
||||
try {
|
||||
it.matchesUri(uri)
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
} ?: return GalleryAddEvent.Fail.UnknownSource(url, context)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import kotlin.collections.List as ____KtList
|
||||
|
||||
public object EhAssets
|
||||
|
||||
@Suppress("ObjectPropertyName", "ktlint:standard:backing-property-naming")
|
||||
private var __AllAssets: ____KtList<ImageVector>? = null
|
||||
|
||||
public val EhAssets.AllAssets: ____KtList<ImageVector>
|
||||
|
||||
@@ -165,4 +165,5 @@ public val EhAssets.EhLogo: ImageVector
|
||||
return _ehLogo!!
|
||||
}
|
||||
|
||||
@Suppress("ObjectPropertyName", "ktlint:standard:backing-property-naming")
|
||||
private var _ehLogo: ImageVector? = null
|
||||
|
||||
@@ -427,4 +427,5 @@ public val EhAssets.MangadexLogo: ImageVector
|
||||
return _mangadexLogo!!
|
||||
}
|
||||
|
||||
@Suppress("ObjectPropertyName", "ktlint:standard:backing-property-naming")
|
||||
private var _mangadexLogo: ImageVector? = null
|
||||
|
||||
@@ -11,6 +11,7 @@ public object ExhGroup
|
||||
public val EhAssets.Exh: ExhGroup
|
||||
get() = ExhGroup
|
||||
|
||||
@Suppress("ObjectPropertyName", "ktlint:standard:backing-property-naming")
|
||||
private var __AllAssets: ____KtList<ImageVector>? = null
|
||||
|
||||
public val ExhGroup.AllAssets: ____KtList<ImageVector>
|
||||
|
||||
@@ -11,6 +11,7 @@ public object AssetsGroup
|
||||
public val ExhGroup.Assets: AssetsGroup
|
||||
get() = AssetsGroup
|
||||
|
||||
@Suppress("ObjectPropertyName", "ktlint:standard:backing-property-naming")
|
||||
private var __AllAssets: ____KtList<ImageVector>? = null
|
||||
|
||||
public val AssetsGroup.AllAssets: ____KtList<ImageVector>
|
||||
|
||||
@@ -9,6 +9,7 @@ public object EhassetsGroup
|
||||
public val AssetsGroup.Ehassets: EhassetsGroup
|
||||
get() = EhassetsGroup
|
||||
|
||||
@Suppress("ObjectPropertyName", "ktlint:standard:backing-property-naming")
|
||||
private var __AllAssets: ____KtList<ImageVector>? = null
|
||||
|
||||
public val EhassetsGroup.AllAssets: ____KtList<ImageVector>
|
||||
|
||||
@@ -88,7 +88,12 @@ class EHentaiUpdateWorker(private val context: Context, workerParams: WorkerPara
|
||||
val raisedMeta = meta.raise<EHentaiSearchMetadata>()
|
||||
|
||||
// Don't update galleries too frequently
|
||||
if (raisedMeta.aged || (curTime - raisedMeta.lastUpdateCheck < MIN_BACKGROUND_UPDATE_FREQ && DebugToggles.RESTRICT_EXH_GALLERY_UPDATE_CHECK_FREQUENCY.enabled)) {
|
||||
if (raisedMeta.aged ||
|
||||
(
|
||||
curTime - raisedMeta.lastUpdateCheck < MIN_BACKGROUND_UPDATE_FREQ &&
|
||||
DebugToggles.RESTRICT_EXH_GALLERY_UPDATE_CHECK_FREQUENCY.enabled
|
||||
)
|
||||
) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,8 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
}
|
||||
|
||||
// Validate library state
|
||||
status.value = FavoritesSyncStatus.Processing(context.stringResource(SYMR.strings.favorites_sync_verifying_library))
|
||||
status.value =
|
||||
FavoritesSyncStatus.Processing(context.stringResource(SYMR.strings.favorites_sync_verifying_library))
|
||||
val libraryManga = getLibraryManga.await()
|
||||
val seenManga = HashSet<Long>(libraryManga.size)
|
||||
libraryManga.forEach { (manga) ->
|
||||
@@ -116,10 +117,12 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
|
||||
// Download remote favorites
|
||||
val favorites = try {
|
||||
status.value = FavoritesSyncStatus.Processing(context.stringResource(SYMR.strings.favorites_sync_downloading))
|
||||
status.value =
|
||||
FavoritesSyncStatus.Processing(context.stringResource(SYMR.strings.favorites_sync_downloading))
|
||||
exh.fetchFavorites()
|
||||
} catch (e: Exception) {
|
||||
status.value = FavoritesSyncStatus.Error(context.stringResource(SYMR.strings.favorites_sync_failed_to_featch))
|
||||
status.value =
|
||||
FavoritesSyncStatus.Error(context.stringResource(SYMR.strings.favorites_sync_failed_to_featch))
|
||||
logger.e(context.stringResource(SYMR.strings.favorites_sync_could_not_fetch), e)
|
||||
return
|
||||
}
|
||||
@@ -179,7 +182,8 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
applyChangeSetToRemote(errorList, localChanges)
|
||||
}
|
||||
|
||||
status.value = FavoritesSyncStatus.Processing(context.stringResource(SYMR.strings.favorites_sync_cleaning_up))
|
||||
status.value =
|
||||
FavoritesSyncStatus.Processing(context.stringResource(SYMR.strings.favorites_sync_cleaning_up))
|
||||
storage.snapshotEntries()
|
||||
|
||||
withUIContext {
|
||||
|
||||
@@ -88,7 +88,14 @@ class LocalFavoritesStorage(
|
||||
private fun FavoriteEntry.urlEquals(other: FavoriteEntry) = (gid == other.gid && token == other.token) ||
|
||||
(otherGid != null && otherToken != null && (otherGid == other.gid && otherToken == other.token)) ||
|
||||
(other.otherGid != null && other.otherToken != null && (gid == other.otherGid && token == other.otherToken)) ||
|
||||
(otherGid != null && otherToken != null && other.otherGid != null && other.otherToken != null && otherGid == other.otherGid && otherToken == other.otherToken)
|
||||
(
|
||||
otherGid != null &&
|
||||
otherToken != null &&
|
||||
other.otherGid != null &&
|
||||
other.otherToken != null &&
|
||||
otherGid == other.otherGid &&
|
||||
otherToken == other.otherToken
|
||||
)
|
||||
|
||||
private fun queryListForEntry(list: List<FavoriteEntry>, entry: FavoriteEntry) =
|
||||
list.find { it.urlEquals(entry) && it.category == entry.category }
|
||||
|
||||
@@ -60,7 +60,14 @@ class EnhancedFilePrinter internal constructor(
|
||||
val lastFileName = writer.lastFileName
|
||||
if (fileNameGenerator.isFileNameChangeable) {
|
||||
val newFileName = fileNameGenerator.generateFileName(logLevel, System.currentTimeMillis())
|
||||
require(!(newFileName == null || newFileName.trim { it <= ' ' }.isEmpty())) { "File name should not be empty." }
|
||||
require(
|
||||
!(
|
||||
newFileName == null ||
|
||||
newFileName.trim {
|
||||
it <= ' '
|
||||
}.isEmpty()
|
||||
),
|
||||
) { "File name should not be empty." }
|
||||
if (newFileName != lastFileName) {
|
||||
if (writer.isOpened) {
|
||||
writer.close()
|
||||
|
||||
@@ -115,7 +115,7 @@ class MangaDexFollowsScreen(private val sourceId: Long) : Screen() {
|
||||
dialog.duplicate.id,
|
||||
dialog.manga.id,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
is BrowseSourceScreenModel.Dialog.RemoveManga -> {
|
||||
|
||||
@@ -131,10 +131,14 @@ class ApiMangaParser(
|
||||
// things that will go with the genre tags but aren't actually genre
|
||||
val nonGenres = listOfNotNull(
|
||||
mangaAttributesDto.publicationDemographic
|
||||
?.let { RaisedTag("Demographic", it.capitalize(Locale.US), MangaDexSearchMetadata.TAG_TYPE_DEFAULT) },
|
||||
?.let {
|
||||
RaisedTag("Demographic", it.capitalize(Locale.US), MangaDexSearchMetadata.TAG_TYPE_DEFAULT)
|
||||
},
|
||||
mangaAttributesDto.contentRating
|
||||
?.takeUnless { it == "safe" }
|
||||
?.let { RaisedTag("Content Rating", it.capitalize(Locale.US), MangaDexSearchMetadata.TAG_TYPE_DEFAULT) },
|
||||
?.let {
|
||||
RaisedTag("Content Rating", it.capitalize(Locale.US), MangaDexSearchMetadata.TAG_TYPE_DEFAULT)
|
||||
},
|
||||
)
|
||||
|
||||
val genres = nonGenres + mangaAttributesDto.tags
|
||||
|
||||
@@ -36,7 +36,7 @@ class NamicomiHandler(currentClient: OkHttpClient, userAgent: String) {
|
||||
val hash = data.jsonObject["hash"]!!.jsonPrimitive.content
|
||||
|
||||
/* Available quality levels: source, high, medium, low */
|
||||
val quality = if(dataSaver) "low" else "high"
|
||||
val quality = if (dataSaver) "low" else "high"
|
||||
|
||||
return data
|
||||
.jsonObject[quality]!!
|
||||
|
||||
@@ -15,7 +15,6 @@ import exh.source.getMainSource
|
||||
import exh.util.dropBlank
|
||||
import exh.util.floor
|
||||
import exh.util.nullIfZero
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.FormBody
|
||||
|
||||
@@ -50,7 +50,11 @@ class MetadataViewScreen(private val mangaId: Long, private val sourceId: Long)
|
||||
)
|
||||
},
|
||||
) { paddingValues ->
|
||||
when (@Suppress("NAME_SHADOWING") val state = state) {
|
||||
when
|
||||
(
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val state = state
|
||||
) {
|
||||
MetadataViewState.Loading -> LoadingScreen()
|
||||
MetadataViewState.MetadataNotFound -> EmptyScreen(MR.strings.no_results_found)
|
||||
MetadataViewState.SourceNotFound -> EmptyScreen(MR.strings.source_empty_screen)
|
||||
@@ -58,7 +62,8 @@ class MetadataViewScreen(private val mangaId: Long, private val sourceId: Long)
|
||||
val context = LocalContext.current
|
||||
val items = remember(state.meta) { state.meta.getExtraInfoPairs(context) }
|
||||
ScrollbarLazyColumn(
|
||||
contentPadding = paddingValues + WindowInsets.navigationBars.asPaddingValues() + topSmallPaddingValues,
|
||||
contentPadding =
|
||||
paddingValues + WindowInsets.navigationBars.asPaddingValues() + topSmallPaddingValues,
|
||||
) {
|
||||
items(items) { (title, text) ->
|
||||
Row(
|
||||
|
||||
@@ -41,7 +41,11 @@ fun EHentaiDescription(state: State.Success, openMetadataViewer: () -> Unit, sea
|
||||
?: meta.genre
|
||||
?: context.stringResource(MR.strings.unknown)
|
||||
|
||||
binding.visible.text = context.stringResource(SYMR.strings.is_visible, meta.visible ?: context.stringResource(MR.strings.unknown))
|
||||
binding.visible.text =
|
||||
context.stringResource(
|
||||
SYMR.strings.is_visible,
|
||||
meta.visible ?: context.stringResource(MR.strings.unknown),
|
||||
)
|
||||
|
||||
binding.favorites.text = (meta.favorites ?: 0).toString()
|
||||
binding.favorites.bindDrawable(context, R.drawable.ic_book_24dp)
|
||||
@@ -65,7 +69,8 @@ fun EHentaiDescription(state: State.Success, openMetadataViewer: () -> Unit, sea
|
||||
val ratingFloat = meta.averageRating?.toFloat()
|
||||
binding.ratingBar.rating = ratingFloat ?: 0F
|
||||
@SuppressLint("SetTextI18n")
|
||||
binding.rating.text = (ratingFloat ?: 0F).toString() + " - " + MetadataUIUtil.getRatingString(context, ratingFloat?.times(2))
|
||||
binding.rating.text =
|
||||
(ratingFloat ?: 0F).toString() + " - " + MetadataUIUtil.getRatingString(context, ratingFloat?.times(2))
|
||||
|
||||
binding.moreInfo.bindDrawable(context, R.drawable.ic_info_24dp)
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ fun HBrowseDescription(state: State.Success, openMetadataViewer: () -> Unit) {
|
||||
if (meta == null || meta !is HBrowseSearchMetadata) return@AndroidView
|
||||
val binding = DescriptionAdapterHbBinding.bind(it)
|
||||
|
||||
binding.pages.text = context.pluralStringResource(SYMR.plurals.num_pages, meta.length ?: 0, meta.length ?: 0)
|
||||
binding.pages.text =
|
||||
context.pluralStringResource(SYMR.plurals.num_pages, meta.length ?: 0, meta.length ?: 0)
|
||||
binding.pages.bindDrawable(context, R.drawable.ic_baseline_menu_book_24)
|
||||
|
||||
binding.moreInfo.bindDrawable(context, R.drawable.ic_info_24dp)
|
||||
|
||||
@@ -34,7 +34,8 @@ fun MangaDexDescription(state: State.Success, openMetadataViewer: () -> Unit) {
|
||||
val ratingFloat = meta.rating
|
||||
binding.ratingBar.rating = ratingFloat?.div(2F) ?: 0F
|
||||
@SuppressLint("SetTextI18n")
|
||||
binding.rating.text = (round((ratingFloat ?: 0F) * 100.0) / 100.0).toString() + " - " + getRatingString(context, ratingFloat)
|
||||
binding.rating.text =
|
||||
(round((ratingFloat ?: 0F) * 100.0) / 100.0).toString() + " - " + getRatingString(context, ratingFloat)
|
||||
binding.rating.isVisible = ratingFloat != null
|
||||
binding.ratingBar.isVisible = ratingFloat != null
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ fun NHentaiDescription(state: State.Success, openMetadataViewer: () -> Unit) {
|
||||
binding.whenPosted.text = MetadataUtil.EX_DATE_FORMAT
|
||||
.format(
|
||||
ZonedDateTime
|
||||
.ofInstant(Instant.ofEpochSecond(meta.uploadDate ?: 0), ZoneId.systemDefault())
|
||||
.ofInstant(Instant.ofEpochSecond(meta.uploadDate ?: 0), ZoneId.systemDefault()),
|
||||
)
|
||||
|
||||
binding.pages.text = context.pluralStringResource(
|
||||
|
||||
@@ -32,12 +32,13 @@ fun PururinDescription(state: State.Success, openMetadataViewer: () -> Unit) {
|
||||
if (meta == null || meta !is PururinSearchMetadata) return@AndroidView
|
||||
val binding = DescriptionAdapterPuBinding.bind(it)
|
||||
|
||||
binding.genre.text = meta.tags.find { it.namespace == PururinSearchMetadata.TAG_NAMESPACE_CATEGORY }.let { genre ->
|
||||
genre?.let { MetadataUIUtil.getGenreAndColour(context, it.name) }?.let {
|
||||
binding.genre.setBackgroundColor(it.first)
|
||||
it.second
|
||||
} ?: genre?.name ?: context.stringResource(MR.strings.unknown)
|
||||
}
|
||||
binding.genre.text =
|
||||
meta.tags.find { it.namespace == PururinSearchMetadata.TAG_NAMESPACE_CATEGORY }.let { genre ->
|
||||
genre?.let { MetadataUIUtil.getGenreAndColour(context, it.name) }?.let {
|
||||
binding.genre.setBackgroundColor(it.first)
|
||||
it.second
|
||||
} ?: genre?.name ?: context.stringResource(MR.strings.unknown)
|
||||
}
|
||||
|
||||
binding.uploader.text = meta.uploaderDisp ?: meta.uploader.orEmpty()
|
||||
|
||||
@@ -50,7 +51,9 @@ fun PururinDescription(state: State.Success, openMetadataViewer: () -> Unit) {
|
||||
val ratingFloat = meta.averageRating?.toFloat()
|
||||
binding.ratingBar.rating = ratingFloat ?: 0F
|
||||
@SuppressLint("SetTextI18n")
|
||||
binding.rating.text = (round((ratingFloat ?: 0F) * 100.0) / 100.0).toString() + " - " + MetadataUIUtil.getRatingString(context, ratingFloat?.times(2))
|
||||
binding.rating.text =
|
||||
(round((ratingFloat ?: 0F) * 100.0) / 100.0).toString() + " - " +
|
||||
MetadataUIUtil.getRatingString(context, ratingFloat?.times(2))
|
||||
|
||||
binding.moreInfo.bindDrawable(context, R.drawable.ic_info_24dp)
|
||||
|
||||
|
||||
@@ -45,12 +45,15 @@ fun TsuminoDescription(state: State.Success, openMetadataViewer: () -> Unit) {
|
||||
|
||||
binding.uploader.text = meta.uploader ?: context.stringResource(MR.strings.unknown)
|
||||
|
||||
binding.pages.text = context.pluralStringResource(SYMR.plurals.num_pages, meta.length ?: 0, meta.length ?: 0)
|
||||
binding.pages.text =
|
||||
context.pluralStringResource(SYMR.plurals.num_pages, meta.length ?: 0, meta.length ?: 0)
|
||||
binding.pages.bindDrawable(context, R.drawable.ic_baseline_menu_book_24)
|
||||
|
||||
binding.ratingBar.rating = meta.averageRating ?: 0F
|
||||
@SuppressLint("SetTextI18n")
|
||||
binding.rating.text = (round((meta.averageRating ?: 0F) * 100.0) / 100.0).toString() + " - " + MetadataUIUtil.getRatingString(context, meta.averageRating?.times(2))
|
||||
binding.rating.text =
|
||||
(round((meta.averageRating ?: 0F) * 100.0) / 100.0).toString() + " - " +
|
||||
MetadataUIUtil.getRatingString(context, meta.averageRating?.times(2))
|
||||
|
||||
binding.moreInfo.bindDrawable(context, R.drawable.ic_info_24dp)
|
||||
|
||||
|
||||
@@ -92,20 +92,21 @@ private class WsrvNlDataSaver(preferences: SourcePreferences) : DataSaver {
|
||||
|
||||
private fun getUrl(imageUrl: String): String {
|
||||
// Network Request sent to wsrv
|
||||
return "https://wsrv.nl/?url=$imageUrl" + if (imageUrl.contains(".webp", true) || imageUrl.contains(".gif", true)) {
|
||||
if (!format) {
|
||||
// Preserve output image extension for animated images(.webp and .gif)
|
||||
"&q=$quality&n=-1"
|
||||
return "https://wsrv.nl/?url=$imageUrl" +
|
||||
if (imageUrl.contains(".webp", true) || imageUrl.contains(".gif", true)) {
|
||||
if (!format) {
|
||||
// Preserve output image extension for animated images(.webp and .gif)
|
||||
"&q=$quality&n=-1"
|
||||
} else {
|
||||
// Do not preserve output Extension if User asked to convert into Jpeg
|
||||
"&output=jpg&q=$quality&n=-1"
|
||||
}
|
||||
} else {
|
||||
// Do not preserve output Extension if User asked to convert into Jpeg
|
||||
"&output=jpg&q=$quality&n=-1"
|
||||
if (format) {
|
||||
"&output=jpg&q=$quality"
|
||||
} else {
|
||||
"&output=webp&q=$quality"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (format) {
|
||||
"&output=jpg&q=$quality"
|
||||
} else {
|
||||
"&output=webp&q=$quality"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package exh.util
|
||||
|
||||
inline fun <T> ignore(expr: () -> T): T? {
|
||||
return try { expr() } catch (t: Throwable) { null }
|
||||
return try {
|
||||
expr()
|
||||
} catch (t: Throwable) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Throwable> T.withRootCause(cause: Throwable): T {
|
||||
|
||||
Reference in New Issue
Block a user