Search in sources :

Example 1 with AudioRecorder

use of org.thoughtcrime.securesms.audio.AudioRecorder in project Signal-Android by signalapp.

the class ConversationActivity method initializeViews.

private void initializeViews() {
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar == null)
        throw new AssertionError();
    titleView = (ConversationTitleView) supportActionBar.getCustomView();
    buttonToggle = ViewUtil.findById(this, R.id.button_toggle);
    sendButton = ViewUtil.findById(this, R.id.send_button);
    attachButton = ViewUtil.findById(this, R.id.attach_button);
    composeText = ViewUtil.findById(this, R.id.embedded_text_editor);
    charactersLeft = ViewUtil.findById(this, R.id.space_left);
    emojiDrawerStub = ViewUtil.findStubById(this, R.id.emoji_drawer_stub);
    unblockButton = ViewUtil.findById(this, R.id.unblock_button);
    makeDefaultSmsButton = ViewUtil.findById(this, R.id.make_default_sms_button);
    registerButton = ViewUtil.findById(this, R.id.register_button);
    composePanel = ViewUtil.findById(this, R.id.bottom_panel);
    container = ViewUtil.findById(this, R.id.layout_container);
    reminderView = ViewUtil.findStubById(this, R.id.reminder_stub);
    unverifiedBannerView = ViewUtil.findStubById(this, R.id.unverified_banner_stub);
    groupShareProfileView = ViewUtil.findStubById(this, R.id.group_share_profile_view_stub);
    quickAttachmentDrawer = ViewUtil.findById(this, R.id.quick_attachment_drawer);
    quickAttachmentToggle = ViewUtil.findById(this, R.id.quick_attachment_toggle);
    inputPanel = ViewUtil.findById(this, R.id.bottom_panel);
    ImageButton quickCameraToggle = ViewUtil.findById(this, R.id.quick_camera_toggle);
    View composeBubble = ViewUtil.findById(this, R.id.compose_bubble);
    container.addOnKeyboardShownListener(this);
    inputPanel.setListener(this);
    inputPanel.setMediaListener(this);
    int[] attributes = new int[] { R.attr.conversation_item_bubble_background };
    TypedArray colors = obtainStyledAttributes(attributes);
    int defaultColor = colors.getColor(0, Color.WHITE);
    composeBubble.getBackground().setColorFilter(defaultColor, PorterDuff.Mode.MULTIPLY);
    colors.recycle();
    attachmentTypeSelector = null;
    attachmentManager = new AttachmentManager(this, this);
    audioRecorder = new AudioRecorder(this);
    SendButtonListener sendButtonListener = new SendButtonListener();
    ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
    composeText.setOnEditorActionListener(sendButtonListener);
    attachButton.setOnClickListener(new AttachButtonListener());
    attachButton.setOnLongClickListener(new AttachButtonLongClickListener());
    sendButton.setOnClickListener(sendButtonListener);
    sendButton.setEnabled(true);
    sendButton.addOnTransportChangedListener((newTransport, manuallySelected) -> {
        calculateCharactersRemaining();
        composeText.setTransport(newTransport);
        buttonToggle.getBackground().setColorFilter(newTransport.getBackgroundColor(), Mode.MULTIPLY);
        buttonToggle.getBackground().invalidateSelf();
        if (manuallySelected)
            recordSubscriptionIdPreference(newTransport.getSimSubscriptionId());
    });
    titleView.setOnClickListener(v -> handleConversationSettings());
    titleView.setOnLongClickListener(v -> handleDisplayQuickContact());
    titleView.setOnBackClickedListener(view -> super.onBackPressed());
    unblockButton.setOnClickListener(v -> handleUnblock());
    makeDefaultSmsButton.setOnClickListener(v -> handleMakeDefaultSms());
    registerButton.setOnClickListener(v -> handleRegisterForSignal());
    composeText.setOnKeyListener(composeKeyPressedListener);
    composeText.addTextChangedListener(composeKeyPressedListener);
    composeText.setOnEditorActionListener(sendButtonListener);
    composeText.setOnClickListener(composeKeyPressedListener);
    composeText.setOnFocusChangeListener(composeKeyPressedListener);
    if (QuickAttachmentDrawer.isDeviceSupported(this)) {
        quickAttachmentDrawer.setListener(this);
        quickCameraToggle.setOnClickListener(new QuickCameraToggleListener());
    } else {
        quickCameraToggle.setVisibility(View.GONE);
        quickCameraToggle.setEnabled(false);
    }
}
Also used : ReminderView(org.thoughtcrime.securesms.components.reminder.ReminderView) UnverifiedBannerView(org.thoughtcrime.securesms.components.identity.UnverifiedBannerView) View(android.view.View) TextView(android.widget.TextView) GroupShareProfileView(org.thoughtcrime.securesms.profiles.GroupShareProfileView) SuppressLint(android.annotation.SuppressLint) ImageButton(android.widget.ImageButton) TypedArray(android.content.res.TypedArray) AudioRecorder(org.thoughtcrime.securesms.audio.AudioRecorder) AttachmentManager(org.thoughtcrime.securesms.mms.AttachmentManager) ActionBar(android.support.v7.app.ActionBar)

Example 2 with AudioRecorder

use of org.thoughtcrime.securesms.audio.AudioRecorder in project Signal-Android by WhisperSystems.

the class ConversationParentFragment method initializeViews.

private void initializeViews(View view) {
    toolbar = view.findViewById(R.id.toolbar);
    titleView = view.findViewById(R.id.conversation_title_view);
    buttonToggle = view.findViewById(R.id.button_toggle);
    sendButton = view.findViewById(R.id.send_button);
    attachButton = view.findViewById(R.id.attach_button);
    composeText = view.findViewById(R.id.embedded_text_editor);
    charactersLeft = view.findViewById(R.id.space_left);
    emojiDrawerStub = ViewUtil.findStubById(view, R.id.emoji_drawer_stub);
    attachmentKeyboardStub = ViewUtil.findStubById(view, R.id.attachment_keyboard_stub);
    unblockButton = view.findViewById(R.id.unblock_button);
    makeDefaultSmsButton = view.findViewById(R.id.make_default_sms_button);
    registerButton = view.findViewById(R.id.register_button);
    container = view.findViewById(R.id.layout_container);
    reminderView = ViewUtil.findStubById(view, R.id.reminder_stub);
    unverifiedBannerView = ViewUtil.findStubById(view, R.id.unverified_banner_stub);
    reviewBanner = ViewUtil.findStubById(view, R.id.review_banner_stub);
    quickAttachmentToggle = view.findViewById(R.id.quick_attachment_toggle);
    inlineAttachmentToggle = view.findViewById(R.id.inline_attachment_container);
    inputPanel = view.findViewById(R.id.bottom_panel);
    panelParent = view.findViewById(R.id.conversation_activity_panel_parent);
    searchNav = view.findViewById(R.id.conversation_search_nav);
    messageRequestBottomView = view.findViewById(R.id.conversation_activity_message_request_bottom_bar);
    mentionsSuggestions = ViewUtil.findStubById(view, R.id.conversation_mention_suggestions_stub);
    wallpaper = view.findViewById(R.id.conversation_wallpaper);
    wallpaperDim = view.findViewById(R.id.conversation_wallpaper_dim);
    voiceNotePlayerViewStub = ViewUtil.findStubById(view, R.id.voice_note_player_stub);
    ImageButton quickCameraToggle = view.findViewById(R.id.quick_camera_toggle);
    ImageButton inlineAttachmentButton = view.findViewById(R.id.inline_attachment_button);
    Stub<ConversationReactionOverlay> reactionOverlayStub = ViewUtil.findStubById(view, R.id.conversation_reaction_scrubber_stub);
    reactionDelegate = new ConversationReactionDelegate(reactionOverlayStub);
    noLongerMemberBanner = view.findViewById(R.id.conversation_no_longer_member_banner);
    cannotSendInAnnouncementGroupBanner = ViewUtil.findStubById(view, R.id.conversation_cannot_send_announcement_stub);
    requestingMemberBanner = view.findViewById(R.id.conversation_requesting_banner);
    cancelJoinRequest = view.findViewById(R.id.conversation_cancel_request);
    releaseChannelUnmute = ViewUtil.findStubById(view, R.id.conversation_release_notes_unmute_stub);
    joinGroupCallButton = view.findViewById(R.id.conversation_group_call_join);
    container.setIsBubble(isInBubble());
    container.addOnKeyboardShownListener(this);
    inputPanel.setListener(this);
    inputPanel.setMediaListener(this);
    attachmentManager = new AttachmentManager(requireActivity(), this);
    audioRecorder = new AudioRecorder(requireContext());
    typingTextWatcher = new TypingStatusTextWatcher();
    SendButtonListener sendButtonListener = new SendButtonListener();
    ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
    composeText.setOnEditorActionListener(sendButtonListener);
    composeText.setCursorPositionChangedListener(this);
    attachButton.setOnClickListener(new AttachButtonListener());
    attachButton.setOnLongClickListener(new AttachButtonLongClickListener());
    sendButton.setOnClickListener(sendButtonListener);
    sendButton.setEnabled(true);
    sendButton.addOnTransportChangedListener((newTransport, manuallySelected) -> {
        calculateCharactersRemaining();
        updateLinkPreviewState();
        linkPreviewViewModel.onTransportChanged(newTransport.isSms());
        composeText.setTransport(newTransport);
        buttonToggle.getBackground().setColorFilter(newTransport.getBackgroundColor(), PorterDuff.Mode.MULTIPLY);
        buttonToggle.getBackground().invalidateSelf();
        if (manuallySelected)
            recordTransportPreference(newTransport);
    });
    titleView.setOnClickListener(v -> handleConversationSettings());
    titleView.setOnLongClickListener(v -> handleDisplayQuickContact());
    unblockButton.setOnClickListener(v -> handleUnblock());
    makeDefaultSmsButton.setOnClickListener(v -> handleMakeDefaultSms());
    registerButton.setOnClickListener(v -> handleRegisterForSignal());
    composeText.setOnKeyListener(composeKeyPressedListener);
    composeText.addTextChangedListener(composeKeyPressedListener);
    composeText.setOnEditorActionListener(sendButtonListener);
    composeText.setOnClickListener(composeKeyPressedListener);
    composeText.setOnFocusChangeListener(composeKeyPressedListener);
    if (Camera.getNumberOfCameras() > 0) {
        quickCameraToggle.setVisibility(View.VISIBLE);
        quickCameraToggle.setOnClickListener(new QuickCameraToggleListener());
    } else {
        quickCameraToggle.setVisibility(View.GONE);
    }
    searchNav.setEventListener(this);
    inlineAttachmentButton.setOnClickListener(v -> handleAddAttachment());
    reactionDelegate.setOnReactionSelectedListener(this);
    joinGroupCallButton.setOnClickListener(v -> handleVideo(getRecipient()));
    voiceNoteMediaController.getVoiceNotePlayerViewState().observe(getViewLifecycleOwner(), state -> {
        if (state.isPresent()) {
            requireVoiceNotePlayerView().show();
            requireVoiceNotePlayerView().setState(state.get());
        } else if (voiceNotePlayerViewStub.resolved()) {
            requireVoiceNotePlayerView().hide();
        }
    });
    voiceNoteMediaController.getVoiceNotePlaybackState().observe(getViewLifecycleOwner(), inputPanel.getPlaybackStateObserver());
}
Also used : ImageButton(android.widget.ImageButton) AudioRecorder(org.thoughtcrime.securesms.audio.AudioRecorder) AttachmentManager(org.thoughtcrime.securesms.mms.AttachmentManager)

Example 3 with AudioRecorder

use of org.thoughtcrime.securesms.audio.AudioRecorder in project Signal-Android by WhisperSystems.

the class ConversationActivity method initializeViews.

private void initializeViews() {
    titleView = (ConversationTitleView) getSupportActionBar().getCustomView();
    buttonToggle = ViewUtil.findById(this, R.id.button_toggle);
    sendButton = ViewUtil.findById(this, R.id.send_button);
    attachButton = ViewUtil.findById(this, R.id.attach_button);
    composeText = ViewUtil.findById(this, R.id.embedded_text_editor);
    charactersLeft = ViewUtil.findById(this, R.id.space_left);
    emojiDrawerStub = ViewUtil.findStubById(this, R.id.emoji_drawer_stub);
    unblockButton = ViewUtil.findById(this, R.id.unblock_button);
    makeDefaultSmsButton = ViewUtil.findById(this, R.id.make_default_sms_button);
    composePanel = ViewUtil.findById(this, R.id.bottom_panel);
    container = ViewUtil.findById(this, R.id.layout_container);
    reminderView = ViewUtil.findStubById(this, R.id.reminder_stub);
    quickAttachmentDrawer = ViewUtil.findById(this, R.id.quick_attachment_drawer);
    quickAttachmentToggle = ViewUtil.findById(this, R.id.quick_attachment_toggle);
    inputPanel = ViewUtil.findById(this, R.id.bottom_panel);
    ImageButton quickCameraToggle = ViewUtil.findById(this, R.id.quick_camera_toggle);
    View composeBubble = ViewUtil.findById(this, R.id.compose_bubble);
    container.addOnKeyboardShownListener(this);
    inputPanel.setListener(this);
    inputPanel.setMediaListener(this);
    int[] attributes = new int[] { R.attr.conversation_item_bubble_background };
    TypedArray colors = obtainStyledAttributes(attributes);
    int defaultColor = colors.getColor(0, Color.WHITE);
    composeBubble.getBackground().setColorFilter(defaultColor, PorterDuff.Mode.MULTIPLY);
    colors.recycle();
    attachmentTypeSelector = null;
    attachmentManager = new AttachmentManager(this, this);
    audioRecorder = new AudioRecorder(this, masterSecret);
    SendButtonListener sendButtonListener = new SendButtonListener();
    ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
    composeText.setOnEditorActionListener(sendButtonListener);
    attachButton.setOnClickListener(new AttachButtonListener());
    attachButton.setOnLongClickListener(new AttachButtonLongClickListener());
    sendButton.setOnClickListener(sendButtonListener);
    sendButton.setEnabled(true);
    sendButton.addOnTransportChangedListener(new OnTransportChangedListener() {

        @Override
        public void onChange(TransportOption newTransport, boolean manuallySelected) {
            calculateCharactersRemaining();
            composeText.setTransport(newTransport);
            buttonToggle.getBackground().setColorFilter(newTransport.getBackgroundColor(), Mode.MULTIPLY);
            buttonToggle.getBackground().invalidateSelf();
            if (manuallySelected)
                recordSubscriptionIdPreference(newTransport.getSimSubscriptionId());
        }
    });
    titleView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(ConversationActivity.this, RecipientPreferenceActivity.class);
            intent.putExtra(RecipientPreferenceActivity.RECIPIENTS_EXTRA, recipients.getIds());
            intent.putExtra(RecipientPreferenceActivity.CAN_HAVE_SAFETY_NUMBER_EXTRA, isSecureText && !isSelfConversation());
            startActivitySceneTransition(intent, titleView.findViewById(R.id.title), "recipient_name");
        }
    });
    unblockButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            handleUnblock();
        }
    });
    makeDefaultSmsButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            handleMakeDefaultSms();
        }
    });
    composeText.setOnKeyListener(composeKeyPressedListener);
    composeText.addTextChangedListener(composeKeyPressedListener);
    composeText.setOnEditorActionListener(sendButtonListener);
    composeText.setOnClickListener(composeKeyPressedListener);
    composeText.setOnFocusChangeListener(composeKeyPressedListener);
    if (QuickAttachmentDrawer.isDeviceSupported(this)) {
        quickAttachmentDrawer.setListener(this);
        quickCameraToggle.setOnClickListener(new QuickCameraToggleListener());
    } else {
        quickCameraToggle.setVisibility(View.GONE);
        quickCameraToggle.setEnabled(false);
    }
}
Also used : OnTransportChangedListener(org.thoughtcrime.securesms.TransportOptions.OnTransportChangedListener) Intent(android.content.Intent) ReminderView(org.thoughtcrime.securesms.components.reminder.ReminderView) View(android.view.View) TextView(android.widget.TextView) ImageButton(android.widget.ImageButton) TypedArray(android.content.res.TypedArray) AudioRecorder(org.thoughtcrime.securesms.audio.AudioRecorder) OnClickListener(android.view.View.OnClickListener) AttachmentManager(org.thoughtcrime.securesms.mms.AttachmentManager)

Aggregations

ImageButton (android.widget.ImageButton)3 AudioRecorder (org.thoughtcrime.securesms.audio.AudioRecorder)3 AttachmentManager (org.thoughtcrime.securesms.mms.AttachmentManager)3 TypedArray (android.content.res.TypedArray)2 View (android.view.View)2 TextView (android.widget.TextView)2 ReminderView (org.thoughtcrime.securesms.components.reminder.ReminderView)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 ActionBar (android.support.v7.app.ActionBar)1 OnClickListener (android.view.View.OnClickListener)1 OnTransportChangedListener (org.thoughtcrime.securesms.TransportOptions.OnTransportChangedListener)1 UnverifiedBannerView (org.thoughtcrime.securesms.components.identity.UnverifiedBannerView)1 GroupShareProfileView (org.thoughtcrime.securesms.profiles.GroupShareProfileView)1