|
|
@ -22,7 +22,6 @@ package eu.faircode.email;
|
|
|
|
import static android.app.ActionBar.DISPLAY_SHOW_CUSTOM;
|
|
|
|
import static android.app.ActionBar.DISPLAY_SHOW_CUSTOM;
|
|
|
|
import static android.app.Activity.RESULT_OK;
|
|
|
|
import static android.app.Activity.RESULT_OK;
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
|
|
|
|
import android.app.RecoverableSecurityException;
|
|
|
|
import android.app.RecoverableSecurityException;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
@ -37,7 +36,6 @@ import android.net.Uri;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.ResultReceiver;
|
|
|
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.MenuItem;
|
|
|
@ -48,6 +46,7 @@ import android.widget.ScrollView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.activity.OnBackPressedCallback;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
@ -59,6 +58,8 @@ import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.FragmentActivity;
|
|
|
|
import androidx.fragment.app.FragmentActivity;
|
|
|
|
import androidx.fragment.app.FragmentResultListener;
|
|
|
|
import androidx.fragment.app.FragmentResultListener;
|
|
|
|
import androidx.lifecycle.Lifecycle;
|
|
|
|
import androidx.lifecycle.Lifecycle;
|
|
|
|
|
|
|
|
import androidx.lifecycle.LifecycleObserver;
|
|
|
|
|
|
|
|
import androidx.lifecycle.OnLifecycleEvent;
|
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
@ -420,6 +421,23 @@ public class FragmentBase extends Fragment {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void setBackPressedCallback(OnBackPressedCallback backPressedCallback) {
|
|
|
|
|
|
|
|
backPressedCallback.setEnabled(false);
|
|
|
|
|
|
|
|
FragmentActivity activity = getActivity();
|
|
|
|
|
|
|
|
if (activity == null)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
activity.getOnBackPressedDispatcher().addCallback(backPressedCallback);
|
|
|
|
|
|
|
|
getViewLifecycleOwner().getLifecycle().addObserver(new LifecycleObserver() {
|
|
|
|
|
|
|
|
@OnLifecycleEvent(Lifecycle.Event.ON_ANY)
|
|
|
|
|
|
|
|
public void onAny() {
|
|
|
|
|
|
|
|
Lifecycle.State state = getViewLifecycleOwner().getLifecycle().getCurrentState();
|
|
|
|
|
|
|
|
backPressedCallback.setEnabled(state.isAtLeast(Lifecycle.State.STARTED));
|
|
|
|
|
|
|
|
if (state.isAtLeast(Lifecycle.State.DESTROYED))
|
|
|
|
|
|
|
|
backPressedCallback.remove();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isPane() {
|
|
|
|
private boolean isPane() {
|
|
|
|
Bundle args = getArguments();
|
|
|
|
Bundle args = getArguments();
|
|
|
|
return (args != null && args.getBoolean("pane"));
|
|
|
|
return (args != null && args.getBoolean("pane"));
|
|
|
|