Search in sources :

Example 1 with OnBackPressedCallback

use of androidx.activity.OnBackPressedCallback in project Signal-Android by WhisperSystems.

the class BaseAccountLockedFragment method onViewCreated.

@Override
@CallSuper
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    TextView description = view.findViewById(R.id.account_locked_description);
    BaseRegistrationViewModel viewModel = getViewModel();
    viewModel.getLockedTimeRemaining().observe(getViewLifecycleOwner(), t -> description.setText(getString(R.string.AccountLockedFragment__your_account_has_been_locked_to_protect_your_privacy, durationToDays(t))));
    view.findViewById(R.id.account_locked_next).setOnClickListener(v -> onNext());
    view.findViewById(R.id.account_locked_learn_more).setOnClickListener(v -> learnMore());
    requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {

        @Override
        public void handleOnBackPressed() {
            onNext();
        }
    });
}
Also used : BaseRegistrationViewModel(org.thoughtcrime.securesms.registration.viewmodel.BaseRegistrationViewModel) OnBackPressedCallback(androidx.activity.OnBackPressedCallback) TextView(android.widget.TextView) CallSuper(androidx.annotation.CallSuper)

Example 2 with OnBackPressedCallback

use of androidx.activity.OnBackPressedCallback in project Signal-Android by WhisperSystems.

the class NewDeviceTransferCompleteFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {

        @Override
        public void handleOnBackPressed() {
        }
    });
}
Also used : OnBackPressedCallback(androidx.activity.OnBackPressedCallback)

Example 3 with OnBackPressedCallback

use of androidx.activity.OnBackPressedCallback in project Signal-Android by signalapp.

the class ConversationParentFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    if (requireActivity() instanceof Callback) {
        callback = (Callback) requireActivity();
    } else if (getParentFragment() instanceof Callback) {
        callback = (Callback) getParentFragment();
    } else {
        throw new ClassCastException("Cannot cast activity or parent fragment into a Callback object");
    }
    // TODO [alex] LargeScreenSupport -- This check will no longer be valid / necessary
    if (ConversationIntents.isInvalid(requireActivity().getIntent())) {
        Log.w(TAG, "[onCreate] Missing recipientId!");
        // TODO [greyson] Navigation
        startActivity(MainActivity.clearTop(requireContext()));
        requireActivity().finish();
        return;
    }
    isDefaultSms = Util.isDefaultSmsProvider(requireContext());
    voiceNoteMediaController = new VoiceNoteMediaController(requireActivity());
    voiceRecorderWakeLock = new VoiceRecorderWakeLock(requireActivity());
    // TODO [alex] LargeScreenSupport -- Should be removed once we move to multi-pane layout.
    new FullscreenHelper(requireActivity()).showSystemUI();
    // TODO [alex] LargeScreenSupport -- This will need to be built from requireArguments()
    ConversationIntents.Args args = ConversationIntents.Args.from(requireActivity().getIntent());
    isSearchRequested = args.isWithSearchOpen();
    reportShortcutLaunch(args.getRecipientId());
    requireActivity().getWindow().getDecorView().setBackgroundResource(R.color.signal_background_primary);
    fragment = (ConversationFragment) getChildFragmentManager().findFragmentById(R.id.fragment_content);
    if (fragment == null) {
        fragment = new ConversationFragment();
        getChildFragmentManager().beginTransaction().replace(R.id.fragment_content, fragment).commitNow();
    }
    final boolean typingIndicatorsEnabled = TextSecurePreferences.isTypingIndicatorsEnabled(requireContext());
    initializeReceivers();
    initializeViews(view);
    updateWallpaper(args.getWallpaper());
    initializeResources(args);
    initializeLinkPreviewObserver();
    initializeSearchObserver();
    initializeStickerObserver();
    initializeViewModel(args);
    initializeGroupViewModel();
    initializeMentionsViewModel();
    initializeGroupCallViewModel();
    initializeDraftViewModel();
    initializeEnabledCheck();
    initializePendingRequestsBanner();
    initializeGroupV1MigrationsBanners();
    initializeSecurity(recipient.get().isRegistered(), isDefaultSms).addListener(new AssertedSuccessListener<Boolean>() {

        @Override
        public void onSuccess(Boolean result) {
            if (getActivity() == null) {
                Log.w(TAG, "Activity is not attached. Not proceeding with initialization.");
                return;
            }
            if (requireActivity().isFinishing()) {
                Log.w(TAG, "Activity is finishing. Not proceeding with initialization.");
                return;
            }
            initializeProfiles();
            initializeGv1Migration();
            initializeDraft(args).addListener(new AssertedSuccessListener<Boolean>() {

                @Override
                public void onSuccess(Boolean loadedDraft) {
                    if (loadedDraft != null && loadedDraft) {
                        Log.i(TAG, "Finished loading draft");
                        ThreadUtil.runOnMain(() -> {
                            if (fragment != null && fragment.isResumed()) {
                                fragment.moveToLastSeen();
                            } else {
                                Log.w(TAG, "Wanted to move to the last seen position, but the fragment was in an invalid state");
                            }
                        });
                    }
                    if (typingIndicatorsEnabled) {
                        composeText.addTextChangedListener(typingTextWatcher);
                    }
                    composeText.setSelection(composeText.length(), composeText.length());
                    screenInitialized = true;
                }
            });
        }
    });
    initializeInsightObserver();
    initializeActionBar();
    requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {

        @Override
        public void handleOnBackPressed() {
            onBackPressed();
        }
    });
}
Also used : VoiceNoteMediaController(org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController) AssertedSuccessListener(org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener) OnBackPressedCallback(androidx.activity.OnBackPressedCallback) AsynchronousCallback(org.thoughtcrime.securesms.util.AsynchronousCallback) OnBackPressedCallback(androidx.activity.OnBackPressedCallback) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FullscreenHelper(org.thoughtcrime.securesms.util.FullscreenHelper)

Example 4 with OnBackPressedCallback

use of androidx.activity.OnBackPressedCallback in project Signal-Android by signalapp.

the class KbsSplashFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    title = view.findViewById(R.id.kbs_splash_title);
    description = view.findViewById(R.id.kbs_splash_description);
    primaryAction = view.findViewById(R.id.kbs_splash_primary_action);
    secondaryAction = view.findViewById(R.id.kbs_splash_secondary_action);
    primaryAction.setOnClickListener(v -> onCreatePin());
    secondaryAction.setOnClickListener(v -> onLearnMore());
    if (RegistrationLockUtil.userHasRegistrationLock(requireContext())) {
        setUpRegLockEnabled();
    } else {
        setUpRegLockDisabled();
    }
    description.setMovementMethod(LinkMovementMethod.getInstance());
    Toolbar toolbar = view.findViewById(R.id.kbs_splash_toolbar);
    ((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
    ((AppCompatActivity) requireActivity()).getSupportActionBar().setTitle(null);
    requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {

        @Override
        public void handleOnBackPressed() {
        }
    });
}
Also used : OnBackPressedCallback(androidx.activity.OnBackPressedCallback) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) Toolbar(androidx.appcompat.widget.Toolbar)

Example 5 with OnBackPressedCallback

use of androidx.activity.OnBackPressedCallback in project Signal-Android by signalapp.

the class BaseAccountLockedFragment method onViewCreated.

@Override
@CallSuper
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    TextView description = view.findViewById(R.id.account_locked_description);
    BaseRegistrationViewModel viewModel = getViewModel();
    viewModel.getLockedTimeRemaining().observe(getViewLifecycleOwner(), t -> description.setText(getString(R.string.AccountLockedFragment__your_account_has_been_locked_to_protect_your_privacy, durationToDays(t))));
    view.findViewById(R.id.account_locked_next).setOnClickListener(v -> onNext());
    view.findViewById(R.id.account_locked_learn_more).setOnClickListener(v -> learnMore());
    requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {

        @Override
        public void handleOnBackPressed() {
            onNext();
        }
    });
}
Also used : BaseRegistrationViewModel(org.thoughtcrime.securesms.registration.viewmodel.BaseRegistrationViewModel) OnBackPressedCallback(androidx.activity.OnBackPressedCallback) TextView(android.widget.TextView) CallSuper(androidx.annotation.CallSuper)

Aggregations

OnBackPressedCallback (androidx.activity.OnBackPressedCallback)10 TextView (android.widget.TextView)2 CallSuper (androidx.annotation.CallSuper)2 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)2 Toolbar (androidx.appcompat.widget.Toolbar)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 VoiceNoteMediaController (org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController)2 BaseRegistrationViewModel (org.thoughtcrime.securesms.registration.viewmodel.BaseRegistrationViewModel)2 AsynchronousCallback (org.thoughtcrime.securesms.util.AsynchronousCallback)2 FullscreenHelper (org.thoughtcrime.securesms.util.FullscreenHelper)2 AssertedSuccessListener (org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener)2