wg: Collapse fab when pressing back before exiting
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
f1fa46829d
commit
f9d68185e2
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user