Skip to content

Commit

Permalink
Merge pull request #75 from Ryosuke839/emoji2
Browse files Browse the repository at this point in the history
Use androidx.emoji2
  • Loading branch information
Ryosuke839 authored Sep 17, 2022
2 parents 4eda3e3 + c84801f commit cfa4eea
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 23 deletions.
25 changes: 17 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 30
buildToolsVersion "29.0.3"
compileSdkVersion 32

defaultConfig {
applicationId "jp.ddo.hotmist.unicodepad"
minSdkVersion 16
targetSdkVersion 30
targetSdkVersion 32
versionCode 52
versionName "2.11.0"
}
Expand All @@ -18,6 +17,15 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

buildTypes {
release {
shrinkResources true
Expand All @@ -28,6 +36,7 @@ android {
lintOptions {
disable "ResourceType"
disable 'GoogleAppIndexingWarning'
disable 'NullSafeMutableLiveData'
}

flavorDimensions "distribution"
Expand All @@ -45,15 +54,15 @@ android {
}

dependencies {
implementation "androidx.core:core-ktx:1.6.0"
implementation "androidx.core:core-ktx:$kotlin_version"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.emoji:emoji-appcompat:1.1.0'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.emoji2:emoji2:1.2.0'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'com.mobeta.android.dslv:library:0.9.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

playImplementation 'com.google.android.gms:play-services-ads-lite:20.3.0'
playImplementation 'com.google.android.gms:play-services-ads-lite:20.6.0'
}
repositories {
mavenCentral()
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="jp.ddo.hotmist.unicodepad"
android:installLocation="auto">

Expand Down Expand Up @@ -77,5 +78,14 @@
<activity android:name="TabsActivity" />

<activity android:name="RestartActivity" />

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data android:name="androidx.emoji2.text.EmojiCompatInitializer"
tools:node="remove" />
</provider>
</application>
</manifest>
16 changes: 7 additions & 9 deletions app/src/main/java/jp/ddo/hotmist/unicodepad/CharacterView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import android.text.Spannable
import android.util.AttributeSet
import android.view.View
import androidx.core.graphics.ColorUtils
import androidx.emoji.text.EmojiCompat
import androidx.emoji.text.EmojiSpan
import androidx.emoji2.text.EmojiCompat
import androidx.emoji2.text.EmojiSpan
import java.util.*
import kotlin.math.ceil
import kotlin.math.floor
Expand Down Expand Up @@ -59,13 +59,11 @@ class CharacterView @JvmOverloads constructor(context: Context, attrs: Attribute
span = null
try {
val emojiCompat = EmojiCompat.get()
if (emojiCompat != null) {
val spanned = emojiCompat.process(str)
if (spanned is Spannable) {
val spans = spanned.getSpans(0, str.length, EmojiSpan::class.java)
if (spans.isNotEmpty()) {
span = spans[0]
}
val spanned = emojiCompat.process(str)
if (spanned is Spannable) {
val spans = spanned.getSpans(0, str.length, EmojiSpan::class.java)
if (spans.isNotEmpty()) {
span = spans[0]
}
}
} catch (e: IllegalStateException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import android.widget.*
import androidx.appcompat.app.AppCompatActivity
import androidx.core.provider.FontRequest
import androidx.core.view.MenuItemCompat
import androidx.emoji.text.EmojiCompat
import androidx.emoji.text.EmojiCompat.InitCallback
import androidx.emoji.text.FontRequestEmojiCompatConfig
import androidx.emoji2.text.EmojiCompat
import androidx.emoji2.text.EmojiCompat.InitCallback
import androidx.emoji2.text.FontRequestEmojiCompatConfig
import androidx.preference.PreferenceManager
import androidx.viewpager.widget.ViewPager
import java.io.File
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/main_emojicompat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
android:layout_height="wrap_content"
android:layout_weight="1">

<androidx.emoji.widget.EmojiAppCompatEditText
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -40,7 +40,7 @@
android:maxLines="1">

<requestFocus />
</androidx.emoji.widget.EmojiAppCompatEditText>
</androidx.appcompat.widget.AppCompatEditText>

<ImageButton
android:id="@+id/clear"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.5.30'
ext.kotlin_version = '1.6.0'
repositories {
jcenter()
google()
Expand Down

0 comments on commit cfa4eea

Please sign in to comment.