use of androidx.fragment.app.Fragment in project Signal-Android by WhisperSystems.
the class SafetyNumberChangeDialog method showForDuringGroupCall.
public static void showForDuringGroupCall(@NonNull FragmentManager fragmentManager, @NonNull Collection<RecipientId> recipientIds) {
Fragment previous = fragmentManager.findFragmentByTag(SAFETY_NUMBER_DIALOG);
if (previous != null) {
((SafetyNumberChangeDialog) previous).updateRecipients(recipientIds);
return;
}
List<String> ids = Stream.of(recipientIds).map(RecipientId::serialize).distinct().toList();
Bundle arguments = new Bundle();
arguments.putStringArray(RECIPIENT_IDS_EXTRA, ids.toArray(new String[0]));
arguments.putInt(CONTINUE_TEXT_RESOURCE_EXTRA, R.string.safety_number_change_dialog__continue_call);
arguments.putInt(CANCEL_TEXT_RESOURCE_EXTRA, R.string.safety_number_change_dialog__leave_call);
SafetyNumberChangeDialog fragment = new SafetyNumberChangeDialog();
fragment.setArguments(arguments);
fragment.show(fragmentManager, SAFETY_NUMBER_DIALOG);
}
use of androidx.fragment.app.Fragment in project Signal-Android by WhisperSystems.
the class SafetyNumberChangeDialog method handleSendAnyway.
private void handleSendAnyway(DialogInterface dialogInterface, int which) {
Log.d(TAG, "handleSendAnyway");
boolean skipCallbacks = requireArguments().getBoolean(SKIP_CALLBACKS_EXTRA, false);
Activity activity = getActivity();
Callback callback;
if (activity instanceof Callback && !skipCallbacks) {
callback = (Callback) activity;
} else {
Fragment parent = getParentFragment();
if (parent instanceof Callback && !skipCallbacks) {
callback = (Callback) parent;
} else {
callback = null;
}
}
LiveData<TrustAndVerifyResult> trustOrVerifyResultLiveData = viewModel.trustOrVerifyChangedRecipients();
Observer<TrustAndVerifyResult> observer = new Observer<TrustAndVerifyResult>() {
@Override
public void onChanged(TrustAndVerifyResult result) {
if (callback != null) {
switch(result.getResult()) {
case TRUST_AND_VERIFY:
Log.d(TAG, "Trust and verify");
callback.onSendAnywayAfterSafetyNumberChange(result.getChangedRecipients());
break;
case TRUST_VERIFY_AND_RESEND:
Log.d(TAG, "Trust, verify, and resent");
callback.onMessageResentAfterSafetyNumberChange();
break;
}
}
trustOrVerifyResultLiveData.removeObserver(this);
}
};
trustOrVerifyResultLiveData.observeForever(observer);
}
use of androidx.fragment.app.Fragment in project Signal-Android by WhisperSystems.
the class ConversationListFragment method updateNotificationProfileStatus.
private void updateNotificationProfileStatus(@NonNull List<NotificationProfile> notificationProfiles) {
NotificationProfile activeProfile = NotificationProfiles.getActiveProfile(notificationProfiles);
if (activeProfile != null) {
if (activeProfile.getId() != SignalStore.notificationProfileValues().getLastProfilePopup()) {
requireView().postDelayed(() -> {
SignalStore.notificationProfileValues().setLastProfilePopup(activeProfile.getId());
SignalStore.notificationProfileValues().setLastProfilePopupTime(System.currentTimeMillis());
if (previousTopToastPopup != null && previousTopToastPopup.isShowing()) {
previousTopToastPopup.dismiss();
}
ViewGroup view = ((ViewGroup) requireView());
Fragment fragment = getParentFragmentManager().findFragmentByTag(BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG);
if (fragment != null && fragment.isAdded() && fragment.getView() != null) {
view = ((ViewGroup) fragment.requireView());
}
try {
previousTopToastPopup = TopToastPopup.show(view, R.drawable.ic_moon_16, getString(R.string.ConversationListFragment__s_on, activeProfile.getName()));
} catch (Exception e) {
Log.w(TAG, "Unable to show toast popup", e);
}
}, 500L);
}
notificationProfileStatus.setVisibility(View.VISIBLE);
} else {
notificationProfileStatus.setVisibility(View.GONE);
}
if (!SignalStore.notificationProfileValues().getHasSeenTooltip() && Util.hasItems(notificationProfiles)) {
View target = findOverflowMenuButton(getToolbar(requireView()));
if (target != null) {
TooltipPopup.forTarget(target).setText(R.string.ConversationListFragment__turn_your_notification_profile_on_or_off_here).setBackgroundTint(ContextCompat.getColor(requireContext(), R.color.signal_button_primary)).setTextColor(ContextCompat.getColor(requireContext(), R.color.signal_button_primary_text)).setOnDismissListener(() -> SignalStore.notificationProfileValues().setHasSeenTooltip(true)).show(POSITION_BELOW);
} else {
Log.w(TAG, "Unable to find overflow menu to show Notification Profile tooltip");
}
}
}
use of androidx.fragment.app.Fragment in project xabber-android by redsolution.
the class ContactActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
account = getAccount(getIntent());
user = getUser(getIntent());
AccountItem accountItem = AccountManager.getInstance().getAccount(this.account);
if (accountItem == null) {
LogManager.e(LOG_TAG, "Account item is null " + account);
finish();
return;
}
if (user != null && user.getBareJid().equals(account.getFullJid().asBareJid())) {
try {
user = UserJid.from(accountItem.getRealJid().asBareJid());
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
}
}
if (account == null || user == null) {
Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
finish();
return;
}
setContentView(R.layout.activity_contact);
if (savedInstanceState == null) {
Fragment fragment;
if (MUCManager.getInstance().hasRoom(account, user)) {
fragment = ConferenceInfoFragment.newInstance(account, user.getJid().asEntityBareJidIfPossible());
} else {
fragment = ContactVcardViewerFragment.newInstance(account, user);
}
getSupportFragmentManager().beginTransaction().add(R.id.scrollable_container, fragment).commit();
}
bestContact = RosterManager.getInstance().getBestContact(account, user);
toolbar = (Toolbar) findViewById(R.id.toolbar_default);
toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
StatusBarPainter statusBarPainter = new StatusBarPainter(this);
statusBarPainter.updateWithAccountName(account);
final int accountMainColor = ColorManager.getInstance().getAccountPainter().getAccountMainColor(account);
contactTitleView = findViewById(R.id.contact_title_expanded);
findViewById(R.id.ivStatus).setVisibility(View.GONE);
contactTitleView.setBackgroundColor(accountMainColor);
TextView contactNameView = (TextView) findViewById(R.id.name);
contactNameView.setVisibility(View.INVISIBLE);
collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbar.setTitle(bestContact.getName());
collapsingToolbar.setBackgroundColor(accountMainColor);
collapsingToolbar.setContentScrimColor(accountMainColor);
}
use of androidx.fragment.app.Fragment in project Signal-Android by WhisperSystems.
the class MediaKeyboard method onCloseEmojiSearchInternal.
private void onCloseEmojiSearchInternal(boolean showAfterCommit) {
if (keyboardState == State.NORMAL) {
return;
}
keyboardState = State.NORMAL;
Fragment emojiSearch = fragmentManager.findFragmentByTag(EMOJI_SEARCH);
if (emojiSearch == null) {
return;
}
FragmentTransaction transaction = fragmentManager.beginTransaction().remove(emojiSearch).show(keyboardPagerFragment).setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
if (showAfterCommit) {
transaction.runOnCommit(() -> show(latestKeyboardHeight, false));
}
transaction.commitAllowingStateLoss();
}
Aggregations