diff --git a/app/src/main/java/app/fedilab/android/helper/CrossActionHelper.java b/app/src/main/java/app/fedilab/android/helper/CrossActionHelper.java index e5064a55..73db56ac 100644 --- a/app/src/main/java/app/fedilab/android/helper/CrossActionHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/CrossActionHelper.java @@ -15,6 +15,7 @@ package app.fedilab.android.helper; * see . */ import android.content.Context; +import android.content.SharedPreferences; import android.os.Handler; import android.os.Looper; @@ -23,6 +24,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelStoreOwner; +import androidx.preference.PreferenceManager; import java.util.ArrayList; import java.util.List; @@ -50,7 +52,7 @@ public class CrossActionHelper { * @param targetedStatus status that is targeted */ public static void doCrossAction(@NonNull Context context, @NonNull TypeOfCrossAction actionType, app.fedilab.android.client.mastodon.entities.Account targetedAccount, Status targetedStatus) { - + final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); new Thread(() -> { try { List accounts = new Account(context).getCrossAccounts(); @@ -76,8 +78,26 @@ public class CrossActionHelper { } builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); builderSingle.setAdapter(accountsSearchAdapter, (dialog, which) -> { + boolean confirmFav = sharedpreferences.getBoolean(context.getString(R.string.SET_NOTIF_VALIDATION_FAV), false); + boolean confirmBoost = sharedpreferences.getBoolean(context.getString(R.string.SET_NOTIF_VALIDATION), true); Account selectedAccount = accountArray[which]; - fetchRemote(context, actionType, selectedAccount, targetedAccount, targetedStatus); + if ((actionType == TypeOfCrossAction.REBLOG_ACTION && confirmBoost) || (actionType == TypeOfCrossAction.FAVOURITE_ACTION && confirmFav)) { + AlertDialog.Builder alt_bld = new AlertDialog.Builder(context, Helper.dialogStyle()); + if (actionType == TypeOfCrossAction.REBLOG_ACTION) { + alt_bld.setMessage(context.getString(R.string.reblog_add)); + } else { + alt_bld.setMessage(context.getString(R.string.favourite_add)); + } + alt_bld.setPositiveButton(R.string.yes, (dia, id) -> { + fetchRemote(context, actionType, selectedAccount, targetedAccount, targetedStatus); + dialog.dismiss(); + }); + alt_bld.setNegativeButton(R.string.cancel, (dia, id) -> dialog.dismiss()); + AlertDialog alert = alt_bld.create(); + alert.show(); + } else { + fetchRemote(context, actionType, selectedAccount, targetedAccount, targetedStatus); + } dialog.dismiss(); }); builderSingle.show(); diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index 8c9b793e..88611ce5 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -427,23 +427,7 @@ public class StatusAdapter extends RecyclerView.Adapter if (statusToDeal.visibility.equals("direct") || (statusToDeal.visibility.equals("private"))) { return true; } - if (confirmBoost) { - AlertDialog.Builder alt_bld = new AlertDialog.Builder(context, Helper.dialogStyle()); - if (statusToDeal.reblogged) { - alt_bld.setMessage(context.getString(R.string.reblog_remove)); - } else { - alt_bld.setMessage(context.getString(R.string.reblog_add)); - } - alt_bld.setPositiveButton(R.string.yes, (dialog, id) -> { - CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, null, statusToDeal); - dialog.dismiss(); - }); - alt_bld.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); - AlertDialog alert = alt_bld.create(); - alert.show(); - } else { - CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, null, statusToDeal); - } + CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, null, statusToDeal); return true; }); holder.binding.actionButtonBoost.setOnClickListener(v -> { @@ -541,16 +525,7 @@ public class StatusAdapter extends RecyclerView.Adapter if (statusToDeal.visibility.equals("direct") || (statusToDeal.visibility.equals("private"))) { return true; } - if (confirmFav) { - AlertDialog.Builder alt_bld = new AlertDialog.Builder(context, Helper.dialogStyle()); - alt_bld.setMessage(context.getString(R.string.favourite_add)); - alt_bld.setPositiveButton(R.string.yes, (dialog, id) -> CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, null, statusToDeal)); - alt_bld.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); - AlertDialog alert = alt_bld.create(); - alert.show(); - } else { - CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, null, statusToDeal); - } + CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, null, statusToDeal); return true; }); holder.binding.actionButtonFavorite.setOnClickListener(v -> {