Search in sources :

Example 1 with VoiceNoteMediaController

use of org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController 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 2 with VoiceNoteMediaController

use of org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController in project Signal-Android by signalapp.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState, boolean ready) {
    AppStartup.getInstance().onCriticalRenderEventStart();
    super.onCreate(savedInstanceState, ready);
    setContentView(R.layout.main_activity);
    mediaController = new VoiceNoteMediaController(this);
    navigator.onCreate(savedInstanceState);
    handleGroupLinkInIntent(getIntent());
    handleProxyInIntent(getIntent());
    handleSignalMeIntent(getIntent());
    CachedInflater.from(this).clear();
}
Also used : VoiceNoteMediaController(org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController)

Example 3 with VoiceNoteMediaController

use of org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController in project Signal-Android by WhisperSystems.

the class MediaOverviewPageFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    voiceNoteMediaController = new VoiceNoteMediaController((AppCompatActivity) requireActivity());
}
Also used : VoiceNoteMediaController(org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController) AppCompatActivity(androidx.appcompat.app.AppCompatActivity)

Example 4 with VoiceNoteMediaController

use of org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController in project Signal-Android by WhisperSystems.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState, boolean ready) {
    AppStartup.getInstance().onCriticalRenderEventStart();
    super.onCreate(savedInstanceState, ready);
    setContentView(R.layout.main_activity);
    mediaController = new VoiceNoteMediaController(this);
    navigator.onCreate(savedInstanceState);
    handleGroupLinkInIntent(getIntent());
    handleProxyInIntent(getIntent());
    handleSignalMeIntent(getIntent());
    CachedInflater.from(this).clear();
}
Also used : VoiceNoteMediaController(org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController)

Example 5 with VoiceNoteMediaController

use of org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController 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();
        }
    });
}
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)

Aggregations

VoiceNoteMediaController (org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController)6 OnBackPressedCallback (androidx.activity.OnBackPressedCallback)2 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AsynchronousCallback (org.thoughtcrime.securesms.util.AsynchronousCallback)2 FullscreenHelper (org.thoughtcrime.securesms.util.FullscreenHelper)2 AssertedSuccessListener (org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener)2