From a128356fc40f2486229e85a3784aac2d826e586a Mon Sep 17 00:00:00 2001 From: GG Bond Date: Mon, 27 Nov 2023 22:13:48 +0800 Subject: [PATCH] Cleanup unused --- .../com/hippo/ehviewer/util/AnimationUtils.kt | 25 ---------- .../com/hippo/ehviewer/util/LayoutUtils.kt | 25 ---------- .../hippo/ehviewer/util/ParcelableCompat.kt | 3 -- .../com/hippo/ehviewer/util/RangeSets.kt | 40 ---------------- .../ehviewer/util/SimpleAnimatorListener.kt | 25 ---------- .../hippo/ehviewer/util/WindowInsetsUtil.kt | 47 ------------------- .../main/kotlin/rikka/core/res/Resources.kt | 8 ---- 7 files changed, 173 deletions(-) delete mode 100644 app/src/main/kotlin/com/hippo/ehviewer/util/AnimationUtils.kt delete mode 100644 app/src/main/kotlin/com/hippo/ehviewer/util/LayoutUtils.kt delete mode 100644 app/src/main/kotlin/com/hippo/ehviewer/util/SimpleAnimatorListener.kt delete mode 100644 app/src/main/kotlin/com/hippo/ehviewer/util/WindowInsetsUtil.kt diff --git a/app/src/main/kotlin/com/hippo/ehviewer/util/AnimationUtils.kt b/app/src/main/kotlin/com/hippo/ehviewer/util/AnimationUtils.kt deleted file mode 100644 index 7983ff8e4..000000000 --- a/app/src/main/kotlin/com/hippo/ehviewer/util/AnimationUtils.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2016 Hippo Seven - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.hippo.ehviewer.util - -import android.view.animation.Interpolator -import androidx.interpolator.view.animation.FastOutLinearInInterpolator -import androidx.interpolator.view.animation.LinearOutSlowInInterpolator - -object AnimationUtils { - val FAST_SLOW_INTERPOLATOR: Interpolator = LinearOutSlowInInterpolator() - val SLOW_FAST_INTERPOLATOR: Interpolator = FastOutLinearInInterpolator() -} diff --git a/app/src/main/kotlin/com/hippo/ehviewer/util/LayoutUtils.kt b/app/src/main/kotlin/com/hippo/ehviewer/util/LayoutUtils.kt deleted file mode 100644 index 4556c94d9..000000000 --- a/app/src/main/kotlin/com/hippo/ehviewer/util/LayoutUtils.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2015 Hippo Seven - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.hippo.ehviewer.util - -import android.content.Context -import android.util.TypedValue.COMPLEX_UNIT_DIP -import android.util.TypedValue.applyDimension -import kotlin.math.roundToInt - -fun dp2px(context: Context, dp: Float): Int { - return applyDimension(COMPLEX_UNIT_DIP, dp, context.resources.displayMetrics).roundToInt() -} diff --git a/app/src/main/kotlin/com/hippo/ehviewer/util/ParcelableCompat.kt b/app/src/main/kotlin/com/hippo/ehviewer/util/ParcelableCompat.kt index bd802850c..aa1d3c076 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/util/ParcelableCompat.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/util/ParcelableCompat.kt @@ -3,11 +3,8 @@ package com.hippo.ehviewer.util import android.content.Intent import android.os.Bundle import android.os.Parcelable -import android.util.SparseArray import androidx.core.content.IntentCompat import androidx.core.os.BundleCompat inline fun Bundle.getParcelableCompat(key: String?): T? = BundleCompat.getParcelable(this, key, T::class.java) -inline fun Bundle.getParcelableArrayListCompat(key: String?): ArrayList? = BundleCompat.getParcelableArrayList(this, key, T::class.java) -inline fun Bundle.getSparseParcelableArrayCompat(key: String?): SparseArray? = BundleCompat.getSparseParcelableArray(this, key, T::class.java) inline fun Intent.getParcelableExtraCompat(key: String?): T? = IntentCompat.getParcelableExtra(this, key, T::class.java) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/util/RangeSets.kt b/app/src/main/kotlin/com/hippo/ehviewer/util/RangeSets.kt index 7d9678281..187f22892 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/util/RangeSets.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/util/RangeSets.kt @@ -45,43 +45,3 @@ class IntRangeSet : RangeSet { } fun List.toRangeSet() = IntRangeSet(this) - -class LongRangeSet : RangeSet { - - constructor() : super() - - constructor(ranges: List) : super(ranges) - - constructor(vararg ranges: LongRange) : this(ranges.asList()) - - private constructor(rangeSet: LongRangeSet) : super(rangeSet) - - override fun createRange(start: Long, endInclusive: Long): LongRange = - LongRange(start, endInclusive) - - override fun incrementValue(value: Long): Long = value + 1 - - override fun decrementValue(value: Long): Long = value - 1 - - override fun clone(): RangeSet = LongRangeSet(this) -} - -class CharRangeSet : RangeSet { - - constructor() : super() - - constructor(ranges: List) : super(ranges) - - constructor(vararg ranges: CharRange) : this(ranges.asList()) - - private constructor(rangeSet: CharRangeSet) : super(rangeSet) - - override fun createRange(start: Char, endInclusive: Char): CharRange = - CharRange(start, endInclusive) - - override fun incrementValue(value: Char): Char = value + 1 - - override fun decrementValue(value: Char): Char = value - 1 - - override fun clone(): RangeSet = CharRangeSet(this) -} diff --git a/app/src/main/kotlin/com/hippo/ehviewer/util/SimpleAnimatorListener.kt b/app/src/main/kotlin/com/hippo/ehviewer/util/SimpleAnimatorListener.kt deleted file mode 100644 index 35d25f3f4..000000000 --- a/app/src/main/kotlin/com/hippo/ehviewer/util/SimpleAnimatorListener.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2016 Hippo Seven - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.hippo.ehviewer.util - -import android.animation.Animator - -abstract class SimpleAnimatorListener : Animator.AnimatorListener { - override fun onAnimationStart(animation: Animator) {} - override fun onAnimationEnd(animation: Animator) {} - override fun onAnimationCancel(animation: Animator) {} - override fun onAnimationRepeat(animation: Animator) {} -} diff --git a/app/src/main/kotlin/com/hippo/ehviewer/util/WindowInsetsUtil.kt b/app/src/main/kotlin/com/hippo/ehviewer/util/WindowInsetsUtil.kt deleted file mode 100644 index 2b96b506f..000000000 --- a/app/src/main/kotlin/com/hippo/ehviewer/util/WindowInsetsUtil.kt +++ /dev/null @@ -1,47 +0,0 @@ -package com.hippo.ehviewer.util - -import android.graphics.Rect -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.runtime.Composable -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.platform.LocalLayoutDirection -import androidx.core.graphics.Insets -import androidx.core.view.WindowInsetsCompat -import kotlin.contracts.InvocationKind -import kotlin.contracts.contract - -inline fun buildWindowInsets(builderAction: WindowInsetsCompat.Builder.() -> Unit): WindowInsetsCompat { - contract { callsInPlace(builderAction, InvocationKind.EXACTLY_ONCE) } - val builder = if (isAtLeastQ) { - WindowInsetsCompat.Builder() - } else { - // TODO: Report to google issue tracker - // On API 20-28, WindowInsetsCompat.Builder() will copy the WindowInsets.CONSUMED static field, - // which isConsumed() returns true, resulting in the insets not being dispatched - runCatching { - val constructor = android.view.WindowInsets::class.java.getConstructor(Rect::class.java) - val platformInsets = constructor.newInstance(Rect()) - WindowInsetsCompat.Builder(WindowInsetsCompat.toWindowInsetsCompat(platformInsets)) - }.getOrElse { - it.printStackTrace() - WindowInsetsCompat.Builder() - } - } - builder.builderAction() - return builder.build() -} - -@Composable -fun WindowInsetsCompat.Builder.set(type: Int, insets: WindowInsets): WindowInsetsCompat.Builder { - val density = LocalDensity.current - val layoutDirection = LocalLayoutDirection.current - return setInsets( - type, - Insets.of( - insets.getLeft(density, layoutDirection), - insets.getTop(density), - insets.getRight(density, layoutDirection), - insets.getBottom(density), - ), - ) -} diff --git a/app/src/main/kotlin/rikka/core/res/Resources.kt b/app/src/main/kotlin/rikka/core/res/Resources.kt index 3558d35c1..27e839d29 100644 --- a/app/src/main/kotlin/rikka/core/res/Resources.kt +++ b/app/src/main/kotlin/rikka/core/res/Resources.kt @@ -1,7 +1,6 @@ package rikka.core.res import android.content.res.Resources -import android.graphics.drawable.Drawable import androidx.annotation.AttrRes import androidx.annotation.ColorInt @@ -12,10 +11,3 @@ fun Resources.Theme.resolveColor(@AttrRes attrId: Int): Int { a.recycle() return res } - -fun Resources.Theme.resolveDrawable(@AttrRes attrId: Int): Drawable? { - val a = obtainStyledAttributes(intArrayOf(attrId)) - val res = a.getDrawable(0) - a.recycle() - return res -}