1/*
2 * Copyright (c) 2018, Daniel Gultsch All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation and/or
12 * other materials provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30package eu.siacs.conversations.ui;
31
32
33import android.annotation.SuppressLint;
34import android.app.Activity;
35import android.app.Fragment;
36import android.app.FragmentManager;
37import android.app.FragmentTransaction;
38import android.content.ActivityNotFoundException;
39import android.content.Context;
40import android.content.Intent;
41import android.content.pm.PackageManager;
42import android.databinding.DataBindingUtil;
43import android.net.Uri;
44import android.os.Build;
45import android.os.Bundle;
46import android.provider.Settings;
47import android.support.annotation.IdRes;
48import android.support.annotation.NonNull;
49import android.support.v7.app.ActionBar;
50import android.support.v7.app.AlertDialog;
51import android.util.Log;
52import android.view.Menu;
53import android.view.MenuItem;
54import android.widget.Toast;
55
56import org.openintents.openpgp.util.OpenPgpApi;
57
58import java.util.concurrent.atomic.AtomicBoolean;
59
60import eu.siacs.conversations.Config;
61import eu.siacs.conversations.R;
62import eu.siacs.conversations.databinding.ActivityConversationsBinding;
63import eu.siacs.conversations.entities.Account;
64import eu.siacs.conversations.entities.Conversation;
65import eu.siacs.conversations.services.XmppConnectionService;
66import eu.siacs.conversations.ui.interfaces.OnConversationArchived;
67import eu.siacs.conversations.ui.interfaces.OnConversationRead;
68import eu.siacs.conversations.ui.interfaces.OnConversationSelected;
69import eu.siacs.conversations.ui.interfaces.OnConversationsListItemUpdated;
70import eu.siacs.conversations.ui.service.EmojiService;
71import eu.siacs.conversations.ui.util.ActivityResult;
72import eu.siacs.conversations.ui.util.PendingItem;
73import eu.siacs.conversations.utils.ExceptionHelper;
74import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
75
76import static eu.siacs.conversations.ui.ConversationFragment.REQUEST_DECRYPT_PGP;
77
78public class ConversationsActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast {
79
80 public static final String ACTION_VIEW_CONVERSATION = "eu.siacs.conversations.action.VIEW";
81 public static final String EXTRA_CONVERSATION = "conversationUuid";
82 public static final String EXTRA_DOWNLOAD_UUID = "eu.siacs.conversations.download_uuid";
83 public static final String EXTRA_TEXT = "text";
84 public static final String EXTRA_NICK = "nick";
85 public static final String EXTRA_IS_PRIVATE_MESSAGE = "pm";
86
87 public static final int REQUEST_OPEN_MESSAGE = 0x9876;
88 public static final int REQUEST_PLAY_PAUSE = 0x5432;
89
90
91 //secondary fragment (when holding the conversation, must be initialized before refreshing the overview fragment
92 private static final @IdRes
93 int[] FRAGMENT_ID_NOTIFICATION_ORDER = {R.id.secondary_fragment, R.id.main_fragment};
94 private final PendingItem<Intent> pendingViewIntent = new PendingItem<>();
95 private final PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
96 private ActivityConversationsBinding binding;
97 private boolean mActivityPaused = true;
98 private AtomicBoolean mRedirectInProcess = new AtomicBoolean(false);
99
100 private static boolean isViewIntent(Intent i) {
101 return i != null && ACTION_VIEW_CONVERSATION.equals(i.getAction()) && i.hasExtra(EXTRA_CONVERSATION);
102 }
103
104 private static Intent createLauncherIntent(Context context) {
105 final Intent intent = new Intent(context, ConversationsActivity.class);
106 intent.setAction(Intent.ACTION_MAIN);
107 intent.addCategory(Intent.CATEGORY_LAUNCHER);
108 return intent;
109 }
110
111 @Override
112 protected void refreshUiReal() {
113 for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
114 refreshFragment(id);
115 }
116 }
117
118 @Override
119 void onBackendConnected() {
120 if (performRedirectIfNecessary(true)) {
121 return;
122 }
123 xmppConnectionService.getNotificationService().setIsInForeground(true);
124 Intent intent = pendingViewIntent.pop();
125 if (intent != null) {
126 if (processViewIntent(intent)) {
127 if (binding.secondaryFragment != null) {
128 notifyFragmentOfBackendConnected(R.id.main_fragment);
129 }
130 invalidateActionBarTitle();
131 return;
132 }
133 }
134 for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
135 notifyFragmentOfBackendConnected(id);
136 }
137
138 ActivityResult activityResult = postponedActivityResult.pop();
139 if (activityResult != null) {
140 handleActivityResult(activityResult);
141 }
142
143 invalidateActionBarTitle();
144 if (binding.secondaryFragment != null && ConversationFragment.getConversation(this) == null) {
145 Conversation conversation = ConversationsOverviewFragment.getSuggestion(this);
146 if (conversation != null) {
147 openConversation(conversation, null);
148 }
149 }
150 showDialogsIfMainIsOverview();
151 }
152
153 private boolean performRedirectIfNecessary(boolean noAnimation) {
154 return performRedirectIfNecessary(null, noAnimation);
155 }
156
157 private boolean performRedirectIfNecessary(final Conversation ignore, final boolean noAnimation) {
158 if (xmppConnectionService == null) {
159 return false;
160 }
161 boolean isConversationsListEmpty = xmppConnectionService.isConversationsListEmpty(ignore);
162 if (isConversationsListEmpty && mRedirectInProcess.compareAndSet(false, true)) {
163 final Intent intent = getRedirectionIntent(noAnimation);
164 runOnUiThread(() -> {
165 startActivity(intent);
166 if (noAnimation) {
167 overridePendingTransition(0, 0);
168 }
169 });
170 }
171 return mRedirectInProcess.get();
172 }
173
174 private Intent getRedirectionIntent(boolean noAnimation) {
175 Account pendingAccount = xmppConnectionService.getPendingAccount();
176 Intent intent;
177 if (pendingAccount != null) {
178 intent = new Intent(this, EditAccountActivity.class);
179 intent.putExtra("jid", pendingAccount.getJid().asBareJid().toString());
180 } else {
181 if (xmppConnectionService.getAccounts().size() == 0) {
182 if (Config.X509_VERIFICATION) {
183 intent = new Intent(this, ManageAccountActivity.class);
184 } else if (Config.MAGIC_CREATE_DOMAIN != null) {
185 intent = new Intent(this, WelcomeActivity.class);
186 WelcomeActivity.addInviteUri(intent, getIntent());
187 } else {
188 intent = new Intent(this, EditAccountActivity.class);
189 }
190 } else {
191 intent = new Intent(this, StartConversationActivity.class);
192 }
193 }
194 intent.putExtra("init", true);
195 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
196 if (noAnimation) {
197 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
198 }
199 return intent;
200 }
201
202 private void showDialogsIfMainIsOverview() {
203 if (xmppConnectionService == null) {
204 return;
205 }
206 final Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
207 if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
208 if (ExceptionHelper.checkForCrash(this)) {
209 return;
210 }
211 openBatteryOptimizationDialogIfNeeded();
212 }
213 }
214
215 private String getBatteryOptimizationPreferenceKey() {
216 @SuppressLint("HardwareIds") String device = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
217 return "show_battery_optimization" + (device == null ? "" : device);
218 }
219
220 private void setNeverAskForBatteryOptimizationsAgain() {
221 getPreferences().edit().putBoolean(getBatteryOptimizationPreferenceKey(), false).apply();
222 }
223
224 private void openBatteryOptimizationDialogIfNeeded() {
225 if (hasAccountWithoutPush()
226 && isOptimizingBattery()
227 && getPreferences().getBoolean(getBatteryOptimizationPreferenceKey(), true)) {
228 AlertDialog.Builder builder = new AlertDialog.Builder(this);
229 builder.setTitle(R.string.battery_optimizations_enabled);
230 builder.setMessage(R.string.battery_optimizations_enabled_dialog);
231 builder.setPositiveButton(R.string.next, (dialog, which) -> {
232 Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
233 Uri uri = Uri.parse("package:" + getPackageName());
234 intent.setData(uri);
235 try {
236 startActivityForResult(intent, REQUEST_BATTERY_OP);
237 } catch (ActivityNotFoundException e) {
238 Toast.makeText(this, R.string.device_does_not_support_battery_op, Toast.LENGTH_SHORT).show();
239 }
240 });
241 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
242 builder.setOnDismissListener(dialog -> setNeverAskForBatteryOptimizationsAgain());
243 }
244 AlertDialog dialog = builder.create();
245 dialog.setCanceledOnTouchOutside(false);
246 dialog.show();
247 }
248 }
249
250 private boolean hasAccountWithoutPush() {
251 for (Account account : xmppConnectionService.getAccounts()) {
252 if (account.getStatus() == Account.State.ONLINE && !xmppConnectionService.getPushManagementService().available(account)) {
253 return true;
254 }
255 }
256 return false;
257 }
258
259 private void notifyFragmentOfBackendConnected(@IdRes int id) {
260 final Fragment fragment = getFragmentManager().findFragmentById(id);
261 if (fragment != null && fragment instanceof XmppFragment) {
262 ((XmppFragment) fragment).onBackendConnected();
263 }
264 }
265
266 private void refreshFragment(@IdRes int id) {
267 final Fragment fragment = getFragmentManager().findFragmentById(id);
268 if (fragment != null && fragment instanceof XmppFragment) {
269 ((XmppFragment) fragment).refresh();
270 }
271 }
272
273 private boolean processViewIntent(Intent intent) {
274 String uuid = intent.getStringExtra(EXTRA_CONVERSATION);
275 Conversation conversation = uuid != null ? xmppConnectionService.findConversationByUuid(uuid) : null;
276 if (conversation == null) {
277 Log.d(Config.LOGTAG, "unable to view conversation with uuid:" + uuid);
278 return false;
279 }
280 openConversation(conversation, intent.getExtras());
281 return true;
282 }
283
284 @Override
285 public void onRequestPermissionsResult(int requestCode,@NonNull String permissions[], @NonNull int[] grantResults) {
286 UriHandlerActivity.onRequestPermissionResult(this, requestCode, grantResults);
287 if (grantResults.length > 0) {
288 if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
289 switch(requestCode) {
290 case REQUEST_OPEN_MESSAGE:
291 refreshUiReal();
292 ConversationFragment.openPendingMessage(this);
293 break;
294 case REQUEST_PLAY_PAUSE:
295 ConversationFragment.startStopPending(this);
296 break;
297 }
298 }
299 }
300 }
301
302 @Override
303 public void onActivityResult(int requestCode, int resultCode, final Intent data) {
304 super.onActivityResult(requestCode, resultCode, data);
305 ActivityResult activityResult = ActivityResult.of(requestCode, resultCode, data);
306 if (xmppConnectionService != null) {
307 handleActivityResult(activityResult);
308 } else {
309 this.postponedActivityResult.push(activityResult);
310 }
311 }
312
313 private void handleActivityResult(ActivityResult activityResult) {
314 if (activityResult.resultCode == Activity.RESULT_OK) {
315 handlePositiveActivityResult(activityResult.requestCode, activityResult.data);
316 } else {
317 handleNegativeActivityResult(activityResult.requestCode);
318 }
319 }
320
321 private void handleNegativeActivityResult(int requestCode) {
322 Conversation conversation = ConversationFragment.getConversationReliable(this);
323 switch (requestCode) {
324 case REQUEST_DECRYPT_PGP:
325 if (conversation == null) {
326 break;
327 }
328 conversation.getAccount().getPgpDecryptionService().giveUpCurrentDecryption();
329 break;
330 case REQUEST_BATTERY_OP:
331 setNeverAskForBatteryOptimizationsAgain();
332 break;
333 }
334 }
335
336 private void handlePositiveActivityResult(int requestCode, final Intent data) {
337 Conversation conversation = ConversationFragment.getConversationReliable(this);
338 if (conversation == null) {
339 Log.d(Config.LOGTAG,"conversation not found");
340 return;
341 }
342 switch (requestCode) {
343 case REQUEST_DECRYPT_PGP:
344 conversation.getAccount().getPgpDecryptionService().continueDecryption(data);
345 break;
346 case REQUEST_CHOOSE_PGP_ID:
347 long id = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0);
348 if (id != 0) {
349 conversation.getAccount().setPgpSignId(id);
350 announcePgp(conversation.getAccount(), null, null, onOpenPGPKeyPublished);
351 } else {
352 choosePgpSignId(conversation.getAccount());
353 }
354 break;
355 case REQUEST_ANNOUNCE_PGP:
356 announcePgp(conversation.getAccount(), conversation, data, onOpenPGPKeyPublished);
357 break;
358 }
359 }
360
361 @Override
362 protected void onCreate(final Bundle savedInstanceState) {
363 super.onCreate(savedInstanceState);
364 new EmojiService(this).init();
365 this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations);
366 this.getFragmentManager().addOnBackStackChangedListener(this::invalidateActionBarTitle);
367 this.getFragmentManager().addOnBackStackChangedListener(this::showDialogsIfMainIsOverview);
368 this.initializeFragments();
369 this.invalidateActionBarTitle();
370 final Intent intent;
371 if (savedInstanceState == null) {
372 intent = getIntent();
373 } else {
374 intent = savedInstanceState.getParcelable("intent");
375 }
376 if (isViewIntent(intent)) {
377 pendingViewIntent.push(intent);
378 setIntent(createLauncherIntent(this));
379 }
380 }
381
382 @Override
383 public boolean onCreateOptionsMenu(Menu menu) {
384 getMenuInflater().inflate(R.menu.activity_conversations, menu);
385 MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);
386 if (qrCodeScanMenuItem != null) {
387 Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
388 boolean visible = getResources().getBoolean(R.bool.show_qr_code_scan)
389 && fragment != null
390 && fragment instanceof ConversationsOverviewFragment;
391 qrCodeScanMenuItem.setVisible(visible);
392 }
393 return super.onCreateOptionsMenu(menu);
394 }
395
396 @Override
397 public void onConversationSelected(Conversation conversation) {
398 if (ConversationFragment.getConversation(this) == conversation) {
399 Log.d(Config.LOGTAG,"ignore onConversationSelected() because conversation is already open");
400 return;
401 }
402 openConversation(conversation, null);
403 }
404
405 private void openConversation(Conversation conversation, Bundle extras) {
406 ConversationFragment conversationFragment = (ConversationFragment) getFragmentManager().findFragmentById(R.id.secondary_fragment);
407 final boolean mainNeedsRefresh;
408 if (conversationFragment == null) {
409 mainNeedsRefresh = false;
410 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
411 if (mainFragment != null && mainFragment instanceof ConversationFragment) {
412 conversationFragment = (ConversationFragment) mainFragment;
413 } else {
414 conversationFragment = new ConversationFragment();
415 FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
416 fragmentTransaction.replace(R.id.main_fragment, conversationFragment);
417 fragmentTransaction.addToBackStack(null);
418 fragmentTransaction.commit();
419 }
420 } else {
421 mainNeedsRefresh = true;
422 }
423 conversationFragment.reInit(conversation, extras == null ? new Bundle() : extras);
424 if (mainNeedsRefresh) {
425 refreshFragment(R.id.main_fragment);
426 } else {
427 invalidateActionBarTitle();
428 }
429 }
430
431 @Override
432 public boolean onOptionsItemSelected(MenuItem item) {
433 switch (item.getItemId()) {
434 case android.R.id.home:
435 FragmentManager fm = getFragmentManager();
436 if (fm.getBackStackEntryCount() > 0) {
437 fm.popBackStack();
438 return true;
439 }
440 break;
441 case R.id.action_scan_qr_code:
442 UriHandlerActivity.scan(this);
443 return true;
444 }
445 return super.onOptionsItemSelected(item);
446 }
447
448 @Override
449 public void onSaveInstanceState(Bundle savedInstanceState) {
450 Intent pendingIntent = pendingViewIntent.peek();
451 savedInstanceState.putParcelable("intent", pendingIntent != null ? pendingIntent : getIntent());
452 super.onSaveInstanceState(savedInstanceState);
453 }
454
455 @Override
456 protected void onStart() {
457 final int theme = findTheme();
458 if (this.mTheme != theme) {
459 this.mSkipBackgroundBinding = true;
460 recreate();
461 } else {
462 this.mSkipBackgroundBinding = false;
463 }
464 mRedirectInProcess.set(false);
465 super.onStart();
466 }
467
468 @Override
469 protected void onNewIntent(final Intent intent) {
470 if (isViewIntent(intent)) {
471 if (xmppConnectionService != null) {
472 processViewIntent(intent);
473 } else {
474 pendingViewIntent.push(intent);
475 }
476 }
477 setIntent(createLauncherIntent(this));
478 }
479
480 @Override
481 public void onPause() {
482 this.mActivityPaused = true;
483 super.onPause();
484 }
485
486 @Override
487 public void onResume() {
488 super.onResume();
489 this.mActivityPaused = false;
490 }
491
492 private void initializeFragments() {
493 FragmentTransaction transaction = getFragmentManager().beginTransaction();
494 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
495 Fragment secondaryFragment = getFragmentManager().findFragmentById(R.id.secondary_fragment);
496 if (mainFragment != null) {
497 if (binding.secondaryFragment != null) {
498 if (mainFragment instanceof ConversationFragment) {
499 getFragmentManager().popBackStack();
500 transaction.remove(mainFragment);
501 transaction.commit();
502 getFragmentManager().executePendingTransactions();
503 transaction = getFragmentManager().beginTransaction();
504 transaction.replace(R.id.secondary_fragment, mainFragment);
505 transaction.replace(R.id.main_fragment, new ConversationsOverviewFragment());
506 transaction.commit();
507 return;
508 }
509 } else {
510 if (secondaryFragment != null && secondaryFragment instanceof ConversationFragment) {
511 transaction.remove(secondaryFragment);
512 transaction.commit();
513 getFragmentManager().executePendingTransactions();
514 transaction = getFragmentManager().beginTransaction();
515 transaction.replace(R.id.main_fragment, secondaryFragment);
516 transaction.addToBackStack(null);
517 transaction.commit();
518 return;
519 }
520 }
521 } else {
522 transaction.replace(R.id.main_fragment, new ConversationsOverviewFragment());
523 }
524 if (binding.secondaryFragment != null && secondaryFragment == null) {
525 transaction.replace(R.id.secondary_fragment, new ConversationFragment());
526 }
527 transaction.commit();
528 }
529
530 private void invalidateActionBarTitle() {
531 final ActionBar actionBar = getSupportActionBar();
532 if (actionBar != null) {
533 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
534 if (mainFragment != null && mainFragment instanceof ConversationFragment) {
535 final Conversation conversation = ((ConversationFragment) mainFragment).getConversation();
536 if (conversation != null) {
537 actionBar.setTitle(conversation.getName());
538 actionBar.setDisplayHomeAsUpEnabled(true);
539 return;
540 }
541 }
542 actionBar.setTitle(R.string.app_name);
543 actionBar.setDisplayHomeAsUpEnabled(false);
544 }
545 }
546
547 @Override
548 public void onConversationArchived(Conversation conversation) {
549 if (performRedirectIfNecessary(conversation, false)) {
550 return;
551 }
552 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
553 if (mainFragment != null && mainFragment instanceof ConversationFragment) {
554 getFragmentManager().popBackStack();
555 return;
556 }
557 Fragment secondaryFragment = getFragmentManager().findFragmentById(R.id.secondary_fragment);
558 if (secondaryFragment != null && secondaryFragment instanceof ConversationFragment) {
559 if (((ConversationFragment) secondaryFragment).getConversation() == conversation) {
560 Conversation suggestion = ConversationsOverviewFragment.getSuggestion(this, conversation);
561 if (suggestion != null) {
562 openConversation(suggestion, null);
563 }
564 }
565 }
566 }
567
568 @Override
569 public void onConversationsListItemUpdated() {
570 Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
571 if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
572 ((ConversationsOverviewFragment) fragment).refresh();
573 }
574 }
575
576 @Override
577 public void switchToConversation(Conversation conversation) {
578 Log.d(Config.LOGTAG,"override");
579 openConversation(conversation,null);
580 }
581
582 @Override
583 public void onConversationRead(Conversation conversation) {
584 if (!mActivityPaused && pendingViewIntent.peek() == null) {
585 xmppConnectionService.sendReadMarker(conversation);
586 } else {
587 Log.d(Config.LOGTAG,"ignoring read callback. mActivityPaused="+Boolean.toString(mActivityPaused));
588 }
589 }
590
591 @Override
592 public void onAccountUpdate() {
593 this.refreshUi();
594 }
595
596 @Override
597 public void onConversationUpdate() {
598 if (performRedirectIfNecessary(false)) {
599 return;
600 }
601 this.refreshUi();
602 }
603
604 @Override
605 public void onRosterUpdate() {
606 this.refreshUi();
607 }
608
609 @Override
610 public void OnUpdateBlocklist(OnUpdateBlocklist.Status status) {
611 this.refreshUi();
612 }
613
614 @Override
615 public void onShowErrorToast(int resId) {
616 runOnUiThread(() -> Toast.makeText(this, resId, Toast.LENGTH_SHORT).show());
617 }
618}