use emoji compat

This commit is contained in:
Daniel Gultsch 2017-09-29 19:44:30 +02:00
parent c69c358bac
commit 42b4528d03
11 changed files with 106 additions and 11 deletions

View file

@ -21,10 +21,11 @@ repositories {
configurations { configurations {
playstoreCompile playstoreCompile
freeCompile
} }
ext { ext {
supportLibVersion = '25.4.0' supportLibVersion = '26.1.0'
} }
dependencies { dependencies {
@ -34,6 +35,8 @@ dependencies {
compile 'com.soundcloud.android:android-crop:1.0.1@aar' compile 'com.soundcloud.android:android-crop:1.0.1@aar'
compile "com.android.support:support-v13:$supportLibVersion" compile "com.android.support:support-v13:$supportLibVersion"
compile "com.android.support:appcompat-v7:$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:bcprov-jdk15on:1.52'
compile 'org.bouncycastle:bcmail-jdk15on:1.52' compile 'org.bouncycastle:bcmail-jdk15on:1.52'
compile 'org.jitsi:org.otr4j:0.22' compile 'org.jitsi:org.otr4j:0.22'
@ -59,7 +62,7 @@ ext {
} }
android { android {
compileSdkVersion 25 compileSdkVersion 26
buildToolsVersion "26.0.2" buildToolsVersion "26.0.2"
defaultConfig { defaultConfig {

View file

@ -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);
}
}

View file

@ -62,6 +62,7 @@ import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate;
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
import eu.siacs.conversations.ui.adapter.ConversationAdapter; 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.ExceptionHelper;
import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
@ -178,6 +179,7 @@ public class ConversationActivity extends XmppActivity
@Override @Override
protected void onCreate(final Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
new EmojiService(this).init();
if (savedInstanceState != null) { if (savedInstanceState != null) {
mOpenConversation = savedInstanceState.getString(STATE_OPEN_CONVERSATION, null); mOpenConversation = savedInstanceState.getString(STATE_OPEN_CONVERSATION, null);
mPanelOpen = savedInstanceState.getBoolean(STATE_PANEL_OPEN, true); mPanelOpen = savedInstanceState.getBoolean(STATE_PANEL_OPEN, true);

View file

@ -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;
import eu.siacs.conversations.ui.adapter.MessageAdapter.OnContactPictureClicked; import eu.siacs.conversations.ui.adapter.MessageAdapter.OnContactPictureClicked;
import eu.siacs.conversations.ui.adapter.MessageAdapter.OnContactPictureLongClicked; 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.ui.widget.ListSelectionManager;
import eu.siacs.conversations.utils.NickValidityChecker; import eu.siacs.conversations.utils.NickValidityChecker;
import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.utils.UIHelper;

View file

@ -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);
}
}

View file

@ -5,10 +5,10 @@ import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
import android.support.text.emoji.widget.EmojiTextView;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.widget.TextView;
public class CopyTextView extends TextView { public class CopyTextView extends EmojiTextView {
public CopyTextView(Context context) { public CopyTextView(Context context) {
super(context); super(context);

View file

@ -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.EditorInfoCompat;
import android.support.v13.view.inputmethod.InputConnectionCompat; import android.support.v13.view.inputmethod.InputConnectionCompat;
import android.support.v13.view.inputmethod.InputContentInfoCompat; import android.support.v13.view.inputmethod.InputContentInfoCompat;
@ -15,11 +16,10 @@ import android.util.AttributeSet;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputConnection;
import android.widget.EditText;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
public class EditMessage extends EditText { public class EditMessage extends EmojiEditText {
public interface OnCommitContentListener { public interface OnCommitContentListener {
boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts, String[] mimeTypes); boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts, String[] mimeTypes);

View file

@ -37,7 +37,7 @@
android:layout_toRightOf="@+id/conversation_image" android:layout_toRightOf="@+id/conversation_image"
android:paddingLeft="8dp"> android:paddingLeft="8dp">
<TextView <android.support.text.emoji.widget.EmojiTextView
android:id="@+id/conversation_name" android:id="@+id/conversation_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -79,7 +79,7 @@
android:layout_alignWithParentIfMissing="true" android:layout_alignWithParentIfMissing="true"
android:layout_toLeftOf="@+id/notification_status" android:layout_toLeftOf="@+id/notification_status"
android:id="@+id/txt_img_wrapper"> android:id="@+id/txt_img_wrapper">
<TextView <android.support.text.emoji.widget.EmojiTextView
android:id="@+id/conversation_lastmsg" android:id="@+id/conversation_lastmsg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -29,7 +29,7 @@
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:background="?attr/color_background_primary" > android:background="?attr/color_background_primary" >
<eu.siacs.conversations.ui.EditMessage <eu.siacs.conversations.ui.widget.EditMessage
android:id="@+id/textinput" android:id="@+id/textinput"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -48,7 +48,7 @@
android:textColor="?attr/color_text_primary" > android:textColor="?attr/color_text_primary" >
<requestFocus /> <requestFocus />
</eu.siacs.conversations.ui.EditMessage> </eu.siacs.conversations.ui.widget.EditMessage>
<ImageButton <ImageButton
android:id="@+id/textSendButton" android:id="@+id/textSendButton"

View file

@ -0,0 +1,45 @@
package eu.siacs.conversations.ui.service;
import android.content.Context;
import android.support.text.emoji.EmojiCompat;
import android.support.text.emoji.FontRequestEmojiCompatConfig;
import android.support.v4.provider.FontRequest;
import android.util.Log;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
public class EmojiService extends AbstractEmojiService {
private final EmojiCompat.InitCallback initCallback = new EmojiCompat.InitCallback() {
@Override
public void onInitialized() {
super.onInitialized();
Log.d(Config.LOGTAG,"EmojiService succeeded in loading fonts");
}
@Override
public void onFailed(Throwable throwable) {
super.onFailed(throwable);
Log.d(Config.LOGTAG,"EmojiService failed to load fonts",throwable);
}
};
public EmojiService(Context context) {
super(context);
}
@Override
protected EmojiCompat.Config buildConfig() {
final FontRequest fontRequest = new FontRequest(
"com.google.android.gms.fonts",
"com.google.android.gms",
"Noto Color Emoji Compat",
R.array.font_certs);
FontRequestEmojiCompatConfig fontRequestEmojiCompatConfig = new FontRequestEmojiCompatConfig(context, fontRequest);
fontRequestEmojiCompatConfig.registerInitCallback(initCallback);
return fontRequestEmojiCompatConfig;
}
}

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="font_certs">
<item>MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtWLgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKkedxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5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