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 ConversationActivity 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
89
90 //secondary fragment (when holding the conversation, must be initialized before refreshing the overview fragment
91 private static final @IdRes
92 int[] FRAGMENT_ID_NOTIFICATION_ORDER = {R.id.secondary_fragment, R.id.main_fragment};
93 private final PendingItem<Intent> pendingViewIntent = new PendingItem<>();
94 private final PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
95 private ActivityConversationsBinding binding;
96 private boolean mActivityPaused = true;
97 private AtomicBoolean mRedirectInProcess = new AtomicBoolean(false);
98
99 private static boolean isViewIntent(Intent i) {
100 return i != null && ACTION_VIEW_CONVERSATION.equals(i.getAction()) && i.hasExtra(EXTRA_CONVERSATION);
101 }
102
103 private static Intent createLauncherIntent(Context context) {
104 final Intent intent = new Intent(context, ConversationActivity.class);
105 intent.setAction(Intent.ACTION_MAIN);
106 intent.addCategory(Intent.CATEGORY_LAUNCHER);
107 return intent;
108 }
109
110 @Override
111 protected void refreshUiReal() {
112 for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
113 refreshFragment(id);
114 }
115 }
116
117 @Override
118 void onBackendConnected() {
119 if (performRedirectIfNecessary(true)) {
120 return;
121 }
122 xmppConnectionService.getNotificationService().setIsInForeground(true);
123 Intent intent = pendingViewIntent.pop();
124 if (intent != null) {
125 if (processViewIntent(intent)) {
126 if (binding.secondaryFragment != null) {
127 notifyFragmentOfBackendConnected(R.id.main_fragment);
128 }
129 invalidateActionBarTitle();
130 return;
131 }
132 }
133 for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
134 notifyFragmentOfBackendConnected(id);
135 }
136
137 ActivityResult activityResult = postponedActivityResult.pop();
138 if (activityResult != null) {
139 handleActivityResult(activityResult);
140 }
141
142 invalidateActionBarTitle();
143 if (binding.secondaryFragment != null && ConversationFragment.getConversation(this) == null) {
144 Conversation conversation = ConversationsOverviewFragment.getSuggestion(this);
145 if (conversation != null) {
146 openConversation(conversation, null);
147 }
148 }
149 showDialogsIfMainIsOverview();
150 }
151
152 private boolean performRedirectIfNecessary(boolean noAnimation) {
153 return performRedirectIfNecessary(null, noAnimation);
154 }
155
156 private boolean performRedirectIfNecessary(final Conversation ignore, final boolean noAnimation) {
157 if (xmppConnectionService == null) {
158 return false;
159 }
160 boolean isConversationsListEmpty = xmppConnectionService.isConversationsListEmpty(ignore);
161 if (isConversationsListEmpty && mRedirectInProcess.compareAndSet(false, true)) {
162 final Intent intent = getRedirectionIntent(noAnimation);
163 runOnUiThread(() -> {
164 startActivity(intent);
165 if (noAnimation) {
166 overridePendingTransition(0, 0);
167 }
168 });
169 }
170 return mRedirectInProcess.get();
171 }
172
173 private Intent getRedirectionIntent(boolean noAnimation) {
174 Account pendingAccount = xmppConnectionService.getPendingAccount();
175 Intent intent;
176 if (pendingAccount != null) {
177 intent = new Intent(this, EditAccountActivity.class);
178 intent.putExtra("jid", pendingAccount.getJid().toBareJid().toString());
179 } else {
180 if (xmppConnectionService.getAccounts().size() == 0) {
181 if (Config.X509_VERIFICATION) {
182 intent = new Intent(this, ManageAccountActivity.class);
183 } else if (Config.MAGIC_CREATE_DOMAIN != null) {
184 intent = new Intent(this, WelcomeActivity.class);
185 WelcomeActivity.addInviteUri(intent, getIntent());
186 } else {
187 intent = new Intent(this, EditAccountActivity.class);
188 }
189 } else {
190 intent = new Intent(this, StartConversationActivity.class);
191 }
192 }
193 intent.putExtra("init", true);
194 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
195 if (noAnimation) {
196 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
197 }
198 return intent;
199 }
200
201 private void showDialogsIfMainIsOverview() {
202 if (xmppConnectionService == null) {
203 return;
204 }
205 final Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
206 if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
207 if (ExceptionHelper.checkForCrash(this)) {
208 return;
209 }
210 openBatteryOptimizationDialogIfNeeded();
211 }
212 }
213
214 private String getBatteryOptimizationPreferenceKey() {
215 @SuppressLint("HardwareIds") String device = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
216 return "show_battery_optimization" + (device == null ? "" : device);
217 }
218
219 private void setNeverAskForBatteryOptimizationsAgain() {
220 getPreferences().edit().putBoolean(getBatteryOptimizationPreferenceKey(), false).apply();
221 }
222
223 private void openBatteryOptimizationDialogIfNeeded() {
224 if (hasAccountWithoutPush()
225 && isOptimizingBattery()
226 && getPreferences().getBoolean(getBatteryOptimizationPreferenceKey(), true)) {
227 AlertDialog.Builder builder = new AlertDialog.Builder(this);
228 builder.setTitle(R.string.battery_optimizations_enabled);
229 builder.setMessage(R.string.battery_optimizations_enabled_dialog);
230 builder.setPositiveButton(R.string.next, (dialog, which) -> {
231 Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
232 Uri uri = Uri.parse("package:" + getPackageName());
233 intent.setData(uri);
234 try {
235 startActivityForResult(intent, REQUEST_BATTERY_OP);
236 } catch (ActivityNotFoundException e) {
237 Toast.makeText(this, R.string.device_does_not_support_battery_op, Toast.LENGTH_SHORT).show();
238 }
239 });
240 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
241 builder.setOnDismissListener(dialog -> setNeverAskForBatteryOptimizationsAgain());
242 }
243 AlertDialog dialog = builder.create();
244 dialog.setCanceledOnTouchOutside(false);
245 dialog.show();
246 }
247 }
248
249 private boolean hasAccountWithoutPush() {
250 for (Account account : xmppConnectionService.getAccounts()) {
251 if (account.getStatus() == Account.State.ONLINE && !xmppConnectionService.getPushManagementService().available(account)) {
252 return true;
253 }
254 }
255 return false;
256 }
257
258 private void notifyFragmentOfBackendConnected(@IdRes int id) {
259 final Fragment fragment = getFragmentManager().findFragmentById(id);
260 if (fragment != null && fragment instanceof XmppFragment) {
261 ((XmppFragment) fragment).onBackendConnected();
262 }
263 }
264
265 private void refreshFragment(@IdRes int id) {
266 final Fragment fragment = getFragmentManager().findFragmentById(id);
267 if (fragment != null && fragment instanceof XmppFragment) {
268 ((XmppFragment) fragment).refresh();
269 }
270 }
271
272 private boolean processViewIntent(Intent intent) {
273 Log.d(Config.LOGTAG,"process view 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 }
295 }
296 }
297 }
298
299 @Override
300 public void onActivityResult(int requestCode, int resultCode, final Intent data) {
301 super.onActivityResult(requestCode, resultCode, data);
302 ActivityResult activityResult = ActivityResult.of(requestCode, resultCode, data);
303 if (xmppConnectionService != null) {
304 handleActivityResult(activityResult);
305 } else {
306 this.postponedActivityResult.push(activityResult);
307 }
308 }
309
310 private void handleActivityResult(ActivityResult activityResult) {
311 if (activityResult.resultCode == Activity.RESULT_OK) {
312 handlePositiveActivityResult(activityResult.requestCode, activityResult.data);
313 } else {
314 handleNegativeActivityResult(activityResult.requestCode);
315 }
316 }
317
318 private void handleNegativeActivityResult(int requestCode) {
319 Conversation conversation = ConversationFragment.getConversationReliable(this);
320 switch (requestCode) {
321 case REQUEST_DECRYPT_PGP:
322 if (conversation == null) {
323 break;
324 }
325 conversation.getAccount().getPgpDecryptionService().giveUpCurrentDecryption();
326 break;
327 case REQUEST_BATTERY_OP:
328 setNeverAskForBatteryOptimizationsAgain();
329 break;
330 }
331 }
332
333 private void handlePositiveActivityResult(int requestCode, final Intent data) {
334 Log.d(Config.LOGTAG,"positive activity result");
335 Conversation conversation = ConversationFragment.getConversationReliable(this);
336 if (conversation == null) {
337 Log.d(Config.LOGTAG,"conversation not found");
338 return;
339 }
340 switch (requestCode) {
341 case REQUEST_DECRYPT_PGP:
342 conversation.getAccount().getPgpDecryptionService().continueDecryption(data);
343 break;
344 case REQUEST_CHOOSE_PGP_ID:
345 long id = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0);
346 if (id != 0) {
347 conversation.getAccount().setPgpSignId(id);
348 announcePgp(conversation.getAccount(), null, null, onOpenPGPKeyPublished);
349 } else {
350 choosePgpSignId(conversation.getAccount());
351 }
352 break;
353 case REQUEST_ANNOUNCE_PGP:
354 announcePgp(conversation.getAccount(), conversation, data, onOpenPGPKeyPublished);
355 break;
356 }
357 }
358
359 @Override
360 protected void onCreate(final Bundle savedInstanceState) {
361 super.onCreate(savedInstanceState);
362 new EmojiService(this).init();
363 this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations);
364 this.getFragmentManager().addOnBackStackChangedListener(this::invalidateActionBarTitle);
365 this.getFragmentManager().addOnBackStackChangedListener(this::showDialogsIfMainIsOverview);
366 this.initializeFragments();
367 this.invalidateActionBarTitle();
368 final Intent intent;
369 if (savedInstanceState == null) {
370 intent = getIntent();
371 } else {
372 intent = savedInstanceState.getParcelable("intent");
373 }
374 if (isViewIntent(intent)) {
375 pendingViewIntent.push(intent);
376 setIntent(createLauncherIntent(this));
377 }
378 }
379
380 @Override
381 public boolean onCreateOptionsMenu(Menu menu) {
382 getMenuInflater().inflate(R.menu.activity_conversations, menu);
383 MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);
384 if (qrCodeScanMenuItem != null) {
385 Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
386 boolean visible = getResources().getBoolean(R.bool.show_qr_code_scan)
387 && fragment != null
388 && fragment instanceof ConversationsOverviewFragment;
389 qrCodeScanMenuItem.setVisible(visible);
390 }
391 return super.onCreateOptionsMenu(menu);
392 }
393
394 @Override
395 public void onConversationSelected(Conversation conversation) {
396 if (ConversationFragment.getConversation(this) == conversation) {
397 Log.d(Config.LOGTAG,"ignore onConversationSelected() because conversation is already open");
398 return;
399 }
400 openConversation(conversation, null);
401 }
402
403 private void openConversation(Conversation conversation, Bundle extras) {
404 ConversationFragment conversationFragment = (ConversationFragment) getFragmentManager().findFragmentById(R.id.secondary_fragment);
405 final boolean mainNeedsRefresh;
406 if (conversationFragment == null) {
407 mainNeedsRefresh = false;
408 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
409 if (mainFragment != null && mainFragment instanceof ConversationFragment) {
410 conversationFragment = (ConversationFragment) mainFragment;
411 } else {
412 conversationFragment = new ConversationFragment();
413 FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
414 fragmentTransaction.replace(R.id.main_fragment, conversationFragment);
415 fragmentTransaction.addToBackStack(null);
416 fragmentTransaction.commit();
417 }
418 } else {
419 mainNeedsRefresh = true;
420 }
421 conversationFragment.reInit(conversation, extras == null ? new Bundle() : extras);
422 if (mainNeedsRefresh) {
423 refreshFragment(R.id.main_fragment);
424 } else {
425 invalidateActionBarTitle();
426 }
427 }
428
429 @Override
430 public boolean onOptionsItemSelected(MenuItem item) {
431 switch (item.getItemId()) {
432 case android.R.id.home:
433 FragmentManager fm = getFragmentManager();
434 if (fm.getBackStackEntryCount() > 0) {
435 fm.popBackStack();
436 return true;
437 }
438 break;
439 case R.id.action_scan_qr_code:
440 UriHandlerActivity.scan(this);
441 return true;
442 }
443 return super.onOptionsItemSelected(item);
444 }
445
446 @Override
447 public void onSaveInstanceState(Bundle savedInstanceState) {
448 Intent pendingIntent = pendingViewIntent.peek();
449 savedInstanceState.putParcelable("intent", pendingIntent != null ? pendingIntent : getIntent());
450 super.onSaveInstanceState(savedInstanceState);
451 }
452
453 @Override
454 protected void onStart() {
455 final int theme = findTheme();
456 if (this.mTheme != theme) {
457 this.mSkipBackgroundBinding = true;
458 recreate();
459 } else {
460 this.mSkipBackgroundBinding = false;
461 }
462 mRedirectInProcess.set(false);
463 super.onStart();
464 }
465
466 @Override
467 protected void onNewIntent(final Intent intent) {
468 if (isViewIntent(intent)) {
469 if (xmppConnectionService != null) {
470 processViewIntent(intent);
471 } else {
472 pendingViewIntent.push(intent);
473 }
474 }
475 setIntent(createLauncherIntent(this));
476 }
477
478 @Override
479 public void onPause() {
480 this.mActivityPaused = true;
481 super.onPause();
482 }
483
484 @Override
485 public void onResume() {
486 super.onResume();
487 this.mActivityPaused = false;
488 }
489
490 private void initializeFragments() {
491 FragmentTransaction transaction = getFragmentManager().beginTransaction();
492 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
493 Fragment secondaryFragment = getFragmentManager().findFragmentById(R.id.secondary_fragment);
494 if (mainFragment != null) {
495 Log.d(Config.LOGTAG, "initializeFragment(). main fragment exists");
496 if (binding.secondaryFragment != null) {
497 if (mainFragment instanceof ConversationFragment) {
498 Log.d(Config.LOGTAG, "gained secondary fragment. moving...");
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 Log.d(Config.LOGTAG, "lost secondary fragment. moving...");
512 transaction.remove(secondaryFragment);
513 transaction.commit();
514 getFragmentManager().executePendingTransactions();
515 transaction = getFragmentManager().beginTransaction();
516 transaction.replace(R.id.main_fragment, secondaryFragment);
517 transaction.addToBackStack(null);
518 transaction.commit();
519 return;
520 }
521 }
522 } else {
523 transaction.replace(R.id.main_fragment, new ConversationsOverviewFragment());
524 }
525 if (binding.secondaryFragment != null && secondaryFragment == null) {
526 transaction.replace(R.id.secondary_fragment, new ConversationFragment());
527 }
528 transaction.commit();
529 }
530
531 private void invalidateActionBarTitle() {
532 final ActionBar actionBar = getSupportActionBar();
533 if (actionBar != null) {
534 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
535 if (mainFragment != null && mainFragment instanceof ConversationFragment) {
536 final Conversation conversation = ((ConversationFragment) mainFragment).getConversation();
537 if (conversation != null) {
538 actionBar.setTitle(conversation.getName());
539 actionBar.setDisplayHomeAsUpEnabled(true);
540 return;
541 }
542 }
543 actionBar.setTitle(R.string.app_name);
544 actionBar.setDisplayHomeAsUpEnabled(false);
545 }
546 }
547
548 @Override
549 public void onConversationArchived(Conversation conversation) {
550 if (performRedirectIfNecessary(conversation, false)) {
551 return;
552 }
553 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
554 if (mainFragment != null && mainFragment instanceof ConversationFragment) {
555 getFragmentManager().popBackStack();
556 return;
557 }
558 Fragment secondaryFragment = getFragmentManager().findFragmentById(R.id.secondary_fragment);
559 if (secondaryFragment != null && secondaryFragment instanceof ConversationFragment) {
560 if (((ConversationFragment) secondaryFragment).getConversation() == conversation) {
561 Conversation suggestion = ConversationsOverviewFragment.getSuggestion(this, conversation);
562 if (suggestion != null) {
563 openConversation(suggestion, null);
564 }
565 }
566 }
567 }
568
569 @Override
570 public void onConversationsListItemUpdated() {
571 Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
572 if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
573 ((ConversationsOverviewFragment) fragment).refresh();
574 }
575 }
576
577 @Override
578 public void switchToConversation(Conversation conversation) {
579 Log.d(Config.LOGTAG,"override");
580 openConversation(conversation,null);
581 }
582
583 @Override
584 public void onConversationRead(Conversation conversation) {
585 if (!mActivityPaused && pendingViewIntent.peek() == null) {
586 xmppConnectionService.sendReadMarker(conversation);
587 } else {
588 Log.d(Config.LOGTAG,"ignoring read callback. mActivityPaused="+Boolean.toString(mActivityPaused));
589 }
590 }
591
592 @Override
593 public void onAccountUpdate() {
594 this.refreshUi();
595 }
596
597 @Override
598 public void onConversationUpdate() {
599 if (performRedirectIfNecessary(false)) {
600 return;
601 }
602 this.refreshUi();
603 }
604
605 @Override
606 public void onRosterUpdate() {
607 this.refreshUi();
608 }
609
610 @Override
611 public void OnUpdateBlocklist(OnUpdateBlocklist.Status status) {
612 this.refreshUi();
613 }
614
615 @Override
616 public void onShowErrorToast(int resId) {
617 runOnUiThread(() -> Toast.makeText(this, resId, Toast.LENGTH_SHORT).show());
618 }
619}