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			Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
389			boolean visible = getResources().getBoolean(R.bool.show_qr_code_scan)
390					&& fragment != null
391					&& fragment instanceof ConversationsOverviewFragment;
392			qrCodeScanMenuItem.setVisible(visible);
393		}
394		return super.onCreateOptionsMenu(menu);
395	}
396
397	@Override
398	public void onConversationSelected(Conversation conversation) {
399		if (ConversationFragment.getConversation(this) == conversation) {
400			Log.d(Config.LOGTAG,"ignore onConversationSelected() because conversation is already open");
401			return;
402		}
403		openConversation(conversation, null);
404	}
405
406	private void openConversation(Conversation conversation, Bundle extras) {
407		ConversationFragment conversationFragment = (ConversationFragment) getFragmentManager().findFragmentById(R.id.secondary_fragment);
408		final boolean mainNeedsRefresh;
409		if (conversationFragment == null) {
410			mainNeedsRefresh = false;
411			Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
412			if (mainFragment != null && mainFragment instanceof ConversationFragment) {
413				conversationFragment = (ConversationFragment) mainFragment;
414			} else {
415				conversationFragment = new ConversationFragment();
416				FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
417				fragmentTransaction.replace(R.id.main_fragment, conversationFragment);
418				fragmentTransaction.addToBackStack(null);
419				fragmentTransaction.commit();
420			}
421		} else {
422			mainNeedsRefresh = true;
423		}
424		conversationFragment.reInit(conversation, extras == null ? new Bundle() : extras);
425		if (mainNeedsRefresh) {
426			refreshFragment(R.id.main_fragment);
427		} else {
428			invalidateActionBarTitle();
429		}
430	}
431
432	@Override
433	public boolean onOptionsItemSelected(MenuItem item) {
434		switch (item.getItemId()) {
435			case android.R.id.home:
436				FragmentManager fm = getFragmentManager();
437				if (fm.getBackStackEntryCount() > 0) {
438					fm.popBackStack();
439					return true;
440				}
441				break;
442			case R.id.action_scan_qr_code:
443				UriHandlerActivity.scan(this);
444				return true;
445		}
446		return super.onOptionsItemSelected(item);
447	}
448
449	@Override
450	public void onSaveInstanceState(Bundle savedInstanceState) {
451		Intent pendingIntent = pendingViewIntent.peek();
452		savedInstanceState.putParcelable("intent", pendingIntent != null ? pendingIntent : getIntent());
453		super.onSaveInstanceState(savedInstanceState);
454	}
455
456	@Override
457	protected void onStart() {
458		final int theme = findTheme();
459		if (this.mTheme != theme) {
460			this.mSkipBackgroundBinding = true;
461			recreate();
462		} else {
463			this.mSkipBackgroundBinding = false;
464		}
465		mRedirectInProcess.set(false);
466		super.onStart();
467	}
468
469	@Override
470	protected void onNewIntent(final Intent intent) {
471		if (isViewIntent(intent)) {
472			if (xmppConnectionService != null) {
473				processViewIntent(intent);
474			} else {
475				pendingViewIntent.push(intent);
476			}
477		}
478		setIntent(createLauncherIntent(this));
479	}
480
481	@Override
482	public void onPause() {
483		this.mActivityPaused = true;
484		super.onPause();
485	}
486
487	@Override
488	public void onResume() {
489		super.onResume();
490		this.mActivityPaused = false;
491	}
492
493	private void initializeFragments() {
494		FragmentTransaction transaction = getFragmentManager().beginTransaction();
495		Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
496		Fragment secondaryFragment = getFragmentManager().findFragmentById(R.id.secondary_fragment);
497		if (mainFragment != null) {
498			if (binding.secondaryFragment != null) {
499				if (mainFragment instanceof ConversationFragment) {
500					getFragmentManager().popBackStack();
501					transaction.remove(mainFragment);
502					transaction.commit();
503					getFragmentManager().executePendingTransactions();
504					transaction = getFragmentManager().beginTransaction();
505					transaction.replace(R.id.secondary_fragment, mainFragment);
506					transaction.replace(R.id.main_fragment, new ConversationsOverviewFragment());
507					transaction.commit();
508					return;
509				}
510			} else {
511				if (secondaryFragment != null && secondaryFragment instanceof ConversationFragment) {
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}