-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature|build|fix|chore] Switch to Mpv (#42); fix enclosures won't s…
…how issue; update dependencies * [feature|build] Remove ExoPlayer, use MPV to play videos; update dependencies * [feature|fix] Support player gestures; fix enclosures won't show issue * [feature|chore|build] Improve player control UI; remove unused resources; upgrade AGP
- Loading branch information
Showing
81 changed files
with
2,263 additions
and
6,975 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/src/main/java/com/skyd/anivu/base/BaseComposeActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.skyd.anivu.base | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import com.skyd.anivu.model.preference.SettingsProvider | ||
import com.skyd.anivu.model.preference.appearance.ThemePreference | ||
import com.skyd.anivu.ui.local.LocalDarkMode | ||
import com.skyd.anivu.ui.local.LocalWindowSizeClass | ||
import com.skyd.anivu.ui.theme.AniVuTheme | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
open class BaseComposeActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
enableEdgeToEdge() | ||
super.onCreate(savedInstanceState) | ||
|
||
initTheme() | ||
} | ||
|
||
fun setContentBase(content: @Composable () -> Unit) = setContent { | ||
CompositionLocalProvider( | ||
LocalWindowSizeClass provides calculateWindowSizeClass(this@BaseComposeActivity) | ||
) { | ||
SettingsProvider { AniVuTheme(darkTheme = LocalDarkMode.current, content) } | ||
} | ||
} | ||
|
||
private fun initTheme() { | ||
setTheme(ThemePreference.toResId(this)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.skyd.anivu.ext | ||
|
||
import androidx.compose.runtime.MutableState | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.saveable.Saver | ||
import androidx.compose.ui.geometry.Offset | ||
import androidx.compose.ui.util.packFloats | ||
import androidx.compose.ui.util.unpackFloat1 | ||
import androidx.compose.ui.util.unpackFloat2 | ||
|
||
fun snapshotStateOffsetSaver() = Saver<MutableState<Offset>, Long>( | ||
save = { state -> packFloats(state.value.x, state.value.y) }, | ||
restore = { value -> mutableStateOf(Offset(unpackFloat1(value), unpackFloat2(value))) } | ||
) |
121 changes: 121 additions & 0 deletions
121
app/src/main/java/com/skyd/anivu/ext/PointerInputScopeExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package com.skyd.anivu.ext | ||
|
||
import androidx.compose.foundation.gestures.awaitEachGesture | ||
import androidx.compose.foundation.gestures.awaitFirstDown | ||
import androidx.compose.foundation.gestures.calculateCentroid | ||
import androidx.compose.foundation.gestures.calculateCentroidSize | ||
import androidx.compose.foundation.gestures.calculatePan | ||
import androidx.compose.foundation.gestures.calculateRotation | ||
import androidx.compose.foundation.gestures.calculateZoom | ||
import androidx.compose.ui.geometry.Offset | ||
import androidx.compose.ui.input.pointer.PointerInputChange | ||
import androidx.compose.ui.input.pointer.PointerInputScope | ||
import androidx.compose.ui.input.pointer.positionChanged | ||
import androidx.compose.ui.util.fastAny | ||
import androidx.compose.ui.util.fastForEach | ||
import kotlin.math.PI | ||
import kotlin.math.abs | ||
|
||
|
||
suspend fun PointerInputScope.detectDoubleFingerTransformGestures( | ||
onVerticalDragStart: (Offset) -> Unit = { }, | ||
onVerticalDragEnd: () -> Unit = { }, | ||
onVerticalDragCancel: () -> Unit = { }, | ||
onVerticalDrag: (change: PointerInputChange, dragAmount: Float) -> Unit, | ||
onHorizontalDragStart: (Offset) -> Unit = { }, | ||
onHorizontalDragEnd: () -> Unit = { }, | ||
onHorizontalDragCancel: () -> Unit = { }, | ||
onHorizontalDrag: (change: PointerInputChange, dragAmount: Float) -> Unit, | ||
onGesture: (centroid: Offset, pan: Offset, zoom: Float, rotation: Float) -> Unit, | ||
) { | ||
awaitEachGesture { | ||
var rotation = 0f | ||
var zoom = 1f | ||
var pan = Offset.Zero | ||
var singlePan = Offset.Zero | ||
var pastTouchSlop = false | ||
val touchSlop = viewConfiguration.touchSlop | ||
var lockedToPanZoom = false | ||
|
||
var horizontalDrag = false | ||
var verticalDrag = false | ||
var transformDrag = false | ||
|
||
val firstDown = awaitFirstDown(requireUnconsumed = false) | ||
var canceled: Boolean | ||
|
||
do { | ||
val event = awaitPointerEvent() | ||
canceled = event.changes.fastAny { it.isConsumed } | ||
val count: Int = if (event.changes.size > 2) { | ||
event.changes.takeIf { it.last().id != it.first().id }?.size ?: 1 | ||
} else event.changes.size | ||
|
||
if (!canceled) { | ||
val zoomChange = event.calculateZoom() | ||
val panChange = event.calculatePan() | ||
val rotationChange = event.calculateRotation() | ||
if (!pastTouchSlop) { | ||
if (count == 1) { | ||
singlePan += panChange | ||
val singlePanMotion = singlePan.getDistance() | ||
if (singlePanMotion > touchSlop) { | ||
pastTouchSlop = true | ||
if (abs(singlePan.x) > abs(singlePan.y)) { | ||
horizontalDrag = true | ||
onHorizontalDragStart(firstDown.position) | ||
} else { | ||
verticalDrag = true | ||
onVerticalDragStart(firstDown.position) | ||
} | ||
} | ||
} else if (count > 1) { | ||
zoom *= zoomChange | ||
rotation += rotationChange | ||
pan += panChange | ||
|
||
val centroidSize = event.calculateCentroidSize(useCurrent = false) | ||
val zoomMotion = abs(1 - zoom) * centroidSize | ||
val rotationMotion = abs(rotation * PI.toFloat() * centroidSize / 180f) | ||
val panMotion = pan.getDistance() | ||
|
||
if (zoomMotion > touchSlop || | ||
rotationMotion > touchSlop || | ||
panMotion > touchSlop | ||
) { | ||
transformDrag = true | ||
pastTouchSlop = true | ||
lockedToPanZoom = rotationMotion < touchSlop | ||
} | ||
} | ||
} | ||
if (pastTouchSlop) { | ||
if (horizontalDrag) { | ||
onHorizontalDrag(event.changes.first(), panChange.x) | ||
} else if (verticalDrag) { | ||
onVerticalDrag(event.changes.first(), panChange.y) | ||
} else if (transformDrag) { | ||
val centroid = event.calculateCentroid(useCurrent = false) | ||
val effectiveRotation = if (lockedToPanZoom) 0f else rotationChange | ||
if (effectiveRotation != 0f || | ||
zoomChange != 1f || | ||
panChange != Offset.Zero | ||
) { | ||
onGesture(centroid, panChange, zoomChange, effectiveRotation) | ||
} | ||
} | ||
event.changes.fastForEach { | ||
if (it.positionChanged()) { | ||
it.consume() | ||
} | ||
} | ||
} | ||
} | ||
} while (!canceled && event.changes.fastAny { it.pressed }) | ||
if (horizontalDrag) { | ||
if (canceled) onHorizontalDragCancel() else onHorizontalDragEnd() | ||
} else if (verticalDrag) { | ||
if (canceled) onVerticalDragCancel() else onVerticalDragEnd() | ||
} | ||
} | ||
} |
Oops, something went wrong.