mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 17:57:16 +00:00
parent
123c72f870
commit
11617bc585
2 changed files with 31 additions and 13 deletions
|
@ -23,13 +23,11 @@ import android.content.Intent;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
|
||||
public class ActivityCompose extends ActivityBilling implements FragmentManager.OnBackStackChangedListener {
|
||||
static final int REQUEST_CONTACT_TO = 1;
|
||||
|
@ -98,17 +96,6 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||
getSupportFragmentManager().popBackStack();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackStackChanged() {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() == 0)
|
||||
|
|
|
@ -87,6 +87,7 @@ import androidx.constraintlayout.widget.Group;
|
|||
import androidx.core.content.ContextCompat;
|
||||
import androidx.cursoradapter.widget.SimpleCursorAdapter;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -253,6 +254,14 @@ public class FragmentCompose extends FragmentEx {
|
|||
}
|
||||
});
|
||||
|
||||
((ActivityBase) getActivity()).addBackPressedListener(new ActivityBase.IBackPressedListener() {
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
handleExit();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
// Initialize
|
||||
|
@ -409,6 +418,9 @@ public class FragmentCompose extends FragmentEx {
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
handleExit();
|
||||
return true;
|
||||
case R.id.menu_bold:
|
||||
case R.id.menu_italic:
|
||||
case R.id.menu_link:
|
||||
|
@ -500,6 +512,25 @@ public class FragmentCompose extends FragmentEx {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleExit() {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setMessage(R.string.title_ask_delete)
|
||||
.setPositiveButton(R.string.title_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
onAction(R.id.action_delete);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.title_no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void handlePickContact(int requestCode, Intent data) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue