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 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, ConversationActivity.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 Log.d(Config.LOGTAG,"process view intent");
275 String uuid = intent.getStringExtra(EXTRA_CONVERSATION);
276 Conversation conversation = uuid != null ? xmppConnectionService.findConversationByUuid(uuid) : null;
277 if (conversation == null) {
278 Log.d(Config.LOGTAG, "unable to view conversation with uuid:" + uuid);
279 return false;
280 }
281 openConversation(conversation, intent.getExtras());
282 return true;
283 }
284
285 @Override
286 public void onRequestPermissionsResult(int requestCode,@NonNull String permissions[], @NonNull int[] grantResults) {
287 UriHandlerActivity.onRequestPermissionResult(this, requestCode, grantResults);
288 if (grantResults.length > 0) {
289 if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
290 switch(requestCode) {
291 case REQUEST_OPEN_MESSAGE:
292 refreshUiReal();
293 ConversationFragment.openPendingMessage(this);
294 break;
295 case REQUEST_PLAY_PAUSE:
296 ConversationFragment.startStopPending(this);
297 break;
298 }
299 }
300 }
301 }
302
303 @Override
304 public void onActivityResult(int requestCode, int resultCode, final Intent data) {
305 super.onActivityResult(requestCode, resultCode, data);
306 ActivityResult activityResult = ActivityResult.of(requestCode, resultCode, data);
307 if (xmppConnectionService != null) {
308 handleActivityResult(activityResult);
309 } else {
310 this.postponedActivityResult.push(activityResult);
311 }
312 }
313
314 private void handleActivityResult(ActivityResult activityResult) {
315 if (activityResult.resultCode == Activity.RESULT_OK) {
316 handlePositiveActivityResult(activityResult.requestCode, activityResult.data);
317 } else {
318 handleNegativeActivityResult(activityResult.requestCode);
319 }
320 }
321
322 private void handleNegativeActivityResult(int requestCode) {
323 Conversation conversation = ConversationFragment.getConversationReliable(this);
324 switch (requestCode) {
325 case REQUEST_DECRYPT_PGP:
326 if (conversation == null) {
327 break;
328 }
329 conversation.getAccount().getPgpDecryptionService().giveUpCurrentDecryption();
330 break;
331 case REQUEST_BATTERY_OP:
332 setNeverAskForBatteryOptimizationsAgain();
333 break;
334 }
335 }
336
337 private void handlePositiveActivityResult(int requestCode, final Intent data) {
338 Log.d(Config.LOGTAG,"positive activity result");
339 Conversation conversation = ConversationFragment.getConversationReliable(this);
340 if (conversation == null) {
341 Log.d(Config.LOGTAG,"conversation not found");
342 return;
343 }
344 switch (requestCode) {
345 case REQUEST_DECRYPT_PGP:
346 conversation.getAccount().getPgpDecryptionService().continueDecryption(data);
347 break;
348 case REQUEST_CHOOSE_PGP_ID:
349 long id = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0);
350 if (id != 0) {
351 conversation.getAccount().setPgpSignId(id);
352 announcePgp(conversation.getAccount(), null, null, onOpenPGPKeyPublished);
353 } else {
354 choosePgpSignId(conversation.getAccount());
355 }
356 break;
357 case REQUEST_ANNOUNCE_PGP:
358 announcePgp(conversation.getAccount(), conversation, data, onOpenPGPKeyPublished);
359 break;
360 }
361 }
362
363 @Override
364 protected void onCreate(final Bundle savedInstanceState) {
365 super.onCreate(savedInstanceState);
366 new EmojiService(this).init();
367 this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations);
368 this.getFragmentManager().addOnBackStackChangedListener(this::invalidateActionBarTitle);
369 this.getFragmentManager().addOnBackStackChangedListener(this::showDialogsIfMainIsOverview);
370 this.initializeFragments();
371 this.invalidateActionBarTitle();
372 final Intent intent;
373 if (savedInstanceState == null) {
374 intent = getIntent();
375 } else {
376 intent = savedInstanceState.getParcelable("intent");
377 }
378 if (isViewIntent(intent)) {
379 pendingViewIntent.push(intent);
380 setIntent(createLauncherIntent(this));
381 }
382 }
383
384 @Override
385 public boolean onCreateOptionsMenu(Menu menu) {
386 getMenuInflater().inflate(R.menu.activity_conversations, menu);
387 MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);
388 if (qrCodeScanMenuItem != null) {
389 Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
390 boolean visible = getResources().getBoolean(R.bool.show_qr_code_scan)
391 && fragment != null
392 && fragment instanceof ConversationsOverviewFragment;
393 qrCodeScanMenuItem.setVisible(visible);
394 }
395 return super.onCreateOptionsMenu(menu);
396 }
397
398 @Override
399 public void onConversationSelected(Conversation conversation) {
400 if (ConversationFragment.getConversation(this) == conversation) {
401 Log.d(Config.LOGTAG,"ignore onConversationSelected() because conversation is already open");
402 return;
403 }
404 openConversation(conversation, null);
405 }
406
407 private void openConversation(Conversation conversation, Bundle extras) {
408 ConversationFragment conversationFragment = (ConversationFragment) getFragmentManager().findFragmentById(R.id.secondary_fragment);
409 final boolean mainNeedsRefresh;
410 if (conversationFragment == null) {
411 mainNeedsRefresh = false;
412 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
413 if (mainFragment != null && mainFragment instanceof ConversationFragment) {
414 conversationFragment = (ConversationFragment) mainFragment;
415 } else {
416 conversationFragment = new ConversationFragment();
417 FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
418 fragmentTransaction.replace(R.id.main_fragment, conversationFragment);
419 fragmentTransaction.addToBackStack(null);
420 fragmentTransaction.commit();
421 }
422 } else {
423 mainNeedsRefresh = true;
424 }
425 conversationFragment.reInit(conversation, extras == null ? new Bundle() : extras);
426 if (mainNeedsRefresh) {
427 refreshFragment(R.id.main_fragment);
428 } else {
429 invalidateActionBarTitle();
430 }
431 }
432
433 @Override
434 public boolean onOptionsItemSelected(MenuItem item) {
435 switch (item.getItemId()) {
436 case android.R.id.home:
437 FragmentManager fm = getFragmentManager();
438 if (fm.getBackStackEntryCount() > 0) {
439 fm.popBackStack();
440 return true;
441 }
442 break;
443 case R.id.action_scan_qr_code:
444 UriHandlerActivity.scan(this);
445 return true;
446 }
447 return super.onOptionsItemSelected(item);
448 }
449
450 @Override
451 public void onSaveInstanceState(Bundle savedInstanceState) {
452 Intent pendingIntent = pendingViewIntent.peek();
453 savedInstanceState.putParcelable("intent", pendingIntent != null ? pendingIntent : getIntent());
454 super.onSaveInstanceState(savedInstanceState);
455 }
456
457 @Override
458 protected void onStart() {
459 final int theme = findTheme();
460 if (this.mTheme != theme) {
461 this.mSkipBackgroundBinding = true;
462 recreate();
463 } else {
464 this.mSkipBackgroundBinding = false;
465 }
466 mRedirectInProcess.set(false);
467 super.onStart();
468 }
469
470 @Override
471 protected void onNewIntent(final Intent intent) {
472 if (isViewIntent(intent)) {
473 if (xmppConnectionService != null) {
474 processViewIntent(intent);
475 } else {
476 pendingViewIntent.push(intent);
477 }
478 }
479 setIntent(createLauncherIntent(this));
480 }
481
482 @Override
483 public void onPause() {
484 this.mActivityPaused = true;
485 super.onPause();
486 }
487
488 @Override
489 public void onResume() {
490 super.onResume();
491 this.mActivityPaused = false;
492 }
493
494 private void initializeFragments() {
495 FragmentTransaction transaction = getFragmentManager().beginTransaction();
496 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
497 Fragment secondaryFragment = getFragmentManager().findFragmentById(R.id.secondary_fragment);
498 if (mainFragment != null) {
499 Log.d(Config.LOGTAG, "initializeFragment(). main fragment exists");
500 if (binding.secondaryFragment != null) {
501 if (mainFragment instanceof ConversationFragment) {
502 Log.d(Config.LOGTAG, "gained secondary fragment. moving...");
503 getFragmentManager().popBackStack();
504 transaction.remove(mainFragment);
505 transaction.commit();
506 getFragmentManager().executePendingTransactions();
507 transaction = getFragmentManager().beginTransaction();
508 transaction.replace(R.id.secondary_fragment, mainFragment);
509 transaction.replace(R.id.main_fragment, new ConversationsOverviewFragment());
510 transaction.commit();
511 return;
512 }
513 } else {
514 if (secondaryFragment != null && secondaryFragment instanceof ConversationFragment) {
515 Log.d(Config.LOGTAG, "lost secondary fragment. moving...");
516 transaction.remove(secondaryFragment);
517 transaction.commit();
518 getFragmentManager().executePendingTransactions();
519 transaction = getFragmentManager().beginTransaction();
520 transaction.replace(R.id.main_fragment, secondaryFragment);
521 transaction.addToBackStack(null);
522 transaction.commit();
523 return;
524 }
525 }
526 } else {
527 transaction.replace(R.id.main_fragment, new ConversationsOverviewFragment());
528 }
529 if (binding.secondaryFragment != null && secondaryFragment == null) {
530 transaction.replace(R.id.secondary_fragment, new ConversationFragment());
531 }
532 transaction.commit();
533 }
534
535 private void invalidateActionBarTitle() {
536 final ActionBar actionBar = getSupportActionBar();
537 if (actionBar != null) {
538 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
539 if (mainFragment != null && mainFragment instanceof ConversationFragment) {
540 final Conversation conversation = ((ConversationFragment) mainFragment).getConversation();
541 if (conversation != null) {
542 actionBar.setTitle(conversation.getName());
543 actionBar.setDisplayHomeAsUpEnabled(true);
544 return;
545 }
546 }
547 actionBar.setTitle(R.string.app_name);
548 actionBar.setDisplayHomeAsUpEnabled(false);
549 }
550 }
551
552 @Override
553 public void onConversationArchived(Conversation conversation) {
554 if (performRedirectIfNecessary(conversation, false)) {
555 return;
556 }
557 Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
558 if (mainFragment != null && mainFragment instanceof ConversationFragment) {
559 getFragmentManager().popBackStack();
560 return;
561 }
562 Fragment secondaryFragment = getFragmentManager().findFragmentById(R.id.secondary_fragment);
563 if (secondaryFragment != null && secondaryFragment instanceof ConversationFragment) {
564 if (((ConversationFragment) secondaryFragment).getConversation() == conversation) {
565 Conversation suggestion = ConversationsOverviewFragment.getSuggestion(this, conversation);
566 if (suggestion != null) {
567 openConversation(suggestion, null);
568 }
569 }
570 }
571 }
572
573 @Override
574 public void onConversationsListItemUpdated() {
575 Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
576 if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
577 ((ConversationsOverviewFragment) fragment).refresh();
578 }
579 }
580
581 @Override
582 public void switchToConversation(Conversation conversation) {
583 Log.d(Config.LOGTAG,"override");
584 openConversation(conversation,null);
585 }
586
587 @Override
588 public void onConversationRead(Conversation conversation) {
589 if (!mActivityPaused && pendingViewIntent.peek() == null) {
590 xmppConnectionService.sendReadMarker(conversation);
591 } else {
592 Log.d(Config.LOGTAG,"ignoring read callback. mActivityPaused="+Boolean.toString(mActivityPaused));
593 }
594 }
595
596 @Override
597 public void onAccountUpdate() {
598 this.refreshUi();
599 }
600
601 @Override
602 public void onConversationUpdate() {
603 if (performRedirectIfNecessary(false)) {
604 return;
605 }
606 this.refreshUi();
607 }
608
609 @Override
610 public void onRosterUpdate() {
611 this.refreshUi();
612 }
613
614 @Override
615 public void OnUpdateBlocklist(OnUpdateBlocklist.Status status) {
616 this.refreshUi();
617 }
618
619 @Override
620 public void onShowErrorToast(int resId) {
621 runOnUiThread(() -> Toast.makeText(this, resId, Toast.LENGTH_SHORT).show());
622 }
623}