diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7db3439597f..c12c4d0268e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -50,6 +50,24 @@ + + + + + + + + + + + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package org.schabi.newpipe + +import android.os.Bundle +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import coil3.imageLoader +import org.schabi.newpipe.util.InfoCache + +/** + * Invisible activity that clears NewPipe's caches (metadata + image caches) and + * immediately returns to the previous screen. It is used as the target of the + * "Clear cache" long-press shortcut on the app icon, so that users can wipe the + * caches without having to open the app and dig through the settings. + * + * See https://github.com/TeamNewPipe/NewPipe/issues/8981 + */ +class ClearCacheActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + // Metadata cache (video info, streams metadata, ...) + InfoCache.getInstance().clearCache() + + // Image caches (memory + disk) used for all the images loaded by Coil + imageLoader.memoryCache?.clear() + imageLoader.diskCache?.clear() + + Toast.makeText(applicationContext, R.string.clear_cache_complete_notice, Toast.LENGTH_SHORT) + .show() + + // Do not open the app: the user just asked for the cache to be cleared from + // the home screen, so go straight back to whatever was shown before us. + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java b/app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java index 563927e19f4..3243058e27d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java +++ b/app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java @@ -1553,6 +1553,26 @@ public boolean onKeyDown(final int keyCode) { return true; } + // On non-TV devices with a hardware keyboard, arrow keys should seek + // instead of jumping between UI elements or focusing player controls. + // TV devices keep their D-pad navigation behavior. + // See https://github.com/TeamNewPipe/NewPipe/issues/10448 + if (!DeviceUtils.isTv(context)) { + switch (keyCode) { + case KeyEvent.KEYCODE_DPAD_LEFT: + player.fastRewind(); + return true; + case KeyEvent.KEYCODE_DPAD_RIGHT: + player.fastForward(); + return true; + case KeyEvent.KEYCODE_DPAD_CENTER: + player.playPause(); + return true; + default: + break; // UP/DDOWN keep falling through to the UI logic below + } + } + if (isControlsVisible()) { hideControls(DEFAULT_CONTROLS_DURATION, DPAD_CONTROLS_HIDE_TIME); } else { @@ -1562,6 +1582,28 @@ public boolean onKeyDown(final int keyCode) { return true; } break; + case KeyEvent.KEYCODE_SPACE: + case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: + player.playPause(); + return true; + case KeyEvent.KEYCODE_MEDIA_PLAY: + player.play(); + return true; + case KeyEvent.KEYCODE_MEDIA_PAUSE: + player.pause(); + return true; + case KeyEvent.KEYCODE_J: + case KeyEvent.KEYCODE_MEDIA_FAST_REWIND: + player.fastRewind(); + return true; + case KeyEvent.KEYCODE_L: + case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: + player.fastForward(); + return true; + case KeyEvent.KEYCODE_M: + case KeyEvent.KEYCODE_VOLUME_MUTE: + player.toggleMute(); + return true; default: break; // ignore other keys } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d8d1fadee25..4018b643455 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -106,6 +106,9 @@ Wipe cached metadata Remove all cached webpage data Metadata cache wiped + Clear cache + Clear NewPipe cache + Cache cleared Auto-enqueue next stream Continue ending (non-repeating) playback queue by appending a related stream Auto-enqueuing diff --git a/app/src/main/res/xml/shortcuts.xml b/app/src/main/res/xml/shortcuts.xml new file mode 100644 index 00000000000..0c88d68a1bb --- /dev/null +++ b/app/src/main/res/xml/shortcuts.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + \ No newline at end of file