|
|
@ -2,18 +2,46 @@ package eu.faircode.email;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.fragment.app.DialogFragment;
|
|
|
|
import androidx.fragment.app.DialogFragment;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
|
|
|
|
import androidx.lifecycle.Lifecycle;
|
|
|
|
|
|
|
|
import androidx.lifecycle.LifecycleObserver;
|
|
|
|
|
|
|
|
import androidx.lifecycle.OnLifecycleEvent;
|
|
|
|
|
|
|
|
|
|
|
|
import static android.app.Activity.RESULT_CANCELED;
|
|
|
|
import static android.app.Activity.RESULT_CANCELED;
|
|
|
|
|
|
|
|
|
|
|
|
public class FragmentDialogEx extends DialogFragment {
|
|
|
|
public class FragmentDialogEx extends DialogFragment {
|
|
|
|
private boolean once = false;
|
|
|
|
private boolean once = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
Log.i("Create " + this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onResume() {
|
|
|
|
|
|
|
|
super.onResume();
|
|
|
|
|
|
|
|
Log.i("Resume " + this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onPause() {
|
|
|
|
|
|
|
|
super.onPause();
|
|
|
|
|
|
|
|
Log.i("Pause " + this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onDestroy() {
|
|
|
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
|
|
|
Log.i("Destroy " + this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onStart() {
|
|
|
|
public void onStart() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -40,6 +68,20 @@ public class FragmentDialogEx extends DialogFragment {
|
|
|
|
super.onDismiss(dialog);
|
|
|
|
super.onDismiss(dialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void setTargetFragment(@Nullable Fragment fragment, int requestCode) {
|
|
|
|
|
|
|
|
super.setTargetFragment(fragment, requestCode);
|
|
|
|
|
|
|
|
Log.i("Set target " + this + " " + fragment);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fragment.getViewLifecycleOwner().getLifecycle().addObserver(new LifecycleObserver() {
|
|
|
|
|
|
|
|
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
|
|
|
|
|
|
public void onDestroy() {
|
|
|
|
|
|
|
|
Log.i("Reset target " + FragmentDialogEx.this);
|
|
|
|
|
|
|
|
FragmentDialogEx.super.setTargetFragment(null, requestCode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void sendResult(int result) {
|
|
|
|
protected void sendResult(int result) {
|
|
|
|
if (!once) {
|
|
|
|
if (!once) {
|
|
|
|
once = true;
|
|
|
|
once = true;
|
|
|
|