From a3019be7b6e4946d208867c21960a5d872a2f880 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Mon, 26 Dec 2016 15:14:23 -0800 Subject: [PATCH] Support for image keyboards // FREEBIE --- AndroidManifest.xml | 2 +- build.gradle | 38 +++++------ .../securesms/ConversationActivity.java | 22 ++++++- .../securesms/components/ComposeText.java | 63 +++++++++++++++++-- .../securesms/components/InputPanel.java | 16 ++++- 5 files changed, 114 insertions(+), 27 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2b42c3ce3b..9ecede95d9 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -5,7 +5,7 @@ android:versionCode="222" android:versionName="3.25.4"> - + 0) { + mediaListener.onMediaSelected(inputContentInfo.getContentUri(), + inputContentInfo.getDescription().getMimeType(0)); + + return true; + } + + return false; + } + } + } diff --git a/src/org/thoughtcrime/securesms/components/InputPanel.java b/src/org/thoughtcrime/securesms/components/InputPanel.java index 1067a05089..f7a07c88ee 100644 --- a/src/org/thoughtcrime/securesms/components/InputPanel.java +++ b/src/org/thoughtcrime/securesms/components/InputPanel.java @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.components; import android.annotation.TargetApi; import android.content.Context; +import android.net.Uri; import android.os.Build; import android.os.Handler; import android.support.annotation.NonNull; @@ -32,14 +33,17 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; public class InputPanel extends LinearLayout - implements MicrophoneRecorderView.Listener, KeyboardAwareLinearLayout.OnKeyboardShownListener, EmojiDrawer.EmojiEventListener { + implements MicrophoneRecorderView.Listener, + KeyboardAwareLinearLayout.OnKeyboardShownListener, + EmojiDrawer.EmojiEventListener +{ private static final String TAG = InputPanel.class.getSimpleName(); private static final int FADE_TIME = 150; private EmojiToggle emojiToggle; - private EmojiEditText composeText; + private ComposeText composeText; private View quickCameraToggle; private View quickAudioToggle; private View buttonToggle; @@ -106,6 +110,10 @@ public class InputPanel extends LinearLayout }); } + public void setMediaListener(@NonNull MediaListener listener) { + composeText.setMediaListener(listener); + } + @Override public void onRecordPressed(float startPositionX) { if (listener != null) listener.onRecorderStarted(); @@ -300,4 +308,8 @@ public class InputPanel extends LinearLayout } } } + + public interface MediaListener { + public void onMediaSelected(@NonNull Uri uri, String contentType); + } }