ConversationsActivity.java

  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.OnBackendConnected;
 67import eu.siacs.conversations.ui.interfaces.OnConversationArchived;
 68import eu.siacs.conversations.ui.interfaces.OnConversationRead;
 69import eu.siacs.conversations.ui.interfaces.OnConversationSelected;
 70import eu.siacs.conversations.ui.interfaces.OnConversationsListItemUpdated;
 71import eu.siacs.conversations.ui.service.EmojiService;
 72import eu.siacs.conversations.ui.util.ActivityResult;
 73import eu.siacs.conversations.ui.util.PendingItem;
 74import eu.siacs.conversations.utils.ExceptionHelper;
 75import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
 76
 77import static eu.siacs.conversations.ui.ConversationFragment.REQUEST_DECRYPT_PGP;
 78
 79public class ConversationsActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast {
 80
 81	public static final String ACTION_VIEW_CONVERSATION = "eu.siacs.conversations.action.VIEW";
 82	public static final String EXTRA_CONVERSATION = "conversationUuid";
 83	public static final String EXTRA_DOWNLOAD_UUID = "eu.siacs.conversations.download_uuid";
 84	public static final String EXTRA_TEXT = "text";
 85	public static final String EXTRA_NICK = "nick";
 86	public static final String EXTRA_IS_PRIVATE_MESSAGE = "pm";
 87
 88	public static final int REQUEST_OPEN_MESSAGE = 0x9876;
 89	public static final int REQUEST_PLAY_PAUSE = 0x5432;
 90
 91
 92	//secondary fragment (when holding the conversation, must be initialized before refreshing the overview fragment
 93	private static final @IdRes
 94	int[] FRAGMENT_ID_NOTIFICATION_ORDER = {R.id.secondary_fragment, R.id.main_fragment};
 95	private final PendingItem<Intent> pendingViewIntent = new PendingItem<>();
 96	private final PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
 97	private ActivityConversationsBinding binding;
 98	private boolean mActivityPaused = true;
 99	private AtomicBoolean mRedirectInProcess = new AtomicBoolean(false);
100
101	private static boolean isViewIntent(Intent i) {
102		return i != null && ACTION_VIEW_CONVERSATION.equals(i.getAction()) && i.hasExtra(EXTRA_CONVERSATION);
103	}
104
105	private static Intent createLauncherIntent(Context context) {
106		final Intent intent = new Intent(context, ConversationsActivity.class);
107		intent.setAction(Intent.ACTION_MAIN);
108		intent.addCategory(Intent.CATEGORY_LAUNCHER);
109		return intent;
110	}
111
112	@Override
113	protected void refreshUiReal() {
114		for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
115			refreshFragment(id);
116		}
117	}
118
119	@Override
120	void onBackendConnected() {
121		if (performRedirectIfNecessary(true)) {
122			return;
123		}
124		xmppConnectionService.getNotificationService().setIsInForeground(true);
125		Intent intent = pendingViewIntent.pop();
126		if (intent != null) {
127			if (processViewIntent(intent)) {
128				if (binding.secondaryFragment != null) {
129					notifyFragmentOfBackendConnected(R.id.main_fragment);
130				}
131				invalidateActionBarTitle();
132				return;
133			}
134		}
135		for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
136			notifyFragmentOfBackendConnected(id);
137		}
138
139		ActivityResult activityResult = postponedActivityResult.pop();
140		if (activityResult != null) {
141			handleActivityResult(activityResult);
142		}
143
144		invalidateActionBarTitle();
145		if (binding.secondaryFragment != null && ConversationFragment.getConversation(this) == null) {
146			Conversation conversation = ConversationsOverviewFragment.getSuggestion(this);
147			if (conversation != null) {
148				openConversation(conversation, null);
149			}
150		}
151		showDialogsIfMainIsOverview();
152	}
153
154	private boolean performRedirectIfNecessary(boolean noAnimation) {
155		return performRedirectIfNecessary(null, noAnimation);
156	}
157
158	private boolean performRedirectIfNecessary(final Conversation ignore, final boolean noAnimation) {
159		if (xmppConnectionService == null) {
160			return false;
161		}
162		boolean isConversationsListEmpty = xmppConnectionService.isConversationsListEmpty(ignore);
163		if (isConversationsListEmpty && mRedirectInProcess.compareAndSet(false, true)) {
164			final Intent intent = getRedirectionIntent(noAnimation);
165			runOnUiThread(() -> {
166				startActivity(intent);
167				if (noAnimation) {
168					overridePendingTransition(0, 0);
169				}
170			});
171		}
172		return mRedirectInProcess.get();
173	}
174
175	private Intent getRedirectionIntent(boolean noAnimation) {
176		Account pendingAccount = xmppConnectionService.getPendingAccount();
177		Intent intent;
178		if (pendingAccount != null) {
179			intent = new Intent(this, EditAccountActivity.class);
180			intent.putExtra("jid", pendingAccount.getJid().asBareJid().toString());
181		} else {
182			if (xmppConnectionService.getAccounts().size() == 0) {
183				if (Config.X509_VERIFICATION) {
184					intent = new Intent(this, ManageAccountActivity.class);
185				} else if (Config.MAGIC_CREATE_DOMAIN != null) {
186					intent = new Intent(this, WelcomeActivity.class);
187					WelcomeActivity.addInviteUri(intent, getIntent());
188				} else {
189					intent = new Intent(this, EditAccountActivity.class);
190				}
191			} else {
192				intent = new Intent(this, StartConversationActivity.class);
193			}
194		}
195		intent.putExtra("init", true);
196		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
197		if (noAnimation) {
198			intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
199		}
200		return intent;
201	}
202
203	private void showDialogsIfMainIsOverview() {
204		if (xmppConnectionService == null) {
205			return;
206		}
207		final Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
208		if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
209			if (ExceptionHelper.checkForCrash(this)) {
210				return;
211			}
212			openBatteryOptimizationDialogIfNeeded();
213		}
214	}
215
216	private String getBatteryOptimizationPreferenceKey() {
217		@SuppressLint("HardwareIds") String device = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
218		return "show_battery_optimization" + (device == null ? "" : device);
219	}
220
221	private void setNeverAskForBatteryOptimizationsAgain() {
222		getPreferences().edit().putBoolean(getBatteryOptimizationPreferenceKey(), false).apply();
223	}
224
225	private void openBatteryOptimizationDialogIfNeeded() {
226		if (hasAccountWithoutPush()
227				&& isOptimizingBattery()
228				&& getPreferences().getBoolean(getBatteryOptimizationPreferenceKey(), true)) {
229			AlertDialog.Builder builder = new AlertDialog.Builder(this);
230			builder.setTitle(R.string.battery_optimizations_enabled);
231			builder.setMessage(R.string.battery_optimizations_enabled_dialog);
232			builder.setPositiveButton(R.string.next, (dialog, which) -> {
233				Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
234				Uri uri = Uri.parse("package:" + getPackageName());
235				intent.setData(uri);
236				try {
237					startActivityForResult(intent, REQUEST_BATTERY_OP);
238				} catch (ActivityNotFoundException e) {
239					Toast.makeText(this, R.string.device_does_not_support_battery_op, Toast.LENGTH_SHORT).show();
240				}
241			});
242			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
243				builder.setOnDismissListener(dialog -> setNeverAskForBatteryOptimizationsAgain());
244			}
245			AlertDialog dialog = builder.create();
246			dialog.setCanceledOnTouchOutside(false);
247			dialog.show();
248		}
249	}
250
251	private boolean hasAccountWithoutPush() {
252		for (Account account : xmppConnectionService.getAccounts()) {
253			if (account.getStatus() == Account.State.ONLINE && !xmppConnectionService.getPushManagementService().available(account)) {
254				return true;
255			}
256		}
257		return false;
258	}
259
260	private void notifyFragmentOfBackendConnected(@IdRes int id) {
261		final Fragment fragment = getFragmentManager().findFragmentById(id);
262		if (fragment != null && fragment instanceof OnBackendConnected) {
263			((OnBackendConnected) fragment).onBackendConnected();
264		}
265	}
266
267	private void refreshFragment(@IdRes int id) {
268		final Fragment fragment = getFragmentManager().findFragmentById(id);
269		if (fragment != null && fragment instanceof XmppFragment) {
270			((XmppFragment) fragment).refresh();
271		}
272	}
273
274	private boolean processViewIntent(Intent 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		Conversation conversation = ConversationFragment.getConversationReliable(this);
339		if (conversation == null) {
340			Log.d(Config.LOGTAG,"conversation not found");
341			return;
342		}
343		switch (requestCode) {
344			case REQUEST_DECRYPT_PGP:
345				conversation.getAccount().getPgpDecryptionService().continueDecryption(data);
346				break;
347			case REQUEST_CHOOSE_PGP_ID:
348				long id = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0);
349				if (id != 0) {
350					conversation.getAccount().setPgpSignId(id);
351					announcePgp(conversation.getAccount(), null, null, onOpenPGPKeyPublished);
352				} else {
353					choosePgpSignId(conversation.getAccount());
354				}
355				break;
356			case REQUEST_ANNOUNCE_PGP:
357				announcePgp(conversation.getAccount(), conversation, data, onOpenPGPKeyPublished);
358				break;
359		}
360	}
361
362	@Override
363	protected void onCreate(final Bundle savedInstanceState) {
364		super.onCreate(savedInstanceState);
365		new EmojiService(this).init();
366		this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations);
367		this.getFragmentManager().addOnBackStackChangedListener(this::invalidateActionBarTitle);
368		this.getFragmentManager().addOnBackStackChangedListener(this::showDialogsIfMainIsOverview);
369		this.initializeFragments();
370		this.invalidateActionBarTitle();
371		final Intent intent;
372		if (savedInstanceState == null) {
373			intent = getIntent();
374		} else {
375			intent = savedInstanceState.getParcelable("intent");
376		}
377		if (isViewIntent(intent)) {
378			pendingViewIntent.push(intent);
379			setIntent(createLauncherIntent(this));
380		}
381	}
382
383	@Override
384	public boolean onCreateOptionsMenu(Menu menu) {
385		getMenuInflater().inflate(R.menu.activity_conversations, menu);
386		MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);
387		if (qrCodeScanMenuItem != null) {
388			if (isCameraFeatureAvailable()) {
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			} else {
395				qrCodeScanMenuItem.setVisible(false);
396			}
397		}
398		return super.onCreateOptionsMenu(menu);
399	}
400
401	@Override
402	public void onConversationSelected(Conversation conversation) {
403		if (ConversationFragment.getConversation(this) == conversation) {
404			Log.d(Config.LOGTAG,"ignore onConversationSelected() because conversation is already open");
405			return;
406		}
407		openConversation(conversation, null);
408	}
409
410	private void openConversation(Conversation conversation, Bundle extras) {
411		ConversationFragment conversationFragment = (ConversationFragment) getFragmentManager().findFragmentById(R.id.secondary_fragment);
412		final boolean mainNeedsRefresh;
413		if (conversationFragment == null) {
414			mainNeedsRefresh = false;
415			Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
416			if (mainFragment != null && mainFragment instanceof ConversationFragment) {
417				conversationFragment = (ConversationFragment) mainFragment;
418			} else {
419				conversationFragment = new ConversationFragment();
420				FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
421				fragmentTransaction.replace(R.id.main_fragment, conversationFragment);
422				fragmentTransaction.addToBackStack(null);
423				fragmentTransaction.commit();
424			}
425		} else {
426			mainNeedsRefresh = true;
427		}
428		conversationFragment.reInit(conversation, extras == null ? new Bundle() : extras);
429		if (mainNeedsRefresh) {
430			refreshFragment(R.id.main_fragment);
431		} else {
432			invalidateActionBarTitle();
433		}
434	}
435
436	@Override
437	public boolean onOptionsItemSelected(MenuItem item) {
438		switch (item.getItemId()) {
439			case android.R.id.home:
440				FragmentManager fm = getFragmentManager();
441				if (fm.getBackStackEntryCount() > 0) {
442					fm.popBackStack();
443					return true;
444				}
445				break;
446			case R.id.action_scan_qr_code:
447				UriHandlerActivity.scan(this);
448				return true;
449		}
450		return super.onOptionsItemSelected(item);
451	}
452
453	@Override
454	public void onSaveInstanceState(Bundle savedInstanceState) {
455		Intent pendingIntent = pendingViewIntent.peek();
456		savedInstanceState.putParcelable("intent", pendingIntent != null ? pendingIntent : getIntent());
457		super.onSaveInstanceState(savedInstanceState);
458	}
459
460	@Override
461	protected void onStart() {
462		final int theme = findTheme();
463		if (this.mTheme != theme) {
464			this.mSkipBackgroundBinding = true;
465			recreate();
466		} else {
467			this.mSkipBackgroundBinding = false;
468		}
469		mRedirectInProcess.set(false);
470		super.onStart();
471	}
472
473	@Override
474	protected void onNewIntent(final Intent intent) {
475		if (isViewIntent(intent)) {
476			if (xmppConnectionService != null) {
477				processViewIntent(intent);
478			} else {
479				pendingViewIntent.push(intent);
480			}
481		}
482		setIntent(createLauncherIntent(this));
483	}
484
485	@Override
486	public void onPause() {
487		this.mActivityPaused = true;
488		super.onPause();
489	}
490
491	@Override
492	public void onResume() {
493		super.onResume();
494		this.mActivityPaused = false;
495	}
496
497	private void initializeFragments() {
498		FragmentTransaction transaction = getFragmentManager().beginTransaction();
499		Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
500		Fragment secondaryFragment = getFragmentManager().findFragmentById(R.id.secondary_fragment);
501		if (mainFragment != null) {
502			if (binding.secondaryFragment != null) {
503				if (mainFragment instanceof ConversationFragment) {
504					getFragmentManager().popBackStack();
505					transaction.remove(mainFragment);
506					transaction.commit();
507					getFragmentManager().executePendingTransactions();
508					transaction = getFragmentManager().beginTransaction();
509					transaction.replace(R.id.secondary_fragment, mainFragment);
510					transaction.replace(R.id.main_fragment, new ConversationsOverviewFragment());
511					transaction.commit();
512					return;
513				}
514			} else {
515				if (secondaryFragment != null && secondaryFragment instanceof ConversationFragment) {
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}