use of androidx.activity.OnBackPressedCallback in project Signal-Android by WhisperSystems.
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() {
}
});
}
use of androidx.activity.OnBackPressedCallback in project Signal-Android by WhisperSystems.
the class OldDeviceTransferCompleteFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
close();
}
});
}
use of androidx.activity.OnBackPressedCallback in project Signal-Android by WhisperSystems.
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();
}
});
}
use of androidx.activity.OnBackPressedCallback in project Signal-Android by signalapp.
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() {
}
});
}
use of androidx.activity.OnBackPressedCallback in project Signal-Android by signalapp.
the class OldDeviceTransferCompleteFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
close();
}
});
}
Aggregations