From 26351e1515551895a448515821ecf6e3f4da88e6 Mon Sep 17 00:00:00 2001 From: Iordan Iordanov Date: Sun, 31 Mar 2024 13:35:52 -0400 Subject: [PATCH] Fix for back button not calling disconnect on Android TV. --- .../java/com/iiordanov/bVNC/RemoteCanvasActivity.java | 5 +++++ .../com/iiordanov/bVNC/input/PointerInputHandler.java | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 bVNC/src/main/java/com/iiordanov/bVNC/input/PointerInputHandler.java diff --git a/bVNC/src/main/java/com/iiordanov/bVNC/RemoteCanvasActivity.java b/bVNC/src/main/java/com/iiordanov/bVNC/RemoteCanvasActivity.java index 8046efb91..976490c69 100644 --- a/bVNC/src/main/java/com/iiordanov/bVNC/RemoteCanvasActivity.java +++ b/bVNC/src/main/java/com/iiordanov/bVNC/RemoteCanvasActivity.java @@ -90,6 +90,7 @@ import com.undatech.opaque.RemoteClientLibConstants; import com.undatech.opaque.dialogs.SelectTextElementFragment; import com.undatech.opaque.util.FileUtils; +import com.undatech.opaque.util.GeneralUtils; import com.undatech.opaque.util.OnTouchViewMover; import com.undatech.opaque.util.RemoteToolbar; import com.undatech.remoteClientUi.R; @@ -1381,6 +1382,7 @@ private void setInputHandler(TouchInputHandler input) { inputListener = new RemoteClientsInputListener( this, remoteConnection, + remoteConnection, touchInputHandler, this::resetOnScreenKeys, connection.getUseDpadAsArrows() @@ -1588,6 +1590,9 @@ private boolean isMasterPasswordEnabled() { @Override public void onBackPressed() { + if (GeneralUtils.isTv(this)) { + disconnectAndFinishActivity(); + } if (inputListener != null) { inputListener.onKey(canvas, KeyEvent.KEYCODE_BACK, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK)); } diff --git a/bVNC/src/main/java/com/iiordanov/bVNC/input/PointerInputHandler.java b/bVNC/src/main/java/com/iiordanov/bVNC/input/PointerInputHandler.java new file mode 100644 index 000000000..ca00e73c0 --- /dev/null +++ b/bVNC/src/main/java/com/iiordanov/bVNC/input/PointerInputHandler.java @@ -0,0 +1,9 @@ +package com.iiordanov.bVNC.input; + +import android.view.KeyEvent; + +public interface PointerInputHandler { + boolean onKeyDownEvent(int keyCode, KeyEvent event); + + boolean onKeyUpEvent(int keyCode, KeyEvent event); +}