1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 02:07:12 +00:00

Dismiss undo on opening thread

This commit is contained in:
M66B 2020-07-25 21:28:26 +02:00
parent 2dd695eb18
commit 9878853d20

View file

@ -115,6 +115,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private boolean exit = false; private boolean exit = false;
private boolean searching = false; private boolean searching = false;
private Snackbar lastSnackbar = null;
static final int REQUEST_UNIFIED = 1; static final int REQUEST_UNIFIED = 1;
static final int REQUEST_WHY = 2; static final int REQUEST_WHY = 2;
@ -735,12 +736,14 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
final Snackbar snackbar = Snackbar.make(content, title, Snackbar.LENGTH_INDEFINITE) final Snackbar snackbar = Snackbar.make(content, title, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true); .setGestureInsetBottomIgnored(true);
lastSnackbar = snackbar;
snackbar.setAction(R.string.title_undo, new View.OnClickListener() { snackbar.setAction(R.string.title_undo, new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
snackbar.dismiss(); Log.i("Undo cancel");
snackbar.getView().setTag(true); snackbar.getView().setTag(true);
show.execute(ActivityView.this, args, "undo:show"); snackbar.dismiss();
} }
}); });
@ -757,6 +760,11 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
@Override @Override
public void onDismissed(Snackbar transientBottomBar, int event) { public void onDismissed(Snackbar transientBottomBar, int event) {
if (snackbar.getView().getTag() == null)
move.execute(ActivityView.this, args, "undo:move");
else
show.execute(ActivityView.this, args, "undo:show");
ViewGroup.MarginLayoutParams lparam = (ViewGroup.MarginLayoutParams) content.getLayoutParams(); ViewGroup.MarginLayoutParams lparam = (ViewGroup.MarginLayoutParams) content.getLayoutParams();
lparam.bottomMargin = margin; lparam.bottomMargin = margin;
content.setLayoutParams(lparam); content.setLayoutParams(lparam);
@ -768,16 +776,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
Log.i("Move timeout"); Log.i("Undo timeout");
if (snackbar.getView().getTag() != null)
return;
// Remove snackbar
if (snackbar.isShown()) if (snackbar.isShown())
snackbar.dismiss(); snackbar.dismiss();
move.execute(ActivityView.this, args, "undo:move");
} }
}, undo_timeout); }, undo_timeout);
} }
@ -1298,6 +1299,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private void onViewThread(Intent intent) { private void onViewThread(Intent intent) {
boolean found = intent.getBooleanExtra("found", false); boolean found = intent.getBooleanExtra("found", false);
if (lastSnackbar != null && lastSnackbar.isShown())
lastSnackbar.dismiss();
if (!found && getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) if (!found && getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("thread", FragmentManager.POP_BACK_STACK_INCLUSIVE); getSupportFragmentManager().popBackStack("thread", FragmentManager.POP_BACK_STACK_INCLUSIVE);