From 1f9bc159742248a652e6515888850014814f9086 Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Thu, 22 Aug 2019 22:43:39 -0300 Subject: [PATCH 01/12] added EmojiCompat dependency --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 39edc8f04..87c27b10e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,7 +34,6 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0' implementation 'androidx.navigation:navigation-ui-ktx:2.0.0' - implementation 'com.google.android.material:material:1.0.0' implementation 'com.github.bumptech.glide:glide:4.9.0' @@ -45,6 +44,7 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + implementation 'androidx.emoji:emoji:1.0.0' } android.buildTypes.all { buildType -> From 19dd0f793e21eaecfa388a6757ca13a84ae6c14c Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Thu, 22 Aug 2019 22:44:18 -0300 Subject: [PATCH 02/12] added google services certs for EmojiCompat, taken from official sample demo EmojiCompat app --- app/src/main/res/values/font_certs.xml | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 app/src/main/res/values/font_certs.xml diff --git a/app/src/main/res/values/font_certs.xml b/app/src/main/res/values/font_certs.xml new file mode 100644 index 000000000..d2b2ca800 --- /dev/null +++ b/app/src/main/res/values/font_certs.xml @@ -0,0 +1,29 @@ + + + + + @array/com_google_android_gms_fonts_certs_dev + @array/com_google_android_gms_fonts_certs_prod + + + + MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1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4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK + + + From 98b366725977315cabcca6f09d97700aca87b6c2 Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Thu, 22 Aug 2019 22:45:03 -0300 Subject: [PATCH 03/12] declared fontProviderRequests in manifest, following EmojiCompat official demo app --- app/src/main/AndroidManifest.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e265d9879..449fb8a17 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,6 +15,10 @@ + + Date: Thu, 22 Aug 2019 22:45:26 -0300 Subject: [PATCH 04/12] initializing EmojiCompat in MainActivity - will need to move it to Application instance when it's ready --- .../com/automattic/portkey/MainActivity.kt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/app/src/main/java/com/automattic/portkey/MainActivity.kt b/app/src/main/java/com/automattic/portkey/MainActivity.kt index 10d003a1e..c744250f1 100644 --- a/app/src/main/java/com/automattic/portkey/MainActivity.kt +++ b/app/src/main/java/com/automattic/portkey/MainActivity.kt @@ -4,8 +4,12 @@ import android.net.Uri import android.os.Bundle import com.google.android.material.snackbar.Snackbar import androidx.appcompat.app.AppCompatActivity +import androidx.emoji.text.EmojiCompat import androidx.navigation.Navigation import kotlinx.android.synthetic.main.activity_main.* +import androidx.emoji.text.FontRequestEmojiCompatConfig +import android.util.Log +import androidx.core.provider.FontRequest class MainActivity : AppCompatActivity(), MainFragment.OnFragmentInteractionListener { override fun onFragmentInteraction(uri: Uri) { @@ -14,6 +18,7 @@ class MainActivity : AppCompatActivity(), MainFragment.OnFragmentInteractionList override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + initEmojiCompat() setContentView(R.layout.activity_main) setSupportActionBar(toolbar) @@ -25,6 +30,36 @@ class MainActivity : AppCompatActivity(), MainFragment.OnFragmentInteractionList } } + // TODO move this method to the Application instance once we have it + private fun initEmojiCompat() { + val config: EmojiCompat.Config + + // Use a downloadable font for EmojiCompat + val fontRequest = FontRequest( + "com.google.android.gms.fonts", + "com.google.android.gms", + "Noto Color Emoji Compat", + R.array.com_google_android_gms_fonts_certs + ) + config = FontRequestEmojiCompatConfig(applicationContext, fontRequest) + + config.registerInitCallback(object : EmojiCompat.InitCallback() { + override fun onInitialized() { + Log.d(TAG, "EmojiCompat initialized") + } + + override fun onFailed(throwable: Throwable?) { + Log.d(TAG, "EmojiCompat initialization failed", throwable) + } + }) + + EmojiCompat.init(config) + } + override fun onSupportNavigateUp() = Navigation.findNavController(this, R.id.nav_host_fragment).navigateUp() + + companion object { + private val TAG = "MainActivity" + } } From b967c9a3e69a682ac29f2bc62a6002e23b837cdc Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Thu, 22 Aug 2019 22:51:53 -0300 Subject: [PATCH 05/12] dependency reorder --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 87c27b10e..23a900b15 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,6 +34,7 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0' implementation 'androidx.navigation:navigation-ui-ktx:2.0.0' + implementation 'androidx.emoji:emoji:1.0.0' implementation 'com.google.android.material:material:1.0.0' implementation 'com.github.bumptech.glide:glide:4.9.0' @@ -44,7 +45,6 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' - implementation 'androidx.emoji:emoji:1.0.0' } android.buildTypes.all { buildType -> From e4af1d54652f6d1c195c2b1bf16f934108f58c1b Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Fri, 23 Aug 2019 14:13:25 -0300 Subject: [PATCH 06/12] added EmojiCompat usage within PhotoEditor when calling addEmoji() --- photoeditor/build.gradle | 1 + .../com/automattic/photoeditor/PhotoEditor.kt | 25 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/photoeditor/build.gradle b/photoeditor/build.gradle index a35338c27..292832f0f 100644 --- a/photoeditor/build.gradle +++ b/photoeditor/build.gradle @@ -52,6 +52,7 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + implementation 'androidx.emoji:emoji:1.0.0' } repositories { mavenCentral() diff --git a/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt b/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt index f94d3e96c..b35bc61d8 100644 --- a/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt +++ b/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt @@ -24,6 +24,8 @@ import androidx.annotation.ColorInt import androidx.annotation.IntRange import androidx.annotation.RequiresPermission import androidx.annotation.UiThread +import androidx.emoji.text.EmojiCompat +import androidx.emoji.text.EmojiCompat.InitCallback import com.automattic.photoeditor.views.ViewType.BRUSH_DRAWING import com.automattic.photoeditor.views.ViewType.STICKER_ANIMATED import com.automattic.photoeditor.gesture.MultiTouchListener @@ -50,6 +52,7 @@ import java.io.FileOutputStream import java.util.ArrayList import kotlinx.android.synthetic.main.view_photo_editor_text.view.* import java.io.FileInputStream +import java.lang.ref.WeakReference /** * @@ -355,9 +358,27 @@ class PhotoEditor private constructor(builder: Builder) : if (emojiTypeface != null) { emojiTextView.typeface = emojiTypeface + emojiTextView.text = emojiName + } else { + // if user did not set a specific emojiTypface, use EmojiCompat to process + // the string and make sure we have an emoji that can be rendered + EmojiCompat.get().registerInitCallback(object: EmojiCompat.InitCallback() { + val regularTextViewRef = WeakReference(emojiTextView) + override fun onInitialized() { + val regularTextView = regularTextViewRef.get() + if (regularTextView != null) { + val compat = EmojiCompat.get() + regularTextView.text = compat.process(emojiName) + } + } + + override fun onFailed(throwable: Throwable?) { + // just fallback to setting the text + emojiTextView.text = emojiName + } + }) } emojiTextView.textSize = 56f - emojiTextView.text = emojiName // hide cross and background borders for now imgClose.visibility = View.GONE @@ -417,7 +438,7 @@ class PhotoEditor private constructor(builder: Builder) : val txtTextEmoji = rootView.tvPhotoEditorText if (txtTextEmoji != null) { if (mDefaultEmojiTypeface != null) { - txtTextEmoji.typeface = mDefaultEmojiTypeface + txtTextEmoji.typeface = mDefaultEmojiTypeface } txtTextEmoji.gravity = Gravity.CENTER txtTextEmoji.setLayerType(View.LAYER_TYPE_SOFTWARE, null) From 2fd986ff0428328bf3c495763b6891f95af1e2d1 Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Fri, 23 Aug 2019 14:17:30 -0300 Subject: [PATCH 07/12] made row_emoji have an androidx.emoji.widget.EmojiTextView which handles emoji rendering seamlessly --- app/src/main/res/layout/row_emoji.xml | 2 +- .../src/main/java/com/automattic/photoeditor/PhotoEditor.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/row_emoji.xml b/app/src/main/res/layout/row_emoji.xml index 43d1a7063..065c82106 100644 --- a/app/src/main/res/layout/row_emoji.xml +++ b/app/src/main/res/layout/row_emoji.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - Date: Fri, 23 Aug 2019 14:21:24 -0300 Subject: [PATCH 08/12] fixed lint warnings plus bad null check --- .../src/main/java/com/automattic/photoeditor/PhotoEditor.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt b/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt index 84d895a96..05bde3d6f 100644 --- a/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt +++ b/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt @@ -362,7 +362,7 @@ class PhotoEditor private constructor(builder: Builder) : } else { // if user did not set a specific emojiTypeface, use EmojiCompat to process // the string and make sure we have an emoji that can be rendered - EmojiCompat.get().registerInitCallback(object: EmojiCompat.InitCallback() { + EmojiCompat.get().registerInitCallback(object : EmojiCompat.InitCallback() { val regularTextViewRef = WeakReference(emojiTextView) override fun onInitialized() { val regularTextView = regularTextViewRef.get() @@ -427,7 +427,7 @@ class PhotoEditor private constructor(builder: Builder) : rootView = layoutInflater.inflate(R.layout.view_photo_editor_text, null) if (rootView.tvPhotoEditorText != null && mDefaultTextTypeface != null) { rootView.tvPhotoEditorText.gravity = Gravity.CENTER - if (mDefaultEmojiTypeface != null) { + if (mDefaultTextTypeface != null) { rootView.tvPhotoEditorText.typeface = mDefaultTextTypeface } } @@ -438,7 +438,7 @@ class PhotoEditor private constructor(builder: Builder) : val txtTextEmoji = rootView.tvPhotoEditorText if (txtTextEmoji != null) { if (mDefaultEmojiTypeface != null) { - txtTextEmoji.typeface = mDefaultEmojiTypeface + txtTextEmoji.typeface = mDefaultEmojiTypeface } txtTextEmoji.gravity = Gravity.CENTER txtTextEmoji.setLayerType(View.LAYER_TYPE_SOFTWARE, null) From d8ddc62813466cdf726c2178017402422b23985b Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Fri, 23 Aug 2019 15:45:15 -0300 Subject: [PATCH 09/12] moved EmojiCompat.init call to Portkey Application class --- .../com/automattic/portkey/MainActivity.kt | 27 -------------- .../java/com/automattic/portkey/Portkey.kt | 36 +++++++++++++++++++ 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/automattic/portkey/MainActivity.kt b/app/src/main/java/com/automattic/portkey/MainActivity.kt index 158ca65a5..b408075a4 100644 --- a/app/src/main/java/com/automattic/portkey/MainActivity.kt +++ b/app/src/main/java/com/automattic/portkey/MainActivity.kt @@ -20,7 +20,6 @@ class MainActivity : AppCompatActivity(), MainFragment.OnFragmentInteractionList override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - initEmojiCompat() setContentView(R.layout.activity_main) setSupportActionBar(toolbar) @@ -35,32 +34,6 @@ class MainActivity : AppCompatActivity(), MainFragment.OnFragmentInteractionList } } - // TODO move this method to the Application instance once we have it - private fun initEmojiCompat() { - val config: EmojiCompat.Config - - // Use a downloadable font for EmojiCompat - val fontRequest = FontRequest( - "com.google.android.gms.fonts", - "com.google.android.gms", - "Noto Color Emoji Compat", - R.array.com_google_android_gms_fonts_certs - ) - config = FontRequestEmojiCompatConfig(applicationContext, fontRequest) - - config.registerInitCallback(object : EmojiCompat.InitCallback() { - override fun onInitialized() { - Log.d(TAG, "EmojiCompat initialized") - } - - override fun onFailed(throwable: Throwable?) { - Log.d(TAG, "EmojiCompat initialization failed", throwable) - } - }) - - EmojiCompat.init(config) - } - override fun onSupportNavigateUp() = Navigation.findNavController(this, R.id.nav_host_fragment).navigateUp() diff --git a/app/src/main/java/com/automattic/portkey/Portkey.kt b/app/src/main/java/com/automattic/portkey/Portkey.kt index 5f0be3578..127163bc6 100644 --- a/app/src/main/java/com/automattic/portkey/Portkey.kt +++ b/app/src/main/java/com/automattic/portkey/Portkey.kt @@ -1,11 +1,47 @@ package com.automattic.portkey import android.app.Application +import android.util.Log +import androidx.core.provider.FontRequest +import androidx.emoji.text.EmojiCompat +import androidx.emoji.text.FontRequestEmojiCompatConfig +import com.automattic.portkey.R.array class Portkey : Application() { override fun onCreate() { super.onCreate() AppPrefs.init(this) + + initEmojiCompat() + } + + private fun initEmojiCompat() { + val config: EmojiCompat.Config + + // Use a downloadable font for EmojiCompat + val fontRequest = FontRequest( + "com.google.android.gms.fonts", + "com.google.android.gms", + "Noto Color Emoji Compat", + array.com_google_android_gms_fonts_certs + ) + config = FontRequestEmojiCompatConfig(applicationContext, fontRequest) + + config.registerInitCallback(object : EmojiCompat.InitCallback() { + override fun onInitialized() { + Log.d(TAG, "EmojiCompat initialized") + } + + override fun onFailed(throwable: Throwable?) { + Log.d(TAG, "EmojiCompat initialization failed", throwable) + } + }) + + EmojiCompat.init(config) + } + + companion object { + const val TAG = "Portkey" } } From 8b6299ff3325bf3ba103178fac825bd5a5024595 Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Fri, 23 Aug 2019 15:48:47 -0300 Subject: [PATCH 10/12] removed unused imports and code --- app/src/main/java/com/automattic/portkey/MainActivity.kt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/src/main/java/com/automattic/portkey/MainActivity.kt b/app/src/main/java/com/automattic/portkey/MainActivity.kt index b408075a4..b8d14363b 100644 --- a/app/src/main/java/com/automattic/portkey/MainActivity.kt +++ b/app/src/main/java/com/automattic/portkey/MainActivity.kt @@ -4,14 +4,10 @@ import android.content.Intent import android.net.Uri import android.os.Bundle import androidx.appcompat.app.AppCompatActivity -import androidx.emoji.text.EmojiCompat import androidx.navigation.Navigation import com.automattic.photoeditor.util.PermissionUtils import com.automattic.portkey.intro.IntroActivity import kotlinx.android.synthetic.main.activity_main.* -import androidx.emoji.text.FontRequestEmojiCompatConfig -import android.util.Log -import androidx.core.provider.FontRequest class MainActivity : AppCompatActivity(), MainFragment.OnFragmentInteractionListener { override fun onFragmentInteraction(uri: Uri) { @@ -36,8 +32,4 @@ class MainActivity : AppCompatActivity(), MainFragment.OnFragmentInteractionList override fun onSupportNavigateUp() = Navigation.findNavController(this, R.id.nav_host_fragment).navigateUp() - - companion object { - private val TAG = "MainActivity" - } } From 5406f1187aa20a46a1a996f5f4b372413fda2d5e Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Sun, 13 Oct 2019 11:45:22 -0300 Subject: [PATCH 11/12] make sure to unregister no longer needed emojicompat callback --- .../src/main/java/com/automattic/photoeditor/PhotoEditor.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt b/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt index e3a47ff7e..eebbb5104 100644 --- a/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt +++ b/photoeditor/src/main/java/com/automattic/photoeditor/PhotoEditor.kt @@ -377,6 +377,8 @@ class PhotoEditor private constructor(builder: Builder) : EmojiCompat.get().registerInitCallback(object : EmojiCompat.InitCallback() { val regularTextViewRef = WeakReference(emojiTextView) override fun onInitialized() { + EmojiCompat.get().unregisterInitCallback(this) + val regularTextView = regularTextViewRef.get() if (regularTextView != null) { val compat = EmojiCompat.get() @@ -385,6 +387,8 @@ class PhotoEditor private constructor(builder: Builder) : } override fun onFailed(throwable: Throwable?) { + EmojiCompat.get().unregisterInitCallback(this) + // just fallback to setting the text emojiTextView.text = emojiName } From fe49ad2c5681e8ba0af2bca95057b17605c31998 Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Sun, 13 Oct 2019 11:46:07 -0300 Subject: [PATCH 12/12] force replacement of all emoji through EmojiCompat and use Emoji as default style on the widgets we use --- app/src/main/java/com/automattic/portkey/Portkey.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/automattic/portkey/Portkey.kt b/app/src/main/java/com/automattic/portkey/Portkey.kt index 71f803282..69256bc9f 100644 --- a/app/src/main/java/com/automattic/portkey/Portkey.kt +++ b/app/src/main/java/com/automattic/portkey/Portkey.kt @@ -31,6 +31,8 @@ class Portkey : Application() { array.com_google_android_gms_fonts_certs ) config = FontRequestEmojiCompatConfig(applicationContext, fontRequest) + config.setReplaceAll(true) + config.setUseEmojiAsDefaultStyle(true) config.registerInitCallback(object : EmojiCompat.InitCallback() { override fun onInitialized() {