Skip to content

Commit 83748c2

Browse files
committed
FocusOverlayView: Avoid accessing restricted API
Signed-off-by: Aayush Gupta <[email protected]>
1 parent e0e86b7 commit 83748c2

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

app/src/main/java/org/schabi/newpipe/views/FocusOverlayView.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import androidx.annotation.NonNull;
4141
import androidx.annotation.Nullable;
4242
import androidx.annotation.RequiresApi;
43-
import androidx.appcompat.view.WindowCallbackWrapper;
4443

4544
import org.schabi.newpipe.R;
4645

@@ -232,7 +231,7 @@ private static void setupOverlay(final Window window, final FocusOverlayView ove
232231
// Unfortunately many such forms of "scrolling" do not count as scrolling for purpose
233232
// of dispatching ViewTreeObserver callbacks, so we have to intercept them by directly
234233
// receiving keys from Window.
235-
window.setCallback(new WindowCallbackWrapper(window.getCallback()) {
234+
window.setCallback(new SimpleWindowCallback(window.getCallback()) {
236235
@Override
237236
public boolean dispatchKeyEvent(final KeyEvent event) {
238237
final boolean res = super.dispatchKeyEvent(event);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*/
5+
6+
package org.schabi.newpipe.views
7+
8+
import android.os.Build
9+
import android.view.KeyEvent
10+
import android.view.KeyboardShortcutGroup
11+
import android.view.Menu
12+
import android.view.Window
13+
import androidx.annotation.RequiresApi
14+
15+
open class SimpleWindowCallback(private val baseCallback: Window.Callback) :
16+
Window.Callback by baseCallback {
17+
18+
override fun dispatchKeyEvent(event: KeyEvent?): Boolean {
19+
return baseCallback.dispatchKeyEvent(event)
20+
}
21+
22+
@RequiresApi(Build.VERSION_CODES.O)
23+
override fun onPointerCaptureChanged(hasCapture: Boolean) {
24+
baseCallback.onPointerCaptureChanged(hasCapture)
25+
}
26+
27+
@RequiresApi(Build.VERSION_CODES.N)
28+
override fun onProvideKeyboardShortcuts(
29+
data: List<KeyboardShortcutGroup?>?,
30+
menu: Menu?,
31+
deviceId: Int
32+
) {
33+
baseCallback.onProvideKeyboardShortcuts(data, menu, deviceId)
34+
}
35+
}

0 commit comments

Comments
 (0)