1
0
Fork 1

bump appcompat, migrate to emoji2 and get rid of emoji flavor [Daniel Gultsch]

This commit is contained in:
12aw 2022-03-19 17:12:05 +01:00
parent efbe37cace
commit ff0e3ca111
23 changed files with 71 additions and 267 deletions

View file

@ -64,9 +64,8 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1' // 1.4.0 needs minCompileSdk 31
implementation 'androidx.exifinterface:exifinterface:1.3.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.emoji:emoji:1.1.0'
gitImplementation 'androidx.emoji:emoji-appcompat:1.1.0'
gitImplementation 'androidx.emoji:emoji-bundled:1.1.0'
implementation "androidx.emoji2:emoji2:1.1.0-rc01"
gitImplementation "androidx.emoji2:emoji2-bundled:1.1.0-rc01"
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.cardview:cardview:1.0.0' // for compatibility
@ -101,7 +100,7 @@ ext {
android {
//noinspection GradleCompatible
compileSdkVersion 30
compileSdkVersion 31
defaultConfig {
minSdkVersion 21

View file

@ -0,0 +1,14 @@
package eu.siacs.conversations.services;
import android.content.Context;
import androidx.emoji2.bundled.BundledEmojiCompatConfig;
import androidx.emoji2.text.EmojiCompat;
public class EmojiInitializationService {
public static void execute(final Context context) {
EmojiCompat.init(new BundledEmojiCompatConfig(context).setReplaceAll(true));
}
}

View file

@ -0,0 +1,14 @@
package eu.siacs.conversations.services;
import android.content.Context;
import androidx.emoji2.bundled.BundledEmojiCompatConfig;
import androidx.emoji2.text.EmojiCompat;
public class EmojiInitializationService {
public static void execute(final Context context) {
EmojiCompat.init(new BundledEmojiCompatConfig(context).setReplaceAll(true));
}
}

View file

@ -1,18 +0,0 @@
package eu.siacs.conversations.ui.widget;
import android.content.Context;
import android.util.AttributeSet;
import androidx.emoji.widget.EmojiAppCompatEditText;
public class EmojiWrapperEditText extends EmojiAppCompatEditText {
public EmojiWrapperEditText(Context context) {
super(context);
}
public EmojiWrapperEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
}

View file

@ -1,53 +0,0 @@
package eu.siacs.conversations.services;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import androidx.core.provider.FontRequest;
import androidx.emoji.text.EmojiCompat;
import androidx.emoji.text.FontRequestEmojiCompatConfig;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
public class EmojiService {
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);
}
};
private final Context context;
public EmojiService(Context context) {
this.context = context;
}
public void init(boolean useBundledEmoji) {
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);
//On recent Androids we assume to have the latest emojis
//there are some annoying bugs with emoji compat that make it a safer choice not to use it when possible
// a) when using the ondemand emoji font (play store) flags dont work
// b) the text preview has annoying glitches when the cut of text contains emojis (the emoji will be half visible)
// c) can trigger a hardware rendering bug https://issuetracker.google.com/issues/67102093
fontRequestEmojiCompatConfig.setReplaceAll(useBundledEmoji && Build.VERSION.SDK_INT < Build.VERSION_CODES.O);
EmojiCompat.init(fontRequestEmojiCompatConfig);
}
}

View file

@ -67,7 +67,6 @@ import eu.siacs.conversations.ui.RtpSessionActivity;
import eu.siacs.conversations.ui.TimePreference;
import eu.siacs.conversations.utils.AccountUtils;
import eu.siacs.conversations.utils.Compatibility;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.GeoHelper;
import eu.siacs.conversations.utils.ThemeHelper;
import eu.siacs.conversations.utils.TorServiceUtils;
@ -1386,14 +1385,14 @@ public class NotificationService {
SpannableString styledString;
for (Message message : messages) {
final SpannableString name = UIHelper.getColoredUsername(mXmppConnectionService, message);
styledString = new SpannableString(name + ": " + EmojiWrapper.transform(replaceYoutube(mXmppConnectionService, message.getBody())));
styledString = new SpannableString(name + ": " + replaceYoutube(mXmppConnectionService, message.getBody()));
style.addLine(styledString);
}
builder.setStyle(style);
int count = messages.size();
if (count == 1) {
final SpannableString name = UIHelper.getColoredUsername(mXmppConnectionService, messages.get(0));
styledString = new SpannableString(name + ": " + EmojiWrapper.transform(replaceYoutube(mXmppConnectionService, messages.get(0).getBody())));
styledString = new SpannableString(name + ": " + replaceYoutube(mXmppConnectionService, messages.get(0).getBody()));
builder.setContentText(styledString);
builder.setTicker(styledString);
} else {

View file

@ -52,7 +52,6 @@ import eu.siacs.conversations.ui.util.MucDetailsContextMenuHelper;
import eu.siacs.conversations.ui.util.MyLinkify;
import eu.siacs.conversations.ui.util.SoftKeyboardUtils;
import eu.siacs.conversations.utils.Compatibility;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.MenuDoubleTabUtil;
import eu.siacs.conversations.utils.StringUtils;
import eu.siacs.conversations.utils.StylingHelper;
@ -414,7 +413,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
if (owner || printableValue(name)) {
this.binding.mucEditTitle.setVisibility(View.VISIBLE);
if (name != null) {
this.binding.mucEditTitle.append(EmojiWrapper.transform(name));
this.binding.mucEditTitle.append(name);
}
} else {
this.binding.mucEditTitle.setVisibility(View.GONE);
@ -423,7 +422,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
final String subject = mucOptions.getSubject();
this.binding.mucEditSubject.setText("");
if (subject != null) {
this.binding.mucEditSubject.append(EmojiWrapper.transform(subject));
this.binding.mucEditSubject.append(subject);
}
this.binding.mucEditSubject.setEnabled(mucOptions.canChangeSubject());
if (!owner) {
@ -592,11 +591,11 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
String subject = mucOptions.getSubject();
final boolean hasTitle;
if (printableValue(roomName)) {
this.binding.mucTitle.setText(EmojiWrapper.transform(roomName));
this.binding.mucTitle.setText(roomName);
this.binding.mucTitle.setVisibility(View.VISIBLE);
hasTitle = true;
} else if (!printableValue(subject)) {
this.binding.mucTitle.setText(EmojiWrapper.transform(mConversation.getName()));
this.binding.mucTitle.setText(mConversation.getName());
hasTitle = true;
this.binding.mucTitle.setVisibility(View.VISIBLE);
} else {
@ -607,7 +606,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
SpannableStringBuilder spannable = new SpannableStringBuilder(subject);
StylingHelper.format(spannable, this.binding.mucSubject.getCurrentTextColor(), true);
MyLinkify.addLinks(spannable, false);
this.binding.mucSubject.setText(EmojiWrapper.transform(spannable));
this.binding.mucSubject.setText(spannable);
this.binding.mucSubject.setTextAppearance(this, subject.length() > (hasTitle ? 128 : 196) ? R.style.TextAppearance_Conversations_Body1_Linkified : R.style.TextAppearance_Conversations_Subhead);
this.binding.mucSubject.setAutoLinkMask(0);
this.binding.mucSubject.setVisibility(View.VISIBLE);
@ -615,7 +614,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
} else {
this.binding.mucSubject.setVisibility(View.GONE);
}
this.binding.mucYourNick.setText(EmojiWrapper.transform(mucOptions.getActualNick()));
this.binding.mucYourNick.setText(mucOptions.getActualNick());
if (mucOptions.online()) {
this.binding.usersWrapper.setVisibility(View.VISIBLE);
this.binding.mucInfoMore.setVisibility(this.mAdvancedMode ? View.VISIBLE : View.GONE);

View file

@ -51,7 +51,6 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.databinding.ActivityContactDetailsBinding;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
@ -68,7 +67,6 @@ import eu.siacs.conversations.ui.util.CallManager;
import eu.siacs.conversations.ui.util.GridManager;
import eu.siacs.conversations.ui.util.JidDialog;
import eu.siacs.conversations.utils.Compatibility;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.Emoticons;
import eu.siacs.conversations.utils.IrregularUnicodeDetector;
import eu.siacs.conversations.utils.MenuDoubleTabUtil;
@ -591,7 +589,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
builder.append("\n");
}
}
binding.statusMessage.setText(EmojiWrapper.transform(builder));
binding.statusMessage.setText(builder);
}
String resources = contact.getPresences().getMostAvailableResource();
if (resources.length() == 0) {
@ -681,26 +679,6 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
binding.detailsContactKeys.removeAllViews();
boolean hasKeys = false;
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (Config.supportOtr()) {
for (final String otrFingerprint : contact.getOtrFingerprints()) {
hasKeys = true;
View view = inflater.inflate(R.layout.contact_key, binding.detailsContactKeys, false);
TextView key = view.findViewById(R.id.key);
TextView keyType = view.findViewById(R.id.key_type);
ImageButton removeButton = view
.findViewById(R.id.button_remove);
removeButton.setVisibility(View.VISIBLE);
key.setText(CryptoHelper.prettifyFingerprint(otrFingerprint));
if (otrFingerprint != null && otrFingerprint.equalsIgnoreCase(messageFingerprint)) {
keyType.setText(R.string.otr_fingerprint_selected_message);
keyType.setTextColor(ContextCompat.getColor(this, R.color.accent));
} else {
keyType.setText(R.string.otr_fingerprint);
}
binding.detailsContactKeys.addView(view);
removeButton.setOnClickListener(v -> confirmToDeleteFingerprint(otrFingerprint));
}
}
final AxolotlService axolotlService = contact.getAccount().getAxolotlService();
if (Config.supportOmemo() && axolotlService != null) {
final Collection<XmppAxolotlSession> sessions = axolotlService.findSessionsForContact(contact);
@ -789,20 +767,6 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
}
}
}
protected void confirmToDeleteFingerprint(final String fingerprint) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.delete_fingerprint);
builder.setMessage(R.string.sure_delete_fingerprint);
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(R.string.delete,
(dialog, which) -> {
if (contact.deleteOtrFingerprint(fingerprint)) {
populateView();
xmppConnectionService.syncRosterToDisk(contact.getAccount());
}
});
builder.create().show();
}
public void onBackendConnected() {
if (accountJid != null && contactJid != null) {

View file

@ -97,7 +97,6 @@ import eu.siacs.conversations.ui.util.IntroHelper;
import eu.siacs.conversations.ui.util.PendingItem;
import eu.siacs.conversations.ui.util.StyledAttributes;
import eu.siacs.conversations.ui.util.UpdateHelper;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.utils.MenuDoubleTabUtil;
import eu.siacs.conversations.utils.Namespace;
@ -885,7 +884,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
actionBar.setDisplayShowCustomEnabled(true);
TextView abtitle = findViewById(android.R.id.text1);
TextView absubtitle = findViewById(android.R.id.text2);
abtitle.setText(EmojiWrapper.transform(conversation.getName()));
abtitle.setText(conversation.getName());
abtitle.setSelected(true);
if (conversation.getMode() == Conversation.MODE_SINGLE) {
if (!conversation.withSelf()) {
@ -921,7 +920,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
if (userWithChatStates.size() > 0) {
if (userWithChatStates.size() == 1) {
MucOptions.User user = userWithChatStates.get(0);
absubtitle.setText(EmojiWrapper.transform(getString(R.string.contact_is_typing, UIHelper.getDisplayName(user))));
absubtitle.setText(getString(R.string.contact_is_typing, UIHelper.getDisplayName(user)));
absubtitle.setVisibility(View.VISIBLE);
} else {
StringBuilder builder = new StringBuilder();
@ -931,7 +930,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
}
builder.append(UIHelper.getDisplayName(user));
}
absubtitle.setText(EmojiWrapper.transform(getString(R.string.contacts_are_typing, builder.toString())));
absubtitle.setText(getString(R.string.contacts_are_typing, builder.toString()));
absubtitle.setVisibility(View.VISIBLE);
}
}

View file

@ -84,6 +84,7 @@ import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Presences;
import eu.siacs.conversations.services.AvatarService;
import eu.siacs.conversations.services.BarcodeProvider;
import eu.siacs.conversations.services.EmojiInitializationService;
import eu.siacs.conversations.services.QuickConversationsService;
import eu.siacs.conversations.services.UpdateService;
import eu.siacs.conversations.services.XmppConnectionService;
@ -454,6 +455,7 @@ public abstract class XmppActivity extends ActionBarActivity {
setTheme(this.mTheme);
metrics = getResources().getDisplayMetrics();
ExceptionHelper.init(getApplicationContext());
EmojiInitializationService.execute(this);
this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
if (isDarkTheme()) {
mColorWarningButton = ContextCompat.getColor(this, R.color.warning_button_dark);

View file

@ -33,7 +33,6 @@ import eu.siacs.conversations.ui.ConversationFragment;
import eu.siacs.conversations.ui.XmppActivity;
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
import eu.siacs.conversations.ui.util.StyledAttributes;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.IrregularUnicodeDetector;
import eu.siacs.conversations.utils.StylingHelper;
import eu.siacs.conversations.utils.UIHelper;
@ -72,7 +71,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
if (name instanceof Jid) {
viewHolder.binding.conversationName.setText(IrregularUnicodeDetector.style(activity, (Jid) name));
} else {
viewHolder.binding.conversationName.setText(EmojiWrapper.transform(name));
viewHolder.binding.conversationName.setText(name);
}
if (activity.xmppConnectionService.multipleAccounts() && activity.xmppConnectionService.showOwnAccounts()) {
@ -119,7 +118,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
if (draft != null) {
viewHolder.binding.conversationLastmsgImg.setVisibility(View.GONE);
viewHolder.binding.conversationLastmsg.setText(EmojiWrapper.transform(replaceYoutube(activity.getApplicationContext(), draft.getMessage())));
viewHolder.binding.conversationLastmsg.setText(draft.getMessage());
viewHolder.binding.senderName.setText(R.string.draft);
viewHolder.binding.senderName.setVisibility(View.VISIBLE);
viewHolder.binding.conversationLastmsg.setTypeface(null, Typeface.NORMAL);
@ -163,11 +162,11 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
final Pair<CharSequence, Boolean> preview = UIHelper.getMessagePreview(activity, message, viewHolder.binding.conversationLastmsg.getCurrentTextColor());
if (showPreviewText) {
if (message.hasDeletedBody()) {
viewHolder.binding.conversationLastmsg.setText(EmojiWrapper.transform(UIHelper.shorten(activity.getString(R.string.message_deleted))));
viewHolder.binding.conversationLastmsg.setText(UIHelper.shorten(activity.getString(R.string.message_deleted)));
} else {
SpannableStringBuilder body = new SpannableStringBuilder(replaceYoutube(activity.getApplicationContext(), preview.first.toString()));
StylingHelper.format(body, viewHolder.binding.conversationLastmsg.getCurrentTextColor(), true);
viewHolder.binding.conversationLastmsg.setText(EmojiWrapper.transform(UIHelper.shorten(body)));
viewHolder.binding.conversationLastmsg.setText(UIHelper.shorten(body));
}
} else {
viewHolder.binding.conversationLastmsgImg.setContentDescription(preview.first);

View file

@ -22,7 +22,6 @@ import eu.siacs.conversations.ui.SettingsActivity;
import eu.siacs.conversations.ui.XmppActivity;
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
import eu.siacs.conversations.ui.util.StyledAttributes;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.IrregularUnicodeDetector;
import eu.siacs.conversations.xmpp.Jid;
@ -98,7 +97,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
} else {
viewHolder.account.setVisibility(View.GONE);
}
viewHolder.name.setText(EmojiWrapper.transform(item.getDisplayName()));
viewHolder.name.setText(item.getDisplayName());
if (tags.size() != 0) {
for (ListItem.Tag tag : tags) {
offline = tag.getOffline() == 1;

View file

@ -89,7 +89,6 @@ import eu.siacs.conversations.ui.util.ViewUtil;
import eu.siacs.conversations.ui.widget.ClickableMovementMethod;
import eu.siacs.conversations.ui.widget.RichLinkView;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.Emoticons;
import eu.siacs.conversations.utils.GeoHelper;
import eu.siacs.conversations.utils.MessageUtils;
@ -474,7 +473,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
final Spannable span = new SpannableString(body);
final float size = Emoticons.isEmoji(body) ? 3.0f : 2.0f;
span.setSpan(new RelativeSizeSpan(size), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
viewHolder.messageBody.setText(EmojiWrapper.transform(span));
viewHolder.messageBody.setText(span);
}
private void displayXmppMessage(final ViewHolder viewHolder, final String body) {
@ -678,7 +677,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
MyLinkify.addLinks(body, true);
viewHolder.messageBody.setAutoLinkMask(0);
viewHolder.messageBody.setText(EmojiWrapper.transform(body));
viewHolder.messageBody.setText(body);
viewHolder.messageBody.setMovementMethod(ClickableMovementMethod.getInstance());
} else {
viewHolder.messageBody.setText("");
@ -1229,7 +1228,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else {
viewHolder.status_message.setVisibility(View.VISIBLE);
viewHolder.load_more_messages.setVisibility(View.GONE);
viewHolder.status_message.setText(EmojiWrapper.transform(message.getBody()));
viewHolder.status_message.setText(message.getBody());
boolean showAvatar;
if (conversation.getMode() == Conversation.MODE_SINGLE) {
showAvatar = true;

View file

@ -15,6 +15,7 @@ import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.core.view.inputmethod.EditorInfoCompat;
import androidx.core.view.inputmethod.InputConnectionCompat;
import androidx.core.view.inputmethod.InputContentInfoCompat;
@ -26,7 +27,7 @@ import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.ui.util.QuoteHelper;
public class EditMessage extends EmojiWrapperEditText {
public class EditMessage extends AppCompatEditText {
private static final InputFilter SPAN_FILTER = (source, start, end, dest, dstart, dend) -> source instanceof Spanned ? source.toString() : source;
private final ExecutorService executor = Executors.newSingleThreadExecutor();

View file

@ -1,46 +0,0 @@
/*
* Copyright (c) 2017, Daniel Gultsch All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package eu.siacs.conversations.utils;
import androidx.emoji.text.EmojiCompat;
public class EmojiWrapper {
public static CharSequence transform(CharSequence input) {
try {
if (EmojiCompat.get().getLoadState() == EmojiCompat.LOAD_STATE_SUCCEEDED) {
return EmojiCompat.get().process(input);
} else {
return input;
}
} catch (IllegalStateException e) {
return input;
}
}
}

View file

@ -126,7 +126,7 @@
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint">
<eu.siacs.conversations.ui.widget.EmojiWrapperEditText
<EditText
android:id="@+id/muc_edit_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -141,7 +141,7 @@
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint">
<eu.siacs.conversations.ui.widget.EmojiWrapperEditText
<EditText
android:id="@+id/muc_edit_subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -34,7 +34,7 @@
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint">
<eu.siacs.conversations.ui.widget.EmojiWrapperEditText
<EditText
android:id="@+id/group_chat_name"
style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent"

View file

@ -28,7 +28,7 @@
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint">
<eu.siacs.conversations.ui.widget.EmojiWrapperEditText
<EditText
android:id="@+id/group_chat_name"
style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent"

View file

@ -17,7 +17,7 @@
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint">
<eu.siacs.conversations.ui.widget.EmojiWrapperEditText
<EditText
android:id="@+id/input_edit_text"
style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent"
@ -26,8 +26,7 @@
android:inputType="textPersonName"
android:textColor="?attr/text_Color_Main">
<requestFocus />
</eu.siacs.conversations.ui.widget.EmojiWrapperEditText>
</EditText>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</layout>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="font_certs">
<item>MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtWLgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKkedxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK</item>
</string-array>
</resources>

View file

@ -0,0 +1,10 @@
package eu.siacs.conversations.services;
import android.content.Context;
public class EmojiInitializationService {
public static void execute(final Context context) {
}
}

View file

@ -1,53 +0,0 @@
package eu.siacs.conversations.services;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import androidx.core.provider.FontRequest;
import androidx.emoji.text.EmojiCompat;
import androidx.emoji.text.FontRequestEmojiCompatConfig;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
public class EmojiService {
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);
}
};
private final Context context;
public EmojiService(Context context) {
this.context = context;
}
public void init(boolean useBundledEmoji) {
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);
//On recent Androids we assume to have the latest emojis
//there are some annoying bugs with emoji compat that make it a safer choice not to use it when possible
// a) when using the ondemand emoji font (play store) flags dont work
// b) the text preview has annoying glitches when the cut of text contains emojis (the emoji will be half visible)
// c) can trigger a hardware rendering bug https://issuetracker.google.com/issues/67102093
fontRequestEmojiCompatConfig.setReplaceAll(useBundledEmoji && Build.VERSION.SDK_INT < Build.VERSION_CODES.O);
EmojiCompat.init(fontRequestEmojiCompatConfig);
}
}

View file

@ -1,17 +0,0 @@
package eu.siacs.conversations.ui.widget;
import android.content.Context;
import android.util.AttributeSet;
import androidx.appcompat.widget.AppCompatEditText;
public class EmojiWrapperEditText extends AppCompatEditText {
public EmojiWrapperEditText(Context context) {
super(context);
}
public EmojiWrapperEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
}