summaryrefslogtreecommitdiffhomepage
path: root/app/src
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2018-04-27 23:50:11 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2018-04-30 17:33:24 +0530
commitf9d68185e2b18d0c589e578d8f73e3a8a3130b95 (patch)
treef1e725266db0750dca8bfc1d73424ccf12a6e7c7 /app/src
parentf1fa46829d10c5159a8b6c6aad97339f9734b42b (diff)
wg: Collapse fab when pressing back before exiting
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src')
-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)