From 42b4528d034ccad9c9eda5e6b2bbd6b636507548 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 29 Sep 2017 19:44:30 +0200 Subject: [PATCH] use emoji compat --- build.gradle | 7 ++- .../ui/service/EmojiService.java | 17 +++++++ .../ui/ConversationActivity.java | 2 + .../ui/ConversationFragment.java | 1 + .../ui/service/AbstractEmojiService.java | 21 +++++++++ .../conversations/ui/widget/CopyTextView.java | 4 +- .../ui/{ => widget}/EditMessage.java | 6 +-- src/main/res/layout/conversation_list_row.xml | 4 +- src/main/res/layout/fragment_conversation.xml | 4 +- .../ui/service/EmojiService.java | 45 +++++++++++++++++++ src/playstore/res/values/font_certs.xml | 6 +++ 11 files changed, 106 insertions(+), 11 deletions(-) create mode 100644 src/free/java/eu/siacs/conversations/ui/service/EmojiService.java create mode 100644 src/main/java/eu/siacs/conversations/ui/service/AbstractEmojiService.java rename src/main/java/eu/siacs/conversations/ui/{ => widget}/EditMessage.java (97%) create mode 100644 src/playstore/java/eu/siacs/conversations/ui/service/EmojiService.java create mode 100644 src/playstore/res/values/font_certs.xml diff --git a/build.gradle b/build.gradle index b8dbb30b4..767f37ae9 100644 --- a/build.gradle +++ b/build.gradle @@ -21,10 +21,11 @@ repositories { configurations { playstoreCompile + freeCompile } ext { - supportLibVersion = '25.4.0' + supportLibVersion = '26.1.0' } dependencies { @@ -34,6 +35,8 @@ dependencies { compile 'com.soundcloud.android:android-crop:1.0.1@aar' compile "com.android.support:support-v13:$supportLibVersion" compile "com.android.support:appcompat-v7:$supportLibVersion" + compile "com.android.support:support-emoji:$supportLibVersion" + freeCompile "com.android.support:support-emoji-bundled:$supportLibVersion" compile 'org.bouncycastle:bcprov-jdk15on:1.52' compile 'org.bouncycastle:bcmail-jdk15on:1.52' compile 'org.jitsi:org.otr4j:0.22' @@ -59,7 +62,7 @@ ext { } android { - compileSdkVersion 25 + compileSdkVersion 26 buildToolsVersion "26.0.2" defaultConfig { diff --git a/src/free/java/eu/siacs/conversations/ui/service/EmojiService.java b/src/free/java/eu/siacs/conversations/ui/service/EmojiService.java new file mode 100644 index 000000000..5d336a6fc --- /dev/null +++ b/src/free/java/eu/siacs/conversations/ui/service/EmojiService.java @@ -0,0 +1,17 @@ +package eu.siacs.conversations.ui.service; + +import android.content.Context; +import android.support.text.emoji.EmojiCompat; +import android.support.text.emoji.bundled.BundledEmojiCompatConfig; + +public class EmojiService extends AbstractEmojiService { + + public EmojiService(Context context) { + super(context); + } + + @Override + protected EmojiCompat.Config buildConfig() { + return new BundledEmojiCompatConfig(context); + } +} \ No newline at end of file diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index a044b4dca..7ce1c5cda 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -62,6 +62,7 @@ import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.ui.adapter.ConversationAdapter; +import eu.siacs.conversations.ui.service.EmojiService; import eu.siacs.conversations.utils.ExceptionHelper; import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.xmpp.OnUpdateBlocklist; @@ -178,6 +179,7 @@ public class ConversationActivity extends XmppActivity @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + new EmojiService(this).init(); if (savedInstanceState != null) { mOpenConversation = savedInstanceState.getString(STATE_OPEN_CONVERSATION, null); mPanelOpen = savedInstanceState.getBoolean(STATE_PANEL_OPEN, true); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 02b7dd732..98fdbf409 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -70,6 +70,7 @@ import eu.siacs.conversations.ui.XmppActivity.OnValueEdited; import eu.siacs.conversations.ui.adapter.MessageAdapter; import eu.siacs.conversations.ui.adapter.MessageAdapter.OnContactPictureClicked; import eu.siacs.conversations.ui.adapter.MessageAdapter.OnContactPictureLongClicked; +import eu.siacs.conversations.ui.widget.EditMessage; import eu.siacs.conversations.ui.widget.ListSelectionManager; import eu.siacs.conversations.utils.NickValidityChecker; import eu.siacs.conversations.utils.UIHelper; diff --git a/src/main/java/eu/siacs/conversations/ui/service/AbstractEmojiService.java b/src/main/java/eu/siacs/conversations/ui/service/AbstractEmojiService.java new file mode 100644 index 000000000..407d8d728 --- /dev/null +++ b/src/main/java/eu/siacs/conversations/ui/service/AbstractEmojiService.java @@ -0,0 +1,21 @@ +package eu.siacs.conversations.ui.service; + +import android.content.Context; +import android.support.text.emoji.EmojiCompat; + +public abstract class AbstractEmojiService { + + protected final Context context; + + public AbstractEmojiService(Context context) { + this.context = context; + } + + protected abstract EmojiCompat.Config buildConfig(); + + public void init() { + final EmojiCompat.Config config = buildConfig(); + config.setReplaceAll(true); + EmojiCompat.init(config); + } +} diff --git a/src/main/java/eu/siacs/conversations/ui/widget/CopyTextView.java b/src/main/java/eu/siacs/conversations/ui/widget/CopyTextView.java index bed56192e..4857254bc 100644 --- a/src/main/java/eu/siacs/conversations/ui/widget/CopyTextView.java +++ b/src/main/java/eu/siacs/conversations/ui/widget/CopyTextView.java @@ -5,10 +5,10 @@ import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.os.Build; +import android.support.text.emoji.widget.EmojiTextView; import android.util.AttributeSet; -import android.widget.TextView; -public class CopyTextView extends TextView { +public class CopyTextView extends EmojiTextView { public CopyTextView(Context context) { super(context); diff --git a/src/main/java/eu/siacs/conversations/ui/EditMessage.java b/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java similarity index 97% rename from src/main/java/eu/siacs/conversations/ui/EditMessage.java rename to src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java index 6686d951b..ca73564f5 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditMessage.java +++ b/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java @@ -1,5 +1,6 @@ -package eu.siacs.conversations.ui; +package eu.siacs.conversations.ui.widget; +import android.support.text.emoji.widget.EmojiEditText; import android.support.v13.view.inputmethod.EditorInfoCompat; import android.support.v13.view.inputmethod.InputConnectionCompat; import android.support.v13.view.inputmethod.InputContentInfoCompat; @@ -15,11 +16,10 @@ import android.util.AttributeSet; import android.view.KeyEvent; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; -import android.widget.EditText; import eu.siacs.conversations.Config; -public class EditMessage extends EditText { +public class EditMessage extends EmojiEditText { public interface OnCommitContentListener { boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts, String[] mimeTypes); diff --git a/src/main/res/layout/conversation_list_row.xml b/src/main/res/layout/conversation_list_row.xml index 65be4802a..44e7553f5 100644 --- a/src/main/res/layout/conversation_list_row.xml +++ b/src/main/res/layout/conversation_list_row.xml @@ -37,7 +37,7 @@ android:layout_toRightOf="@+id/conversation_image" android:paddingLeft="8dp"> - - - - + + + + MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcN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