summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/com/wireguard/android/activity/MainActivity.java13
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java8
2 files changed, 19 insertions, 2 deletions
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 c43c0023..bfb3be7e 100644
--- a/app/src/main/java/com/wireguard/android/activity/MainActivity.java
+++ b/app/src/main/java/com/wireguard/android/activity/MainActivity.java
@@ -63,8 +63,17 @@ public class MainActivity extends BaseActivity {
@Override
public void onBackPressed() {
- if (!moveToState(State.ofLayer(state.layer - 1)))
- super.onBackPressed();
+ TunnelListFragment fragment = null;
+ try {
+ fragment =
+ ((TunnelListFragment)
+ getSupportFragmentManager().getFragments().get(0));
+ } catch (ClassCastException ignored) {
+ }
+ if (fragment == null || !(fragment.collapseActionMenu())) {
+ if (!moveToState(State.ofLayer(state.layer - 1)))
+ super.onBackPressed();
+ }
}
@Override
diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
index f8a35d89..683a8b6d 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
@@ -193,6 +193,14 @@ public class TunnelListFragment extends BaseFragment {
super.onDestroyView();
}
+ public boolean collapseActionMenu() {
+ if (binding.createMenu.isExpanded()) {
+ binding.createMenu.collapse();
+ return true;
+ }
+ return false;
+ }
+
public void onRequestCreateConfig(@SuppressWarnings("unused") final View view) {
startActivity(new Intent(getActivity(), TunnelCreatorActivity.class));
if (binding != null)