mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Make InputPanel fully responsible for emoji toggle
Fixes #4638 // FREEBIE
This commit is contained in:
parent
fc5777e904
commit
a4f7b78fd0
@ -59,7 +59,6 @@ import com.google.protobuf.ByteString;
|
||||
import org.thoughtcrime.redphone.RedPhone;
|
||||
import org.thoughtcrime.redphone.RedPhoneService;
|
||||
import org.thoughtcrime.securesms.TransportOptions.OnTransportChangedListener;
|
||||
import org.thoughtcrime.securesms.audio.AudioCodec;
|
||||
import org.thoughtcrime.securesms.audio.AudioRecorder;
|
||||
import org.thoughtcrime.securesms.audio.AudioSlidePlayer;
|
||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||
@ -75,8 +74,6 @@ import org.thoughtcrime.securesms.components.camera.QuickAttachmentDrawer;
|
||||
import org.thoughtcrime.securesms.components.camera.QuickAttachmentDrawer.AttachmentDrawerListener;
|
||||
import org.thoughtcrime.securesms.components.camera.QuickAttachmentDrawer.DrawerState;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer.EmojiEventListener;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
|
||||
import org.thoughtcrime.securesms.components.reminder.InviteReminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.ReminderView;
|
||||
import org.thoughtcrime.securesms.contacts.ContactAccessor;
|
||||
@ -193,7 +190,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
private BroadcastReceiver securityUpdateReceiver;
|
||||
private BroadcastReceiver groupUpdateReceiver;
|
||||
private EmojiDrawer emojiDrawer;
|
||||
private EmojiToggle emojiToggle;
|
||||
protected HidingLinearLayout quickAttachmentToggle;
|
||||
private QuickAttachmentDrawer quickAttachmentDrawer;
|
||||
private InputPanel inputPanel;
|
||||
@ -423,7 +419,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
@Override
|
||||
public void onKeyboardShown() {
|
||||
emojiToggle.setToEmoji();
|
||||
inputPanel.onKeyboardShown();
|
||||
}
|
||||
|
||||
//////// Event Handlers
|
||||
@ -853,7 +849,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
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);
|
||||
emojiToggle = ViewUtil.findById(this, R.id.emoji_toggle);
|
||||
emojiDrawer = ViewUtil.findById(this, R.id.emoji_drawer);
|
||||
unblockButton = ViewUtil.findById(this, R.id.unblock_button);
|
||||
composePanel = ViewUtil.findById(this, R.id.bottom_panel);
|
||||
@ -867,7 +862,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
View composeBubble = ViewUtil.findById(this, R.id.compose_bubble);
|
||||
|
||||
container.addOnKeyboardShownListener(this);
|
||||
inputPanel.setListener(this);
|
||||
inputPanel.setListener(this, emojiDrawer);
|
||||
|
||||
int[] attributes = new int[]{R.attr.conversation_item_bubble_background};
|
||||
TypedArray colors = obtainStyledAttributes(attributes);
|
||||
@ -882,22 +877,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
SendButtonListener sendButtonListener = new SendButtonListener();
|
||||
ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
|
||||
|
||||
if (TextSecurePreferences.isSystemEmojiPreferred(this)) {
|
||||
emojiToggle.setVisibility(View.GONE);
|
||||
} else {
|
||||
emojiToggle.attach(emojiDrawer);
|
||||
emojiToggle.setOnClickListener(new EmojiToggleListener());
|
||||
emojiDrawer.setEmojiEventListener(new EmojiEventListener() {
|
||||
@Override public void onKeyEvent(KeyEvent keyEvent) {
|
||||
composeText.dispatchKeyEvent(keyEvent);
|
||||
}
|
||||
|
||||
@Override public void onEmojiSelected(String emoji) {
|
||||
composeText.insertEmoji(emoji);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
emojiDrawer.setEmojiEventListener(inputPanel);
|
||||
composeText.setOnEditorActionListener(sendButtonListener);
|
||||
attachButton.setOnClickListener(new AttachButtonListener());
|
||||
attachButton.setOnLongClickListener(new AttachButtonLongClickListener());
|
||||
@ -1444,6 +1424,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEmojiToggle() {
|
||||
if (container.getCurrentInput() == emojiDrawer) container.showSoftkey(composeText);
|
||||
else container.show(composeText, emojiDrawer);
|
||||
}
|
||||
|
||||
// Listeners
|
||||
|
||||
private class AttachmentTypeListener implements AttachmentTypeSelector.AttachmentClickedListener {
|
||||
@ -1453,14 +1439,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
}
|
||||
|
||||
private class EmojiToggleListener implements OnClickListener {
|
||||
|
||||
@Override public void onClick(View v) {
|
||||
if (container.getCurrentInput() == emojiDrawer) container.showSoftkey(composeText);
|
||||
else container.show(composeText, emojiDrawer);
|
||||
}
|
||||
}
|
||||
|
||||
private class QuickCameraToggleListener implements OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -4,9 +4,11 @@ import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
@ -17,6 +19,10 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiEditText;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener;
|
||||
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
|
||||
@ -25,24 +31,26 @@ import org.thoughtcrime.securesms.util.concurrent.SettableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class InputPanel extends LinearLayout implements MicrophoneRecorderView.Listener {
|
||||
public class InputPanel extends LinearLayout
|
||||
implements MicrophoneRecorderView.Listener, KeyboardAwareLinearLayout.OnKeyboardShownListener, EmojiDrawer.EmojiEventListener {
|
||||
|
||||
private static final String TAG = InputPanel.class.getSimpleName();
|
||||
|
||||
private static final int FADE_TIME = 150;
|
||||
|
||||
private View emojiToggle;
|
||||
private View composeText;
|
||||
private View quickCameraToggle;
|
||||
private View quickAudioToggle;
|
||||
private View buttonToggle;
|
||||
private View recordingContainer;
|
||||
private EmojiToggle emojiToggle;
|
||||
private EmojiEditText composeText;
|
||||
private View quickCameraToggle;
|
||||
private View quickAudioToggle;
|
||||
private View buttonToggle;
|
||||
private View recordingContainer;
|
||||
|
||||
private MicrophoneRecorderView microphoneRecorderView;
|
||||
private SlideToCancel slideToCancel;
|
||||
private RecordTime recordTime;
|
||||
|
||||
private @Nullable Listener listener;
|
||||
private boolean emojiVisible;
|
||||
|
||||
public InputPanel(Context context) {
|
||||
super(context);
|
||||
@ -76,10 +84,26 @@ public class InputPanel extends LinearLayout implements MicrophoneRecorderView.L
|
||||
this.microphoneRecorderView.setVisibility(View.GONE);
|
||||
this.microphoneRecorderView.setClickable(false);
|
||||
}
|
||||
|
||||
if (TextSecurePreferences.isSystemEmojiPreferred(getContext())) {
|
||||
emojiToggle.setVisibility(View.GONE);
|
||||
emojiVisible = false;
|
||||
} else {
|
||||
emojiToggle.setVisibility(View.VISIBLE);
|
||||
emojiVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(@Nullable Listener listener) {
|
||||
public void setListener(final @NonNull Listener listener, @NonNull EmojiDrawer emojiDrawer) {
|
||||
this.listener = listener;
|
||||
|
||||
emojiToggle.attach(emojiDrawer);
|
||||
emojiToggle.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
listener.onEmojiToggle();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,7 +112,7 @@ public class InputPanel extends LinearLayout implements MicrophoneRecorderView.L
|
||||
recordTime.display();
|
||||
slideToCancel.display(startPositionX);
|
||||
|
||||
ViewUtil.fadeOut(emojiToggle, FADE_TIME, View.INVISIBLE);
|
||||
if (emojiVisible) ViewUtil.fadeOut(emojiToggle, FADE_TIME, View.INVISIBLE);
|
||||
ViewUtil.fadeOut(composeText, FADE_TIME, View.INVISIBLE);
|
||||
ViewUtil.fadeOut(quickCameraToggle, FADE_TIME, View.INVISIBLE);
|
||||
ViewUtil.fadeOut(quickAudioToggle, FADE_TIME, View.INVISIBLE);
|
||||
@ -136,7 +160,7 @@ public class InputPanel extends LinearLayout implements MicrophoneRecorderView.L
|
||||
future.addListener(new AssertedSuccessListener<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
ViewUtil.fadeIn(emojiToggle, FADE_TIME);
|
||||
if (emojiVisible) ViewUtil.fadeIn(emojiToggle, FADE_TIME);
|
||||
ViewUtil.fadeIn(composeText, FADE_TIME);
|
||||
ViewUtil.fadeIn(quickCameraToggle, FADE_TIME);
|
||||
ViewUtil.fadeIn(quickAudioToggle, FADE_TIME);
|
||||
@ -147,10 +171,26 @@ public class InputPanel extends LinearLayout implements MicrophoneRecorderView.L
|
||||
return elapsedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyboardShown() {
|
||||
emojiToggle.setToEmoji();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyEvent(KeyEvent keyEvent) {
|
||||
composeText.dispatchKeyEvent(keyEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEmojiSelected(String emoji) {
|
||||
composeText.insertEmoji(emoji);
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
public void onRecorderStarted();
|
||||
public void onRecorderFinished();
|
||||
public void onRecorderCanceled();
|
||||
public void onEmojiToggle();
|
||||
}
|
||||
|
||||
private static class SlideToCancel {
|
||||
|
Loading…
x
Reference in New Issue
Block a user