From da4edc8f747615452b08f3341b154c101f8ba06b Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 3 Jul 2020 09:07:21 +0200 Subject: [PATCH] android: fix back button not working (main surface loses focus) fixes #6276 --- contrib/android/Dockerfile | 4 +++- electrum/gui/kivy/main_window.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/contrib/android/Dockerfile b/contrib/android/Dockerfile index 3c19469bb..b68b5de06 100644 --- a/contrib/android/Dockerfile +++ b/contrib/android/Dockerfile @@ -151,6 +151,7 @@ RUN cd /opt \ && cd buildozer \ && git remote add sombernight https://github.com/SomberNight/buildozer \ && git fetch --all \ + # commit: kivy/buildozer "1.2.0" tag && git checkout "94cfcb8d591c11d6ad0e11f129b08c1e27a161c5^{commit}" \ && python3 -m pip install --user -e . @@ -160,7 +161,8 @@ RUN cd /opt \ && cd python-for-android \ && git remote add sombernight https://github.com/SomberNight/python-for-android \ && git fetch --all \ - && git checkout "257cfacbdd523af0b5b6bb5b2ba64ab7a5c82d58^{commit}" \ + # commit: from branch sombernight/electrum_20200703 + && git checkout "0dd2ce87a8f380d20505ca5dc1e2d2357b4a08fc^{commit}" \ && python3 -m pip install --user -e . # build env vars diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py index ae4126eca..a9ee1f1ea 100644 --- a/electrum/gui/kivy/main_window.py +++ b/electrum/gui/kivy/main_window.py @@ -849,6 +849,17 @@ class ElectrumWindow(App): return self.use_change = self.wallet.use_change self.electrum_config.save_last_wallet(wallet) + self.request_focus_for_main_view() + + def request_focus_for_main_view(self): + if platform != 'android': + return + # The main view of the activity might be not have focus + # in which case e.g. the OS "back" button would not work. + # see #6276 (specifically "method 2" and "method 3") + from jnius import autoclass + PythonActivity = autoclass('org.kivy.android.PythonActivity') + PythonActivity.requestFocusForMainView() def update_status(self, *dt): if not self.wallet: