mirror of
https://codeberg.org/monocles/monocles_chat.git
synced 2025-01-16 06:32:22 +01:00
Continuing emoji picker
This commit is contained in:
parent
860e86bc4e
commit
2c191a6969
6 changed files with 142 additions and 7 deletions
|
@ -129,6 +129,7 @@ dependencies {
|
|||
implementation 'com.nineoldandroids:library:2.4.0'
|
||||
implementation "androidx.core:core-ktx:1.12.0"
|
||||
implementation "androidx.compose.material3:material3-android:1.2.0-beta01"
|
||||
implementation "androidx.emoji2:emoji2-emojipicker:1.4.0"
|
||||
}
|
||||
|
||||
ext {
|
||||
|
|
|
@ -243,7 +243,7 @@
|
|||
android:launchMode="singleTask"
|
||||
android:minWidth="336dp"
|
||||
android:minHeight="480dp"
|
||||
android:windowSoftInputMode="stateHidden" />
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".ui.ScanActivity"
|
||||
android:screenOrientation="portrait"
|
||||
|
|
|
@ -238,6 +238,9 @@ import eu.siacs.conversations.xmpp.jingle.RtpCapability;
|
|||
import io.ipfs.cid.Cid;
|
||||
import me.drakeet.support.toast.ToastCompat;
|
||||
import net.java.otr4j.session.SessionStatus;
|
||||
import androidx.emoji2.emojipicker.EmojiPickerView;
|
||||
import androidx.emoji2.emojipicker.RecentEmojiAsyncProvider;
|
||||
import androidx.emoji2.emojipicker.RecentEmojiProviderAdapter;
|
||||
|
||||
public class ConversationFragment extends XmppFragment
|
||||
implements EditMessage.KeyboardListener,
|
||||
|
@ -680,6 +683,42 @@ public class ConversationFragment extends XmppFragment
|
|||
}
|
||||
};
|
||||
|
||||
private final OnClickListener memojiButtonListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (binding.emojiButton.getVisibility() == VISIBLE) {
|
||||
binding.emojiPicker.setVisibility(VISIBLE);
|
||||
binding.emojiButton.setVisibility(GONE);
|
||||
binding.keyboardButton.setVisibility(VISIBLE);
|
||||
hideSoftKeyboard(activity);
|
||||
EmojiPickerView emojiPickerView = (EmojiPickerView) activity.findViewById(R.id.emoji_picker);
|
||||
backPressedLeaveEmojiPicker.setEnabled(true);
|
||||
binding.textinput.requestFocus();
|
||||
emojiPickerView.setOnEmojiPickedListener(emojiViewItem -> {
|
||||
int start = binding.textinput.getSelectionStart(); //this is to get the the cursor position
|
||||
binding.textinput.getText().insert(start, emojiViewItem.getEmoji()); //this will get the text and insert the emoji into the current position
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final OnClickListener mkeyboardButtonListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (binding.keyboardButton.getVisibility() == VISIBLE) {
|
||||
binding.keyboardButton.setVisibility(GONE);
|
||||
binding.emojiPicker.setVisibility(GONE);
|
||||
binding.emojiButton.setVisibility(VISIBLE);
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (inputMethodManager != null) {
|
||||
binding.textinput.requestFocus();
|
||||
inputMethodManager.showSoftInput(binding.textinput, InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private final OnClickListener mRecordVoiceButtonListener = v -> attachFile(ATTACHMENT_CHOICE_RECORD_VOICE);
|
||||
|
||||
private final OnClickListener mtakePictureButtonListener = v -> attachFile(ATTACHMENT_CHOICE_TAKE_PHOTO);
|
||||
|
@ -752,6 +791,21 @@ public class ConversationFragment extends XmppFragment
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
private final OnBackPressedCallback backPressedLeaveEmojiPicker = new OnBackPressedCallback(false) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (binding.emojiPicker.getVisibility()==VISIBLE) {
|
||||
binding.emojiPicker.setVisibility(GONE);
|
||||
binding.keyboardButton.setVisibility(GONE);
|
||||
binding.emojiButton.setVisibility(VISIBLE);
|
||||
}
|
||||
this.setEnabled(false);
|
||||
refresh();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private int completionIndex = 0;
|
||||
private int lastCompletionLength = 0;
|
||||
private String incomplete;
|
||||
|
@ -1430,7 +1484,7 @@ public class ConversationFragment extends XmppFragment
|
|||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
activity.getOnBackPressedDispatcher().addCallback(this, backPressedLeaveSingleThread);
|
||||
|
||||
activity.getOnBackPressedDispatcher().addCallback(this, backPressedLeaveEmojiPicker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1551,6 +1605,12 @@ public class ConversationFragment extends XmppFragment
|
|||
//Setting hide thread icon
|
||||
showThreadFeature();
|
||||
|
||||
if (binding.emojiPicker.getVisibility()==VISIBLE) {
|
||||
backPressedLeaveEmojiPicker.setEnabled(true);
|
||||
} else {
|
||||
backPressedLeaveEmojiPicker.setEnabled(false);
|
||||
}
|
||||
|
||||
binding.textinput.addTextChangedListener(new StylingHelper.MessageEditorStyler(binding.textinput));
|
||||
binding.textinput.setOnEditorActionListener(mEditorActionListener);
|
||||
binding.textinput.setRichContentListener(new String[] {"image/*"}, mEditorContentListener);
|
||||
|
@ -1567,6 +1627,8 @@ public class ConversationFragment extends XmppFragment
|
|||
binding.textSendButton.setOnLongClickListener(this.mSendButtonLongListener);
|
||||
binding.scrollToBottomButton.setOnClickListener(this.mScrollButtonListener);
|
||||
binding.recordVoiceButton.setOnClickListener(this.mRecordVoiceButtonListener);
|
||||
binding.emojiButton.setOnClickListener(this.memojiButtonListener);
|
||||
binding.keyboardButton.setOnClickListener(this.mkeyboardButtonListener);
|
||||
binding.takePictureButton.setOnClickListener(this.mtakePictureButtonListener);
|
||||
binding.messagesView.setOnScrollListener(mOnScrollListener);
|
||||
binding.messagesView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
|
||||
|
@ -1879,6 +1941,7 @@ public class ConversationFragment extends XmppFragment
|
|||
MenuItem moderateMessage = menu.findItem(R.id.moderate_message);
|
||||
MenuItem onlyThisThread = menu.findItem(R.id.only_this_thread);
|
||||
MenuItem deleteMessage = menu.findItem(R.id.delete_message);
|
||||
MenuItem messageReaction = menu.findItem(R.id.message_reaction); //add the most used emoticons
|
||||
MenuItem shareWith = menu.findItem(R.id.share_with);
|
||||
MenuItem sendAgain = menu.findItem(R.id.send_again);
|
||||
MenuItem copyUrl = menu.findItem(R.id.copy_url);
|
||||
|
@ -2114,6 +2177,14 @@ public class ConversationFragment extends XmppFragment
|
|||
setThread(selectedMessage.getThread());
|
||||
}
|
||||
return true;
|
||||
case R.id.message_reaction:
|
||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||
quoteMessage(selectedMessage, user);
|
||||
} else {
|
||||
quoteMessage(selectedMessage, null);
|
||||
}
|
||||
chooseReaction(selectedMessage);
|
||||
return true;
|
||||
default:
|
||||
return onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -2268,6 +2339,10 @@ public class ConversationFragment extends XmppFragment
|
|||
}
|
||||
return true;
|
||||
}
|
||||
if (binding.emojiPicker.getVisibility()==VISIBLE){
|
||||
binding.emojiPicker.setVisibility(GONE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3325,6 +3400,26 @@ public class ConversationFragment extends XmppFragment
|
|||
this.binding.textinput.append(message.getBody());
|
||||
}
|
||||
|
||||
private void chooseReaction(Message message) {
|
||||
while (message.mergeable(message.next())) {
|
||||
message = message.next();
|
||||
}
|
||||
setThread(message.getThread());
|
||||
conversation.setUserSelectedThread(true);
|
||||
//Open emoji picker
|
||||
binding.emojiPicker.setVisibility(VISIBLE);
|
||||
binding.emojiButton.setVisibility(GONE);
|
||||
binding.keyboardButton.setVisibility(VISIBLE);
|
||||
hideSoftKeyboard(activity);
|
||||
EmojiPickerView emojiPickerView = (EmojiPickerView) activity.findViewById(R.id.emoji_picker);
|
||||
backPressedLeaveEmojiPicker.setEnabled(true);
|
||||
binding.textinput.requestFocus();
|
||||
emojiPickerView.setOnEmojiPickedListener(emojiViewItem -> {
|
||||
binding.textinput.append(emojiViewItem.getEmoji());
|
||||
});
|
||||
// TODO: Directly choose emojis from popup menu
|
||||
}
|
||||
|
||||
private void highlightInConference(String nick) {
|
||||
final Editable editable = this.binding.textinput.getText();
|
||||
String oldString = editable.toString().trim();
|
||||
|
|
|
@ -179,7 +179,7 @@
|
|||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:visibility="visible"
|
||||
android:background="@drawable/thread_hint">
|
||||
|
||||
|
@ -204,12 +204,38 @@
|
|||
android:contentDescription="@string/thread_locked" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
<ImageButton
|
||||
android:id="@+id/keyboardButton"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_toEndOf="@+id/thread_identicon_layout"
|
||||
android:layout_toRightOf="@+id/thread_identicon_layout"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/show_keyboard"
|
||||
android:src="?attr/ic_keyboard_button"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/emojiButton"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_toEndOf="@+id/keyboardButton"
|
||||
android:layout_toRightOf="@+id/keyboardButton"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/choose_emoji"
|
||||
android:src="?attr/ic_emoji_button"
|
||||
android:visibility="visible" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/textinput_layout_new"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@+id/thread_identicon_layout"
|
||||
android:layout_toRightOf="@+id/thread_identicon_layout"
|
||||
android:layout_toEndOf="@+id/emojiButton"
|
||||
android:layout_toRightOf="@+id/emojiButton"
|
||||
android:layout_toStartOf="@+id/takePictureButton"
|
||||
android:layout_toLeftOf="@+id/takePictureButton">
|
||||
|
||||
|
@ -299,6 +325,15 @@
|
|||
android:src="@drawable/ic_send_text_offline" />
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.emoji2.emojipicker.EmojiPickerView
|
||||
android:id="@+id/emoji_picker"
|
||||
android:layout_below="@+id/message_input_box"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="270dp"
|
||||
app:emojiGridColumns="9"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/textformat"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
android:id="@+id/delete_message"
|
||||
android:title="@string/delete_message"
|
||||
android:visible="false" />
|
||||
<item
|
||||
android:id="@+id/message_reaction"
|
||||
android:title="@string/message_reaction"
|
||||
android:visible="false" />
|
||||
<item
|
||||
android:id="@+id/moderate_message"
|
||||
android:title="@string/moderate_message"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<bool name="dont_trust_system_cas">false</bool>
|
||||
<bool name="btbv">true</bool>
|
||||
<bool name="send_button_status">true</bool>
|
||||
<bool name="display_enter_key">false</bool>
|
||||
<bool name="display_enter_key">true</bool>
|
||||
<bool name="show_dynamic_tags">true</bool>
|
||||
<bool name="presence_colored_names">false</bool>
|
||||
<bool name="use_max_brightness">false</bool>
|
||||
|
|
Loading…
Reference in a new issue