From 3c3de065c61d5f846da76394ebda0e9cd06fd88a Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Tue, 5 Jun 2018 18:33:09 +0530 Subject: MainActivity: collapse action menu on toolbar touch Signed-off-by: Harsh Shandilya --- .../main/java/com/wireguard/android/activity/MainActivity.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/com/wireguard/android/activity/MainActivity.java b/app/src/main/java/com/wireguard/android/activity/MainActivity.java index 2ed1da61..e60fa8cf 100644 --- a/app/src/main/java/com/wireguard/android/activity/MainActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/MainActivity.java @@ -95,6 +95,15 @@ public class MainActivity extends BaseActivity { moveToState(initialState); } updateActionBar(); + final int actionBarId = getResources().getIdentifier("action_bar", "id", getPackageName()); + if (actionBarId != 0 && findViewById(actionBarId) != null) { + findViewById(actionBarId).setOnTouchListener((v, e) -> { + try { + ((TunnelListFragment) getSupportFragmentManager().getFragments().get(0)).collapseActionMenu(); + } catch (final ClassCastException ignored) { } + return false; + }); + } } @Override -- cgit v1.2.3