ContentWrapper(
+fun ContentWrapper(
stateFlow: LiveData,
config: IStateLayoutConfig = koinInject(),
param: P? = null,
@@ -129,14 +148,15 @@ fun ContentWrapper(
if (param == null) {
ErrorContent(
config = config,
- state = LoadState.Error(
- RequestError(
- topic = stringResource(R.string.app_controller_heading_missing_param),
- description = stringResource(R.string.app_controller_message_missing_param),
- )
- ),
+ state =
+ LoadState.Error(
+ RequestError(
+ topic = stringResource(R.string.app_controller_heading_missing_param),
+ description = stringResource(R.string.app_controller_message_missing_param),
+ ),
+ ),
modifier = modifier,
- onClick = onClick
+ onClick = onClick,
)
return
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/AniTrendImage.kt b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/AniTrendImage.kt
index ee404ba11..2e0deec21 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/AniTrendImage.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/AniTrendImage.kt
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2024 AniTrend
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package co.anitrend.core.android.compose.design.image
import androidx.compose.foundation.clickable
@@ -8,7 +24,6 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import co.anitrend.core.android.helpers.image.model.RequestImage
-import co.anitrend.core.android.helpers.image.model.RequestImage.Media.ImageType.*
import co.anitrend.core.android.helpers.image.toRequestBuilder
import co.anitrend.domain.common.entity.contract.ICoverImage
import co.anitrend.domain.common.entity.contract.IMediaCover
@@ -43,27 +58,33 @@ fun AniTrendImage(
onClick: (ImageViewerRouter.ImageSourceParam) -> Unit,
) {
val context = LocalContext.current
- val requestImageBuilder = rememberRequestImage(
- image = image,
- type = imageType
- ) { toRequestBuilder(context, transformations) }
+ val requestImageBuilder =
+ rememberRequestImage(
+ image = image,
+ type = imageType,
+ ) { toRequestBuilder(context, transformations) }
AsyncImage(
model = requestImageBuilder.build(),
contentDescription = "$imageType image",
contentScale = contentScale,
- modifier = modifier.clickable {
- val source = when (image) {
- is IMediaCover -> {
- if (imageType == BANNER) image.banner
- else image.extraLarge ?: image.large ?: image.medium
- }
- else -> image.large ?: image.medium
- } ?: return@clickable
+ modifier =
+ modifier.clickable {
+ val source =
+ when (image) {
+ is IMediaCover -> {
+ if (imageType == RequestImage.Media.ImageType.BANNER) {
+ image.banner
+ } else {
+ image.extraLarge ?: image.large ?: image.medium
+ }
+ }
+ else -> image.large ?: image.medium
+ } ?: return@clickable
- onClick(
- ImageViewerRouter.ImageSourceParam(source)
- )
- },
+ onClick(
+ ImageViewerRouter.ImageSourceParam(source),
+ )
+ },
)
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/CoverImageUtils.kt b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/CoverImageUtils.kt
index 602c475bb..ce5cb1208 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/CoverImageUtils.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/CoverImageUtils.kt
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2024 AniTrend
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package co.anitrend.core.android.compose.design.image
import androidx.compose.runtime.Composable
@@ -13,10 +29,11 @@ import coil.request.ImageRequest
fun rememberRequestImage(
image: ICoverImage,
type: RequestImage.Media.ImageType,
- builder: RequestImage.() -> ImageRequest.Builder
-): ImageRequest.Builder = remember(image) {
- when (image) {
- is IMediaCover -> image.toMediaRequestImage(type)
- else -> image.toRequestImage()
- }.run(builder)
-}
+ builder: RequestImage.() -> ImageRequest.Builder,
+): ImageRequest.Builder =
+ remember(image) {
+ when (image) {
+ is IMediaCover -> image.toMediaRequestImage(type)
+ else -> image.toRequestImage()
+ }.run(builder)
+ }
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/AndroidPowerController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/AndroidPowerController.kt
index a38ff8aa6..afed55961 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/AndroidPowerController.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/AndroidPowerController.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.controller.power
import android.content.Context
@@ -45,17 +44,16 @@ internal class AndroidPowerController(
private val connectivityManager: ConnectivityManager?,
private val settings: IPowerSettings,
) : IPowerController {
-
override fun powerSaverStateFlow(ignorePreference: Boolean): Flow {
return when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> {
merge(
context.flowOfBroadcast(
- IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED)
+ IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED),
),
context.flowOfBroadcast(
- IntentFilter(ConnectivityManager.ACTION_RESTRICT_BACKGROUND_CHANGED)
- )
+ IntentFilter(ConnectivityManager.ACTION_RESTRICT_BACKGROUND_CHANGED),
+ ),
).map {
powerSaverState()
}.onStart {
@@ -64,7 +62,7 @@ internal class AndroidPowerController(
}
else -> {
context.flowOfBroadcast(
- IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED)
+ IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED),
).map {
powerSaverState()
}.onStart {
@@ -74,18 +72,19 @@ internal class AndroidPowerController(
}
}
- override fun powerSaverState(): PowerSaverState = when {
- settings.isPowerSaverOn.value -> {
- PowerSaverState.Enabled(PowerSaverState.Reason.PREFERENCE)
- }
- powerManager?.isPowerSaveMode == true -> {
- PowerSaverState.Enabled(PowerSaverState.Reason.SYSTEM_POWER_SAVER)
- }
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isBackgroundDataRestricted() -> {
- PowerSaverState.Enabled(PowerSaverState.Reason.SYSTEM_DATA_SAVER)
+ override fun powerSaverState(): PowerSaverState =
+ when {
+ settings.isPowerSaverOn.value -> {
+ PowerSaverState.Enabled(PowerSaverState.Reason.PREFERENCE)
+ }
+ powerManager?.isPowerSaveMode == true -> {
+ PowerSaverState.Enabled(PowerSaverState.Reason.SYSTEM_POWER_SAVER)
+ }
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isBackgroundDataRestricted() -> {
+ PowerSaverState.Enabled(PowerSaverState.Reason.SYSTEM_DATA_SAVER)
+ }
+ else -> PowerSaverState.Disabled
}
- else -> PowerSaverState.Disabled
- }
override fun disableBatteryOptimization() {
val packageUri = "package:${context.packageName}"
@@ -95,7 +94,7 @@ internal class AndroidPowerController(
intentOf {
action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
data = packageUri.toUri()
- }
+ },
)
}.onFailure(Timber::e)
}
@@ -104,6 +103,6 @@ internal class AndroidPowerController(
@RequiresApi(Build.VERSION_CODES.N)
private fun isBackgroundDataRestricted(): Boolean {
return connectivityManager?.restrictBackgroundStatus ==
- ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED
+ ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED
}
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/contract/IPowerController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/contract/IPowerController.kt
index 66d2fb80f..934b80ac2 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/contract/IPowerController.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/contract/IPowerController.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.controller.power.contract
import kotlinx.coroutines.flow.Flow
@@ -25,9 +24,7 @@ import kotlinx.coroutines.flow.Flow
* @see [co.anitrend.data.settings.power.IPowerSettings]
*/
interface IPowerController {
- fun powerSaverStateFlow(
- ignorePreference: Boolean
- ): Flow
+ fun powerSaverStateFlow(ignorePreference: Boolean): Flow
fun powerSaverState(): PowerSaverState
@@ -36,8 +33,9 @@ interface IPowerController {
sealed class PowerSaverState {
data object Disabled : PowerSaverState()
+
data class Enabled(
- val reason: Reason
+ val reason: Reason,
) : PowerSaverState()
enum class Reason {
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/WidgetController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/WidgetController.kt
index 3e035acc6..9ff2d56aa 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/WidgetController.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/WidgetController.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.controller.widget
import co.anitrend.arch.extension.lifecycle.SupportLifecycle
@@ -25,7 +24,6 @@ import co.anitrend.core.android.controller.widget.contract.IWidgetController
* is to delegate view logic outside of the UI driver (e.g. Activity, Fragment, View)
*/
abstract class WidgetController : IWidgetController, SupportLifecycle {
-
/**
* This is called when the view is attached to a window. At this point it
* has a Surface and will start drawing.
@@ -45,4 +43,4 @@ abstract class WidgetController : IWidgetController, SupportLifecycle {
override fun onDetached() {
// Optional use-case
}
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/contract/IWidgetController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/contract/IWidgetController.kt
index 555d4a107..26e3ca58a 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/contract/IWidgetController.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/contract/IWidgetController.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,14 +14,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.controller.widget.contract
/**
* Widget controller contract
*/
interface IWidgetController {
-
/**
* This is called when the view is attached to a window. At this point it
* has a Surface and will start drawing.
@@ -37,4 +35,4 @@ interface IWidgetController {
* @see android.view.View.onAttachedToWindow
*/
fun onDetached()
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CascadeMenuExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CascadeMenuExtensions.kt
index ba9568e9a..d8c5522ab 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CascadeMenuExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CascadeMenuExtensions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.extensions
import android.content.Context
@@ -38,12 +37,12 @@ fun Context.cascadePopupStyler(): CascadePopupMenu.Styler {
val rippleDrawable = {
RippleDrawable(
ColorStateList.valueOf(
- getColorFromAttr(androidx.appcompat.R.attr.colorPrimaryDark)
+ getColorFromAttr(androidx.appcompat.R.attr.colorPrimaryDark),
),
null,
ColorDrawable(
- getColorFromAttr(com.google.android.material.R.attr.colorOnBackground)
- )
+ getColorFromAttr(com.google.android.material.R.attr.colorOnBackground),
+ ),
)
}
@@ -51,26 +50,28 @@ fun Context.cascadePopupStyler(): CascadePopupMenu.Styler {
background = {
RoundedDrawable(
color = getColorFromAttr(com.google.android.material.R.attr.colorPrimaryVariant),
- radius = 8f.dp
+ radius = 8f.dp,
)
},
menuTitle = { header ->
- header.titleView.typeface = ResourcesCompat.getFont(
- this,
- co.anitrend.arch.theme.R.font.product_sans_regular
- )
+ header.titleView.typeface =
+ ResourcesCompat.getFont(
+ this,
+ co.anitrend.arch.theme.R.font.product_sans_regular,
+ )
header.setBackground(rippleDrawable())
},
menuItem = { item ->
- item.titleView.typeface = ResourcesCompat.getFont(
- this,
- co.anitrend.arch.theme.R.font.product_sans_regular
- )
+ item.titleView.typeface =
+ ResourcesCompat.getFont(
+ this,
+ co.anitrend.arch.theme.R.font.product_sans_regular,
+ )
item.setBackground(rippleDrawable())
item.setGroupDividerColor(
- getColorFromAttr(com.google.android.material.R.attr.colorOnSurface)
+ getColorFromAttr(com.google.android.material.R.attr.colorOnSurface),
)
- }
+ },
)
}
@@ -84,7 +85,7 @@ fun View.cascadeMenu(): CascadePopupMenu {
context = context,
anchor = this,
gravity = Gravity.NO_GRAVITY,
- styler = context.cascadePopupStyler()
+ styler = context.cascadePopupStyler(),
)
}
@@ -96,11 +97,11 @@ fun View.cascadeMenu(): CascadePopupMenu {
*/
fun CascadePopupMenu.onMenu(
shouldNavigateBack: Boolean = true,
- action: Menu.() -> Unit
+ action: Menu.() -> Unit,
): CascadePopupMenu {
MenuCompat.setGroupDividerEnabled(menu, true)
menu.action()
- if (shouldNavigateBack)
+ if (shouldNavigateBack) {
menu.allChildren.filter { menuItem ->
menuItem.intent == null
}.forEach { menuItem ->
@@ -108,5 +109,6 @@ fun CascadePopupMenu.onMenu(
navigateBack()
}
}
+ }
return this
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ChipExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ChipExtensions.kt
index e1990d9d7..fc831c495 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ChipExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ChipExtensions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.extensions
import android.content.Context
@@ -27,7 +26,7 @@ import com.google.android.material.chip.Chip
fun Chip.asChoice() {
style(co.anitrend.core.android.R.style.AppTheme_Material_Chip_Choice)
setChipBackgroundColorResource(
- co.anitrend.core.android.R.color.selector_chip_background
+ co.anitrend.core.android.R.color.selector_chip_background,
)
isCheckedIconVisible = false
isCheckable = true
@@ -40,9 +39,7 @@ fun Chip.asChoice() {
*
* @see asChoice
*/
-inline fun Chip.asChoice(
- action: Chip.() -> Unit
-): Chip {
+inline fun Chip.asChoice(action: Chip.() -> Unit): Chip {
asChoice()
action(this)
return this
@@ -53,6 +50,4 @@ inline fun Chip.asChoice(
*
* @param action Delegate to access the chip
*/
-inline fun Context.createChipChoice(
- action: Chip.() -> Unit
-): Chip = Chip(this).asChoice(action)
+inline fun Context.createChipChoice(action: Chip.() -> Unit): Chip = Chip(this).asChoice(action)
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ContextExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ContextExtensions.kt
index 7280e2be1..c22f8e332 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ContextExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ContextExtensions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.extensions
import android.content.Context
@@ -32,11 +31,12 @@ import timber.log.Timber
* @throws NotImplementedError when a context type cannot be handled
*/
@Throws(NotImplementedError::class)
-fun Context.fragmentManager() = when (this) {
- is FragmentActivity -> supportFragmentManager
- is ContextWrapper -> (baseContext as FragmentActivity).supportFragmentManager
- else -> throw NotImplementedError("This type of context: $this is not handled/supported")
-}
+fun Context.fragmentManager() =
+ when (this) {
+ is FragmentActivity -> supportFragmentManager
+ is ContextWrapper -> (baseContext as FragmentActivity).supportFragmentManager
+ else -> throw NotImplementedError("This type of context: $this is not handled/supported")
+ }
@Throws(IllegalArgumentException::class)
fun Context.requireLifecycleOwner(): LifecycleOwner {
@@ -57,4 +57,4 @@ fun Context.lifecycleOwner(): LifecycleOwner? {
fun Context.lifecycleScope(): LifecycleCoroutineScope? {
val lifecycleOwner = lifecycleOwner()
return lifecycleOwner?.lifecycleScope
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CoreExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CoreExtensions.kt
index 1785d2873..d878fb022 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CoreExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CoreExtensions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.extensions
import android.content.res.Resources
@@ -28,8 +27,11 @@ fun Int.toHumanReadableQuantity(digits: Int = 1): String {
if (quantity < unit) return "$quantity"
val exp = (ln(quantity.toDouble()) / ln(unit.toDouble())).toInt()
val suffix = "KMGTPE"[exp - 1].toString()
- return String.format(Locale.getDefault(), "%.${digits}f %s",
- quantity / unit.toDouble().pow(exp.toDouble()), suffix
+ return String.format(
+ Locale.getDefault(),
+ "%.${digits}f %s",
+ quantity / unit.toDouble().pow(exp.toDouble()),
+ suffix,
)
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/InsetsExentions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/InsetsExentions.kt
index 40d562988..b11ca5ded 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/InsetsExentions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/InsetsExentions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.extensions
import android.view.ViewGroup
@@ -31,8 +30,8 @@ fun ViewGroup.applySystemBarsWindowInsetsListener() {
val systemBars = WindowInsetsCompat.Type.systemBars()
view.setTag(
R.id.tag_system_window_inset_top,
- windowInsetsCompat.getInsets(systemBars)
+ windowInsetsCompat.getInsets(systemBars),
)
windowInsets
}
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/IntentExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/IntentExtensions.kt
index 50155f4cc..35efeb56b 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/IntentExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/IntentExtensions.kt
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2024 AniTrend
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package co.anitrend.core.android.extensions
import android.content.Intent
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/LiveDataExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/LiveDataExtensions.kt
index 33fe329bc..4b7cda889 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/LiveDataExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/LiveDataExtensions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 AniTrend
+ * Copyright (C) 2022 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.extensions
import androidx.lifecycle.LifecycleOwner
@@ -30,11 +29,17 @@ import androidx.lifecycle.Observer
* @param owner The [LifecycleOwner] which controls the observer
* @param observer The observer that will receive the events
*/
-fun LiveData.observeOnce(owner: LifecycleOwner, observer: (T) -> Unit) {
- observe(owner, object: Observer {
- override fun onChanged(value: T) {
- removeObserver(this)
- observer(value)
- }
- })
-}
\ No newline at end of file
+fun LiveData.observeOnce(
+ owner: LifecycleOwner,
+ observer: (T) -> Unit,
+) {
+ observe(
+ owner,
+ object : Observer {
+ override fun onChanged(value: T) {
+ removeObserver(this)
+ observer(value)
+ }
+ },
+ )
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/TimberExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/TimberExtensions.kt
index 0896405c7..ce4a1a0d1 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/TimberExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/TimberExtensions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 AniTrend
+ * Copyright (C) 2022 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.extensions
import co.anitrend.arch.analytics.contract.ISupportAnalytics
@@ -30,7 +29,9 @@ object Tags {
private const val STATE_PREFIX = "state_"
fun action(postfix: String) = ACTION_PREFIX.plus(postfix)
+
fun view(postfix: String) = VIEW_PREFIX.plus(postfix)
+
fun state(postfix: String) = STATE_PREFIX.plus(postfix)
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ViewExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ViewExtensions.kt
index d3f0ab9f2..1d44cc6b8 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ViewExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ViewExtensions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.extensions
import android.content.Intent
@@ -29,11 +28,12 @@ import androidx.viewpager2.widget.ViewPager2
import timber.log.Timber
fun View.startViewIntent(url: String) {
- val intent = Intent().apply {
- flags = Intent.FLAG_ACTIVITY_NEW_TASK
- action = Intent.ACTION_VIEW
- data = url.toUri()
- }
+ val intent =
+ Intent().apply {
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK
+ action = Intent.ACTION_VIEW
+ data = url.toUri()
+ }
runCatching {
context.startActivity(intent)
}.onFailure { Timber.w(it) }
@@ -53,7 +53,9 @@ fun View.setTooltip(tooltipText: String) {
*
* @param tooltipText the tooltip text
*/
-fun View.setTooltip(@StringRes tooltipText: Int) {
+fun View.setTooltip(
+ @StringRes tooltipText: Int,
+) {
setTooltip(context.getString(tooltipText))
}
@@ -75,4 +77,4 @@ fun ViewPager2.enableBottomSheetScrolling() {
*/
fun View.fragmentManager(): FragmentManager {
return context.fragmentManager()
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/color/ColorExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/color/ColorExtensions.kt
index c9d0b4066..705eb6051 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/color/ColorExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/color/ColorExtensions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.helpers.color
import android.content.Context
@@ -27,10 +26,10 @@ import co.anitrend.domain.common.HexColor
/** Checks if a color has enough contrast */
fun Int.hasEnoughContrastFor(
- @ColorInt backgroundColor: Int
+ @ColorInt backgroundColor: Int,
) = ColorUtils.calculateContrast(
this,
- backgroundColor
+ backgroundColor,
) > 1.8f
/** Decreases the lightness of the color by the [factor] */
@@ -47,11 +46,15 @@ fun Int.increaseContrastBy(factor: Float): Int {
* @param backgroundColor Current background color to allow auto adjusting contrast
*/
@ColorInt
-fun HexColor.asColorInt(@ColorInt backgroundColor: Int): Int {
+fun HexColor.asColorInt(
+ @ColorInt backgroundColor: Int,
+): Int {
val foregroundColor = Color.parseColor(toString())
- return if (foregroundColor.hasEnoughContrastFor(backgroundColor))
+ return if (foregroundColor.hasEnoughContrastFor(backgroundColor)) {
foregroundColor
- else foregroundColor.increaseContrastBy(0.5f)
+ } else {
+ foregroundColor.increaseContrastBy(0.5f)
+ }
}
/**
@@ -70,5 +73,4 @@ fun HexColor.asColorInt(context: Context): Int {
*
* @param context Used to retrieve current theme background color for contrast fixes
*/
-fun HexColor.asDrawable(context: Context) =
- ColorDrawable(asColorInt(context))
+fun HexColor.asDrawable(context: Context) = ColorDrawable(asColorInt(context))
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/date/AniTrendDateHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/date/AniTrendDateHelper.kt
index d093e4a92..9ef2f0bc0 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/date/AniTrendDateHelper.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/date/AniTrendDateHelper.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.helpers.date
import androidx.annotation.IntRange
@@ -31,14 +30,14 @@ import java.util.Date
import java.util.Locale
class AniTrendDateHelper : AbstractSupportDateHelper() {
-
/**
* Returns the current month in the form of an [Int].
*
* @return [IntRange] between 0 - 11
*/
val month: Int
- @IntRange(from = 0, to = 11) get() =
+ @IntRange(from = 0, to = 11)
+ get() =
Calendar.getInstance().get(Calendar.MONTH)
/**
@@ -47,7 +46,8 @@ class AniTrendDateHelper : AbstractSupportDateHelper() {
* @return [IntRange] between 1 - 31
*/
val day: Int
- @IntRange(from = 0, to = 30) get() =
+ @IntRange(from = 0, to = 30)
+ get() =
Calendar.getInstance().get(Calendar.DATE)
/**
@@ -59,11 +59,12 @@ class AniTrendDateHelper : AbstractSupportDateHelper() {
/**
* @return [FuzzyDate]
*/
- fun fuzzyDateNow() = FuzzyDate(
- day = day,
- month = month.plus(1),
- year = year
- )
+ fun fuzzyDateNow() =
+ FuzzyDate(
+ day = day,
+ month = month.plus(1),
+ year = year,
+ )
/**
* @return current seasons name
@@ -85,46 +86,61 @@ class AniTrendDateHelper : AbstractSupportDateHelper() {
* @return current year with a given delta
*/
override fun getCurrentYear(delta: Int): Int {
- return if (month >= 11 && currentSeason == SeasonType.WINTER)
+ return if (month >= 11 && currentSeason == SeasonType.WINTER) {
year + delta
- else year
+ } else {
+ year
+ }
}
fun convertToTextDate(fuzzyDate: FuzzyDate?): CharSequence? {
if (fuzzyDate == null || fuzzyDate.isDateNotSet()) return null
- val month = if (fuzzyDate.month <= 9)
- "0${fuzzyDate.month}"
- else "${fuzzyDate.month}"
+ val month =
+ if (fuzzyDate.month <= 9) {
+ "0${fuzzyDate.month}"
+ } else {
+ "${fuzzyDate.month}"
+ }
- val day = if (fuzzyDate.day <= 9)
- "0${fuzzyDate.day}"
- else "${fuzzyDate.day}"
+ val day =
+ if (fuzzyDate.day <= 9) {
+ "0${fuzzyDate.day}"
+ } else {
+ "${fuzzyDate.day}"
+ }
- val dateFormatted = "${fuzzyDate.year}-${month}-${day}"
- val dateFormatter = DateTimeFormatter.ofPattern(
- "yyyy-MM-dd", Locale.getDefault()
- )
+ val dateFormatted = "${fuzzyDate.year}-$month-$day"
+ val dateFormatter =
+ DateTimeFormatter.ofPattern(
+ "yyyy-MM-dd",
+ Locale.getDefault(),
+ )
val parsedDate = dateFormatter.parse(dateFormatted)
val localDate = from(parsedDate)
- val outputDateFormat = DateTimeFormatter.ofPattern(
- "MMM dd, yyyy", Locale.getDefault()
- )
+ val outputDateFormat =
+ DateTimeFormatter.ofPattern(
+ "MMM dd, yyyy",
+ Locale.getDefault(),
+ )
return localDate.format(outputDateFormat)
}
fun convertToUnixTimeStamp(fuzzyDate: FuzzyDate): Long {
val fuzzyTextDate = convertToTextDate(fuzzyDate)
- val dateFormatter = DateTimeFormatter.ofPattern(
- "MMM dd, yyyy", Locale.getDefault()
- )
+ val dateFormatter =
+ DateTimeFormatter.ofPattern(
+ "MMM dd, yyyy",
+ Locale.getDefault(),
+ )
val parsedDate = dateFormatter.parse(fuzzyTextDate)
- val instant = from(parsedDate).atTime(LocalTime.MIDNIGHT)
- .toInstant(ZoneOffset.UTC)
+ val instant =
+ from(parsedDate).atTime(LocalTime.MIDNIGHT)
+ .toInstant(ZoneOffset.UTC)
return instant.toEpochMilli()
}
@@ -136,7 +152,7 @@ class AniTrendDateHelper : AbstractSupportDateHelper() {
return FuzzyDate(
year = segments[0].toInt(),
month = segments[1].toInt(),
- day = segments[2].toInt()
+ day = segments[2].toInt(),
)
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/ImageExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/ImageExtensions.kt
index f86e8106a..559cfea83 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/ImageExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/ImageExtensions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.helpers.image
import android.content.Context
@@ -34,7 +33,6 @@ import coil.request.ImageRequest
import coil.target.Target
import coil.transform.RoundedCornersTransformation
import coil.transform.Transformation
-import coil.transition.CrossfadeTransition
val roundedCornersTransformation =
RoundedCornersTransformation(8f.dp)
@@ -67,9 +65,7 @@ fun ICoverImage.toRequestImage() = RequestImage.Cover(this)
* @see using for usage from multiple receiver types
* @see toRequestBuilder to build a coil image request builder
*/
-fun IMediaCover.toMediaRequestImage(
- type: RequestImage.Media.ImageType
-) = RequestImage.Media(this, type)
+fun IMediaCover.toMediaRequestImage(type: RequestImage.Media.ImageType) = RequestImage.Media(this, type)
/**
* A request image builder for coil
@@ -79,12 +75,13 @@ fun IMediaCover.toMediaRequestImage(
*/
fun RequestImage<*>.toRequestBuilder(
context: Context,
- transformations: List = emptyList()
+ transformations: List = emptyList(),
): ImageRequest.Builder {
val requestBuilder = ImageRequest.Builder(context)
- if (transformations.isNotEmpty())
+ if (transformations.isNotEmpty()) {
requestBuilder.transformations(transformations)
+ }
if (this is RequestImage.Media) {
val color = image?.color
@@ -99,8 +96,8 @@ fun RequestImage<*>.toRequestBuilder(
return requestBuilder
.crossfade(
context.resources.getInteger(
- R.integer.motion_duration_long
- )
+ R.integer.motion_duration_long,
+ ),
).data(this)
}
@@ -115,12 +112,13 @@ fun RequestImage<*>.toRequestBuilder(
*/
fun AppCompatImageView.using(
requestImage: RequestImage<*>,
- transformations: List = emptyList()
+ transformations: List = emptyList(),
): Disposable {
val requestBuilder = ImageRequest.Builder(context)
- if (transformations.isNotEmpty())
+ if (transformations.isNotEmpty()) {
requestBuilder.transformations(transformations)
+ }
if (requestImage is RequestImage.Media) {
val color = requestImage.image?.color
@@ -132,15 +130,16 @@ fun AppCompatImageView.using(
}
}
- val request = requestBuilder
- .crossfade(
- context.resources.getInteger(
- R.integer.motion_duration_long
+ val request =
+ requestBuilder
+ .crossfade(
+ context.resources.getInteger(
+ R.integer.motion_duration_long,
+ ),
)
- )
- .data(requestImage)
- .target(this)
- .build()
+ .data(requestImage)
+ .target(this)
+ .build()
return Coil.imageLoader(context).enqueue(request)
}
@@ -156,22 +155,24 @@ fun AppCompatImageView.using(
*/
fun AppCompatImageView.using(
resource: Drawable?,
- transformations: List = emptyList()
+ transformations: List = emptyList(),
): Disposable {
val requestBuilder = ImageRequest.Builder(context)
- if (transformations.isNotEmpty())
+ if (transformations.isNotEmpty()) {
requestBuilder.transformations(transformations)
+ }
- val request = requestBuilder
- .crossfade(
- context.resources.getInteger(
- R.integer.motion_duration_long
+ val request =
+ requestBuilder
+ .crossfade(
+ context.resources.getInteger(
+ R.integer.motion_duration_long,
+ ),
)
- )
- .data(resource)
- .target(this)
- .build()
+ .data(resource)
+ .target(this)
+ .build()
return Coil.imageLoader(context).enqueue(request)
}
@@ -187,7 +188,7 @@ fun AppCompatImageView.using(
*/
fun AppCompatImageView.using(
@DrawableRes resource: Int,
- transformations: List = emptyList()
+ transformations: List = emptyList(),
): Disposable {
val drawable = context.getCompatDrawable(resource)
return using(resource = drawable, transformations)
@@ -202,24 +203,26 @@ fun AppCompatImageView.using(
*
* @return A [Disposable] contract
*/
-fun AppCompatImageView.using(
+fun AppCompatImageView.using(
resource: T?,
- transformations: List = emptyList()
+ transformations: List = emptyList(),
): Disposable {
val requestBuilder = ImageRequest.Builder(context)
- if (transformations.isNotEmpty())
+ if (transformations.isNotEmpty()) {
requestBuilder.transformations(transformations)
+ }
- val request = requestBuilder
- .crossfade(
- context.resources.getInteger(
- R.integer.motion_duration_long
+ val request =
+ requestBuilder
+ .crossfade(
+ context.resources.getInteger(
+ R.integer.motion_duration_long,
+ ),
)
- )
- .data(resource?.toRequestImage())
- .target(this)
- .build()
+ .data(resource?.toRequestImage())
+ .target(this)
+ .build()
return Coil.imageLoader(context).enqueue(request)
}
@@ -233,25 +236,27 @@ fun AppCompatImageView.using(
*
* @return A [Disposable] contract
*/
-fun Target.using(
+fun Target.using(
resource: T?,
context: Context,
- transformations: List = emptyList()
+ transformations: List = emptyList(),
): Disposable {
val requestBuilder = ImageRequest.Builder(context)
- if (transformations.isNotEmpty())
+ if (transformations.isNotEmpty()) {
requestBuilder.transformations(transformations)
+ }
- val request = requestBuilder
- .crossfade(
- context.resources.getInteger(
- R.integer.motion_duration_long
+ val request =
+ requestBuilder
+ .crossfade(
+ context.resources.getInteger(
+ R.integer.motion_duration_long,
+ ),
)
- )
- .data(resource?.toRequestImage())
- .target(this)
- .build()
+ .data(resource?.toRequestImage())
+ .target(this)
+ .build()
return Coil.imageLoader(context).enqueue(request)
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/model/RequestImage.kt b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/model/RequestImage.kt
index 388b5f90a..acda4ee95 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/model/RequestImage.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/model/RequestImage.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.helpers.image.model
import co.anitrend.domain.common.entity.contract.ICoverImage
@@ -24,17 +23,17 @@ import co.anitrend.domain.common.entity.contract.IMediaCover
* Request image model that our custom image loader will use
*/
sealed class RequestImage(val image: T?) {
-
class Media(
mediaImage: IMediaCover?,
- val type: ImageType
+ val type: ImageType,
) : RequestImage(mediaImage) {
enum class ImageType {
- BANNER, POSTER
+ BANNER,
+ POSTER,
}
}
class Cover(
- coverImage: ICoverImage?
+ coverImage: ICoverImage?,
) : RequestImage(coverImage)
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/koin/Modules.kt b/android-core/src/main/kotlin/co/anitrend/core/android/koin/Modules.kt
index 810da4cd3..1fb26185a 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/koin/Modules.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/koin/Modules.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.koin
import android.content.pm.ShortcutManager
@@ -44,79 +43,83 @@ import org.koin.dsl.binds
import org.koin.dsl.module
import org.ocpsoft.prettytime.PrettyTime
-private val coreModule = module {
- factory {
- Settings(
- context = androidContext()
- )
- } binds (Settings.BINDINGS)
+private val coreModule =
+ module {
+ factory {
+ Settings(
+ context = androidContext(),
+ )
+ } binds (Settings.BINDINGS)
- single {
- SupportDispatcher()
- }
+ single {
+ SupportDispatcher()
+ }
- single {
- StorageController()
- }
+ single {
+ StorageController()
+ }
- factory {
- AniTrendDateHelper()
- } bind AbstractSupportDateHelper::class
+ factory {
+ AniTrendDateHelper()
+ } bind AbstractSupportDateHelper::class
- single {
- /** TODO: On language preference change, destroy and recreate [PrettyTime] */
- val localeHelper = get()
- PrettyTime(localeHelper.locale)
+ single {
+ /** TODO: On language preference change, destroy and recreate [PrettyTime] */
+ val localeHelper = get()
+ PrettyTime(localeHelper.locale)
+ }
}
-}
-private val configurationModule = module {
- single {
- LocaleHelper(
- settings = get()
- )
- }
+private val configurationModule =
+ module {
+ single {
+ LocaleHelper(
+ settings = get(),
+ )
+ }
- single {
- ThemeHelper(
- settings = get()
- )
- }
+ single {
+ ThemeHelper(
+ settings = get(),
+ )
+ }
- factory {
- ConfigurationHelper(
- settings = get(),
- localeHelper = get(),
- themeHelper = get()
- )
+ factory {
+ ConfigurationHelper(
+ settings = get(),
+ localeHelper = get(),
+ themeHelper = get(),
+ )
+ }
}
-}
-private val controllerModule = module {
- factory {
- val context = androidContext()
- AndroidPowerController(
- context = context,
- powerManager = context.systemServiceOf(),
- connectivityManager = context.systemServiceOf(),
- settings = get()
- )
- }
+private val controllerModule =
+ module {
+ factory {
+ val context = androidContext()
+ AndroidPowerController(
+ context = context,
+ powerManager = context.systemServiceOf(),
+ connectivityManager = context.systemServiceOf(),
+ settings = get(),
+ )
+ }
- factory {
- val context = androidContext()
- ShortcutController(
- context = context,
- shortcutManager = context.systemServiceOf()
- )
+ factory {
+ val context = androidContext()
+ ShortcutController(
+ context = context,
+ shortcutManager = context.systemServiceOf(),
+ )
+ }
}
-}
-val androidCoreModules = module {
- includes(coreModule, configurationModule, controllerModule)
-}
+val androidCoreModules =
+ module {
+ includes(coreModule, configurationModule, controllerModule)
+ }
enum class MarkdownFlavour {
STANDARD,
- ANILIST
+ ANILIST,
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/provider/StyleActionProvider.kt b/android-core/src/main/kotlin/co/anitrend/core/android/provider/StyleActionProvider.kt
index 5d1cf3519..ae1eae4f7 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/provider/StyleActionProvider.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/provider/StyleActionProvider.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.provider
import android.content.Context
@@ -35,7 +34,6 @@ import org.koin.core.component.inject
import timber.log.Timber
class StyleActionProvider(context: Context) : AbstractActionProvider(context), KoinComponent {
-
private val settings by inject()
private val viewModes = PreferredViewMode.values()
@@ -43,21 +41,23 @@ class StyleActionProvider(context: Context) : AbstractActionProvider(context), K
private fun onActionClicked(view: View) {
val current = settings.preferredViewMode.value
val currentIndex = viewModes.indexOf(current)
- settings.preferredViewMode.value = when (currentIndex) {
- PreferredViewMode.DETAILED.ordinal -> PreferredViewMode.SUMMARY
- PreferredViewMode.SUMMARY.ordinal -> PreferredViewMode.COMPACT
- PreferredViewMode.COMPACT.ordinal -> PreferredViewMode.COMFORTABLE
- else -> PreferredViewMode.DETAILED
- }
+ settings.preferredViewMode.value =
+ when (currentIndex) {
+ PreferredViewMode.DETAILED.ordinal -> PreferredViewMode.SUMMARY
+ PreferredViewMode.SUMMARY.ordinal -> PreferredViewMode.COMPACT
+ PreferredViewMode.COMPACT.ordinal -> PreferredViewMode.COMFORTABLE
+ else -> PreferredViewMode.DETAILED
+ }
}
private fun iconForSetting(preferredViewMode: PreferredViewMode) {
- val resource = when (preferredViewMode) {
- PreferredViewMode.DETAILED -> R.drawable.ic_view_detailed
- PreferredViewMode.SUMMARY -> R.drawable.ic_view_summary
- PreferredViewMode.COMPACT -> R.drawable.ic_view_compact
- else -> R.drawable.ic_view_comfortable
- }
+ val resource =
+ when (preferredViewMode) {
+ PreferredViewMode.DETAILED -> R.drawable.ic_view_detailed
+ PreferredViewMode.SUMMARY -> R.drawable.ic_view_summary
+ PreferredViewMode.COMPACT -> R.drawable.ic_view_compact
+ else -> R.drawable.ic_view_comfortable
+ }
val drawable = context.getCompatDrawable(resource)
actionImageView.setImageDrawable(drawable)
}
@@ -68,8 +68,9 @@ class StyleActionProvider(context: Context) : AbstractActionProvider(context), K
* @param forItem Optional menu item to create view for
*/
override fun createWidget(forItem: MenuItem?): View {
- if (!actionImageView.hasOnClickListeners())
+ if (!actionImageView.hasOnClickListeners()) {
actionImageView.setOnClickListener(::onActionClicked)
+ }
context.lifecycleScope()?.launch {
context.lifecycleOwner()?.repeatOnLifecycle(Lifecycle.State.RESUMED) {
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/provider/contract/AbstractActionProvider.kt b/android-core/src/main/kotlin/co/anitrend/core/android/provider/contract/AbstractActionProvider.kt
index d98156e96..c006ac072 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/provider/contract/AbstractActionProvider.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/provider/contract/AbstractActionProvider.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.provider.contract
import android.content.Context
@@ -29,23 +28,26 @@ import co.anitrend.arch.extension.ext.getDrawableAttr
import co.anitrend.core.android.extensions.dp
abstract class AbstractActionProvider(context: Context) : ActionProvider(context) {
+ protected val actionImageView =
+ AppCompatImageView(context).apply {
+ background =
+ context.getDrawableAttr(
+ androidx.appcompat.R.attr.selectableItemBackgroundBorderless,
+ )
+ isClickable = true
+ isFocusable = true
+ setPadding(2.dp)
+ }
- protected val actionImageView = AppCompatImageView(context).apply {
- background = context.getDrawableAttr(
- androidx.appcompat.R.attr.selectableItemBackgroundBorderless
- )
- isClickable = true
- isFocusable = true
- setPadding(2.dp)
- }
-
- protected val container = FrameLayout(context).apply {
- layoutParams = FrameLayout.LayoutParams(
- ViewGroup.MarginLayoutParams.WRAP_CONTENT,
- ViewGroup.MarginLayoutParams.WRAP_CONTENT
- )
- setPadding(10.dp)
- }
+ protected val container =
+ FrameLayout(context).apply {
+ layoutParams =
+ FrameLayout.LayoutParams(
+ ViewGroup.MarginLayoutParams.WRAP_CONTENT,
+ ViewGroup.MarginLayoutParams.WRAP_CONTENT,
+ )
+ setPadding(10.dp)
+ }
/**
* Factory for creating the [androidx.core.view.ActionProvider] view
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/CarouselRecycler.kt b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/CarouselRecycler.kt
index b95f51c13..2f8483ad9 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/CarouselRecycler.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/CarouselRecycler.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.recycler
import android.content.Context
@@ -26,47 +25,61 @@ import co.anitrend.arch.recycler.SupportRecyclerView
import co.anitrend.arch.ui.view.contract.CustomView
import co.anitrend.core.android.recycler.decorator.DefaultSpacingDecorator
-class CarouselRecycler @JvmOverloads constructor(
- context: Context, attrs: AttributeSet? = null, defStyle: Int = 0
-) : SupportRecyclerView(context, attrs, defStyle), CustomView {
-
- private val defaultItemAnimator by lazy(UNSAFE) {
- val animator = object : DefaultItemAnimator() {
- override fun getSupportsChangeAnimations() = false
+class CarouselRecycler
+ @JvmOverloads
+ constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyle: Int = 0,
+ ) : SupportRecyclerView(context, attrs, defStyle), CustomView {
+ private val defaultItemAnimator by lazy(UNSAFE) {
+ val animator =
+ object : DefaultItemAnimator() {
+ override fun getSupportsChangeAnimations() = false
+ }
+ animator.supportsChangeAnimations = false
+ animator
}
- animator.supportsChangeAnimations = false
- animator
- }
- private val defaultDecorator by lazy(UNSAFE) {
- DefaultSpacingDecorator()
- }
+ private val defaultDecorator by lazy(UNSAFE) {
+ DefaultSpacingDecorator()
+ }
- init { onInit(context, attrs, defStyle) }
+ init {
+ onInit(context, attrs, defStyle)
+ }
- /**
- * Applies start and end padding to items
- */
- private fun useCarouselDecorator() {
- if (itemDecorationCount == 0)
- addItemDecoration(defaultDecorator)
- }
+ /**
+ * Applies start and end padding to items
+ */
+ private fun useCarouselDecorator() {
+ if (itemDecorationCount == 0) {
+ addItemDecoration(defaultDecorator)
+ }
+ }
- private fun disableItemAnimator() {
- itemAnimator = defaultItemAnimator
- }
+ private fun disableItemAnimator() {
+ itemAnimator = defaultItemAnimator
+ }
- override fun onInit(context: Context, attrs: AttributeSet?, styleAttr: Int?) {
- layoutManager = LinearLayoutManager(
- context, HORIZONTAL, false
- ).apply {
- // allow prefetching to speed up recycler performance
- isItemPrefetchEnabled = true
- initialPrefetchItemCount = 5
- // If the view types are not the same across RecyclerView then it may lead to performance degradation.
- recycleChildrenOnDetach = true
+ override fun onInit(
+ context: Context,
+ attrs: AttributeSet?,
+ styleAttr: Int?,
+ ) {
+ layoutManager =
+ LinearLayoutManager(
+ context,
+ HORIZONTAL,
+ false,
+ ).apply {
+ // allow prefetching to speed up recycler performance
+ isItemPrefetchEnabled = true
+ initialPrefetchItemCount = 5
+ // If the view types are not the same across RecyclerView then it may lead to performance degradation.
+ recycleChildrenOnDetach = true
+ }
+ useCarouselDecorator()
+ disableItemAnimator()
}
- useCarouselDecorator()
- disableItemAnimator()
}
-}
\ No newline at end of file
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/decorator/DefaultSpacingDecorator.kt b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/decorator/DefaultSpacingDecorator.kt
index 99cba9470..40ac7fc7e 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/decorator/DefaultSpacingDecorator.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/decorator/DefaultSpacingDecorator.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.recycler.decorator
import android.graphics.Rect
@@ -30,9 +29,8 @@ import timber.log.Timber
class DefaultSpacingDecorator(
private val itemSpacing: Int = 2.dp,
- private val edgeSpacing: Int = 2.dp
-): RecyclerView.ItemDecoration() {
-
+ private val edgeSpacing: Int = 2.dp,
+) : RecyclerView.ItemDecoration() {
private fun isVerticalOrientation(recyclerView: RecyclerView): Boolean {
return when (val layoutManager = recyclerView.layoutManager) {
is FlexboxLayoutManager -> layoutManager.flexDirection == FlexDirection.COLUMN
@@ -69,14 +67,14 @@ class DefaultSpacingDecorator(
outRect: Rect,
view: View,
parent: RecyclerView,
- state: RecyclerView.State
+ state: RecyclerView.State,
) {
/** Credits: https://stackoverflow.com/a/64375667/1725347 */
val count = parent.adapter?.itemCount ?: 0
val position = parent.getChildAdapterPosition(view)
val leading = if (position == 0) edgeSpacing else itemSpacing
val trailing = if (position == count - 1) edgeSpacing else 0
- with (outRect) {
+ with(outRect) {
if (isVerticalOrientation(parent)) {
top = leading
bottom = trailing
@@ -86,4 +84,4 @@ class DefaultSpacingDecorator(
}
}
}
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/model/RecyclerItemBinding.kt b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/model/RecyclerItemBinding.kt
index 3157991c6..ebc59f224 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/model/RecyclerItemBinding.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/model/RecyclerItemBinding.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.recycler.model
import android.content.res.Resources
@@ -26,9 +25,8 @@ import co.anitrend.core.android.R
import co.anitrend.core.android.binding.IBindingView
abstract class RecyclerItemBinding(
- override val id: Long
+ override val id: Long,
) : IRecyclerItem, IBindingView {
-
override var binding: B? = null
/**
@@ -63,6 +61,6 @@ abstract class RecyclerItemBinding(
override fun getSpanSize(
spanCount: Int,
position: Int,
- resources: Resources
- )= resources.getInteger(co.anitrend.arch.theme.R.integer.single_list_size)
+ resources: Resources,
+ ) = resources.getInteger(co.anitrend.arch.theme.R.integer.single_list_size)
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/selection/DefaultSelectionMode.kt b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/selection/DefaultSelectionMode.kt
index 8751a4d24..2a18df616 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/selection/DefaultSelectionMode.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/selection/DefaultSelectionMode.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.recycler.selection
import android.view.ActionMode
@@ -25,7 +24,6 @@ import co.anitrend.arch.recycler.action.contract.ISupportSelectionMode
import co.anitrend.arch.recycler.action.decorator.ISelectionDecorator
class DefaultSelectionMode : ISupportSelectionMode {
-
private val selections = mutableListOf()
/**
@@ -60,7 +58,7 @@ class DefaultSelectionMode : ISupportSelectionMode {
override fun isLongSelectionClickable(
view: View,
decorator: ISelectionDecorator,
- id: Long
+ id: Long,
): Boolean = false
/**
@@ -76,12 +74,15 @@ class DefaultSelectionMode : ISupportSelectionMode {
override fun isSelectionClickable(
view: View,
decorator: ISelectionDecorator,
- id: Long
+ id: Long,
): Boolean {
if (id != RecyclerView.NO_ID) {
val exists = containsItem(id)
- if (!exists) selections.add(id)
- else selections.remove(id)
+ if (!exists) {
+ selections.add(id)
+ } else {
+ selections.remove(id)
+ }
decorator.decorateUsing(view, !exists)
return true
}
@@ -103,4 +104,4 @@ class DefaultSelectionMode : ISupportSelectionMode {
override fun selectedItems(): List {
return selections
}
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/Settings.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/Settings.kt
index 2bb850e1e..f5d9c7443 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/Settings.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/Settings.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 AniTrend
+ * Copyright (C) 2019 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings
import android.content.Context
@@ -48,171 +47,201 @@ import co.anitrend.domain.common.sort.order.SortOrder
import co.anitrend.domain.medialist.enums.ScoreFormat
import co.anitrend.domain.user.enums.UserTitleLanguage
-class Settings(context: Context) : SupportPreference(context), IConfigurationSettings,
- IPrivacySettings, IAuthenticationSettings, ISortOrderSettings, IRefreshBehaviourSettings,
- ICustomizationSettings, IPowerSettings, IConnectivitySettings, IUserSettings, ICacheSettings,
- ISyncSettings, IDeveloperSettings {
-
- override val locale = EnumSetting(
- key = R.string.settings_configuration_locale,
- default = AniTrendLocale.AUTOMATIC,
- resources = context.resources,
- preference = this
- )
-
- override val theme = EnumSetting(
- key = R.string.settings_configuration_theme,
- default = AniTrendTheme.SYSTEM,
- resources = context.resources,
- preference = this
- )
-
- override val isAnalyticsEnabled = BooleanSetting(
- key = R.string.settings_privacy_usage_analytics,
- default = false,
- resources = context.resources,
- preference = this
- )
-
- override val isCrashlyticsEnabled = BooleanSetting(
- key = R.string.settings_privacy_crash_analytics,
- default = true,
- resources = context.resources,
- preference = this
- )
-
- override val authenticatedUserId = LongSetting(
- key = R.string.settings_authentication_id,
- default = INVALID_USER_ID,
- resources = context.resources,
- preference = this
- )
-
- override val isAuthenticated = BooleanSetting(
- key = R.string.settings_is_authenticated,
- default = false,
- resources = context.resources,
- preference = this
- )
-
- override val sortOrder = EnumSetting(
- key = R.string.settings_sort_order,
- default = SortOrder.DESC,
- resources = context.resources,
- preference = this
- )
-
- override val isNewInstallation = BooleanSetting(
- key = R.string.settings_is_new_installation,
- default = true,
- resources = context.resources,
- preference = this
- )
-
- override val versionCode = IntSetting(
- key = R.string.settings_version_code,
- default = 1,
- resources = context.resources,
- preference = this
- )
-
- override val clearDataOnSwipeRefresh = BooleanSetting(
- key = R.string.settings_clear_on_swipe_refresh,
- default = false,
- resources = context.resources,
- preference = this
- )
-
- override val preferredViewMode = EnumSetting(
- key = R.string.settings_view_mode_preferred,
- default = PreferredViewMode.COMFORTABLE,
- resources = context.resources,
- preference = this
- )
-
- override val isPowerSaverOn = BooleanSetting(
- key = R.string.settings_power_saver,
- default = false,
- resources = context.resources,
- preference = this
- )
-
- override val isBatteryOptimizationOn = BooleanSetting(
- key = R.string.settings_battery_optimization,
- default = false,
- resources = context.resources,
- preference = this
- )
-
-
- override val titleLanguage = EnumSetting(
- key = R.string.settings_user_title_language,
- default = UserTitleLanguage.ROMAJI,
- resources = context.resources,
- preference = this
- )
-
- override val scoreFormat = EnumSetting(
- key = R.string.settings_user_score_format,
- default = ScoreFormat.POINT_10_DECIMAL,
- resources = context.resources,
- preference = this
- )
-
- override val cacheUsageRatio = FloatSetting(
- key = R.string.settings_cache_usage_ratio,
- default = ICacheSettings.MINIMUM_CACHE_LIMIT,
- resources = context.resources,
- preference = this
- )
-
- override val metaSyncInterval = IntSetting(
- key = R.string.settings_sync_meta_interval,
- default = ISyncSettings.MINIMUM_INTERVAL,
- resources = context.resources,
- preference = this
- )
-
- override val listSyncInterval = IntSetting(
- key = R.string.settings_sync_list_interval,
- default = ISyncSettings.MINIMUM_INTERVAL,
- resources = context.resources,
- preference = this
- )
-
- override val userSyncInterval = IntSetting(
- key = R.string.settings_sync_user_interval,
- default = 300,
- resources = context.resources,
- preference = this
- )
-
- override val automaticHeapDump = BooleanSetting(
- key = R.string.settings_auto_heap_dump,
- default = false,
- resources = context.resources,
- preference = this
- )
-
- override val showLeakLauncher = BooleanSetting(
- key = R.string.settings_show_leak_launcher,
- default = false,
- resources = context.resources,
- preference = this
- )
+class Settings(context: Context) :
+ SupportPreference(context),
+ IConfigurationSettings,
+ IPrivacySettings,
+ IAuthenticationSettings,
+ ISortOrderSettings,
+ IRefreshBehaviourSettings,
+ ICustomizationSettings,
+ IPowerSettings,
+ IConnectivitySettings,
+ IUserSettings,
+ ICacheSettings,
+ ISyncSettings,
+ IDeveloperSettings {
+ override val locale =
+ EnumSetting(
+ key = R.string.settings_configuration_locale,
+ default = AniTrendLocale.AUTOMATIC,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val theme =
+ EnumSetting(
+ key = R.string.settings_configuration_theme,
+ default = AniTrendTheme.SYSTEM,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val isAnalyticsEnabled =
+ BooleanSetting(
+ key = R.string.settings_privacy_usage_analytics,
+ default = false,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val isCrashlyticsEnabled =
+ BooleanSetting(
+ key = R.string.settings_privacy_crash_analytics,
+ default = true,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val authenticatedUserId =
+ LongSetting(
+ key = R.string.settings_authentication_id,
+ default = INVALID_USER_ID,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val isAuthenticated =
+ BooleanSetting(
+ key = R.string.settings_is_authenticated,
+ default = false,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val sortOrder =
+ EnumSetting(
+ key = R.string.settings_sort_order,
+ default = SortOrder.DESC,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val isNewInstallation =
+ BooleanSetting(
+ key = R.string.settings_is_new_installation,
+ default = true,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val versionCode =
+ IntSetting(
+ key = R.string.settings_version_code,
+ default = 1,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val clearDataOnSwipeRefresh =
+ BooleanSetting(
+ key = R.string.settings_clear_on_swipe_refresh,
+ default = false,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val preferredViewMode =
+ EnumSetting(
+ key = R.string.settings_view_mode_preferred,
+ default = PreferredViewMode.COMFORTABLE,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val isPowerSaverOn =
+ BooleanSetting(
+ key = R.string.settings_power_saver,
+ default = false,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val isBatteryOptimizationOn =
+ BooleanSetting(
+ key = R.string.settings_battery_optimization,
+ default = false,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val titleLanguage =
+ EnumSetting(
+ key = R.string.settings_user_title_language,
+ default = UserTitleLanguage.ROMAJI,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val scoreFormat =
+ EnumSetting(
+ key = R.string.settings_user_score_format,
+ default = ScoreFormat.POINT_10_DECIMAL,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val cacheUsageRatio =
+ FloatSetting(
+ key = R.string.settings_cache_usage_ratio,
+ default = ICacheSettings.MINIMUM_CACHE_LIMIT,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val metaSyncInterval =
+ IntSetting(
+ key = R.string.settings_sync_meta_interval,
+ default = ISyncSettings.MINIMUM_INTERVAL,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val listSyncInterval =
+ IntSetting(
+ key = R.string.settings_sync_list_interval,
+ default = ISyncSettings.MINIMUM_INTERVAL,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val userSyncInterval =
+ IntSetting(
+ key = R.string.settings_sync_user_interval,
+ default = 300,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val automaticHeapDump =
+ BooleanSetting(
+ key = R.string.settings_auto_heap_dump,
+ default = false,
+ resources = context.resources,
+ preference = this,
+ )
+
+ override val showLeakLauncher =
+ BooleanSetting(
+ key = R.string.settings_show_leak_launcher,
+ default = false,
+ resources = context.resources,
+ preference = this,
+ )
companion object {
/**
* Binding types for [Settings]
*/
- internal val BINDINGS = arrayOf(
- ISupportPreference::class, IConfigurationSettings::class,
- ILocaleSettings::class, IThemeSettings::class,
- IAuthenticationSettings::class, IPrivacySettings::class,
- ISortOrderSettings::class, IRefreshBehaviourSettings::class,
- ICustomizationSettings::class, IPowerSettings::class,
- IConnectivitySettings::class, IUserSettings::class,
- ICacheSettings::class, ISyncSettings::class, IDeveloperSettings::class
- )
+ internal val BINDINGS =
+ arrayOf(
+ ISupportPreference::class, IConfigurationSettings::class,
+ ILocaleSettings::class, IThemeSettings::class,
+ IAuthenticationSettings::class, IPrivacySettings::class,
+ ISortOrderSettings::class, IRefreshBehaviourSettings::class,
+ ICustomizationSettings::class, IPowerSettings::class,
+ IConnectivitySettings::class, IUserSettings::class,
+ ICacheSettings::class, ISyncSettings::class, IDeveloperSettings::class,
+ )
}
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/IConfigurationSettings.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/IConfigurationSettings.kt
index 1e5f6feed..bb2c22207 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/IConfigurationSettings.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/IConfigurationSettings.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 AniTrend
+ * Copyright (C) 2019 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,10 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.common
import co.anitrend.core.android.settings.common.locale.ILocaleSettings
import co.anitrend.core.android.settings.common.theme.IThemeSettings
-interface IConfigurationSettings : ILocaleSettings, IThemeSettings
\ No newline at end of file
+interface IConfigurationSettings : ILocaleSettings, IThemeSettings
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/locale/ILocaleSettings.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/locale/ILocaleSettings.kt
index 4f52e2df6..6899d6e98 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/locale/ILocaleSettings.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/locale/ILocaleSettings.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 AniTrend
+ * Copyright (C) 2019 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,13 +14,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.common.locale
import co.anitrend.arch.extension.settings.contract.AbstractSetting
import co.anitrend.core.android.settings.helper.locale.model.AniTrendLocale
interface ILocaleSettings {
-
val locale: AbstractSetting
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/theme/IThemeSettings.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/theme/IThemeSettings.kt
index b6862c996..1a84f4a3d 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/theme/IThemeSettings.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/theme/IThemeSettings.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 AniTrend
+ * Copyright (C) 2019 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,13 +14,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.common.theme
import co.anitrend.arch.extension.settings.contract.AbstractSetting
import co.anitrend.core.android.settings.helper.theme.model.AniTrendTheme
interface IThemeSettings {
-
val theme: AbstractSetting
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/extensions/SettingsExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/extensions/SettingsExtensions.kt
index 0788741c3..7870e9cb3 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/extensions/SettingsExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/extensions/SettingsExtensions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 AniTrend
+ * Copyright (C) 2022 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.extensions
import android.annotation.SuppressLint
@@ -34,31 +33,34 @@ import co.anitrend.data.settings.customize.common.PreferredViewMode
*/
suspend fun AbstractSetting.flowUpdating(
recyclerView: RecyclerView?,
- resolver: (PreferredViewMode) -> Int
+ resolver: (PreferredViewMode) -> Int,
) {
flow.collect { viewMode ->
requireNotNull(recyclerView)
val adapter = recyclerView.adapter as RecyclerView.Adapter<*>
- val newSpanCount = recyclerView.resources.getInteger(
- resolver(viewMode)
- )
+ val newSpanCount =
+ recyclerView.resources.getInteger(
+ resolver(viewMode),
+ )
@SuppressLint("NotifyDataSetChanged")
when (val layoutManager = recyclerView.layoutManager) {
is StaggeredGridLayoutManager -> {
val currentSpanCount = layoutManager.spanCount
- if (currentSpanCount != newSpanCount)
+ if (currentSpanCount != newSpanCount) {
layoutManager.spanCount = newSpanCount
- else
+ } else {
adapter.notifyDataSetChanged()
+ }
}
is GridLayoutManager -> {
val currentSpanCount = layoutManager.spanCount
- if (currentSpanCount != newSpanCount)
+ if (currentSpanCount != newSpanCount) {
layoutManager.spanCount = newSpanCount
- else
+ } else {
adapter.notifyDataSetChanged()
+ }
}
}
}
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/ConfigurationHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/ConfigurationHelper.kt
index c8c742027..174f95f8e 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/ConfigurationHelper.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/ConfigurationHelper.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 AniTrend
+ * Copyright (C) 2019 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.helper.config
import android.content.Context
@@ -38,9 +37,8 @@ import co.anitrend.core.android.settings.helper.theme.model.AniTrendTheme
internal class ConfigurationHelper(
private val settings: IConfigurationSettings,
private val localeHelper: ILocaleHelper,
- private val themeHelper: IThemeHelper
+ private val themeHelper: IThemeHelper,
) : IConfigurationHelper {
-
@StyleRes
override var themeOverride: Int? = null
@@ -51,8 +49,7 @@ internal class ConfigurationHelper(
/**
* Creates a new context with configuration
*/
- override fun attachContext(context: Context?) =
- localeHelper.applyLocale(context)
+ override fun attachContext(context: Context?) = localeHelper.applyLocale(context)
/**
* Applies configuration upon the create state of the current activity
@@ -72,7 +69,7 @@ internal class ConfigurationHelper(
*/
override fun onResume(activity: FragmentActivity) {
if (applicationTheme != settings.theme.value) {
- //activity.recreate()
+ // activity.recreate()
activity.resetActivity()
themeHelper.applyDynamicNightModeFromTheme()
}
@@ -93,8 +90,8 @@ internal class ConfigurationHelper(
private operator fun FragmentActivity.invoke() {
overridePendingTransition(
android.R.anim.fade_in,
- android.R.anim.fade_out
+ android.R.anim.fade_out,
)
}
}
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/contract/IConfigurationHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/contract/IConfigurationHelper.kt
index 575b784a9..905108bf1 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/contract/IConfigurationHelper.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/contract/IConfigurationHelper.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 AniTrend
+ * Copyright (C) 2019 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.helper.config.contract
import android.content.Context
@@ -26,7 +25,6 @@ import androidx.fragment.app.FragmentActivity
* @property themeOverride Theme resource override option
*/
interface IConfigurationHelper {
-
var themeOverride: Int?
/**
@@ -47,4 +45,4 @@ interface IConfigurationHelper {
* @param activity
*/
fun onResume(activity: FragmentActivity)
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/LocaleHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/LocaleHelper.kt
index e1ac58880..a469da544 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/LocaleHelper.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/LocaleHelper.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 AniTrend
+ * Copyright (C) 2019 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.helper.locale
import android.content.Context
@@ -27,14 +26,14 @@ import co.anitrend.core.android.settings.helper.locale.model.AniTrendLocale
import java.util.Locale
internal class LocaleHelper(private val settings: ILocaleSettings) : ILocaleHelper {
-
/**
* Current locale
*/
override val locale: Locale
get() {
- if (settings.locale.value == AniTrendLocale.AUTOMATIC)
+ if (settings.locale.value == AniTrendLocale.AUTOMATIC) {
return Locale.getDefault()
+ }
return getPersonalizedLocale()
}
@@ -61,8 +60,9 @@ internal class LocaleHelper(private val settings: ILocaleSettings) : ILocaleHelp
private fun getPersonalizedLocale(): Locale {
val locale = settings.locale.value
- if (locale.country == null)
+ if (locale.country == null) {
return Locale(locale.language)
+ }
return Locale(locale.language, locale.country)
}
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/contract/ILocaleHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/contract/ILocaleHelper.kt
index cd935f428..ea3e29f8b 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/contract/ILocaleHelper.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/contract/ILocaleHelper.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.helper.locale.contract
import android.content.Context
@@ -22,7 +21,6 @@ import androidx.appcompat.app.AppCompatDelegate
import java.util.Locale
interface ILocaleHelper {
-
/**
* Current application locale
*/
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/model/AniTrendLocale.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/model/AniTrendLocale.kt
index 180ada06c..46dbe9481 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/model/AniTrendLocale.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/model/AniTrendLocale.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 AniTrend
+ * Copyright (C) 2019 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.helper.locale.model
import co.anitrend.arch.extension.ext.empty
@@ -36,26 +35,28 @@ enum class AniTrendLocale(val language: String, val country: String? = null) {
AUTOMATIC(String.empty()),
GERMAN_GERMANY(
language = Locale.GERMAN.language,
- country = Locale.GERMAN.country
+ country = Locale.GERMAN.country,
),
ITALIAN_ITALY(
language = Locale.ITALY.language,
- country = Locale.ITALY.country
+ country = Locale.ITALY.country,
),
FRENCH_FRANCE(
language = Locale.FRANCE.language,
- country = Locale.FRANCE.country
- );
+ country = Locale.FRANCE.country,
+ ),
+ ;
companion object {
fun Locale.asLocaleString() = "$language$country"
- fun AniTrendLocale.asLocaleString() = when (this) {
- AUTOMATIC -> {
- val default = Locale.getDefault()
- default.asLocaleString()
+ fun AniTrendLocale.asLocaleString() =
+ when (this) {
+ AUTOMATIC -> {
+ val default = Locale.getDefault()
+ default.asLocaleString()
+ }
+ else -> "$language$country"
}
- else -> "$language$country"
- }
}
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/ThemeHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/ThemeHelper.kt
index 4d517cff4..73ab27f1e 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/ThemeHelper.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/ThemeHelper.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 AniTrend
+ * Copyright (C) 2019 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.helper.theme
import android.annotation.TargetApi
@@ -36,7 +35,6 @@ import co.anitrend.core.android.settings.helper.theme.model.AniTrendTheme
* @param settings instance of theme settings
*/
internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper {
-
@TargetApi(Build.VERSION_CODES.O)
private fun FragmentActivity.applyNightModeDecorations(systemUiOptions: Int) {
val primaryColor = getCompatColor(co.anitrend.arch.theme.R.color.colorPrimary)
@@ -46,13 +44,13 @@ internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.setSystemBarsAppearance(
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS and WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
- WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS and WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
+ WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS and WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
)
} else {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = systemUiOptions and
- View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR and
- View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
+ View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR and
+ View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
}
}
@@ -67,17 +65,16 @@ internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper
} else {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = systemUiOptions or
- View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR or
- View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
+ View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR or
+ View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
window.navigationBarColor = primaryColor
window.statusBarColor = primaryColor
}
}
-
private fun FragmentActivity.applyWindowStyle() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- @Suppress("DEPRECATION") //Until I figure out a way to apply decorations using window controller
+ @Suppress("DEPRECATION") // Until I figure out a way to apply decorations using window controller
val systemUiOptions = window.decorView.systemUiVisibility
when (AppCompatDelegate.getDefaultNightMode()) {
AppCompatDelegate.MODE_NIGHT_NO -> applyDayModeDecorations(systemUiOptions)
@@ -85,9 +82,11 @@ internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper
else -> {
// According to Google/IO other ui options like auto and follow system
// will be deprecated in the future
- if (isEnvironmentNightMode())
+ if (isEnvironmentNightMode()) {
applyNightModeDecorations(systemUiOptions)
- else applyDayModeDecorations(systemUiOptions)
+ } else {
+ applyDayModeDecorations(systemUiOptions)
+ }
}
}
}
@@ -98,19 +97,22 @@ internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper
*/
override fun applyDynamicNightModeFromTheme() {
val theme = settings.theme.value
- if (theme == AniTrendTheme.SYSTEM)
+ if (theme == AniTrendTheme.SYSTEM) {
AppCompatDelegate.setDefaultNightMode(
- AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
+ AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM,
)
- else
+ } else {
when (theme.useNightMode) {
- true -> AppCompatDelegate.setDefaultNightMode(
- AppCompatDelegate.MODE_NIGHT_NO
- )
- else -> AppCompatDelegate.setDefaultNightMode(
- AppCompatDelegate.MODE_NIGHT_YES
- )
+ true ->
+ AppCompatDelegate.setDefaultNightMode(
+ AppCompatDelegate.MODE_NIGHT_NO,
+ )
+ else ->
+ AppCompatDelegate.setDefaultNightMode(
+ AppCompatDelegate.MODE_NIGHT_YES,
+ )
}
+ }
}
/**
@@ -118,12 +120,13 @@ internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper
*/
override fun applyApplicationTheme(
context: FragmentActivity,
- themeOverride: Int?
+ themeOverride: Int?,
) {
- if (themeOverride != null)
+ if (themeOverride != null) {
context.setTheme(themeOverride)
- else
+ } else {
context.setTheme(settings.theme.value.styleAttribute)
+ }
context.applyWindowStyle()
}
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/contract/IThemeHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/contract/IThemeHelper.kt
index 2990b7d84..87f48f14b 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/contract/IThemeHelper.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/contract/IThemeHelper.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,14 +14,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.helper.theme.contract
import androidx.annotation.StyleRes
import androidx.fragment.app.FragmentActivity
interface IThemeHelper {
-
/**
* Sets the default night mode based on the theme set in settings
*/
@@ -32,6 +30,6 @@ interface IThemeHelper {
*/
fun applyApplicationTheme(
context: FragmentActivity,
- @StyleRes themeOverride: Int? = null
+ @StyleRes themeOverride: Int? = null,
)
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/model/AniTrendTheme.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/model/AniTrendTheme.kt
index 9c2c6b436..d6be91be9 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/model/AniTrendTheme.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/model/AniTrendTheme.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 AniTrend
+ * Copyright (C) 2019 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.settings.helper.theme.model
import androidx.annotation.StyleRes
@@ -26,20 +25,23 @@ import co.anitrend.core.android.R
* @param styleAttribute The style resource attribute that will be applied
* @param useNightMode If the current theme should also change the system to use night mode
*/
-enum class AniTrendTheme(@StyleRes val styleAttribute: Int, val useNightMode: Boolean = false) {
+enum class AniTrendTheme(
+ @StyleRes val styleAttribute: Int,
+ val useNightMode: Boolean = false,
+) {
SYSTEM(
- styleAttribute = 0
+ styleAttribute = 0,
),
AMOLED(
styleAttribute = R.style.AppTheme,
- useNightMode = true
+ useNightMode = true,
),
LIGHT(
styleAttribute = R.style.AppTheme,
- useNightMode = false
+ useNightMode = false,
),
DARK(
styleAttribute = R.style.AppTheme_Dark,
- useNightMode = true
- )
-}
\ No newline at end of file
+ useNightMode = true,
+ ),
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/ShortcutController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/ShortcutController.kt
index 7e458e3e9..4b066da66 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/ShortcutController.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/ShortcutController.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.shortcut
import android.annotation.SuppressLint
@@ -34,7 +33,6 @@ internal class ShortcutController(
private val context: Context,
private val shortcutManager: ShortcutManager?,
) : IShortcutController {
-
/**
* Publish the list of dynamic [shortcuts]. If there are already dynamic or
* pinned shortcuts with the same IDs, each mutable shortcut is updated.
@@ -45,27 +43,29 @@ internal class ShortcutController(
*/
override fun createShortcuts(vararg shortcuts: Shortcut): Boolean {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
- val shortcutInfo = shortcuts.mapNotNull { shortcut ->
- val intent = shortcut.router.forActivity(
- context = context,
- navPayload = shortcut.navPayload,
- )
- if (intent == null) {
- Timber.w("Intent for shortcut: `${shortcut.id}` returned null")
- null
- } else {
- ShortcutInfo.Builder(context, shortcut.id)
- .setShortLabel(context.getString(shortcut.label))
- .setDisabledMessage(context.getString(shortcut.disabledMessage))
- .setIcon(Icon.createWithResource(context, shortcut.icon))
- .setIntent(intent)
- .build()
+ val shortcutInfo =
+ shortcuts.mapNotNull { shortcut ->
+ val intent =
+ shortcut.router.forActivity(
+ context = context,
+ navPayload = shortcut.navPayload,
+ )
+ if (intent == null) {
+ Timber.w("Intent for shortcut: `${shortcut.id}` returned null")
+ null
+ } else {
+ ShortcutInfo.Builder(context, shortcut.id)
+ .setShortLabel(context.getString(shortcut.label))
+ .setDisabledMessage(context.getString(shortcut.disabledMessage))
+ .setIcon(Icon.createWithResource(context, shortcut.icon))
+ .setIntent(intent)
+ .build()
+ }
}
- }
shortcutManager?.addDynamicShortcuts(shortcutInfo) ?: false
- }
- else
+ } else {
false
+ }
}
/**
@@ -77,8 +77,9 @@ internal class ShortcutController(
*/
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N_MR1, lambda = 1)
override fun enableShortcuts(vararg shortcuts: Shortcut) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
shortcutManager?.enableShortcuts(shortcuts.map(Shortcut::id))
+ }
}
/**
@@ -90,8 +91,9 @@ internal class ShortcutController(
*/
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N_MR1, lambda = 1)
override fun disableShortcuts(vararg shortcuts: Shortcut) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
shortcutManager?.disableShortcuts(shortcuts.map(Shortcut::id))
+ }
}
/**
@@ -103,8 +105,9 @@ internal class ShortcutController(
*/
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N_MR1, lambda = 1)
override fun reportShortcutUsage(shortcut: Shortcut) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
shortcutManager?.reportShortcutUsed(shortcut.id)
+ }
}
/**
@@ -114,7 +117,8 @@ internal class ShortcutController(
*/
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N_MR1, lambda = 1)
override fun removeAllDynamicShortcuts() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
shortcutManager?.removeAllDynamicShortcuts()
+ }
}
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/contract/IShortcutController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/contract/IShortcutController.kt
index 088aea162..550ee0d00 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/contract/IShortcutController.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/contract/IShortcutController.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.shortcut.contract
import android.os.Build
@@ -23,7 +22,6 @@ import co.anitrend.core.android.shortcut.model.Shortcut
@RequiresApi(Build.VERSION_CODES.N_MR1)
interface IShortcutController {
-
/**
* Publish the list of dynamic [shortcuts]. If there are already dynamic or
* pinned shortcuts with the same IDs, each mutable shortcut is updated.
@@ -77,4 +75,4 @@ interface IShortcutController {
@RequiresApi(Build.VERSION_CODES.N_MR1)
@Throws(IllegalStateException::class)
fun removeAllDynamicShortcuts()
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/model/Shortcut.kt b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/model/Shortcut.kt
index 07ee3fdcd..f8b1cfea9 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/model/Shortcut.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/model/Shortcut.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.shortcut.model
import androidx.annotation.DrawableRes
@@ -38,7 +37,9 @@ sealed class Shortcut {
abstract val navPayload: NavPayload?
@get:StringRes abstract val label: Int
+
@get:DrawableRes abstract val icon: Int
+
@get:StringRes abstract val disabledMessage: Int
data class AiringSchedule(
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/state/IScreenState.kt b/android-core/src/main/kotlin/co/anitrend/core/android/state/IScreenState.kt
index 8d249ff92..2a3527fe3 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/state/IScreenState.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/state/IScreenState.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.state
import android.os.Bundle
@@ -26,5 +25,6 @@ import android.os.Bundle
*/
interface IScreenState {
fun onSaveInstanceState(outState: Bundle)
+
fun onRestoreInstanceState(savedInstanceState: Bundle)
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/storage/StorageController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/storage/StorageController.kt
index fe9d9bf26..094c999e1 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/storage/StorageController.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/storage/StorageController.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.storage
import android.content.Context
@@ -26,27 +25,25 @@ import timber.log.Timber
import java.io.File
class StorageController : IStorageController {
-
- private fun Context.directoryOf(
- storageType: StorageType
- ) = when (storageType) {
- StorageType.CACHE -> externalCacheDir ?: cacheDir
- StorageType.FILES -> getExternalFilesDir(storageType.type) ?: filesDir
- StorageType.MUSIC -> requireNotNull(getExternalFilesDir(storageType.type))
- StorageType.PICTURES -> requireNotNull(getExternalFilesDir(storageType.type))
- StorageType.MOVIES -> requireNotNull(getExternalFilesDir(storageType.type))
- }
+ private fun Context.directoryOf(storageType: StorageType) =
+ when (storageType) {
+ StorageType.CACHE -> externalCacheDir ?: cacheDir
+ StorageType.FILES -> getExternalFilesDir(storageType.type) ?: filesDir
+ StorageType.MUSIC -> requireNotNull(getExternalFilesDir(storageType.type))
+ StorageType.PICTURES -> requireNotNull(getExternalFilesDir(storageType.type))
+ StorageType.MOVIES -> requireNotNull(getExternalFilesDir(storageType.type))
+ }
override fun getLogsCache(context: Context): File {
val external = context.directoryOf(StorageType.FILES)
- val logs = File(external, logsName)
+ val logs = File(external, LOGS)
if (!logs.exists()) logs.mkdirs()
return logs
}
override fun getImageCache(context: Context): File {
val cache = context.directoryOf(StorageType.CACHE)
- val imageCache = File(cache, imageCacheName)
+ val imageCache = File(cache, IMAGE_CACHE)
if (!imageCache.exists()) imageCache.mkdirs()
Timber.v("Cache directory for images: ${imageCache.canonicalPath}")
return imageCache
@@ -54,7 +51,7 @@ class StorageController : IStorageController {
override fun getVideoCache(context: Context): File {
val cache = context.directoryOf(StorageType.CACHE)
- val videoCache = File(cache, videoCacheName)
+ val videoCache = File(cache, VIDEO_CACHE)
if (!videoCache.exists()) videoCache.mkdirs()
Timber.v("Cache directory for exo player cache: ${videoCache.canonicalPath}")
return videoCache
@@ -62,13 +59,16 @@ class StorageController : IStorageController {
override fun getVideoOfflineCache(context: Context): File {
val cache = context.directoryOf(StorageType.CACHE)
- val videoOfflineCache = File(cache, videoOfflineCacheName)
+ val videoOfflineCache = File(cache, VIDEO_OFFLINE_CACHE)
if (!videoOfflineCache.exists()) videoOfflineCache.mkdirs()
Timber.v("Cache directory for exo player offline sync cache: ${videoOfflineCache.canonicalPath}")
return videoOfflineCache
}
- override fun getFreeSpace(context: Context, type: StorageType): Long {
+ override fun getFreeSpace(
+ context: Context,
+ type: StorageType,
+ ): Long {
val cache = context.directoryOf(type)
return cache.freeSpace
}
@@ -76,7 +76,7 @@ class StorageController : IStorageController {
override fun getStorageUsageLimit(
context: Context,
type: StorageType,
- settings: ICacheSettings
+ settings: ICacheSettings,
): Long {
val freeSpace = getFreeSpace(context, type)
val ratio = settings.cacheUsageRatio.value
@@ -85,10 +85,10 @@ class StorageController : IStorageController {
return limit
}
- companion object {
- private const val logsName = "logs"
- private const val imageCacheName = "coil_image_cache"
- private const val videoCacheName = "exo_video_cache"
- private const val videoOfflineCacheName = "exo_video_offline_cache"
+ private companion object {
+ private const val LOGS = "logs"
+ private const val IMAGE_CACHE = "coil_image_cache"
+ private const val VIDEO_CACHE = "exo_video_cache"
+ private const val VIDEO_OFFLINE_CACHE = "exo_video_offline_cache"
}
-}
\ No newline at end of file
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/storage/contract/IStorageController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/storage/contract/IStorageController.kt
index 44d3cc32c..e540aec6e 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/storage/contract/IStorageController.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/storage/contract/IStorageController.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.storage.contract
import android.content.Context
@@ -24,9 +23,21 @@ import java.io.File
interface IStorageController {
fun getLogsCache(context: Context): File
+
fun getImageCache(context: Context): File
+
fun getVideoCache(context: Context): File
+
fun getVideoOfflineCache(context: Context): File
- fun getFreeSpace(context: Context, type: StorageType): Long
- fun getStorageUsageLimit(context: Context, type: StorageType, settings: ICacheSettings): Long
-}
\ No newline at end of file
+
+ fun getFreeSpace(
+ context: Context,
+ type: StorageType,
+ ): Long
+
+ fun getStorageUsageLimit(
+ context: Context,
+ type: StorageType,
+ settings: ICacheSettings,
+ ): Long
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/storage/enums/StorageType.kt b/android-core/src/main/kotlin/co/anitrend/core/android/storage/enums/StorageType.kt
index 272a2b418..722afc140 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/storage/enums/StorageType.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/storage/enums/StorageType.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.storage.enums
import android.os.Environment
@@ -29,5 +28,5 @@ enum class StorageType(val type: String?) {
FILES(null),
MUSIC(Environment.DIRECTORY_MUSIC),
PICTURES(Environment.DIRECTORY_PICTURES),
- MOVIES(Environment.DIRECTORY_MOVIES)
-}
\ No newline at end of file
+ MOVIES(Environment.DIRECTORY_MOVIES),
+}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/storage/extensions/StorageControllerExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/storage/extensions/StorageControllerExtensions.kt
index 3b46ef811..639bdf3d9 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/storage/extensions/StorageControllerExtensions.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/storage/extensions/StorageControllerExtensions.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.storage.extensions
import java.util.Locale
@@ -30,8 +29,10 @@ fun Float.toHumanReadableByteValue(si: Boolean = false): String {
val pre =
(if (si) "kMGTPE" else "KMGTPE")[exp - 1].toString() + if (si) "" else "i"
return String.format(
- Locale.getDefault(), "%.1f %sB",
- bytes / unit.toDouble().pow(exp.toDouble()), pre
+ Locale.getDefault(),
+ "%.1f %sB",
+ bytes / unit.toDouble().pow(exp.toDouble()),
+ pre,
)
}
@@ -44,7 +45,9 @@ fun Long.toHumanReadableByteValue(si: Boolean = false): String {
val pre =
(if (si) "kMGTPE" else "KMGTPE")[exp - 1].toString() + if (si) "" else "i"
return String.format(
- Locale.getDefault(), "%.1f %sB",
- bytes / unit.toDouble().pow(exp.toDouble()), pre
+ Locale.getDefault(),
+ "%.1f %sB",
+ bytes / unit.toDouble().pow(exp.toDouble()),
+ pre,
)
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/ui/AniTrendPreview.kt b/android-core/src/main/kotlin/co/anitrend/core/android/ui/AniTrendPreview.kt
index 7438330b7..c4540c1f2 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/ui/AniTrendPreview.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/ui/AniTrendPreview.kt
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2024 AniTrend
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package co.anitrend.core.android.ui
import android.content.res.Configuration.UI_MODE_NIGHT_NO
@@ -5,44 +21,43 @@ import android.content.res.Configuration.UI_MODE_NIGHT_YES
import androidx.compose.ui.tooling.preview.Preview
annotation class AniTrendPreview {
-
@Preview(
uiMode = UI_MODE_NIGHT_NO,
- name = "Light"
+ name = "Light",
)
annotation class Light
@Preview(
uiMode = UI_MODE_NIGHT_YES,
- name = "Dark"
+ name = "Dark",
)
annotation class Dark
@Preview(
showSystemUi = true,
device = "spec:width=411dp,height=891dp",
- name = "Mobile"
+ name = "Mobile",
)
annotation class Mobile
@Preview(
showSystemUi = true,
device = "spec:width=673.5dp,height=841dp,dpi=480",
- name = "Foldable"
+ name = "Foldable",
)
annotation class Foldable
@Preview(
showSystemUi = true,
device = "spec:width=1280dp,height=800dp,dpi=480",
- name = "Tablet"
+ name = "Tablet",
)
annotation class Tablet
@Preview(
showSystemUi = true,
device = "spec:width=1920dp,height=1080dp,dpi=480",
- name = "Desktop"
+ name = "Desktop",
)
annotation class Desktop
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/ui/color/Color.kt b/android-core/src/main/kotlin/co/anitrend/core/android/ui/color/Color.kt
index 009ad4c57..f43defb49 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/ui/color/Color.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/ui/color/Color.kt
@@ -1,8 +1,23 @@
+/*
+ * Copyright (C) 2024 AniTrend
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package co.anitrend.core.android.ui.color
import androidx.compose.ui.graphics.Color
-
val md_theme_light_primary = Color(0xFF6750A4)
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
val md_theme_light_primaryContainer = Color(0xFFEADDFF)
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/Theme.kt b/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/Theme.kt
index 57d47b5b7..7bcaa5ba6 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/Theme.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/Theme.kt
@@ -1,8 +1,23 @@
+/*
+ * Copyright (C) 2024 AniTrend
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package co.anitrend.core.android.ui.theme
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
-import androidx.compose.material.icons.Icons
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ShapeDefaults
import androidx.compose.material3.Shapes
@@ -77,96 +92,98 @@ import co.anitrend.core.android.ui.color.md_theme_light_tertiaryContainer
import co.anitrend.core.android.ui.typography.AniTrendTypography
import org.koin.compose.koinInject
+private val LightColorScheme =
+ lightColorScheme(
+ primary = md_theme_light_primary,
+ onPrimary = md_theme_light_onPrimary,
+ primaryContainer = md_theme_light_primaryContainer,
+ onPrimaryContainer = md_theme_light_onPrimaryContainer,
+ secondary = md_theme_light_secondary,
+ onSecondary = md_theme_light_onSecondary,
+ secondaryContainer = md_theme_light_secondaryContainer,
+ onSecondaryContainer = md_theme_light_onSecondaryContainer,
+ tertiary = md_theme_light_tertiary,
+ onTertiary = md_theme_light_onTertiary,
+ tertiaryContainer = md_theme_light_tertiaryContainer,
+ onTertiaryContainer = md_theme_light_onTertiaryContainer,
+ error = md_theme_light_error,
+ onError = md_theme_light_onError,
+ errorContainer = md_theme_light_errorContainer,
+ onErrorContainer = md_theme_light_onErrorContainer,
+ outline = md_theme_light_outline,
+ background = md_theme_light_background,
+ onBackground = md_theme_light_onBackground,
+ surface = md_theme_light_surface,
+ onSurface = md_theme_light_onSurface,
+ surfaceVariant = md_theme_light_surfaceVariant,
+ onSurfaceVariant = md_theme_light_onSurfaceVariant,
+ inverseSurface = md_theme_light_inverseSurface,
+ inverseOnSurface = md_theme_light_inverseOnSurface,
+ inversePrimary = md_theme_light_inversePrimary,
+ surfaceTint = md_theme_light_surfaceTint,
+ outlineVariant = md_theme_light_outlineVariant,
+ scrim = md_theme_light_scrim,
+ )
-private val LightColorScheme = lightColorScheme(
- primary = md_theme_light_primary,
- onPrimary = md_theme_light_onPrimary,
- primaryContainer = md_theme_light_primaryContainer,
- onPrimaryContainer = md_theme_light_onPrimaryContainer,
- secondary = md_theme_light_secondary,
- onSecondary = md_theme_light_onSecondary,
- secondaryContainer = md_theme_light_secondaryContainer,
- onSecondaryContainer = md_theme_light_onSecondaryContainer,
- tertiary = md_theme_light_tertiary,
- onTertiary = md_theme_light_onTertiary,
- tertiaryContainer = md_theme_light_tertiaryContainer,
- onTertiaryContainer = md_theme_light_onTertiaryContainer,
- error = md_theme_light_error,
- onError = md_theme_light_onError,
- errorContainer = md_theme_light_errorContainer,
- onErrorContainer = md_theme_light_onErrorContainer,
- outline = md_theme_light_outline,
- background = md_theme_light_background,
- onBackground = md_theme_light_onBackground,
- surface = md_theme_light_surface,
- onSurface = md_theme_light_onSurface,
- surfaceVariant = md_theme_light_surfaceVariant,
- onSurfaceVariant = md_theme_light_onSurfaceVariant,
- inverseSurface = md_theme_light_inverseSurface,
- inverseOnSurface = md_theme_light_inverseOnSurface,
- inversePrimary = md_theme_light_inversePrimary,
- surfaceTint = md_theme_light_surfaceTint,
- outlineVariant = md_theme_light_outlineVariant,
- scrim = md_theme_light_scrim,
-)
-
-private val DarkColorScheme = darkColorScheme(
- primary = md_theme_dark_primary,
- onPrimary = md_theme_dark_onPrimary,
- primaryContainer = md_theme_dark_primaryContainer,
- onPrimaryContainer = md_theme_dark_onPrimaryContainer,
- secondary = md_theme_dark_secondary,
- onSecondary = md_theme_dark_onSecondary,
- secondaryContainer = md_theme_dark_secondaryContainer,
- onSecondaryContainer = md_theme_dark_onSecondaryContainer,
- tertiary = md_theme_dark_tertiary,
- onTertiary = md_theme_dark_onTertiary,
- tertiaryContainer = md_theme_dark_tertiaryContainer,
- onTertiaryContainer = md_theme_dark_onTertiaryContainer,
- error = md_theme_dark_error,
- onError = md_theme_dark_onError,
- errorContainer = md_theme_dark_errorContainer,
- onErrorContainer = md_theme_dark_onErrorContainer,
- outline = md_theme_dark_outline,
- background = md_theme_dark_background,
- onBackground = md_theme_dark_onBackground,
- surface = md_theme_dark_surface,
- onSurface = md_theme_dark_onSurface,
- surfaceVariant = md_theme_dark_surfaceVariant,
- onSurfaceVariant = md_theme_dark_onSurfaceVariant,
- inverseSurface = md_theme_dark_inverseSurface,
- inverseOnSurface = md_theme_dark_inverseOnSurface,
- inversePrimary = md_theme_dark_inversePrimary,
- surfaceTint = md_theme_dark_surfaceTint,
- outlineVariant = md_theme_dark_outlineVariant,
- scrim = md_theme_dark_scrim,
-)
-
-private val AniTrendShapes = Shapes(
- extraSmall = ShapeDefaults.ExtraLarge,
- small = ShapeDefaults.ExtraLarge,
- medium = ShapeDefaults.ExtraLarge,
- large = ShapeDefaults.ExtraLarge,
- extraLarge = ShapeDefaults.ExtraLarge,
-)
+private val DarkColorScheme =
+ darkColorScheme(
+ primary = md_theme_dark_primary,
+ onPrimary = md_theme_dark_onPrimary,
+ primaryContainer = md_theme_dark_primaryContainer,
+ onPrimaryContainer = md_theme_dark_onPrimaryContainer,
+ secondary = md_theme_dark_secondary,
+ onSecondary = md_theme_dark_onSecondary,
+ secondaryContainer = md_theme_dark_secondaryContainer,
+ onSecondaryContainer = md_theme_dark_onSecondaryContainer,
+ tertiary = md_theme_dark_tertiary,
+ onTertiary = md_theme_dark_onTertiary,
+ tertiaryContainer = md_theme_dark_tertiaryContainer,
+ onTertiaryContainer = md_theme_dark_onTertiaryContainer,
+ error = md_theme_dark_error,
+ onError = md_theme_dark_onError,
+ errorContainer = md_theme_dark_errorContainer,
+ onErrorContainer = md_theme_dark_onErrorContainer,
+ outline = md_theme_dark_outline,
+ background = md_theme_dark_background,
+ onBackground = md_theme_dark_onBackground,
+ surface = md_theme_dark_surface,
+ onSurface = md_theme_dark_onSurface,
+ surfaceVariant = md_theme_dark_surfaceVariant,
+ onSurfaceVariant = md_theme_dark_onSurfaceVariant,
+ inverseSurface = md_theme_dark_inverseSurface,
+ inverseOnSurface = md_theme_dark_inverseOnSurface,
+ inversePrimary = md_theme_dark_inversePrimary,
+ surfaceTint = md_theme_dark_surfaceTint,
+ outlineVariant = md_theme_dark_outlineVariant,
+ scrim = md_theme_dark_scrim,
+ )
+private val AniTrendShapes =
+ Shapes(
+ extraSmall = ShapeDefaults.ExtraLarge,
+ small = ShapeDefaults.ExtraLarge,
+ medium = ShapeDefaults.ExtraLarge,
+ large = ShapeDefaults.ExtraLarge,
+ extraLarge = ShapeDefaults.ExtraLarge,
+ )
@Composable
fun AniTrendTheme3(
darkTheme: Boolean = isSystemInDarkTheme(),
themeHelper: IThemeHelper = koinInject(),
dynamicColor: Boolean = true,
- content: @Composable () -> Unit
+ content: @Composable () -> Unit,
) {
- val colorScheme = when {
- dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
- val context = LocalContext.current
- if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
- }
+ val colorScheme =
+ when {
+ dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
+ val context = LocalContext.current
+ if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
+ }
- darkTheme -> DarkColorScheme
- else -> LightColorScheme
- }
+ darkTheme -> DarkColorScheme
+ else -> LightColorScheme
+ }
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
@@ -179,6 +196,6 @@ fun AniTrendTheme3(
colorScheme = colorScheme,
shapes = AniTrendShapes,
typography = AniTrendTypography,
- content = content
+ content = content,
)
}
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/preview/PreviewDefaults.kt b/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/preview/PreviewDefaults.kt
index 54826a09b..7046760d9 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/preview/PreviewDefaults.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/preview/PreviewDefaults.kt
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2024 AniTrend
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package co.anitrend.core.android.ui.theme.preview
import androidx.compose.foundation.isSystemInDarkTheme
@@ -6,23 +22,27 @@ import androidx.fragment.app.FragmentActivity
import co.anitrend.core.android.settings.helper.theme.contract.IThemeHelper
import co.anitrend.core.android.ui.theme.AniTrendTheme3
-private val PreviewThemeHelper = object : IThemeHelper {
- /**
- * Sets the default night mode based on the theme set in settings
- */
- override fun applyDynamicNightModeFromTheme() {}
+private val PreviewThemeHelper =
+ object : IThemeHelper {
+ /**
+ * Sets the default night mode based on the theme set in settings
+ */
+ override fun applyDynamicNightModeFromTheme() {}
- /**
- * Applies settings theme resource or provided [themeOverride] which overrides settings
- */
- override fun applyApplicationTheme(context: FragmentActivity, themeOverride: Int?) {}
-}
+ /**
+ * Applies settings theme resource or provided [themeOverride] which overrides settings
+ */
+ override fun applyApplicationTheme(
+ context: FragmentActivity,
+ themeOverride: Int?,
+ ) {}
+ }
@Composable
fun PreviewTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
dynamicColor: Boolean = true,
- content: @Composable () -> Unit
+ content: @Composable () -> Unit,
) {
AniTrendTheme3(
darkTheme = darkTheme,
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/ui/typography/Typography.kt b/android-core/src/main/kotlin/co/anitrend/core/android/ui/typography/Typography.kt
index cf34aba73..aa5457e1a 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/ui/typography/Typography.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/ui/typography/Typography.kt
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2024 AniTrend
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package co.anitrend.core.android.ui.typography
import androidx.compose.material3.Typography
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/views/FrameLayoutWithBinding.kt b/android-core/src/main/kotlin/co/anitrend/core/android/views/FrameLayoutWithBinding.kt
index 20483a0ad..aaa375be2 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/views/FrameLayoutWithBinding.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/views/FrameLayoutWithBinding.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.views
import android.content.Context
@@ -28,34 +27,39 @@ import co.anitrend.core.android.binding.IBindingView
* Frame layout with view binding support
* > **N.B.** View binding seems to cause a lot of data mix-ups within a view holder item
*/
-abstract class FrameLayoutWithBinding @JvmOverloads constructor(
- context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
-) : FrameLayout(context, attrs, defStyleAttr), CustomView, IBindingView {
-
- override var binding: V? = null
+abstract class FrameLayoutWithBinding
+ @JvmOverloads
+ constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0,
+ ) : FrameLayout(context, attrs, defStyleAttr), CustomView, IBindingView {
+ override var binding: V? = null
- override fun onInit(context: Context, attrs: AttributeSet?, styleAttr: Int?) {
- binding = createBinding()
- }
+ override fun onInit(
+ context: Context,
+ attrs: AttributeSet?,
+ styleAttr: Int?,
+ ) {
+ binding = createBinding()
+ }
- protected abstract fun createBinding(): V
+ protected abstract fun createBinding(): V
- /**
- * Should be called on a view's detach from window to unbind or release object references
- * and cancel all running coroutine jobs if the current view
- *
- * Consider calling this in [android.view.View.onDetachedFromWindow]
- */
- override fun onViewRecycled() {
- super.onViewRecycled()
- binding = null
- }
+ /**
+ * Should be called on a view's detach from window to unbind or release object references
+ * and cancel all running coroutine jobs if the current view
+ *
+ * Consider calling this in [android.view.View.onDetachedFromWindow]
+ */
+ override fun onViewRecycled() {
+ super.onViewRecycled()
+ binding = null
+ }
- override fun onDetachedFromWindow() {
- super.onDetachedFromWindow()
- // TODO: Avoid setting binding to null in onDetach otherwise views don't get updated in a recycler
- //onViewRecycled()
+ override fun onDetachedFromWindow() {
+ super.onDetachedFromWindow()
+ // TODO: Avoid setting binding to null in onDetach otherwise views don't get updated in a recycler
+ // onViewRecycled()
+ }
}
-
-
-}
\ No newline at end of file
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/views/LinearLayoutWithBinding.kt b/android-core/src/main/kotlin/co/anitrend/core/android/views/LinearLayoutWithBinding.kt
index 405179d9b..a467de883 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/views/LinearLayoutWithBinding.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/views/LinearLayoutWithBinding.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 AniTrend
+ * Copyright (C) 2020 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.views
import android.content.Context
@@ -28,32 +27,39 @@ import co.anitrend.core.android.binding.IBindingView
* Linear layout with view binding support
* > **N.B.** View binding seems to cause a lot of data mix-ups within a view holder item
*/
-abstract class LinearLayoutWithBinding @JvmOverloads constructor(
- context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
-) : LinearLayoutCompat(context, attrs, defStyleAttr), CustomView, IBindingView {
-
- override var binding: V? = null
+abstract class LinearLayoutWithBinding
+ @JvmOverloads
+ constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0,
+ ) : LinearLayoutCompat(context, attrs, defStyleAttr), CustomView, IBindingView {
+ override var binding: V? = null
- override fun onInit(context: Context, attrs: AttributeSet?, styleAttr: Int?) {
- binding = createBinding()
- }
+ override fun onInit(
+ context: Context,
+ attrs: AttributeSet?,
+ styleAttr: Int?,
+ ) {
+ binding = createBinding()
+ }
- protected abstract fun createBinding(): V
+ protected abstract fun createBinding(): V
- /**
- * Should be called on a view's detach from window to unbind or release object references
- * and cancel all running coroutine jobs if the current view
- *
- * Consider calling this in [android.view.View.onDetachedFromWindow]
- */
- override fun onViewRecycled() {
- super.onViewRecycled()
- binding = null
- }
+ /**
+ * Should be called on a view's detach from window to unbind or release object references
+ * and cancel all running coroutine jobs if the current view
+ *
+ * Consider calling this in [android.view.View.onDetachedFromWindow]
+ */
+ override fun onViewRecycled() {
+ super.onViewRecycled()
+ binding = null
+ }
- override fun onDetachedFromWindow() {
- super.onDetachedFromWindow()
- // TODO: Avoid setting binding to null in onDetach otherwise views don't get updated in a recycler
- //onViewRecycled()
+ override fun onDetachedFromWindow() {
+ super.onDetachedFromWindow()
+ // TODO: Avoid setting binding to null in onDetach otherwise views don't get updated in a recycler
+ // onViewRecycled()
+ }
}
-}
\ No newline at end of file
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/views/drawable/RoundedDrawable.kt b/android-core/src/main/kotlin/co/anitrend/core/android/views/drawable/RoundedDrawable.kt
index 86c55e631..a56fb0c93 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/views/drawable/RoundedDrawable.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/views/drawable/RoundedDrawable.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.views.drawable
import android.graphics.drawable.PaintDrawable
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/views/scroll/FillNestedScrollView.kt b/android-core/src/main/kotlin/co/anitrend/core/android/views/scroll/FillNestedScrollView.kt
index 86e0a1642..3dc74f7a3 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/views/scroll/FillNestedScrollView.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/views/scroll/FillNestedScrollView.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.views.scroll
import android.content.Context
@@ -23,28 +22,35 @@ import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.widget.NestedScrollView
-class FillNestedScrollView @JvmOverloads constructor(
- context: Context,
- attrs: AttributeSet? = null,
- defStyleAttr: Int = 0
-) : NestedScrollView(context, attrs, defStyleAttr) {
-
- var maxHeight = -1
+class FillNestedScrollView
+ @JvmOverloads
+ constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0,
+ ) : NestedScrollView(context, attrs, defStyleAttr) {
+ var maxHeight = -1
- private fun getBottomHeight(): Int {
- val insets = ViewCompat.getRootWindowInsets(this)
- val systemBars = WindowInsetsCompat.Type.systemBars()
- return insets?.getInsets(systemBars)?.bottom ?: 0
- }
+ private fun getBottomHeight(): Int {
+ val insets = ViewCompat.getRootWindowInsets(this)
+ val systemBars = WindowInsetsCompat.Type.systemBars()
+ return insets?.getInsets(systemBars)?.bottom ?: 0
+ }
- override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
- var heightSpec = if (maxHeight > 0)
- MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST)
- else
- heightMeasureSpec
+ override fun onMeasure(
+ widthMeasureSpec: Int,
+ heightMeasureSpec: Int,
+ ) {
+ var heightSpec =
+ if (maxHeight > 0) {
+ MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST)
+ } else {
+ heightMeasureSpec
+ }
- if (maxHeight < height + getBottomHeight())
- heightSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST)
- super.onMeasure(widthMeasureSpec, heightSpec)
+ if (maxHeight < height + getBottomHeight()) {
+ heightSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST)
+ }
+ super.onMeasure(widthMeasureSpec, heightSpec)
+ }
}
-}
\ No newline at end of file
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/views/text/TextDrawable.kt b/android-core/src/main/kotlin/co/anitrend/core/android/views/text/TextDrawable.kt
index 5b7123ed2..3583bbe20 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/views/text/TextDrawable.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/views/text/TextDrawable.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.views.text
import android.content.Context
@@ -34,42 +33,53 @@ import com.google.android.material.textview.MaterialTextView
*/
class TextDrawable(
context: Context,
- private val text: String?
+ private val text: String?,
) : Drawable() {
-
- private val materialTextView = MaterialTextView(context).also { textView ->
- textView.text = text
- textView.background = textView.context.getCompatDrawable(
- R.drawable.indicator_background, co.anitrend.arch.theme.R.color.colorBackground
- )
- textView.layoutParams = ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT
- )
- textView.setTextColor(
- textView.context.getCompatColor(
- co.anitrend.arch.theme.R.color.colorOnBackground
+ private val materialTextView =
+ MaterialTextView(context).also { textView ->
+ textView.text = text
+ textView.background =
+ textView.context.getCompatDrawable(
+ R.drawable.indicator_background,
+ co.anitrend.arch.theme.R.color.colorBackground,
+ )
+ textView.layoutParams =
+ ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ )
+ textView.setTextColor(
+ textView.context.getCompatColor(
+ co.anitrend.arch.theme.R.color.colorOnBackground,
+ ),
)
- )
- val padding = textView.resources
- .getDimensionPixelSize(R.dimen.text_drawable_margin)
- textView.setPadding(padding, padding, padding, padding)
- }
+ val padding =
+ textView.resources
+ .getDimensionPixelSize(R.dimen.text_drawable_margin)
+ textView.setPadding(padding, padding, padding, padding)
+ }
/**
* Specify a bounding rectangle for the Drawable. This is where the drawable
* will draw when its draw() method is called.
*/
- override fun setBounds(left: Int, top: Int, right: Int, bottom: Int) {
+ override fun setBounds(
+ left: Int,
+ top: Int,
+ right: Int,
+ bottom: Int,
+ ) {
super.setBounds(left, top, right, bottom)
- val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(
- right - left,
- View.MeasureSpec.EXACTLY
- )
- val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(
- bottom - top,
- View.MeasureSpec.EXACTLY
- )
+ val widthMeasureSpec =
+ View.MeasureSpec.makeMeasureSpec(
+ right - left,
+ View.MeasureSpec.EXACTLY,
+ )
+ val heightMeasureSpec =
+ View.MeasureSpec.makeMeasureSpec(
+ bottom - top,
+ View.MeasureSpec.EXACTLY,
+ )
materialTextView.measure(widthMeasureSpec, heightMeasureSpec)
materialTextView.layout(left, top, right, bottom)
}
@@ -89,7 +99,7 @@ class TextDrawable(
* 255 means fully opaque.
*/
override fun setAlpha(alpha: Int) {
- materialTextView.alpha = alpha/255f
+ materialTextView.alpha = alpha / 255f
}
/**
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/widget/appbar/BottomAppBar.kt b/android-core/src/main/kotlin/co/anitrend/core/android/widget/appbar/BottomAppBar.kt
index f048bc34b..ec20b6714 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/widget/appbar/BottomAppBar.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/widget/appbar/BottomAppBar.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.widget.appbar
import android.content.Context
@@ -28,49 +27,54 @@ import com.google.android.material.bottomappbar.BottomAppBar
import kotlinx.coroutines.delay
import me.saket.cascade.overrideAllPopupMenus
-class BottomAppBar @JvmOverloads constructor(
- context: Context,
- attrs: AttributeSet? = null,
- defStyleAttr: Int = R.attr.bottomAppBarStyle
-) : BottomAppBar(context, attrs, defStyleAttr), CustomView {
-
- init {
- onInit(context, attrs, defStyleAttr)
- }
+class BottomAppBar
+ @JvmOverloads
+ constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = R.attr.bottomAppBarStyle,
+ ) : BottomAppBar(context, attrs, defStyleAttr), CustomView {
+ init {
+ onInit(context, attrs, defStyleAttr)
+ }
- /**
- * Change visibility of all items for in this menu
- *
- * @param shouldShow Visibility
- * @param filter Predicate for which menu items to hid
- */
- suspend fun toggleVisibility(
- shouldShow: Boolean,
- filter: (MenuItem) -> Boolean
- ) {
- runCatching {
- delay(128)
- menu.iterator().asSequence()
- .filter(filter)
- .forEach { menuItem ->
- menuItem.isVisible = shouldShow
- }
+ /**
+ * Change visibility of all items for in this menu
+ *
+ * @param shouldShow Visibility
+ * @param filter Predicate for which menu items to hid
+ */
+ suspend fun toggleVisibility(
+ shouldShow: Boolean,
+ filter: (MenuItem) -> Boolean,
+ ) {
+ runCatching {
+ delay(128)
+ menu.iterator().asSequence()
+ .filter(filter)
+ .forEach { menuItem ->
+ menuItem.isVisible = shouldShow
+ }
+ }
}
- }
- /**
- * Callable in view constructors to perform view inflation and attribute initialization
- *
- * @param context view context
- * @param attrs view attributes if applicable
- * @param styleAttr style attribute if applicable
- */
- override fun onInit(context: Context, attrs: AttributeSet?, styleAttr: Int?) {
- hideOnScroll = true
- isHapticFeedbackEnabled = true
- overrideAllPopupMenus { _, anchor ->
- anchor.cascadeMenu()
+ /**
+ * Callable in view constructors to perform view inflation and attribute initialization
+ *
+ * @param context view context
+ * @param attrs view attributes if applicable
+ * @param styleAttr style attribute if applicable
+ */
+ override fun onInit(
+ context: Context,
+ attrs: AttributeSet?,
+ styleAttr: Int?,
+ ) {
+ hideOnScroll = true
+ isHapticFeedbackEnabled = true
+ overrideAllPopupMenus { _, anchor ->
+ anchor.cascadeMenu()
+ }
+ // HideBottomViewOnScrollBehavior
}
- // HideBottomViewOnScrollBehavior
}
-}
\ No newline at end of file
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/widget/button/LoadingTextButton.kt b/android-core/src/main/kotlin/co/anitrend/core/android/widget/button/LoadingTextButton.kt
index 4821bc0db..a412e5e7d 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/widget/button/LoadingTextButton.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/widget/button/LoadingTextButton.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.widget.button
import android.content.Context
@@ -40,103 +39,121 @@ import com.google.android.material.textview.MaterialTextView
*
* @param icon Optional icon for this text button
*/
-class LoadingTextButton @JvmOverloads constructor(
- context: Context,
- attrs: AttributeSet? = null,
- icon: Int? = null,
-) : ViewFlipper(context, attrs), CustomView {
+class LoadingTextButton
+ @JvmOverloads
+ constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ icon: Int? = null,
+ ) : ViewFlipper(context, attrs), CustomView {
+ private val indicator =
+ CircularProgressIndicator(context).apply {
+ layoutParams =
+ LayoutParams(
+ LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
+ LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
+ ).also { params ->
+ params.gravity = Gravity.CENTER_VERTICAL
+ params.marginEnd = 8.dp
+ }
+ indicatorSize = 16.dp
+ trackCornerRadius = 8.dp
+ trackThickness = 4.dp
+ isIndeterminate = true
+ }
- private val indicator = CircularProgressIndicator(context).apply {
- layoutParams = LayoutParams(
- LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
- LinearLayoutCompat.LayoutParams.WRAP_CONTENT
- ).also { params ->
- params.gravity = Gravity.CENTER_VERTICAL
- params.marginEnd = 8.dp
- }
- indicatorSize = 16.dp
- trackCornerRadius = 8.dp
- trackThickness = 4.dp
- isIndeterminate = true
- }
+ private val primaryText =
+ MaterialTextView(context).apply {
+ applyDefaultTextStyle {
+ setCompoundDrawablesWithIntrinsicBounds(
+ icon?.let { context.getCompatDrawable(it) },
+ null,
+ null,
+ null,
+ )
+ }
+ }
- private val primaryText = MaterialTextView(context).apply {
- applyDefaultTextStyle {
- setCompoundDrawablesWithIntrinsicBounds(
- icon?.let { context.getCompatDrawable(it) },
- null, null, null
- )
+ init {
+ onInit(context, attrs)
}
- }
- init { onInit(context, attrs) }
+ /**
+ * @see MaterialTextView.setText
+ */
+ fun setText(text: CharSequence?) {
+ primaryText.text = text
+ showContent()
+ }
- /**
- * @see MaterialTextView.setText
- */
- fun setText(text: CharSequence?) {
- primaryText.text = text
- showContent()
- }
+ /**
+ * @see MaterialTextView.setCompoundDrawables
+ */
+ fun setDrawable(drawable: Drawable?) {
+ primaryText.setCompoundDrawablesWithIntrinsicBounds(
+ drawable,
+ null,
+ null,
+ null,
+ )
+ showContent()
+ }
- /**
- * @see MaterialTextView.setCompoundDrawables
- */
- fun setDrawable(drawable: Drawable?) {
- primaryText.setCompoundDrawablesWithIntrinsicBounds(
- drawable, null, null, null
- )
- showContent()
- }
+ fun showLoading() {
+ if (displayedChild != LOADING_INDEX) {
+ displayedChild = LOADING_INDEX
+ }
+ }
- fun showLoading() {
- if (displayedChild != LOADING_INDEX)
- displayedChild = LOADING_INDEX
- }
+ fun showContent() {
+ if (displayedChild != CONTENT_INDEX) {
+ displayedChild = CONTENT_INDEX
+ }
+ }
- fun showContent() {
- if (displayedChild != CONTENT_INDEX)
- displayedChild = CONTENT_INDEX
- }
+ override fun onInit(
+ context: Context,
+ attrs: AttributeSet?,
+ styleAttr: Int?,
+ ) {
+ inAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_in)
+ outAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_out)
+ layoutParams =
+ LayoutParams(
+ LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
+ LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
+ )
+ addView(primaryText)
+ addView(indicator)
- override fun onInit(context: Context, attrs: AttributeSet?, styleAttr: Int?) {
- inAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_in)
- outAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_out)
- layoutParams = LayoutParams(
- LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
- LinearLayoutCompat.LayoutParams.WRAP_CONTENT
- )
- addView(primaryText)
- addView(indicator)
+ if (isInEditMode) {
+ displayedChild = CONTENT_INDEX
+ }
+ }
- if (isInEditMode)
+ override fun onViewRecycled() {
+ super.onViewRecycled()
displayedChild = CONTENT_INDEX
- }
-
- override fun onViewRecycled() {
- super.onViewRecycled()
- displayedChild = CONTENT_INDEX
- setOnClickListener(null)
- }
+ setOnClickListener(null)
+ }
- private companion object {
- const val CONTENT_INDEX = 0
- const val LOADING_INDEX = 1
+ private companion object {
+ const val CONTENT_INDEX = 0
+ const val LOADING_INDEX = 1
- fun MaterialTextView.applyDefaultTextStyle(
- unit: MaterialTextView.() -> Unit
- ) {
- layoutParams = LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.WRAP_CONTENT
- ).also { param ->
- param.gravity = Gravity.CENTER_VERTICAL
+ fun MaterialTextView.applyDefaultTextStyle(unit: MaterialTextView.() -> Unit) {
+ layoutParams =
+ LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ).also { param ->
+ param.gravity = Gravity.CENTER_VERTICAL
+ }
+ compoundDrawablePadding = 8.dp
+ style(R.style.AppTheme_Material_TextBody_Primary)
+ setTypeface(typeface, Typeface.BOLD)
+ setTextColor(context.getCompatColor(R.color.white_1000))
+ unit()
}
- compoundDrawablePadding = 8.dp
- style(R.style.AppTheme_Material_TextBody_Primary)
- setTypeface(typeface, Typeface.BOLD)
- setTextColor(context.getCompatColor(R.color.white_1000))
- unit()
}
}
-}
\ No newline at end of file
diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/widget/viewpager/BottomSheetViewPager.kt b/android-core/src/main/kotlin/co/anitrend/core/android/widget/viewpager/BottomSheetViewPager.kt
index 2d63a9d9e..e860463d8 100644
--- a/android-core/src/main/kotlin/co/anitrend/core/android/widget/viewpager/BottomSheetViewPager.kt
+++ b/android-core/src/main/kotlin/co/anitrend/core/android/widget/viewpager/BottomSheetViewPager.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 AniTrend
+ * Copyright (C) 2021 AniTrend
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package co.anitrend.core.android.widget.viewpager
import android.content.Context
@@ -31,54 +30,57 @@ import java.lang.reflect.Field
*
* @author kafumi
*/
-class BottomSheetViewPager @JvmOverloads constructor(
- context: Context,
- attrs: AttributeSet? = null,
-) : ViewPager(context, attrs) {
-
- // Need to access package-private `position` field of `ViewPager.LayoutParams` to determine
- // which child view is the view for currently selected item from `ViewPager.getCurrentItem()`.
- private val positionField: Field =
- LayoutParams::class.java.getDeclaredField(
- "position"
- ).also { it.isAccessible = true }
+class BottomSheetViewPager
+ @JvmOverloads
+ constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ ) : ViewPager(context, attrs) {
+ // Need to access package-private `position` field of `ViewPager.LayoutParams` to determine
+ // which child view is the view for currently selected item from `ViewPager.getCurrentItem()`.
+ private val positionField: Field =
+ LayoutParams::class.java.getDeclaredField(
+ "position",
+ ).also { it.isAccessible = true }
- init {
- addOnPageChangeListener(object : SimpleOnPageChangeListener() {
- override fun onPageSelected(position: Int) {
- // Need to call requestLayout() when selected page is changed so that
- // `BottomSheetBehavior` calls `findScrollingChild()` and recognizes the new page
- // as the "scrollable child".
- requestLayout()
- }
- })
- }
+ init {
+ addOnPageChangeListener(
+ object : SimpleOnPageChangeListener() {
+ override fun onPageSelected(position: Int) {
+ // Need to call requestLayout() when selected page is changed so that
+ // `BottomSheetBehavior` calls `findScrollingChild()` and recognizes the new page
+ // as the "scrollable child".
+ requestLayout()
+ }
+ },
+ )
+ }
- override fun getChildAt(index: Int): View {
- // Swap index 0 and `currentItem`
- val currentView = getCurrentView() ?: return super.getChildAt(index)
- return if (index == 0) {
- currentView
- } else {
- var view = super.getChildAt(index)
- if (view == currentView) {
- view = super.getChildAt(0)
+ override fun getChildAt(index: Int): View {
+ // Swap index 0 and `currentItem`
+ val currentView = getCurrentView() ?: return super.getChildAt(index)
+ return if (index == 0) {
+ currentView
+ } else {
+ var view = super.getChildAt(index)
+ if (view == currentView) {
+ view = super.getChildAt(0)
+ }
+ return view
}
- return view
}
- }
- private fun getCurrentView(): View? {
- for (i in 0 until childCount) {
- val child = super.getChildAt(i)
- val lp = child.layoutParams as? LayoutParams
- if (lp != null) {
- val position = positionField.getInt(lp)
- if (!lp.isDecor && currentItem == position) {
- return child
+ private fun getCurrentView(): View? {
+ for (i in 0 until childCount) {
+ val child = super.getChildAt(i)
+ val lp = child.layoutParams as? LayoutParams
+ if (lp != null) {
+ val position = positionField.getInt(lp)
+ if (!lp.isDecor && currentItem == position) {
+ return child
+ }
}
}
+ return null
}
- return null
}
-}
\ No newline at end of file
diff --git a/android-core/src/main/res/anim/enter_from_bottom.xml b/android-core/src/main/res/anim/enter_from_bottom.xml
index 2fdc7387a..fc4b0238a 100644
--- a/android-core/src/main/res/anim/enter_from_bottom.xml
+++ b/android-core/src/main/res/anim/enter_from_bottom.xml
@@ -1,21 +1,20 @@
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
-
+
+
diff --git a/android-core/src/main/res/color/selector_chip_background.xml b/android-core/src/main/res/color/selector_chip_background.xml
index ecb69d567..20183bbe7 100644
--- a/android-core/src/main/res/color/selector_chip_background.xml
+++ b/android-core/src/main/res/color/selector_chip_background.xml
@@ -1,20 +1,20 @@
-
-
+
+
diff --git a/android-core/src/main/res/color/selector_chip_text_color.xml b/android-core/src/main/res/color/selector_chip_text_color.xml
index 5500ca1d6..1773b030c 100644
--- a/android-core/src/main/res/color/selector_chip_text_color.xml
+++ b/android-core/src/main/res/color/selector_chip_text_color.xml
@@ -1,20 +1,20 @@
-
-
+
+
diff --git a/android-core/src/main/res/color/selector_text_button_ripple.xml b/android-core/src/main/res/color/selector_text_button_ripple.xml
index f27bf12af..c69755f47 100644
--- a/android-core/src/main/res/color/selector_text_button_ripple.xml
+++ b/android-core/src/main/res/color/selector_text_button_ripple.xml
@@ -1,20 +1,20 @@
-
-
+
+
-
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
-
diff --git a/android-core/src/main/res/drawable/dashed_background.xml b/android-core/src/main/res/drawable/dashed_background.xml
index 7f0d70dbe..44f24cd48 100644
--- a/android-core/src/main/res/drawable/dashed_background.xml
+++ b/android-core/src/main/res/drawable/dashed_background.xml
@@ -1,20 +1,20 @@
-
-
+
+
+
diff --git a/android-core/src/main/res/drawable/gradient_shadow.xml b/android-core/src/main/res/drawable/gradient_shadow.xml
index 4c38c1855..958487820 100644
--- a/android-core/src/main/res/drawable/gradient_shadow.xml
+++ b/android-core/src/main/res/drawable/gradient_shadow.xml
@@ -1,21 +1,20 @@
-
+~ Copyright (C) 2021 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/gradient_shadow_inverse.xml b/android-core/src/main/res/drawable/gradient_shadow_inverse.xml
index a8935e210..7c6532d59 100644
--- a/android-core/src/main/res/drawable/gradient_shadow_inverse.xml
+++ b/android-core/src/main/res/drawable/gradient_shadow_inverse.xml
@@ -1,21 +1,20 @@
-
+~ Copyright (C) 2021 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
+
diff --git a/android-core/src/main/res/drawable/ic_heart_filled.xml b/android-core/src/main/res/drawable/ic_heart_filled.xml
index e4abe9faf..26806ad91 100644
--- a/android-core/src/main/res/drawable/ic_heart_filled.xml
+++ b/android-core/src/main/res/drawable/ic_heart_filled.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2022 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_heart_outline.xml b/android-core/src/main/res/drawable/ic_heart_outline.xml
index 33c850fd0..80f95efe2 100644
--- a/android-core/src/main/res/drawable/ic_heart_outline.xml
+++ b/android-core/src/main/res/drawable/ic_heart_outline.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2022 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_search.xml b/android-core/src/main/res/drawable/ic_search.xml
index 129974f1d..9d97d01cf 100644
--- a/android-core/src/main/res/drawable/ic_search.xml
+++ b/android-core/src/main/res/drawable/ic_search.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2019 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_shortcut_activity.xml b/android-core/src/main/res/drawable/ic_shortcut_activity.xml
index a297562fb..8d9330a15 100644
--- a/android-core/src/main/res/drawable/ic_shortcut_activity.xml
+++ b/android-core/src/main/res/drawable/ic_shortcut_activity.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_shortcut_airing_schedule.xml b/android-core/src/main/res/drawable/ic_shortcut_airing_schedule.xml
index ae7f06532..a349c5fa1 100644
--- a/android-core/src/main/res/drawable/ic_shortcut_airing_schedule.xml
+++ b/android-core/src/main/res/drawable/ic_shortcut_airing_schedule.xml
@@ -1,21 +1,20 @@
-
+~ Copyright (C) 2021 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_shortcut_anime_list.xml b/android-core/src/main/res/drawable/ic_shortcut_anime_list.xml
index e36fda4a0..877a61fad 100644
--- a/android-core/src/main/res/drawable/ic_shortcut_anime_list.xml
+++ b/android-core/src/main/res/drawable/ic_shortcut_anime_list.xml
@@ -1,21 +1,20 @@
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_shortcut_episodes.xml b/android-core/src/main/res/drawable/ic_shortcut_episodes.xml
index d47b950ce..a7772b72f 100644
--- a/android-core/src/main/res/drawable/ic_shortcut_episodes.xml
+++ b/android-core/src/main/res/drawable/ic_shortcut_episodes.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2019 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_shortcut_forum.xml b/android-core/src/main/res/drawable/ic_shortcut_forum.xml
index d39c90520..f31b896de 100644
--- a/android-core/src/main/res/drawable/ic_shortcut_forum.xml
+++ b/android-core/src/main/res/drawable/ic_shortcut_forum.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_shortcut_manga_list.xml b/android-core/src/main/res/drawable/ic_shortcut_manga_list.xml
index 26529fdbc..e00b4b399 100644
--- a/android-core/src/main/res/drawable/ic_shortcut_manga_list.xml
+++ b/android-core/src/main/res/drawable/ic_shortcut_manga_list.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_shortcut_news.xml b/android-core/src/main/res/drawable/ic_shortcut_news.xml
index f2b4c731e..0f9eecf17 100644
--- a/android-core/src/main/res/drawable/ic_shortcut_news.xml
+++ b/android-core/src/main/res/drawable/ic_shortcut_news.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_shortcut_notifications.xml b/android-core/src/main/res/drawable/ic_shortcut_notifications.xml
index 68fd58b79..117467e4b 100644
--- a/android-core/src/main/res/drawable/ic_shortcut_notifications.xml
+++ b/android-core/src/main/res/drawable/ic_shortcut_notifications.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_shortcut_profile.xml b/android-core/src/main/res/drawable/ic_shortcut_profile.xml
index 24b363437..b1195c1ed 100644
--- a/android-core/src/main/res/drawable/ic_shortcut_profile.xml
+++ b/android-core/src/main/res/drawable/ic_shortcut_profile.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_shortcut_search.xml b/android-core/src/main/res/drawable/ic_shortcut_search.xml
index 68357829a..d8d0f0b22 100644
--- a/android-core/src/main/res/drawable/ic_shortcut_search.xml
+++ b/android-core/src/main/res/drawable/ic_shortcut_search.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2021 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_view_comfortable.xml b/android-core/src/main/res/drawable/ic_view_comfortable.xml
index 344ee8f90..6e8e02811 100644
--- a/android-core/src/main/res/drawable/ic_view_comfortable.xml
+++ b/android-core/src/main/res/drawable/ic_view_comfortable.xml
@@ -1,3 +1,20 @@
+
+
diff --git a/android-core/src/main/res/drawable/ic_view_compact.xml b/android-core/src/main/res/drawable/ic_view_compact.xml
index dc9b078d7..824007686 100644
--- a/android-core/src/main/res/drawable/ic_view_compact.xml
+++ b/android-core/src/main/res/drawable/ic_view_compact.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2021 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_view_detailed.xml b/android-core/src/main/res/drawable/ic_view_detailed.xml
index ae5453ea4..2702328ea 100644
--- a/android-core/src/main/res/drawable/ic_view_detailed.xml
+++ b/android-core/src/main/res/drawable/ic_view_detailed.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2021 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/ic_view_summary.xml b/android-core/src/main/res/drawable/ic_view_summary.xml
index 15beeda0d..0f784e89a 100644
--- a/android-core/src/main/res/drawable/ic_view_summary.xml
+++ b/android-core/src/main/res/drawable/ic_view_summary.xml
@@ -1,20 +1,20 @@
+
-
+~ Copyright (C) 2021 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/indicator_background.xml b/android-core/src/main/res/drawable/indicator_background.xml
index 7577206b7..5c83caf86 100644
--- a/android-core/src/main/res/drawable/indicator_background.xml
+++ b/android-core/src/main/res/drawable/indicator_background.xml
@@ -1,4 +1,20 @@
+
diff --git a/android-core/src/main/res/drawable/material_tab_indicator.xml b/android-core/src/main/res/drawable/material_tab_indicator.xml
index e53e9fbfb..143bdda36 100644
--- a/android-core/src/main/res/drawable/material_tab_indicator.xml
+++ b/android-core/src/main/res/drawable/material_tab_indicator.xml
@@ -1,20 +1,20 @@
-
-
+
+
-
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
diff --git a/android-core/src/main/res/drawable/widget_background.xml b/android-core/src/main/res/drawable/widget_background.xml
index 82ec3fc7a..c7682d082 100644
--- a/android-core/src/main/res/drawable/widget_background.xml
+++ b/android-core/src/main/res/drawable/widget_background.xml
@@ -1,20 +1,20 @@
-
-
+
+
-
diff --git a/android-core/src/main/res/layout/action_frame_layout.xml b/android-core/src/main/res/layout/action_frame_layout.xml
index 6fbd2e4f4..5959fc515 100644
--- a/android-core/src/main/res/layout/action_frame_layout.xml
+++ b/android-core/src/main/res/layout/action_frame_layout.xml
@@ -1,20 +1,20 @@
+~ Copyright (C) 2020 AniTrend
+~
+~ This program is free software: you can redistribute it and/or modify
+~ it under the terms of the GNU General Public License as published by
+~ the Free Software Foundation, either version 3 of the License, or
+~ (at your option) any later version.
+~
+~ This program is distributed in the hope that it will be useful,
+~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~ GNU General Public License for more details.
+~
+~ You should have received a copy of the GNU General Public License
+~ along with this program. If not, see .
+-->
-
+
+