Search in sources :

Example 41 with Fragment

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);
}
Also used : RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) Bundle(android.os.Bundle) Fragment(androidx.fragment.app.Fragment) DialogFragment(androidx.fragment.app.DialogFragment)

Example 42 with Fragment

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);
}
Also used : Observer(androidx.lifecycle.Observer) FragmentActivity(androidx.fragment.app.FragmentActivity) VerifyIdentityActivity(org.thoughtcrime.securesms.verify.VerifyIdentityActivity) Activity(android.app.Activity) Fragment(androidx.fragment.app.Fragment) DialogFragment(androidx.fragment.app.DialogFragment)

Example 43 with Fragment

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");
        }
    }
}
Also used : NotificationProfile(org.thoughtcrime.securesms.notifications.profiles.NotificationProfile) ViewGroup(android.view.ViewGroup) RecaptchaProofBottomSheetFragment(org.thoughtcrime.securesms.ratelimit.RecaptchaProofBottomSheetFragment) Fragment(androidx.fragment.app.Fragment) DialogFragment(androidx.fragment.app.DialogFragment) CantProcessSubscriptionPaymentBottomSheetDialogFragment(org.thoughtcrime.securesms.badges.self.expired.CantProcessSubscriptionPaymentBottomSheetDialogFragment) MainFragment(org.thoughtcrime.securesms.MainFragment) NotificationProfileSelectionFragment(org.thoughtcrime.securesms.components.settings.app.notifications.manual.NotificationProfileSelectionFragment) ConversationFragment(org.thoughtcrime.securesms.conversation.ConversationFragment) ExpiredBadgeBottomSheetDialogFragment(org.thoughtcrime.securesms.badges.self.expired.ExpiredBadgeBottomSheetDialogFragment) ImageView(android.widget.ImageView) ActionMenuView(androidx.appcompat.widget.ActionMenuView) ReminderView(org.thoughtcrime.securesms.components.reminder.ReminderView) UnreadPaymentsView(org.thoughtcrime.securesms.components.UnreadPaymentsView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) VoiceNotePlayerView(org.thoughtcrime.securesms.components.voice.VoiceNotePlayerView) TextView(android.widget.TextView) BadgeImageView(org.thoughtcrime.securesms.badges.BadgeImageView)

Example 44 with Fragment

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);
}
Also used : AccountItem(com.xabber.android.data.account.AccountItem) UserJid(com.xabber.android.data.entity.UserJid) StatusBarPainter(com.xabber.android.ui.color.StatusBarPainter) TextView(android.widget.TextView) ConferenceInfoFragment(com.xabber.android.ui.fragment.ConferenceInfoFragment) Fragment(androidx.fragment.app.Fragment) ContactVcardViewerFragment(com.xabber.android.ui.fragment.ContactVcardViewerFragment) View(android.view.View) TextView(android.widget.TextView)

Example 45 with Fragment

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();
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) EmojiSearchFragment(org.thoughtcrime.securesms.keyboard.emoji.search.EmojiSearchFragment) Fragment(androidx.fragment.app.Fragment) KeyboardPagerFragment(org.thoughtcrime.securesms.keyboard.KeyboardPagerFragment)

Aggregations

Fragment (androidx.fragment.app.Fragment)262 FragmentTransaction (androidx.fragment.app.FragmentTransaction)57 Bundle (android.os.Bundle)49 FragmentManager (androidx.fragment.app.FragmentManager)42 DialogFragment (androidx.fragment.app.DialogFragment)24 FileFragment (com.owncloud.android.ui.fragment.FileFragment)23 Intent (android.content.Intent)22 View (android.view.View)22 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)20 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)20 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)19 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)18 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)18 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)18 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)18 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)18 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)18 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)18 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)18 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)18