1
0
Fork 1

Allow ignoring the mam pref warning

(cherry picked from commit 01cbee36b21bf417e35da3f23999747e6fbbbcc8)
This commit is contained in:
Stephen Paul Weber 2024-11-28 10:37:16 -05:00 committed by Arne
parent 475c01cbc6
commit 3fa2d3be76

View file

@ -45,6 +45,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.PopupMenu;
import android.widget.Toast;
import androidx.annotation.NonNull;
@ -544,6 +545,7 @@ public class ConversationsOverviewFragment extends XmppFragment {
binding.overviewSnackbar.setVisibility(View.GONE);
if (activity.xmppConnectionService == null) return;
for (final var account : activity.xmppConnectionService.getAccounts()) {
if (activity.getPreferences().getBoolean("no_mam_pref_warn:" + account.getUuid(), false)) continue;
if (account.mamPrefs() != null && !"always".equals(account.mamPrefs().getAttribute("default"))) {
binding.overviewSnackbar.setVisibility(View.VISIBLE);
binding.overviewSnackbarMessage.setText("Your account " + account.getJid().asBareJid().toEscapedString() + " does not have archiving fully enabled. This may result in missed messages if you use multiple devices or apps.");
@ -553,6 +555,24 @@ public class ConversationsOverviewFragment extends XmppFragment {
activity.xmppConnectionService.pushMamPreferences(account, prefs);
refresh();
});
binding.overviewSnackbarAction.setOnLongClickListener((v) -> {
PopupMenu popupMenu = new PopupMenu(getActivity(), v);
popupMenu.inflate(R.menu.mam_pref_fix);
popupMenu.setOnMenuItemClickListener(menuItem -> {
switch (menuItem.getItemId()) {
case R.id.ignore:
final var editor = activity.getPreferences().edit();
editor.putBoolean("no_mam_pref_warn:" + account.getUuid(), true).apply();
editor.apply();
refresh();
return true;
}
return true;
});
popupMenu.show();
return true;
});
break;
}
}