Skip to content

Commit 02c332c

Browse files
committed
refactor: clean up gradle and re-enable spotless configuration
1 parent e66895a commit 02c332c

File tree

1,136 files changed

+16685
-14640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,136 files changed

+16685
-14640
lines changed

.editorconfig

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ ij_kotlin_allow_trailing_comma_on_call_site=true
2020
# Don't allow any wildcard imports
2121
ij_kotlin_packages_to_use_import_on_demand = unset
2222

23+
ktlint_function_naming_ignore_when_annotated_with = Composable
24+
2325
[*.md]
24-
trim_trailing_whitespace = false
26+
trim_trailing_whitespace = false

android-core/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 AniTrend
2+
* Copyright (C) 2019 AniTrend
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by

android-core/src/main/AndroidManifest.xml

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
12
<!--
2-
~ Copyright (C) 2019 AniTrend
3-
~
4-
~ This program is free software: you can redistribute it and/or modify
5-
~ it under the terms of the GNU General Public License as published by
6-
~ the Free Software Foundation, either version 3 of the License, or
7-
~ (at your option) any later version.
8-
~
9-
~ This program is distributed in the hope that it will be useful,
10-
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
~ GNU General Public License for more details.
13-
~
14-
~ You should have received a copy of the GNU General Public License
15-
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
16-
-->
17-
3+
~ Copyright (C) 2019 AniTrend
4+
~
5+
~ This program is free software: you can redistribute it and/or modify
6+
~ it under the terms of the GNU General Public License as published by
7+
~ the Free Software Foundation, either version 3 of the License, or
8+
~ (at your option) any later version.
9+
~
10+
~ This program is distributed in the hope that it will be useful,
11+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
~ GNU General Public License for more details.
14+
~
15+
~ You should have received a copy of the GNU General Public License
16+
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
-->
1818
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
1919

2020
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

android-core/src/main/kotlin/co/anitrend/core/android/Extensions.kt

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 AniTrend
2+
* Copyright (C) 2020 AniTrend
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
*/
17-
1817
package co.anitrend.core.android
1918

2019
import android.view.ViewGroup
@@ -40,7 +39,7 @@ import java.util.Date
4039
*/
4140
inline fun <reified T> koinOf(
4241
qualifier: Qualifier? = null,
43-
noinline parameters: ParametersDefinition? = null
42+
noinline parameters: ParametersDefinition? = null,
4443
): T {
4544
val context = KoinPlatformTools.defaultContext()
4645
val koin = context.get()
@@ -55,7 +54,7 @@ inline fun <reified T> koinOf(
5554
fun AiringSchedule.asPrettyTime(): String {
5655
val prettyTime = koinOf<PrettyTime>()
5756
return prettyTime.format(
58-
Date(airingAt * 1000)
57+
Date(airingAt * 1000),
5958
)
6059
}
6160

@@ -72,15 +71,20 @@ fun Instant.asPrettyTime(): String {
7271
/**
7372
* Displays an error message for missing parameters otherwise runs [block]
7473
*/
75-
inline fun ISupportStateLayout.assureParamNotMissing(param: IParam?, block: () -> Unit) {
74+
inline fun ISupportStateLayout.assureParamNotMissing(
75+
param: IParam?,
76+
block: () -> Unit,
77+
) {
7678
if (param == null) {
7779
this as ViewGroup
78-
loadStateFlow.value = LoadState.Error(
79-
RequestError(
80-
topic = context.getString(R.string.app_controller_heading_missing_param),
81-
description = context.getString(R.string.app_controller_message_missing_param),
80+
loadStateFlow.value =
81+
LoadState.Error(
82+
RequestError(
83+
topic = context.getString(R.string.app_controller_heading_missing_param),
84+
description = context.getString(R.string.app_controller_message_missing_param),
85+
),
8286
)
83-
)
87+
} else {
88+
block()
8489
}
85-
else block()
8690
}

android-core/src/main/kotlin/co/anitrend/core/android/animations/AlphaAnimator.kt

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 AniTrend
2+
* Copyright (C) 2020 AniTrend
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
*/
17-
1817
package co.anitrend.core.android.animations
1918

2019
import android.animation.Animator
@@ -25,18 +24,22 @@ import co.anitrend.arch.theme.animator.contract.AbstractAnimator
2524

2625
class AlphaAnimator(
2726
val from: Float = .85f,
28-
val to: Float = 1f
27+
val to: Float = 1f,
2928
) : AbstractAnimator() {
3029
override val interpolator = LinearInterpolator()
3130

3231
override fun getAnimators(view: View): Array<Animator> {
33-
val animator = ObjectAnimator.ofFloat(
34-
view, PROPERTY_NAME, from, to
35-
)
32+
val animator =
33+
ObjectAnimator.ofFloat(
34+
view,
35+
PROPERTY_NAME,
36+
from,
37+
to,
38+
)
3639
return arrayOf(animator)
3740
}
3841

3942
companion object {
4043
private const val PROPERTY_NAME = "alpha"
4144
}
42-
}
45+
}

android-core/src/main/kotlin/co/anitrend/core/android/animations/AnimationExtensions.kt

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 AniTrend
2+
* Copyright (C) 2020 AniTrend
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -14,22 +14,20 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
*/
17-
1817
package co.anitrend.core.android.animations
1918

2019
import androidx.annotation.ColorInt
2120
import androidx.annotation.FloatRange
2221
import com.google.android.material.animation.ArgbEvaluatorCompat
2322
import kotlin.math.roundToInt
2423

25-
2624
/**
2725
* Linearly interpolate between two values
2826
*/
2927
fun lerp(
3028
startValue: Float,
3129
endValue: Float,
32-
@FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float
30+
@FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float,
3331
): Float {
3432
return startValue + fraction * (endValue - startValue)
3533
}
@@ -40,7 +38,7 @@ fun lerp(
4038
fun lerp(
4139
startValue: Int,
4240
endValue: Int,
43-
@FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float
41+
@FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float,
4442
): Int {
4543
return (startValue + fraction * (endValue - startValue)).roundToInt()
4644
}
@@ -55,10 +53,10 @@ fun lerp(
5553
from = 0.0,
5654
fromInclusive = true,
5755
to = 1.0,
58-
toInclusive = false
56+
toInclusive = false,
5957
) startFraction: Float,
6058
@FloatRange(from = 0.0, fromInclusive = false, to = 1.0, toInclusive = true) endFraction: Float,
61-
@FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float
59+
@FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float,
6260
): Float {
6361
if (fraction < startFraction) return startValue
6462
if (fraction > endFraction) return endValue
@@ -76,10 +74,10 @@ fun lerp(
7674
from = 0.0,
7775
fromInclusive = true,
7876
to = 1.0,
79-
toInclusive = false
77+
toInclusive = false,
8078
) startFraction: Float,
8179
@FloatRange(from = 0.0, fromInclusive = false, to = 1.0, toInclusive = true) endFraction: Float,
82-
@FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float
80+
@FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float,
8381
): Int {
8482
if (fraction < startFraction) return startValue
8583
if (fraction > endFraction) return endValue
@@ -98,18 +96,18 @@ fun lerpArgb(
9896
from = 0.0,
9997
fromInclusive = true,
10098
to = 1.0,
101-
toInclusive = false
99+
toInclusive = false,
102100
) startFraction: Float,
103101
@FloatRange(from = 0.0, fromInclusive = false, to = 1.0, toInclusive = true) endFraction: Float,
104-
@FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float
102+
@FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float,
105103
): Int {
106104
if (fraction < startFraction) return startColor
107105
if (fraction > endFraction) return endColor
108106

109107
return ArgbEvaluatorCompat.getInstance().evaluate(
110108
(fraction - startFraction) / (endFraction - startFraction),
111109
startColor,
112-
endColor
110+
endColor,
113111
)
114112
}
115113

@@ -124,7 +122,7 @@ fun Float.normalize(
124122
inputMin: Float,
125123
inputMax: Float,
126124
outputMin: Float,
127-
outputMax: Float
125+
outputMax: Float,
128126
): Float {
129127
if (this < inputMin) {
130128
return outputMin
@@ -133,5 +131,5 @@ fun Float.normalize(
133131
}
134132

135133
return outputMin * (1 - (this - inputMin) / (inputMax - inputMin)) +
136-
outputMax * ((this - inputMin) / (inputMax - inputMin))
137-
}
134+
outputMax * ((this - inputMin) / (inputMax - inputMin))
135+
}

android-core/src/main/kotlin/co/anitrend/core/android/behaviour/BottomOffsetBehavior.kt

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021 AniTrend
2+
* Copyright (C) 2021 AniTrend
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
*/
17-
1817
package co.anitrend.core.android.behaviour
1918

2019
import android.content.Context
@@ -29,10 +28,9 @@ import co.anitrend.core.android.R
2928
*/
3029
class BottomOffsetBehavior(
3130
private val context: Context,
32-
private val attributeSet: AttributeSet
31+
private val attributeSet: AttributeSet,
3332
) : CoordinatorLayout.Behavior<View>() {
34-
35-
//TODO: Offsets don't seem to be getting applied on the bottom, not entirely sure what could be missing
33+
// TODO: Offsets don't seem to be getting applied on the bottom, not entirely sure what could be missing
3634

3735
private lateinit var viewOffsetHelper: ViewOffsetHelper
3836

@@ -60,33 +58,34 @@ class BottomOffsetBehavior(
6058
override fun onLayoutChild(
6159
parent: CoordinatorLayout,
6260
child: View,
63-
layoutDirection: Int
61+
layoutDirection: Int,
6462
): Boolean {
6563
parent.onLayoutChild(child, layoutDirection)
6664

67-
if (!::viewOffsetHelper.isInitialized)
65+
if (!::viewOffsetHelper.isInitialized) {
6866
viewOffsetHelper = ViewOffsetHelper(child)
67+
}
6968

7069
viewOffsetHelper.doOnInit()
7170
viewOffsetHelper.applyOffsets()
7271

7372
return setBottomOffset(
7473
context.resources.getDimensionPixelSize(
75-
R.dimen.design_bottom_app_bar_height
76-
)
74+
R.dimen.design_bottom_app_bar_height,
75+
),
7776
)
7877
}
7978

8079
private fun setBottomOffset(offset: Int): Boolean {
8180
val offsetHelper = viewOffsetHelper
82-
if (::viewOffsetHelper.isInitialized)
81+
if (::viewOffsetHelper.isInitialized) {
8382
return offsetHelper.setBottomOffset(offset)
83+
}
8484

8585
return false
8686
}
8787

8888
private class ViewOffsetHelper(private val view: View) {
89-
9089
private var layoutBottom = 0
9190
private var offsetBottom = 0
9291

@@ -117,4 +116,4 @@ class BottomOffsetBehavior(
117116
return false
118117
}
119118
}
120-
}
119+
}

android-core/src/main/kotlin/co/anitrend/core/android/binding/IBindingView.kt

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 AniTrend
2+
* Copyright (C) 2020 AniTrend
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
*/
17-
1817
package co.anitrend.core.android.binding
1918

2019
import androidx.viewbinding.ViewBinding
@@ -24,8 +23,7 @@ import androidx.viewbinding.ViewBinding
2423
*
2524
* @property binding The binding property that represents a view
2625
*/
27-
interface IBindingView<B: ViewBinding> {
28-
26+
interface IBindingView<B : ViewBinding> {
2927
var binding: B?
3028

3129
/**
@@ -36,4 +34,4 @@ interface IBindingView<B: ViewBinding> {
3634
*/
3735
@Throws(IllegalArgumentException::class)
3836
fun requireBinding(): B = requireNotNull(binding)
39-
}
37+
}

0 commit comments

Comments
 (0)