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