mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-03 13:44:40 +00:00
Delegate fragment back to activity
This commit is contained in:
parent
c072793b58
commit
71425ade16
3 changed files with 27 additions and 11 deletions
|
@ -770,6 +770,11 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void onBackPressedFragment() {
|
||||||
|
performBack();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldUpRecreateTask(Intent targetIntent) {
|
public boolean shouldUpRecreateTask(Intent targetIntent) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
|
|
@ -695,16 +695,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
});
|
});
|
||||||
|
|
||||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||||
|
getOnBackPressedDispatcher().addCallback(this, backPressedCallback);
|
||||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
|
||||||
@Override
|
|
||||||
public void handleOnBackPressed() {
|
|
||||||
if (Helper.isKeyboardVisible(view))
|
|
||||||
Helper.hideKeyboard(view);
|
|
||||||
else
|
|
||||||
onExit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
|
|
||||||
|
@ -727,6 +718,21 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
Shortcuts.update(this, this);
|
Shortcuts.update(this, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressedFragment() {
|
||||||
|
backPressedCallback.handleOnBackPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private OnBackPressedCallback backPressedCallback = new OnBackPressedCallback(true) {
|
||||||
|
@Override
|
||||||
|
public void handleOnBackPressed() {
|
||||||
|
if (Helper.isKeyboardVisible(view))
|
||||||
|
Helper.hideKeyboard(view);
|
||||||
|
else
|
||||||
|
onExit();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
|
||||||
|
|
|
@ -7414,7 +7414,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
}
|
}
|
||||||
|
|
||||||
handleExit();
|
handleExit();
|
||||||
finish();
|
|
||||||
|
FragmentActivity activity = getActivity();
|
||||||
|
if (activity instanceof ActivityBase)
|
||||||
|
((ActivityBase) activity).onBackPressedFragment();
|
||||||
|
else
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue