Skip to content

Commit 34d4eae

Browse files
committed
Finish adding documentation to all files
1 parent ae214a0 commit 34d4eae

File tree

15 files changed

+371
-138
lines changed

15 files changed

+371
-138
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ configure<ApplicationExtension> {
5555
System.getProperty("versionNameSuffix")?.let { versionNameSuffix = it }
5656

5757
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
58+
// https://blog.grobox.de/2019/disable-google-android-instrumentation-test-tracking/
5859
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
60+
// https://developer.android.com/studio/test/espresso-api#set_up_your_project_for_the_espresso_device_api
5961
testOptions {
6062
emulatorControl {
6163
enable = true

app/src/androidTest/java/org/schabi/newpipe/ui/components/menu/LongPressMenuEditorTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class LongPressMenuEditorTest {
261261
assertActionEnabledStatus(label = Enqueue.label, expectedEnabled = true)
262262
assertActionEnabledStatus(label = EnqueueNext.label, expectedEnabled = true)
263263
assertActionEnabledStatus(label = R.string.long_press_menu_header, expectedEnabled = true)
264-
closeEditorAndAssertNewSettings(isHeaderEnabled = true, actionArrangement = getDefaultEnabledLongPressActions(ctx))
264+
closeEditorAndAssertNewSettings(isHeaderEnabled = true, actionArrangement = getDefaultLongPressActionArrangement(ctx))
265265
}
266266

267267
@Test

app/src/androidTest/java/org/schabi/newpipe/ui/components/menu/LongPressMenuSettingsTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ class LongPressMenuSettingsTest {
4444
@Test
4545
fun testLoadingActionArrangementUnset() {
4646
clearPrefs()
47-
assertEquals(getDefaultEnabledLongPressActions(ctx), loadLongPressActionArrangementFromSettings(ctx))
47+
assertEquals(getDefaultLongPressActionArrangement(ctx), loadLongPressActionArrangementFromSettings(ctx))
4848
}
4949

5050
@Test
5151
fun testLoadingActionArrangementInvalid() {
5252
putStringInPrefs(R.string.long_press_menu_action_arrangement_key, "0,1,whatever,3")
53-
assertEquals(getDefaultEnabledLongPressActions(ctx), loadLongPressActionArrangementFromSettings(ctx))
53+
assertEquals(getDefaultLongPressActionArrangement(ctx), loadLongPressActionArrangementFromSettings(ctx))
5454
}
5555

5656
@Test
@@ -73,7 +73,7 @@ class LongPressMenuSettingsTest {
7373
fun testDefaultActionsIncludeKodiIffShowKodiEnabled() {
7474
for (enabled in arrayOf(false, true)) {
7575
putBooleanInPrefs(R.string.show_play_with_kodi_key, enabled)
76-
val actions = getDefaultEnabledLongPressActions(ctx)
76+
val actions = getDefaultLongPressActionArrangement(ctx)
7777
assertEquals(enabled, actions.contains(PlayWithKodi))
7878
}
7979
}
@@ -85,7 +85,7 @@ class LongPressMenuSettingsTest {
8585
for (actions in listOf(listOf(Enqueue), listOf(Enqueue, PlayWithKodi))) {
8686
storeLongPressActionArrangementToSettings(ctx, actions)
8787
addOrRemoveKodiLongPressAction(ctx)
88-
val newActions = getDefaultEnabledLongPressActions(ctx)
88+
val newActions = getDefaultLongPressActionArrangement(ctx)
8989
assertEquals(enabled, newActions.contains(PlayWithKodi))
9090
}
9191
}

app/src/androidTest/java/org/schabi/newpipe/ui/components/menu/LongPressMenuTest.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ import androidx.compose.ui.test.isNotDisplayed
2121
import androidx.compose.ui.test.junit4.createAndroidComposeRule
2222
import androidx.compose.ui.test.onAllNodesWithTag
2323
import androidx.compose.ui.test.onFirst
24-
import androidx.compose.ui.test.onNodeWithContentDescription
2524
import androidx.compose.ui.test.onNodeWithTag
2625
import androidx.compose.ui.test.onNodeWithText
2726
import androidx.compose.ui.test.performClick
2827
import androidx.compose.ui.unit.dp
29-
import androidx.test.espresso.Espresso
3028
import androidx.test.espresso.Espresso.onView
3129
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
3230
import androidx.test.espresso.assertion.ViewAssertions.matches
@@ -508,8 +506,8 @@ class LongPressMenuTest {
508506
fun testOnlyAndAllArrangedActionsDisplayed3() {
509507
assertOnlyAndAllArrangedActionsDisplayed(
510508
availableActions = LongPressAction.Type.entries,
511-
actionArrangement = getDefaultEnabledLongPressActions(ctx),
512-
expectedShownActions = getDefaultEnabledLongPressActions(ctx)
509+
actionArrangement = getDefaultLongPressActionArrangement(ctx),
510+
expectedShownActions = getDefaultLongPressActionArrangement(ctx)
513511
)
514512
}
515513

@@ -534,9 +532,9 @@ class LongPressMenuTest {
534532
@Test
535533
fun testOnlyAndAllAvailableActionsDisplayed3() {
536534
assertOnlyAndAllArrangedActionsDisplayed(
537-
availableActions = getDefaultEnabledLongPressActions(ctx),
535+
availableActions = getDefaultLongPressActionArrangement(ctx),
538536
actionArrangement = LongPressAction.Type.entries,
539-
expectedShownActions = getDefaultEnabledLongPressActions(ctx)
537+
expectedShownActions = getDefaultLongPressActionArrangement(ctx)
540538
)
541539
}
542540

app/src/main/java/org/schabi/newpipe/ui/GestureModifiers.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,17 @@ fun Modifier.detectDragGestures(
6767
return@withTimeout false
6868
}
6969
} catch (_: PointerEventTimeoutCancellationException) {
70-
true
70+
true // the timeout fired, so the "press" is indeed "long"
7171
}
7272

7373
val pointerId = down.id
74+
// importantly, tell `beginDragGesture` whether the drag begun with a long press
7475
beginDragGesture(down.position.toIntOffset(), wasLongPressed)
7576
while (true) {
77+
// go through all events of this gesture and feed them to `handleDragGestureChange`
7678
val change = awaitPointerEvent().changes.find { it.id == pointerId }
7779
if (change == null || !change.pressed) {
78-
break
80+
break // the gesture finished
7981
}
8082
handleDragGestureChange(
8183
change.position.toIntOffset(),
@@ -97,7 +99,7 @@ private fun Offset.toIntOffset() = IntOffset(this.x.toInt(), this.y.toInt())
9799
fun Modifier.discardAllTouchesIf(doDiscard: Boolean) = if (doDiscard) {
98100
pointerInput(Unit) {
99101
awaitPointerEventScope {
100-
// we should wait for all new pointer events
102+
// we should wait for all new pointer events and ignore them all
101103
while (true) {
102104
awaitPointerEvent(pass = PointerEventPass.Initial)
103105
.changes

app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenu.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -832,11 +832,7 @@ private fun LongPressMenuPreview(
832832
onDispose {}
833833
}
834834

835-
// the incorrect theme is set when running the preview in an emulator for some reason...
836-
val initialUseDarkTheme = isSystemInDarkTheme()
837-
var useDarkTheme by remember { mutableStateOf(initialUseDarkTheme) }
838-
839-
AppTheme(useDarkTheme = useDarkTheme) {
835+
AppTheme {
840836
Surface(color = MaterialTheme.colorScheme.surfaceContainerLow) {
841837
// longPressable is null when running the preview in an emulator for some reason...
842838
@Suppress("USELESS_ELVIS")

0 commit comments

Comments
 (0)