add ability to use system emojis instead of integrated ones via expert settings
This commit is contained in:
parent
d03129f130
commit
b6052c82cb
9 changed files with 38 additions and 8 deletions
|
@ -2,6 +2,10 @@ package de.pixart.messenger.services;
|
|||
|
||||
import android.content.Context;
|
||||
import android.support.text.emoji.EmojiCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import de.pixart.messenger.Config;
|
||||
import de.pixart.messenger.utils.Emoticons;
|
||||
|
||||
public abstract class AbstractEmojiService {
|
||||
|
||||
|
@ -13,9 +17,11 @@ public abstract class AbstractEmojiService {
|
|||
|
||||
protected abstract EmojiCompat.Config buildConfig();
|
||||
|
||||
public void init() {
|
||||
final EmojiCompat.Config config = buildConfig();
|
||||
config.setReplaceAll(true);
|
||||
public void init(boolean useBundledEmoji) {
|
||||
Log.d(Config.LOGTAG, "Emojis: use integrated lib " + useBundledEmoji);
|
||||
EmojiCompat.Config config = buildConfig();
|
||||
config.setReplaceAll(useBundledEmoji);
|
||||
EmojiCompat.reset(config);
|
||||
EmojiCompat.init(config);
|
||||
}
|
||||
}
|
|
@ -88,6 +88,7 @@ import de.pixart.messenger.xmpp.jid.InvalidJidException;
|
|||
import de.pixart.messenger.xmpp.jid.Jid;
|
||||
import de.timroes.android.listview.EnhancedListView;
|
||||
|
||||
import static de.pixart.messenger.ui.SettingsActivity.USE_BUNDLED_EMOJIS;
|
||||
import static de.pixart.messenger.ui.ShowFullscreenMessageActivity.getMimeType;
|
||||
|
||||
public class ConversationActivity extends XmppActivity
|
||||
|
@ -210,7 +211,7 @@ public class ConversationActivity extends XmppActivity
|
|||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
new EmojiService(this).init();
|
||||
new EmojiService(this).init(useBundledEmoji());
|
||||
if (savedInstanceState != null) {
|
||||
mOpenConversation = savedInstanceState.getString(STATE_OPEN_CONVERSATION, null);
|
||||
mPanelOpen = savedInstanceState.getBoolean(STATE_PANEL_OPEN, true);
|
||||
|
@ -2100,6 +2101,10 @@ public class ConversationActivity extends XmppActivity
|
|||
return getPreferences().getBoolean("use_white_background", getResources().getBoolean(R.bool.use_white_background));
|
||||
}
|
||||
|
||||
public boolean useBundledEmoji() {
|
||||
return getPreferences().getBoolean(USE_BUNDLED_EMOJIS, getResources().getBoolean(R.bool.use_bundled_emoji));
|
||||
}
|
||||
|
||||
protected boolean trustKeysIfNeeded(int requestCode) {
|
||||
return trustKeysIfNeeded(requestCode, ATTACHMENT_CHOICE_INVALID);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public class SettingsActivity extends XmppActivity implements
|
|||
public static final String THEME = "theme";
|
||||
public static final String SHOW_DYNAMIC_TAGS = "show_dynamic_tags";
|
||||
public static final String SHOW_FOREGROUND_SERVICE = "show_foreground_service";
|
||||
public static final String USE_BUNDLED_EMOJIS = "use_bundled_emoji";
|
||||
|
||||
public static final int REQUEST_WRITE_LOGS = 0xbf8701;
|
||||
private SettingsFragment mSettingsFragment;
|
||||
|
|
|
@ -33,6 +33,7 @@ import de.pixart.messenger.xmpp.XmppConnection;
|
|||
import de.pixart.messenger.xmpp.jid.InvalidJidException;
|
||||
import de.pixart.messenger.xmpp.jid.Jid;
|
||||
|
||||
import static de.pixart.messenger.ui.SettingsActivity.USE_BUNDLED_EMOJIS;
|
||||
import static java.lang.String.format;
|
||||
|
||||
public class ShareWithActivity extends XmppActivity implements XmppConnectionService.OnConversationUpdate {
|
||||
|
@ -173,7 +174,8 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
new EmojiService(this).init();
|
||||
boolean useBundledEmoji = getPreferences().getBoolean(USE_BUNDLED_EMOJIS, getResources().getBoolean(R.bool.use_bundled_emoji));
|
||||
new EmojiService(this).init(useBundledEmoji);
|
||||
if (getActionBar() != null) {
|
||||
getActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
getActionBar().setHomeButtonEnabled(false);
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.app.Activity;
|
|||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
|
@ -12,6 +13,7 @@ import android.net.Uri;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
@ -34,6 +36,8 @@ import de.pixart.messenger.Config;
|
|||
import de.pixart.messenger.R;
|
||||
import de.pixart.messenger.services.EmojiService;
|
||||
|
||||
import static de.pixart.messenger.ui.SettingsActivity.USE_BUNDLED_EMOJIS;
|
||||
|
||||
public class ShowLocationActivity extends Activity implements OnMapReadyCallback {
|
||||
|
||||
private GoogleMap mGoogleMap;
|
||||
|
@ -70,7 +74,8 @@ public class ShowLocationActivity extends Activity implements OnMapReadyCallback
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
new EmojiService(this).init();
|
||||
boolean useBundledEmoji = getPreferences().getBoolean(USE_BUNDLED_EMOJIS, getResources().getBoolean(R.bool.use_bundled_emoji));
|
||||
new EmojiService(this).init(useBundledEmoji);
|
||||
if (getActionBar() != null) {
|
||||
getActionBar().setHomeButtonEnabled(true);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
@ -81,6 +86,10 @@ public class ShowLocationActivity extends Activity implements OnMapReadyCallback
|
|||
fragment.getMapAsync(this);
|
||||
}
|
||||
|
||||
protected SharedPreferences getPreferences() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
|
|
@ -458,8 +458,7 @@ public abstract class XmppActivity extends Activity {
|
|||
}
|
||||
|
||||
protected SharedPreferences getPreferences() {
|
||||
return PreferenceManager
|
||||
.getDefaultSharedPreferences(getApplicationContext());
|
||||
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
}
|
||||
|
||||
public boolean useSubjectToIdentifyConference() {
|
||||
|
|
|
@ -102,5 +102,6 @@
|
|||
<bool name="validate_hostname">false</bool>
|
||||
<bool name="show_foreground_service">true</bool>
|
||||
<bool name="warn_unencrypted_chat">true</bool>
|
||||
<bool name="use_bundled_emoji">true</bool>
|
||||
</resources>
|
||||
|
||||
|
|
|
@ -744,4 +744,6 @@
|
|||
<string name="conversation_unencrypted_hint">This chat is unencrypted, for security reasons you should activate message encryption by using the lock icon. The preferable encryption is OMEMO.</string>
|
||||
<string name="pref_warn_unencrypted_chat">Warn if chat is unencrypted</string>
|
||||
<string name="pref_warn_unencrypted_chat_summary">If message encryption is available, you should use it. If you don\'t use message encryption, show a warning message inside the chat.</string>
|
||||
<string name="pref_use_bundled_emoji">Use integrated emojis</string>
|
||||
<string name="pref_use_bundled_emoji_summary">Use the integrated emoji library instead of using your devices ones. Changes will be available after reopening the app.</string>
|
||||
</resources>
|
||||
|
|
|
@ -267,6 +267,11 @@
|
|||
android:key="show_dynamic_tags"
|
||||
android:summary="@string/pref_show_dynamic_tags_summary"
|
||||
android:title="@string/pref_show_dynamic_tags" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="@bool/use_bundled_emoji"
|
||||
android:key="use_bundled_emoji"
|
||||
android:summary="@string/pref_use_bundled_emoji_summary"
|
||||
android:title="@string/pref_use_bundled_emoji" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_security_settings">
|
||||
<CheckBoxPreference
|
||||
|
|
Reference in a new issue