mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-27 19:35:10 +01:00
Android 13: use on back invoked
This commit is contained in:
@@ -38,7 +38,6 @@ import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@@ -56,6 +55,7 @@ import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
@@ -490,16 +490,10 @@ public class FragmentAccount extends FragmentBase {
|
||||
}
|
||||
});
|
||||
|
||||
addKeyPressedListener(new ActivityBase.IKeyPressedListener() {
|
||||
getActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public boolean onKeyPressed(KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
public void handleOnBackPressed() {
|
||||
onSave(true);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1383,9 +1377,9 @@ public class FragmentAccount extends FragmentBase {
|
||||
if (context != null)
|
||||
WidgetUnified.updateData(context); // Update color stripe
|
||||
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
getParentFragmentManager().popBackStack();
|
||||
finish();
|
||||
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
boolean saved = args.getBoolean("saved");
|
||||
if (saved && cbIdentity.isChecked()) {
|
||||
Bundle aargs = new Bundle();
|
||||
@@ -1689,7 +1683,8 @@ public class FragmentAccount extends FragmentBase {
|
||||
|
||||
fragment.setArguments(aargs);
|
||||
|
||||
getParentFragmentManager().popBackStack();
|
||||
finish();
|
||||
|
||||
FragmentTransaction fragmentTransaction = getParentFragmentManager().beginTransaction();
|
||||
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("quick");
|
||||
fragmentTransaction.commit();
|
||||
@@ -1826,8 +1821,8 @@ public class FragmentAccount extends FragmentBase {
|
||||
onSave(false);
|
||||
else
|
||||
onCheck();
|
||||
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
getParentFragmentManager().popBackStack();
|
||||
} else
|
||||
finish();
|
||||
break;
|
||||
case REQUEST_DELETE:
|
||||
if (resultCode == RESULT_OK)
|
||||
@@ -1864,8 +1859,7 @@ public class FragmentAccount extends FragmentBase {
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, Void data) {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
getParentFragmentManager().popBackStack();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user