Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Jul 5, 2024
1 parent 1451c61 commit 9f5e31d
Show file tree
Hide file tree
Showing 43 changed files with 72 additions and 361 deletions.
4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ dependencies {
implementation("androidx.activity:activity-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.collection:collection-ktx:1.4.0")
implementation("androidx.concurrent:concurrent-futures-ktx:1.1.0")
implementation("androidx.concurrent:concurrent-futures-ktx:1.2.0")
implementation("androidx.constraintlayout:constraintlayout:2.2.0-alpha13")
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.core:core-splashscreen:1.0.1")
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
android:enableOnBackInvokedCallback="false"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Gramophone"
android:windowSoftInputMode="adjustResize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public class CustomSmoothScroller extends RecyclerView.SmoothScroller {
// scrolling slows down and reschedule another interim target scroll
private static final float TARGET_SEEK_EXTRA_SCROLL_RATIO = 1.2f;
private final DisplayMetrics mDisplayMetrics;
protected LinearInterpolator mLinearInterpolator = new LinearInterpolator();
protected TimeInterpolator mDecelerateInterpolator =
protected final LinearInterpolator mLinearInterpolator = new LinearInterpolator();
protected final TimeInterpolator mDecelerateInterpolator =
new PathInterpolator(0.4f, 0.2f, 0f, 1f);
@SuppressLint("UnknownNullness") // b/240775049: Cannot annotate properly
protected PointF mTargetVector;
Expand All @@ -102,6 +102,7 @@ protected void onStart() {

/**
* {@inheritDoc}
* @noinspection NullableProblems
*/
@Override
@SuppressLint("UnknownNullness") // b/240775049: Cannot annotate properly
Expand All @@ -124,6 +125,7 @@ protected void afterTargetFound() {

/**
* {@inheritDoc}
* @noinspection NullableProblems
*/
@Override
@SuppressLint("UnknownNullness") // b/240775049: Cannot annotate properly
Expand All @@ -135,7 +137,6 @@ protected void onSeekTargetStep(int dx, int dy, RecyclerView.State state, Action
stop();
return;
}
//noinspection PointlessBooleanExpression
if (DEBUG && mTargetVector != null
&& (mTargetVector.x * dx < 0 || mTargetVector.y * dy < 0)) {
throw new IllegalStateException("Scroll happened in the opposite direction"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ fun MediaController.getTimer(): Int? =
else null
}

fun MediaController.hasTimer(): Boolean = getTimer() != null
fun MediaController.setTimer(value: Int) {
sendCustomCommand(
SessionCommand(SERVICE_SET_TIMER, Bundle.EMPTY).apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import androidx.media3.session.MediaSession
import androidx.media3.session.MediaSession.MediaItemsWithStartPosition
import androidx.media3.session.MediaSessionService
import androidx.media3.session.SessionCommand
import androidx.media3.session.SessionError
import androidx.media3.session.SessionResult
import androidx.preference.PreferenceManager
import coil3.BitmapImage
Expand Down Expand Up @@ -482,7 +483,7 @@ class GramophonePlaybackService : MediaLibraryService(), MediaSessionService.Lis
}

else -> {
SessionResult(SessionResult.RESULT_ERROR_BAD_VALUE)
SessionResult(SessionError.ERROR_BAD_VALUE)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ object CalculationUtils {
return color and 0x00ffffff or (alpha shl 24)
}

private fun constrain(amount: Float, low: Float, high: Float): Float {
return if (amount < low) low else amount.coerceAtMost(high)
}

@Suppress("NOTHING_TO_INLINE")
inline fun lerp(start: Float, stop: Float, amount: Float): Float {
return start + (stop - start) * amount
Expand All @@ -92,7 +88,7 @@ object CalculationUtils {

/** Returns the single argument constrained between [0.0, 1.0]. */
private fun saturate(value: Float): Float {
return constrain(value, 0.0f, 1.0f)
return value.coerceAtLeast(0f).coerceAtMost(1f)
}

/** Returns the saturated (constrained between [0, 1]) result of [.lerpInv]. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import androidx.lifecycle.LifecycleOwner
import coil3.request.Disposable

interface LifecycleCallbackList<T> {
fun addCallbackForever(callback: T) {
addCallback(null, callback)
}
fun addCallback(lifecycle: Lifecycle?, callback: T)
fun removeCallback(callback: T)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,11 @@ object LrcUtils {
}

// read as single line *IF* this is a single line lyric
if (nextSync == "[$firstSync]") {
lyricLine = line.substring(sequence.last().range.last + 1)
lyricLine = if (nextSync == "[$firstSync]") {
line.substring(sequence.last().range.last + 1)
.let { if (trim) it.trim() else it }
}
else {
lyricLine = lrcContent.substring(startIndex + 1, endIndex)
} else {
lrcContent.substring(startIndex + 1, endIndex)
.let { if (trim) it.trim() else it }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import java.lang.reflect.Constructor
import java.lang.reflect.InvocationTargetException
import java.util.concurrent.atomic.AtomicBoolean

@Suppress("unused")
@OptIn(UnstableApi::class)
class GramophoneExtractorsFactory : ExtractorsFactory {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.google.common.primitives.Ints
import java.io.IOException

@OptIn(UnstableApi::class)
@Suppress("unused")
class GramophoneMediaSourceFactory(
private var dataSourceFactory: DataSource.Factory,
extractorsFactory: ExtractorsFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ abstract class BaseAdapter<T>(
override val concatAdapter by lazy { ConcatAdapter(decorAdapter, this) }
override val itemHeightHelper by lazy {
DefaultItemHeightHelper.concatItemHeightHelper(decorAdapter, {1}, this) }
protected val handler = Handler(Looper.getMainLooper())
private val handler = Handler(Looper.getMainLooper())
private var bgHandlerThread: HandlerThread? = null
private var bgHandler: Handler? = null
private val rawList = ArrayList<T>(liveData?.value?.size ?: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ import androidx.core.view.WindowInsetsCompat
import androidx.media3.common.C
import androidx.media3.common.MediaItem
import androidx.media3.common.Player
import androidx.media3.common.util.UnstableApi
import androidx.media3.session.MediaController
import androidx.media3.session.SessionError
import androidx.media3.session.SessionResult
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.ItemTouchHelper
Expand Down Expand Up @@ -98,13 +100,14 @@ import java.util.LinkedList
import kotlin.math.min

@SuppressLint("NotifyDataSetChanged")
class FullBottomSheet(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) :
@androidx.annotation.OptIn(UnstableApi::class)
class FullBottomSheet
(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) :
ConstraintLayout(context, attrs, defStyleAttr, defStyleRes), Player.Listener,
SharedPreferences.OnSharedPreferenceChangeListener {
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
this(context, attrs, defStyleAttr, 0)
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
constructor(context: Context) : this(context, null)

private val activity
get() = context as MainActivity
Expand Down Expand Up @@ -286,7 +289,7 @@ class FullBottomSheet(context: Context, attrs: AttributeSet?, defStyleAttr: Int,
}

else -> {
return@addCallback Futures.immediateFuture(SessionResult(SessionResult.RESULT_ERROR_NOT_SUPPORTED))
return@addCallback Futures.immediateFuture(SessionResult(SessionError.ERROR_NOT_SUPPORTED))
}
}
return@addCallback Futures.immediateFuture(SessionResult(SessionResult.RESULT_SUCCESS))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("SameReturnValue")

package org.akanework.gramophone.ui.components

import android.content.res.ColorStateList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ class GeneralSubFragment : BaseFragment(true) {
itemList,
true,
helper,
true,
true
ownsView = true,
isSubFragment = true
)

recyclerView.enableEdgeToEdgePaddingListener()
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/drawable/ic_alarm_off.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
xmlns:tools="http://schemas.android.com/tools"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorOnSurface"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M798,690L738,630Q749,603 754.5,577.5Q760,552 760,524Q760,408 678,324Q596,240 480,240Q452,240 426,244.5Q400,249 374,260L314,200Q352,180 393.5,170Q435,160 480,160Q554,160 619.5,188Q685,216 734,265.5Q783,315 811.5,381Q840,447 840,524Q840,569 829,610.5Q818,652 798,690ZM850,320L680,150L736,94L906,264L850,320ZM820,936L694,810Q649,843 594.5,861.5Q540,880 480,880Q406,880 340.5,852Q275,824 226,776Q177,728 148.5,663Q120,598 120,524Q120,462 138.5,407.5Q157,353 192,308L158,274L110,322L54,266L102,218L28,144L84,88L876,880L820,936ZM480,801Q522,801 562,788Q602,775 636,752L248,366Q225,401 212.5,441.5Q200,482 200,524Q200,640 282,720.5Q364,801 480,801ZM442,559Q442,559 442,559Q442,559 442,559Q442,559 442,559Q442,559 442,559L442,559Q442,559 442,559Q442,559 442,559ZM556,445L556,445Q556,445 556,445Q556,445 556,445Q556,445 556,445Q556,445 556,445Q556,445 556,445Q556,445 556,445Z" />
android:pathData="M798,690L738,630Q749,603 754.5,577.5Q760,552 760,524Q760,408 678,324Q596,240 480,240Q452,240 426,244.5Q400,249 374,260L314,200Q352,180 393.5,170Q435,160 480,160Q554,160 619.5,188Q685,216 734,265.5Q783,315 811.5,381Q840,447 840,524Q840,569 829,610.5Q818,652 798,690ZM850,320L680,150L736,94L906,264L850,320ZM820,936L694,810Q649,843 594.5,861.5Q540,880 480,880Q406,880 340.5,852Q275,824 226,776Q177,728 148.5,663Q120,598 120,524Q120,462 138.5,407.5Q157,353 192,308L158,274L110,322L54,266L102,218L28,144L84,88L876,880L820,936ZM480,801Q522,801 562,788Q602,775 636,752L248,366Q225,401 212.5,441.5Q200,482 200,524Q200,640 282,720.5Q364,801 480,801ZM442,559Q442,559 442,559Q442,559 442,559Q442,559 442,559Q442,559 442,559L442,559Q442,559 442,559Q442,559 442,559ZM556,445L556,445Q556,445 556,445Q556,445 556,445Q556,445 556,445Q556,445 556,445Q556,445 556,445Q556,445 556,445Z"
tools:ignore="VectorPath" />
</vector>
6 changes: 4 additions & 2 deletions app/src/main/res/drawable/ic_draw_abstract.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
xmlns:tools="http://schemas.android.com/tools"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorOnSurface"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M120,840Q112,840 104.5,836.5Q97,833 92,828Q80,817 80,800.5Q80,784 91,772Q110,752 136.5,748Q163,744 190,749Q198,751 205,753Q212,755 217,750Q223,744 221.5,735Q220,726 218,718Q214,691 217,664.5Q220,638 239,618Q258,598 284.5,594Q311,590 338,595Q346,597 353.5,599Q361,601 366,596Q372,590 370,581Q368,572 366,564Q362,537 365,510.5Q368,484 387,464Q406,444 432.5,440Q459,436 486,441Q494,443 501.5,445Q509,447 514,442Q520,436 518,427Q516,418 514,410Q510,383 513.5,356.5Q517,330 536,310Q555,290 581.5,286Q608,282 635,287Q643,289 650.5,291Q658,293 663,288Q669,282 667,273Q665,264 663,256Q659,229 662.5,202.5Q666,176 685,156Q704,136 730.5,132Q757,128 784,133Q792,135 799.5,136.5Q807,138 812,133Q823,121 839.5,121Q856,121 868,132Q880,143 880,159.5Q880,176 869,188Q850,208 823.5,212.5Q797,217 770,212Q762,210 754.5,208Q747,206 742,211Q736,217 738,226Q740,235 742,243Q746,270 742.5,296.5Q739,323 720,343Q701,363 674.5,367Q648,371 621,366Q613,364 606,362Q599,360 594,365Q588,371 589.5,380Q591,389 593,397Q597,424 594,450.5Q591,477 572,497Q553,516 526.5,520.5Q500,525 473,520Q465,518 458,516.5Q451,515 446,520Q440,526 441.5,534.5Q443,543 445,551Q449,578 446,604.5Q443,631 424,651Q405,671 378,675Q351,679 324,674Q316,672 309,670.5Q302,669 297,674Q291,680 293,688.5Q295,697 297,705Q301,732 297.5,758.5Q294,785 275,805Q256,825 229.5,829Q203,833 176,828Q168,826 161,824.5Q154,823 149,828Q143,834 135.5,837Q128,840 120,840ZM240,440Q157,440 98.5,381.5Q40,323 40,240Q40,156 98.5,98Q157,40 240,40Q324,40 382,98Q440,156 440,240Q440,323 382,381.5Q324,440 240,440ZM240,360Q291,360 325.5,325Q360,290 360,240Q360,189 325.5,154.5Q291,120 240,120Q190,120 155,154.5Q120,189 120,240Q120,290 155,325Q190,360 240,360ZM640,920Q607,920 583.5,896.5Q560,873 560,840L560,640Q560,607 583.5,583.5Q607,560 640,560L840,560Q873,560 896.5,583.5Q920,607 920,640L920,840Q920,873 896.5,896.5Q873,920 840,920L640,920ZM640,840L840,840Q840,840 840,840Q840,840 840,840L840,640Q840,640 840,640Q840,640 840,640L640,640Q640,640 640,640Q640,640 640,640L640,840Q640,840 640,840Q640,840 640,840ZM740,740L740,740Q740,740 740,740Q740,740 740,740L740,740Q740,740 740,740Q740,740 740,740L740,740Q740,740 740,740Q740,740 740,740L740,740Q740,740 740,740Q740,740 740,740ZM240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Z" />
android:pathData="M120,840Q112,840 104.5,836.5Q97,833 92,828Q80,817 80,800.5Q80,784 91,772Q110,752 136.5,748Q163,744 190,749Q198,751 205,753Q212,755 217,750Q223,744 221.5,735Q220,726 218,718Q214,691 217,664.5Q220,638 239,618Q258,598 284.5,594Q311,590 338,595Q346,597 353.5,599Q361,601 366,596Q372,590 370,581Q368,572 366,564Q362,537 365,510.5Q368,484 387,464Q406,444 432.5,440Q459,436 486,441Q494,443 501.5,445Q509,447 514,442Q520,436 518,427Q516,418 514,410Q510,383 513.5,356.5Q517,330 536,310Q555,290 581.5,286Q608,282 635,287Q643,289 650.5,291Q658,293 663,288Q669,282 667,273Q665,264 663,256Q659,229 662.5,202.5Q666,176 685,156Q704,136 730.5,132Q757,128 784,133Q792,135 799.5,136.5Q807,138 812,133Q823,121 839.5,121Q856,121 868,132Q880,143 880,159.5Q880,176 869,188Q850,208 823.5,212.5Q797,217 770,212Q762,210 754.5,208Q747,206 742,211Q736,217 738,226Q740,235 742,243Q746,270 742.5,296.5Q739,323 720,343Q701,363 674.5,367Q648,371 621,366Q613,364 606,362Q599,360 594,365Q588,371 589.5,380Q591,389 593,397Q597,424 594,450.5Q591,477 572,497Q553,516 526.5,520.5Q500,525 473,520Q465,518 458,516.5Q451,515 446,520Q440,526 441.5,534.5Q443,543 445,551Q449,578 446,604.5Q443,631 424,651Q405,671 378,675Q351,679 324,674Q316,672 309,670.5Q302,669 297,674Q291,680 293,688.5Q295,697 297,705Q301,732 297.5,758.5Q294,785 275,805Q256,825 229.5,829Q203,833 176,828Q168,826 161,824.5Q154,823 149,828Q143,834 135.5,837Q128,840 120,840ZM240,440Q157,440 98.5,381.5Q40,323 40,240Q40,156 98.5,98Q157,40 240,40Q324,40 382,98Q440,156 440,240Q440,323 382,381.5Q324,440 240,440ZM240,360Q291,360 325.5,325Q360,290 360,240Q360,189 325.5,154.5Q291,120 240,120Q190,120 155,154.5Q120,189 120,240Q120,290 155,325Q190,360 240,360ZM640,920Q607,920 583.5,896.5Q560,873 560,840L560,640Q560,607 583.5,583.5Q607,560 640,560L840,560Q873,560 896.5,583.5Q920,607 920,640L920,840Q920,873 896.5,896.5Q873,920 840,920L640,920ZM640,840L840,840Q840,840 840,840Q840,840 840,840L840,640Q840,640 840,640Q840,640 840,640L640,640Q640,640 640,640Q640,640 640,640L640,840Q640,840 640,840Q640,840 640,840ZM740,740L740,740Q740,740 740,740Q740,740 740,740L740,740Q740,740 740,740Q740,740 740,740L740,740Q740,740 740,740Q740,740 740,740L740,740Q740,740 740,740Q740,740 740,740ZM240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Q240,240 240,240Z"
tools:ignore="VectorPath" />
</vector>
6 changes: 4 additions & 2 deletions app/src/main/res/drawable/ic_favorite.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
xmlns:tools="http://schemas.android.com/tools"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorOnSurface"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M480,840L422,788Q321,697 255,631Q189,565 150,512.5Q111,460 95.5,416Q80,372 80,326Q80,232 143,169Q206,106 300,106Q352,106 399,128Q446,150 480,190Q514,150 561,128Q608,106 660,106Q754,106 817,169Q880,232 880,326Q880,372 864.5,416Q849,460 810,512.5Q771,565 705,631Q639,697 538,788L480,840ZM480,732Q576,646 638,584.5Q700,523 736,477.5Q772,432 786,396.5Q800,361 800,326Q800,266 760,226Q720,186 660,186Q613,186 573,212.5Q533,239 518,280L518,280L442,280L442,280Q427,239 387,212.5Q347,186 300,186Q240,186 200,226Q160,266 160,326Q160,361 174,396.5Q188,432 224,477.5Q260,523 322,584.5Q384,646 480,732ZM480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459L480,459L480,459L480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Z" />
android:pathData="M480,840L422,788Q321,697 255,631Q189,565 150,512.5Q111,460 95.5,416Q80,372 80,326Q80,232 143,169Q206,106 300,106Q352,106 399,128Q446,150 480,190Q514,150 561,128Q608,106 660,106Q754,106 817,169Q880,232 880,326Q880,372 864.5,416Q849,460 810,512.5Q771,565 705,631Q639,697 538,788L480,840ZM480,732Q576,646 638,584.5Q700,523 736,477.5Q772,432 786,396.5Q800,361 800,326Q800,266 760,226Q720,186 660,186Q613,186 573,212.5Q533,239 518,280L518,280L442,280L442,280Q427,239 387,212.5Q347,186 300,186Q240,186 200,226Q160,266 160,326Q160,361 174,396.5Q188,432 224,477.5Q260,523 322,584.5Q384,646 480,732ZM480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459L480,459L480,459L480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Q480,459 480,459Z"
tools:ignore="VectorPath" />
</vector>
Loading

0 comments on commit 9f5e31d

Please sign in to comment.