diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-11-29 21:50:33 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-11-29 21:50:33 +0100 |
commit | b6052c82cb8463ee465226949953a7187f4096e4 (patch) | |
tree | 6347fb72ddb1928bfcaafbe914b9de795b76d633 /src/main/java/de/pixart/messenger | |
parent | d03129f1301942ddc9808229c158b92f492e79f1 (diff) |
add ability to use system emojis instead of integrated ones via expert settings
Diffstat (limited to 'src/main/java/de/pixart/messenger')
6 files changed, 30 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/services/AbstractEmojiService.java b/src/main/java/de/pixart/messenger/services/AbstractEmojiService.java index 75f1a4c98..ff10acf0c 100644 --- a/src/main/java/de/pixart/messenger/services/AbstractEmojiService.java +++ b/src/main/java/de/pixart/messenger/services/AbstractEmojiService.java @@ -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); } }
\ No newline at end of file diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index b4968770a..ddda44cc8 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -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); } diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java index 040149a31..5f8c05097 100644 --- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java @@ -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; diff --git a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java index 161a5c366..6de7acd06 100644 --- a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java @@ -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); diff --git a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java index f57b53446..27e48c0d3 100644 --- a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java @@ -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()) { diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index 6263c2e53..df6f6980d 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -458,8 +458,7 @@ public abstract class XmppActivity extends Activity { } protected SharedPreferences getPreferences() { - return PreferenceManager - .getDefaultSharedPreferences(getApplicationContext()); + return PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); } public boolean useSubjectToIdentifyConference() { |