Commit 421106c4 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Some layout fine-grain adjustments on the emoji picker

parent 8c7da0f8
...@@ -139,9 +139,11 @@ class EmojiKeyboardPopup(context: Context, view: View) : OverKeyboardPopupWindow ...@@ -139,9 +139,11 @@ class EmojiKeyboardPopup(context: Context, view: View) : OverKeyboardPopupWindow
@ColorInt @ColorInt
private fun getFitzpatrickColor(tone: Fitzpatrick): Int { private fun getFitzpatrickColor(tone: Fitzpatrick): Int {
val sharedPreferences = context.getSharedPreferences("emoji", Context.MODE_PRIVATE) val sharedPreferences = context.getSharedPreferences("emoji", Context.MODE_PRIVATE)
sharedPreferences.edit { sharedPreferences.edit {
putString(PREF_EMOJI_SKIN_TONE, tone.type) putString(PREF_EMOJI_SKIN_TONE, tone.type)
} }
return when (tone) { return when (tone) {
Fitzpatrick.Default -> ContextCompat.getColor(context, R.color.tone_default) Fitzpatrick.Default -> ContextCompat.getColor(context, R.color.tone_default)
Fitzpatrick.LightTone -> ContextCompat.getColor(context, R.color.tone_light) Fitzpatrick.LightTone -> ContextCompat.getColor(context, R.color.tone_light)
...@@ -194,6 +196,7 @@ class EmojiKeyboardPopup(context: Context, view: View) : OverKeyboardPopupWindow ...@@ -194,6 +196,7 @@ class EmojiKeyboardPopup(context: Context, view: View) : OverKeyboardPopupWindow
} }
class EmojiTextWatcher(private val editor: EditText) : TextWatcher { class EmojiTextWatcher(private val editor: EditText) : TextWatcher {
@Volatile @Volatile
private var emojiToRemove = mutableListOf<EmojiTypefaceSpan>() private var emojiToRemove = mutableListOf<EmojiTypefaceSpan>()
...@@ -237,4 +240,4 @@ class EmojiKeyboardPopup(context: Context, view: View) : OverKeyboardPopupWindow ...@@ -237,4 +240,4 @@ class EmojiKeyboardPopup(context: Context, view: View) : OverKeyboardPopupWindow
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
} }
} }
} }
\ No newline at end of file
...@@ -37,10 +37,12 @@ class EmojiPickerPopup(context: Context) : Dialog(context) { ...@@ -37,10 +37,12 @@ class EmojiPickerPopup(context: Context) : Dialog(context) {
private fun setSize() { private fun setSize() {
val lp = WindowManager.LayoutParams() val lp = WindowManager.LayoutParams()
lp.copyFrom(window.attributes) window?.let {
val dialogWidth = lp.width lp.copyFrom(it.attributes)
val dialogHeight = context.resources.getDimensionPixelSize(R.dimen.picker_popup_height) val dialogWidth = lp.width
window.setLayout(dialogWidth, dialogHeight) val dialogHeight = context.resources.getDimensionPixelSize(R.dimen.picker_popup_height)
it.setLayout(dialogWidth, dialogHeight)
}
} }
private suspend fun setupViewPager() { private suspend fun setupViewPager() {
......
...@@ -57,9 +57,6 @@ abstract class OverKeyboardPopupWindow( ...@@ -57,9 +57,6 @@ abstract class OverKeyboardPopupWindow(
init { init {
setBackgroundDrawable(null) setBackgroundDrawable(null)
if (BuildConfig.VERSION_CODE >= Build.VERSION_CODES.LOLLIPOP) {
elevation = 0f
}
val view = onCreateView(LayoutInflater.from(context)) val view = onCreateView(LayoutInflater.from(context))
onViewCreated(view) onViewCreated(view)
contentView = view contentView = view
...@@ -89,7 +86,7 @@ abstract class OverKeyboardPopupWindow( ...@@ -89,7 +86,7 @@ abstract class OverKeyboardPopupWindow(
/** /**
* Call this function to resize the emoji popup according to your soft keyboard size * Call this function to resize the emoji popup according to your soft keyboard size
*/ */
fun setSizeForSoftKeyboard() { private fun setSizeForSoftKeyboard() {
val viewTreeObserver = rootView.viewTreeObserver val viewTreeObserver = rootView.viewTreeObserver
viewTreeObserver.addOnGlobalLayoutListener(this) viewTreeObserver.addOnGlobalLayoutListener(this)
} }
......
...@@ -147,10 +147,11 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) : ...@@ -147,10 +147,11 @@ internal class EmojiPagerAdapter(private val listener: EmojiKeyboardListener) :
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EmojiRowViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EmojiRowViewHolder {
val inflater = LayoutInflater.from(parent.context)
val view = if (viewType == CUSTOM) { val view = if (viewType == CUSTOM) {
LayoutInflater.from(parent.context).inflate(R.layout.emoji_image_row_item, parent, false) inflater.inflate(R.layout.emoji_image_row_item, parent, false)
} else { } else {
LayoutInflater.from(parent.context).inflate(R.layout.emoji_row_item, parent, false) inflater.inflate(R.layout.emoji_row_item, parent, false)
} }
return EmojiRowViewHolder(view, listener) return EmojiRowViewHolder(view, listener)
} }
......
...@@ -6,18 +6,16 @@ ...@@ -6,18 +6,16 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/emoji_recycler_view" android:id="@+id/emoji_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent" />
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp" />
<TextView <TextView
android:id="@+id/text_no_recent_emoji" android:id="@+id/text_no_recent_emoji"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/msg_no_recent_emoji"
android:layout_gravity="center" android:layout_gravity="center"
android:elevation="10dp" android:elevation="10dp"
android:text="@string/msg_no_recent_emoji"
android:textSize="16sp" android:textSize="16sp"
android:visibility="gone"/> android:visibility="gone" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
android:id="@+id/pager_categories" android:id="@+id/pager_categories"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:background="@color/colorWhite" /> android:background="@color/colorWhite" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/emoji_view" android:id="@+id/emoji_view"
style="@style/TextAppearance.AppCompat.Title"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:foreground="?selectableItemBackground" android:foreground="?selectableItemBackground"
android:layout_gravity="center"
android:gravity="center" android:gravity="center"
android:textColor="#000000" android:textColor="#000000"
android:textSize="26sp" android:textSize="24sp"
tools:text="😀" /> tools:text="😀" />
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment