Prevent crash

This commit is contained in:
M66B 2019-05-27 12:15:25 +02:00
parent 7f5d9293a4
commit 709506deb2
9 changed files with 196 additions and 172 deletions

View File

@ -133,7 +133,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
return Helper.sha256(BuildConfig.APPLICATION_ID + getChallenge()); return Helper.sha256(BuildConfig.APPLICATION_ID + getChallenge());
} }
BroadcastReceiver receiver = new BroadcastReceiver() { private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (ACTION_PURCHASE.equals(intent.getAction())) if (ACTION_PURCHASE.equals(intent.getAction()))

View File

@ -19,7 +19,10 @@ package eu.faircode.email;
Copyright 2018-2019 by Marcel Bokhorst (M66B) Copyright 2018-2019 by Marcel Bokhorst (M66B)
*/ */
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.net.MailTo; import android.net.MailTo;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -31,6 +34,7 @@ import androidx.core.app.TaskStackBuilder;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist; import org.jsoup.safety.Whitelist;
@ -52,6 +56,8 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
static final int PI_REPLY = 1; static final int PI_REPLY = 1;
static final String ACTION_SHOW_PRO = BuildConfig.APPLICATION_ID + ".SHOW_PRO";
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -214,4 +220,37 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
return false; return false;
} }
} }
@Override
protected void onResume() {
super.onResume();
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
IntentFilter iff = new IntentFilter();
iff.addAction(ACTION_SHOW_PRO);
lbm.registerReceiver(receiver, iff);
}
@Override
protected void onPause() {
super.onPause();
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
lbm.unregisterReceiver(receiver);
}
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_SHOW_PRO.equals(intent.getAction()))
onShowPro(intent);
}
};
private void onShowPro(Intent intent) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
getSupportFragmentManager().popBackStack("pro", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
fragmentTransaction.commit();
}
} }

View File

@ -367,19 +367,15 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
} }
private void onMenuExport() { private void onMenuExport() {
if (Helper.isPro(this)) if (!Helper.isPro(this)) {
try { onShowPro(null);
askPassword(true); return;
} catch (Throwable ex) { }
Helper.unexpectedError(this, this, ex);
}
else {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
getSupportFragmentManager().popBackStack("pro", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); try {
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro"); askPassword(true);
fragmentTransaction.commit(); } catch (Throwable ex) {
Helper.unexpectedError(this, this, ex);
} }
} }
@ -921,7 +917,7 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
fragmentTransaction.commit(); fragmentTransaction.commit();
} }
BroadcastReceiver receiver = new BroadcastReceiver() { private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (ACTION_EDIT_ACCOUNT.equals(intent.getAction())) if (ACTION_EDIT_ACCOUNT.equals(intent.getAction()))

View File

@ -344,7 +344,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
@Override @Override
public void run() { public void run() {
drawerLayout.closeDrawer(drawerContainer); drawerLayout.closeDrawer(drawerContainer);
onMenuPro(); onShowPro(null);
} }
})); }));
@ -930,15 +930,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
fragmentTransaction.commit(); fragmentTransaction.commit();
} }
private void onMenuPro() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
getSupportFragmentManager().popBackStack("pro", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
fragmentTransaction.commit();
}
private void onMenuInvite() { private void onMenuInvite() {
startActivity(getIntentInvite()); startActivity(getIntentInvite());
} }
@ -1008,7 +999,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
fragmentTransaction.commit(); fragmentTransaction.commit();
} }
BroadcastReceiver receiver = new BroadcastReceiver() { private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) { if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
@ -1182,9 +1173,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private void onColor(final Intent intent) { private void onColor(final Intent intent) {
if (!Helper.isPro(this)) { if (!Helper.isPro(this)) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); onShowPro(null);
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
fragmentTransaction.commit();
return; return;
} }

View File

@ -61,8 +61,8 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.android.colorpicker.ColorPickerDialog; import com.android.colorpicker.ColorPickerDialog;
import com.android.colorpicker.ColorPickerSwatch; import com.android.colorpicker.ColorPickerSwatch;
@ -327,22 +327,22 @@ public class FragmentAccount extends FragmentBase {
btnColor.setOnClickListener(new View.OnClickListener() { btnColor.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (Helper.isPro(getContext())) { if (!Helper.isPro(getContext())) {
int[] colors = getContext().getResources().getIntArray(R.array.colorPicker); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
ColorPickerDialog colorPickerDialog = new ColorPickerDialog(); lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
colorPickerDialog.initialize(R.string.title_account_color, colors, color, 4, colors.length); return;
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
@Override
public void onColorSelected(int color) {
setColor(color);
}
});
colorPickerDialog.show(getFragmentManager(), "colorpicker");
} else {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
fragmentTransaction.commit();
} }
int[] colors = getContext().getResources().getIntArray(R.array.colorPicker);
ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
colorPickerDialog.initialize(R.string.title_account_color, colors, color, 4, colors.length);
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
@Override
public void onColorSelected(int color) {
setColor(color);
}
});
colorPickerDialog.show(getFragmentManager(), "colorpicker");
} }
}); });
@ -399,9 +399,8 @@ public class FragmentAccount extends FragmentBase {
if (isChecked && !Helper.isPro(getContext())) { if (isChecked && !Helper.isPro(getContext())) {
cbNotify.setChecked(false); cbNotify.setChecked(false);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro"); lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
fragmentTransaction.commit();
} }
} }
}); });

View File

@ -98,9 +98,9 @@ import androidx.constraintlayout.widget.Group;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import androidx.cursoradapter.widget.SimpleCursorAdapter; import androidx.cursoradapter.widget.SimpleCursorAdapter;
import androidx.exifinterface.media.ExifInterface; import androidx.exifinterface.media.ExifInterface;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -1019,11 +1019,11 @@ public class FragmentCompose extends FragmentBase {
private void onMenuAnswer() { private void onMenuAnswer() {
if (!Helper.isPro(getContext())) { if (!Helper.isPro(getContext())) {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro"); lbm.sendBroadcast(new Intent(ActivityCompose.ACTION_SHOW_PRO));
fragmentTransaction.commit();
return; return;
} }
new SimpleTask<List<EntityAnswer>>() { new SimpleTask<List<EntityAnswer>>() {
@Override @Override
protected List<EntityAnswer> onExecute(Context context, Bundle args) { protected List<EntityAnswer> onExecute(Context context, Bundle args) {
@ -1075,6 +1075,12 @@ public class FragmentCompose extends FragmentBase {
new DialogDuration.IDialogDuration() { new DialogDuration.IDialogDuration() {
@Override @Override
public void onDurationSelected(long duration, long time) { public void onDurationSelected(long duration, long time) {
if (!Helper.isPro(getContext())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivityCompose.ACTION_SHOW_PRO));
return;
}
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", working); args.putLong("id", working);
args.putLong("wakeup", time); args.putLong("wakeup", time);
@ -1307,42 +1313,42 @@ public class FragmentCompose extends FragmentBase {
} }
private void onEncrypt() { private void onEncrypt() {
if (Helper.isPro(getContext())) { if (!Helper.isPro(getContext())) {
if (pgpService.isBound()) LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
try { lbm.sendBroadcast(new Intent(ActivityCompose.ACTION_SHOW_PRO));
String to = etTo.getText().toString(); return;
InternetAddress ato[] = (TextUtils.isEmpty(to) ? new InternetAddress[0] : InternetAddress.parse(to)); }
if (ato.length == 0)
throw new IllegalArgumentException(getString(R.string.title_to_missing));
String[] tos = new String[ato.length]; if (pgpService.isBound())
for (int i = 0; i < ato.length; i++) try {
tos[i] = ato[i].getAddress(); String to = etTo.getText().toString();
InternetAddress ato[] = (TextUtils.isEmpty(to) ? new InternetAddress[0] : InternetAddress.parse(to));
if (ato.length == 0)
throw new IllegalArgumentException(getString(R.string.title_to_missing));
Intent intent = new Intent(OpenPgpApi.ACTION_GET_KEY_IDS); String[] tos = new String[ato.length];
intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, tos); for (int i = 0; i < ato.length; i++)
doPgp(intent); tos[i] = ato[i].getAddress();
} catch (Throwable ex) {
if (ex instanceof IllegalArgumentException) Intent intent = new Intent(OpenPgpApi.ACTION_GET_KEY_IDS);
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show(); intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, tos);
else doPgp(intent);
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex); } catch (Throwable ex) {
} if (ex instanceof IllegalArgumentException)
else { Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
Snackbar snackbar = Snackbar.make(view, R.string.title_no_openpgp, Snackbar.LENGTH_LONG); else
if (Helper.getIntentOpenKeychain().resolveActivity(getContext().getPackageManager()) != null) Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(Helper.getIntentOpenKeychain());
}
});
snackbar.show();
} }
} else { else {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); Snackbar snackbar = Snackbar.make(view, R.string.title_no_openpgp, Snackbar.LENGTH_LONG);
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro"); if (Helper.getIntentOpenKeychain().resolveActivity(getContext().getPackageManager()) != null)
fragmentTransaction.commit(); snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(Helper.getIntentOpenKeychain());
}
});
snackbar.show();
} }
} }

View File

@ -21,6 +21,7 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.GradientDrawable;
import android.os.Bundle; import android.os.Bundle;
@ -50,7 +51,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentTransaction; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.android.colorpicker.ColorPickerDialog; import com.android.colorpicker.ColorPickerDialog;
import com.android.colorpicker.ColorPickerSwatch; import com.android.colorpicker.ColorPickerSwatch;
@ -276,22 +277,22 @@ public class FragmentIdentity extends FragmentBase {
btnColor.setOnClickListener(new View.OnClickListener() { btnColor.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (Helper.isPro(getContext())) { if (!Helper.isPro(getContext())) {
int[] colors = getContext().getResources().getIntArray(R.array.colorPicker); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
ColorPickerDialog colorPickerDialog = new ColorPickerDialog(); lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
colorPickerDialog.initialize(R.string.title_account_color, colors, color, 4, colors.length); return;
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
@Override
public void onColorSelected(int color) {
setColor(color);
}
});
colorPickerDialog.show(getFragmentManager(), "colorpicker");
} else {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
fragmentTransaction.commit();
} }
int[] colors = getContext().getResources().getIntArray(R.array.colorPicker);
ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
colorPickerDialog.initialize(R.string.title_account_color, colors, color, 4, colors.length);
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
@Override
public void onColorSelected(int color) {
setColor(color);
}
});
colorPickerDialog.show(getFragmentManager(), "colorpicker");
} }
}); });

View File

@ -299,9 +299,8 @@ public class FragmentMessages extends FragmentBase {
tvSupport.setOnClickListener(new View.OnClickListener() { tvSupport.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro"); lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
fragmentTransaction.commit();
} }
}); });
@ -1544,56 +1543,56 @@ public class FragmentMessages extends FragmentBase {
new DialogDuration.IDialogDuration() { new DialogDuration.IDialogDuration() {
@Override @Override
public void onDurationSelected(long duration, long time) { public void onDurationSelected(long duration, long time) {
if (Helper.isPro(getContext())) { if (!Helper.isPro(getContext())) {
Bundle args = new Bundle(); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
args.putLongArray("ids", getSelection()); lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
args.putLong("wakeup", duration == 0 ? -1 : time); return;
}
selectionTracker.clearSelection(); Bundle args = new Bundle();
args.putLongArray("ids", getSelection());
args.putLong("wakeup", duration == 0 ? -1 : time);
new SimpleTask<Void>() { selectionTracker.clearSelection();
@Override
protected Void onExecute(Context context, Bundle args) {
long[] ids = args.getLongArray("ids");
Long wakeup = args.getLong("wakeup");
if (wakeup < 0)
wakeup = null;
DB db = DB.getInstance(context); new SimpleTask<Void>() {
try { @Override
db.beginTransaction(); protected Void onExecute(Context context, Bundle args) {
long[] ids = args.getLongArray("ids");
Long wakeup = args.getLong("wakeup");
if (wakeup < 0)
wakeup = null;
for (long id : ids) { DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id); try {
if (message != null) { db.beginTransaction();
List<EntityMessage> messages = db.message().getMessageByThread(
message.account, message.thread, threading ? null : id, message.folder); for (long id : ids) {
for (EntityMessage threaded : messages) { EntityMessage message = db.message().getMessage(id);
db.message().setMessageSnoozed(threaded.id, wakeup); if (message != null) {
EntityMessage.snooze(context, threaded.id, wakeup); List<EntityMessage> messages = db.message().getMessageByThread(
EntityOperation.queue(context, threaded, EntityOperation.SEEN, true); message.account, message.thread, threading ? null : id, message.folder);
} for (EntityMessage threaded : messages) {
db.message().setMessageSnoozed(threaded.id, wakeup);
EntityMessage.snooze(context, threaded.id, wakeup);
EntityOperation.queue(context, threaded, EntityOperation.SEEN, true);
} }
} }
db.setTransactionSuccessful();
} finally {
db.endTransaction();
} }
return null; db.setTransactionSuccessful();
} finally {
db.endTransaction();
} }
@Override return null;
protected void onException(Bundle args, Throwable ex) { }
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
} @Override
}.execute(FragmentMessages.this, args, "messages:snooze"); protected void onException(Bundle args, Throwable ex) {
} else { Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); }
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro"); }.execute(FragmentMessages.this, args, "messages:snooze");
fragmentTransaction.commit();
}
} }
@Override @Override
@ -1649,9 +1648,8 @@ public class FragmentMessages extends FragmentBase {
private void onActionFlagColorSelection() { private void onActionFlagColorSelection() {
if (!Helper.isPro(getContext())) { if (!Helper.isPro(getContext())) {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro"); lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
fragmentTransaction.commit();
return; return;
} }
@ -3258,29 +3256,26 @@ public class FragmentMessages extends FragmentBase {
static void search( static void search(
final Context context, final LifecycleOwner owner, final FragmentManager manager, final Context context, final LifecycleOwner owner, final FragmentManager manager,
long folder, boolean server, String query) { long folder, boolean server, String query) {
if (Helper.isPro(context)) { if (!Helper.isPro(context)) {
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
manager.popBackStack("search", FragmentManager.POP_BACK_STACK_INCLUSIVE); lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
return;
Bundle args = new Bundle();
args.putLong("folder", folder);
args.putBoolean("server", server);
args.putString("query", query);
FragmentMessages fragment = new FragmentMessages();
fragment.setArguments(args);
FragmentTransaction fragmentTransaction = manager.beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("search");
fragmentTransaction.commit();
} else {
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
manager.popBackStack("pro", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = manager.beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
fragmentTransaction.commit();
} }
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
manager.popBackStack("search", FragmentManager.POP_BACK_STACK_INCLUSIVE);
Bundle args = new Bundle();
args.putLong("folder", folder);
args.putBoolean("server", server);
args.putString("query", query);
FragmentMessages fragment = new FragmentMessages();
fragment.setArguments(args);
FragmentTransaction fragmentTransaction = manager.beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("search");
fragmentTransaction.commit();
} }
private class MoreResult { private class MoreResult {

View File

@ -48,7 +48,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentTransaction; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -666,9 +666,8 @@ public class FragmentRule extends FragmentBase {
private void onActionSave() { private void onActionSave() {
if (!Helper.isPro(getContext())) { if (!Helper.isPro(getContext())) {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro"); lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
fragmentTransaction.commit();
return; return;
} }