Twidere-App-Android-Twitter.../twidere/src/main/kotlin/org/mariotaku/twidere/text/util/EmojiSpannableFactory.kt

49 lines
1.6 KiB
Kotlin
Raw Normal View History

2015-12-20 12:54:05 +01:00
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2016-08-28 06:24:48 +02:00
package org.mariotaku.twidere.text.util
2015-12-20 12:54:05 +01:00
2016-08-28 06:24:48 +02:00
import android.text.Spannable
import android.widget.TextView
2015-12-20 12:54:05 +01:00
2016-08-28 06:24:48 +02:00
import org.mariotaku.twidere.util.EmojiSupportUtils
import org.mariotaku.twidere.util.ExternalThemeManager
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
2015-12-20 12:54:05 +01:00
2016-08-28 06:24:48 +02:00
import javax.inject.Inject
2015-12-20 12:54:05 +01:00
/**
* Created by mariotaku on 15/12/20.
*/
2016-08-28 06:24:48 +02:00
class EmojiSpannableFactory(textView: TextView) : SafeSpannableFactory() {
2015-12-20 12:54:05 +01:00
@Inject
2016-08-28 06:24:48 +02:00
lateinit internal var externalThemeManager: ExternalThemeManager
2015-12-20 12:54:05 +01:00
2016-08-28 06:24:48 +02:00
init {
GeneralComponentHelper.build(textView.context).inject(this)
2015-12-20 12:54:05 +01:00
}
2016-08-28 06:24:48 +02:00
override fun newSpannable(source: CharSequence): Spannable {
val spannable = super.newSpannable(source)
EmojiSupportUtils.applyEmoji(externalThemeManager, spannable)
return spannable
2015-12-20 12:54:05 +01:00
}
}