mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
advanced pref to use android emoji
// FREEBIE
This commit is contained in:
parent
551274f167
commit
e077cc6581
@ -878,6 +878,8 @@
|
||||
<string name="preferences_chats__when_roaming">When roaming</string>
|
||||
<string name="preferences_chats__media_auto_download">Media auto-download</string>
|
||||
<string name="preferences_chats__message_trimming">Message trimming</string>
|
||||
<string name="preferences_advanced__use_system_emoji">Use system emoji</string>
|
||||
<string name="preferences_advanced__disable_textsecures_built_in_emoji_support">Disable TextSecure\'s built-in emoji support</string>
|
||||
|
||||
<!-- **************************************** -->
|
||||
<!-- menus -->
|
||||
|
@ -13,6 +13,11 @@
|
||||
android:summary="@string/preferences__pressing_the_enter_key_will_send_text_messages"
|
||||
android:title="@string/preferences__pref_enter_sends_title"/>
|
||||
|
||||
<CheckBoxPreference android:defaultValue="false"
|
||||
android:key="pref_system_emoji"
|
||||
android:title="@string/preferences_advanced__use_system_emoji"
|
||||
android:summary="@string/preferences_advanced__disable_textsecures_built_in_emoji_support" />
|
||||
|
||||
<Preference android:key="pref_choose_identity"
|
||||
android:title="@string/preferences__choose_identity"
|
||||
android:summary="@string/preferences__choose_your_contact_entry_from_the_contacts_list"/>
|
||||
|
@ -788,17 +788,21 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
SendButtonListener sendButtonListener = new SendButtonListener();
|
||||
ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
|
||||
|
||||
emojiToggle.attach(emojiDrawer);
|
||||
emojiToggle.setOnClickListener(new EmojiToggleListener());
|
||||
emojiDrawer.setEmojiEventListener(new EmojiEventListener() {
|
||||
@Override public void onKeyEvent(KeyEvent keyEvent) {
|
||||
composeText.dispatchKeyEvent(keyEvent);
|
||||
}
|
||||
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);
|
||||
}
|
||||
});
|
||||
@Override public void onEmojiSelected(String emoji) {
|
||||
composeText.insertEmoji(emoji);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
composeText.setOnEditorActionListener(sendButtonListener);
|
||||
attachButton.setOnClickListener(new AttachButtonListener());
|
||||
|
@ -9,6 +9,7 @@ import android.util.AttributeSet;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiProvider.EmojiDrawable;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
|
||||
public class EmojiEditText extends AppCompatEditText {
|
||||
@ -24,7 +25,9 @@ public class EmojiEditText extends AppCompatEditText {
|
||||
|
||||
public EmojiEditText(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
setFilters(new InputFilter[]{ new EmojiFilter(this) });
|
||||
if (!TextSecurePreferences.isSystemEmojiPreferred(getContext())) {
|
||||
setFilters(new InputFilter[]{ new EmojiFilter(this) });
|
||||
}
|
||||
}
|
||||
|
||||
public void insertEmoji(String emoji) {
|
||||
|
@ -11,11 +11,13 @@ import android.text.TextUtils.TruncateAt;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiProvider.EmojiDrawable;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
public class EmojiTextView extends AppCompatTextView {
|
||||
private CharSequence source;
|
||||
private boolean needsEllipsizing;
|
||||
private boolean useSystemEmoji;
|
||||
|
||||
public EmojiTextView(Context context) {
|
||||
this(context, null);
|
||||
@ -27,14 +29,20 @@ public class EmojiTextView extends AppCompatTextView {
|
||||
|
||||
public EmojiTextView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.useSystemEmoji = TextSecurePreferences.isSystemEmojiPreferred(getContext());
|
||||
}
|
||||
|
||||
@Override public void setText(@Nullable CharSequence text, BufferType type) {
|
||||
if (useSystemEmoji) {
|
||||
super.setText(text, type);
|
||||
return;
|
||||
}
|
||||
|
||||
source = EmojiProvider.getInstance(getContext()).emojify(text, this);
|
||||
setTextEllipsized(source);
|
||||
}
|
||||
|
||||
public void setTextEllipsized(final @Nullable CharSequence source) {
|
||||
private void setTextEllipsized(final @Nullable CharSequence source) {
|
||||
super.setText(needsEllipsizing ? ViewUtil.ellipsize(source, this) : source, BufferType.SPANNABLE);
|
||||
}
|
||||
|
||||
@ -46,7 +54,8 @@ public class EmojiTextView extends AppCompatTextView {
|
||||
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
final int size = MeasureSpec.getSize(widthMeasureSpec);
|
||||
final int mode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
if (getEllipsize() == TruncateAt.END &&
|
||||
if (!useSystemEmoji &&
|
||||
getEllipsize() == TruncateAt.END &&
|
||||
!TextUtils.isEmpty(source) &&
|
||||
(mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY) &&
|
||||
getPaint().breakText(source, 0, source.length()-1, true, size, null) != source.length())
|
||||
@ -62,7 +71,7 @@ public class EmojiTextView extends AppCompatTextView {
|
||||
}
|
||||
|
||||
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
if (changed) setTextEllipsized(source);
|
||||
if (changed && !useSystemEmoji) setTextEllipsized(source);
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
|
||||
|
||||
private static final String PUSH_MESSAGING_PREF = "pref_toggle_push_messaging";
|
||||
private static final String SUBMIT_DEBUG_LOG_PREF = "pref_submit_debug_logs";
|
||||
private static final String SYSTEM_EMOJI_PREF = TextSecurePreferences.SYSTEM_EMOJI_PREF;
|
||||
|
||||
private static final int PICK_IDENTITY_CONTACT = 1;
|
||||
|
||||
|
@ -88,6 +88,8 @@ public class TextSecurePreferences {
|
||||
public static final String MEDIA_DOWNLOAD_WIFI_PREF = "pref_media_download_wifi";
|
||||
public static final String MEDIA_DOWNLOAD_ROAMING_PREF = "pref_media_download_roaming";
|
||||
|
||||
public static final String SYSTEM_EMOJI_PREF = "pref_system_emoji";
|
||||
|
||||
public static NotificationPrivacyPreference getNotificationPrivacy(Context context) {
|
||||
return new NotificationPrivacyPreference(getStringPreference(context, NOTIFICATION_PRIVACY_PREF, "all"));
|
||||
}
|
||||
@ -447,6 +449,10 @@ public class TextSecurePreferences {
|
||||
return Integer.parseInt(getStringPreference(context, THREAD_TRIM_LENGTH, "500"));
|
||||
}
|
||||
|
||||
public static boolean isSystemEmojiPreferred(Context context) {
|
||||
return getBooleanPreference(context, SYSTEM_EMOJI_PREF, false);
|
||||
}
|
||||
|
||||
public static @NonNull Set<String> getMobileMediaDownloadAllowed(Context context) {
|
||||
return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_MOBILE_PREF, R.array.pref_media_download_mobile_data_default);
|
||||
}
|
||||
@ -465,7 +471,6 @@ public class TextSecurePreferences {
|
||||
new HashSet<>(Arrays.asList(context.getResources().getStringArray(defaultValuesRes))));
|
||||
}
|
||||
|
||||
|
||||
public static void setBooleanPreference(Context context, String key, boolean value) {
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(key, value).apply();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user