Add EmojiCompat
This commit is contained in:
@@ -11,10 +11,14 @@ import android.preference.PreferenceManager
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.provider.FontRequest
|
||||
import androidx.emoji.text.EmojiCompat
|
||||
import androidx.emoji.text.FontRequestEmojiCompatConfig
|
||||
import be.mygod.vpnhotspot.room.AppDatabase
|
||||
import be.mygod.vpnhotspot.util.DeviceStorageApp
|
||||
import be.mygod.vpnhotspot.util.Event0
|
||||
import be.mygod.vpnhotspot.util.RootSession
|
||||
import timber.log.Timber
|
||||
import java.util.*
|
||||
|
||||
class App : Application() {
|
||||
@@ -35,6 +39,16 @@ class App : Application() {
|
||||
} else deviceStorage = this
|
||||
DebugHelper.init()
|
||||
ServiceNotification.updateNotificationChannels()
|
||||
EmojiCompat.init(FontRequestEmojiCompatConfig(deviceStorage, FontRequest(
|
||||
"com.google.android.gms.fonts",
|
||||
"com.google.android.gms",
|
||||
"Noto Color Emoji Compat",
|
||||
R.array.com_google_android_gms_fonts_certs)).apply {
|
||||
setEmojiSpanIndicatorEnabled(BuildConfig.DEBUG)
|
||||
registerInitCallback(object : EmojiCompat.InitCallback() {
|
||||
override fun onFailed(throwable: Throwable?) = Timber.d(throwable)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||
|
||||
@@ -15,7 +15,6 @@ import be.mygod.vpnhotspot.room.ClientRecord
|
||||
import be.mygod.vpnhotspot.room.macToString
|
||||
import be.mygod.vpnhotspot.util.makeIpSpan
|
||||
import be.mygod.vpnhotspot.util.makeMacSpan
|
||||
import be.mygod.vpnhotspot.util.onEmpty
|
||||
import java.net.InetAddress
|
||||
import java.util.*
|
||||
|
||||
@@ -43,8 +42,10 @@ open class Client(val mac: Long, val iface: String) {
|
||||
* we hijack the get title process to check if we need to perform MacLookup,
|
||||
* as record might not be initialized in other more appropriate places
|
||||
*/
|
||||
if (record?.nickname.isNullOrEmpty() && record?.macLookupPending != false) MacLookup.perform(mac)
|
||||
SpannableStringBuilder(record?.nickname.onEmpty(macIface)).apply {
|
||||
SpannableStringBuilder(if (record?.nickname.isNullOrEmpty()) {
|
||||
if (record?.macLookupPending != false) MacLookup.perform(mac)
|
||||
macIface
|
||||
} else emojize(record?.nickname)).apply {
|
||||
if (record?.blocked == true) {
|
||||
setSpan(StrikethroughSpan(), 0, length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class ClientsFragment : Fragment(), MainScope by MainScope.Supervisor() {
|
||||
setTitle(getString(R.string.clients_nickname_title, arg.mac.macToString()))
|
||||
setPositiveButton(android.R.string.ok, listener)
|
||||
setNegativeButton(android.R.string.cancel, null)
|
||||
setNeutralButton(R.string.clients_nickname_set_to_vendor, listener)
|
||||
setNeutralButton(emojize(getText(R.string.clients_nickname_set_to_vendor)), listener)
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?) = super.onCreateDialog(savedInstanceState).apply {
|
||||
|
||||
10
mobile/src/main/java/be/mygod/vpnhotspot/client/Emojize.kt
Normal file
10
mobile/src/main/java/be/mygod/vpnhotspot/client/Emojize.kt
Normal file
@@ -0,0 +1,10 @@
|
||||
package be.mygod.vpnhotspot.client
|
||||
|
||||
import androidx.emoji.text.EmojiCompat
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
fun emojize(text: CharSequence?): CharSequence? = if (text == null) null else try {
|
||||
EmojiCompat.get().process(text)
|
||||
} catch (_: IllegalStateException) {
|
||||
text
|
||||
}
|
||||
Reference in New Issue
Block a user