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();
|
||||
}
|
||||
|
||||
|
||||
public void onBackPressedFragment() {
|
||||
performBack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUpRecreateTask(Intent targetIntent) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
|
|
|
@ -695,16 +695,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
});
|
||||
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (Helper.isKeyboardVisible(view))
|
||||
Helper.hideKeyboard(view);
|
||||
else
|
||||
onExit();
|
||||
}
|
||||
});
|
||||
getOnBackPressedDispatcher().addCallback(this, backPressedCallback);
|
||||
|
||||
// Initialize
|
||||
|
||||
|
@ -727,6 +718,21 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
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() {
|
||||
Bundle args = new Bundle();
|
||||
|
||||
|
|
|
@ -7414,7 +7414,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
}
|
||||
|
||||
handleExit();
|
||||
finish();
|
||||
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof ActivityBase)
|
||||
((ActivityBase) activity).onBackPressedFragment();
|
||||
else
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue