Remove emoji buttons

This commit is contained in:
Phillip Thelen 2019-02-28 21:55:44 +01:00
parent 35c2737aaa
commit 3fde7dbba9
5 changed files with 6 additions and 234 deletions

View file

@ -18,26 +18,12 @@
android:layout_marginTop="@dimen/abc_action_bar_content_inset_material"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/emoji.toggle.btn0"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_emoticon_grey600_24dp"
android:background="@drawable/md_transparent"
android:contentDescription="Toogle Emoji"
android:focusable="true"
android:focusableInTouchMode="true" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/TextAppearance.AppCompat">
<net.pherth.android.emoji_library.EmojiEditText
<MultiAutoCompleteTextView
android:id="@+id/task_text_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -47,26 +33,13 @@
android:inputType="textCapSentences|textMultiLine"
android:maxLines="3"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@+id/emoji.toggle.btn1"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_emoticon_grey600_24dp"
android:background="@drawable/md_transparent"
android:layout_gravity="center_vertical"
android:contentDescription="Toogle Emoji" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/TextAppearance.AppCompat">
<net.pherth.android.emoji_library.EmojiEditText
<MultiAutoCompleteTextView
android:id="@+id/task_notes_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -75,7 +48,6 @@
android:textColor="@android:color/black"
android:inputType="textCapSentences|textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/task_value_layout"

View file

@ -15,17 +15,6 @@
android:orientation="horizontal"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/emojiButton"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_emoticon_grey600_24dp"
android:scaleType="center"
android:backgroundTint="@color/transparent"
android:contentDescription="@string/toogle_emojis"
android:tint="@color/brand_400"
android:layout_gravity="center"/>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_weight="1"

View file

@ -36,15 +36,9 @@ import com.habitrpg.android.habitica.modules.AppModule
import com.habitrpg.android.habitica.ui.WrapContentRecyclerViewLayoutManager
import com.habitrpg.android.habitica.ui.adapter.tasks.CheckListAdapter
import com.habitrpg.android.habitica.ui.adapter.tasks.RemindersAdapter
import com.habitrpg.android.habitica.ui.helpers.MarkdownParser
import com.habitrpg.android.habitica.ui.helpers.SimpleItemTouchHelperCallback
import com.habitrpg.android.habitica.ui.helpers.ViewHelper
import com.habitrpg.android.habitica.ui.helpers.bindView
import io.reactivex.functions.Consumer
import io.realm.Realm
import io.realm.RealmList
import net.pherth.android.emoji_library.EmojiEditText
import net.pherth.android.emoji_library.EmojiPopup
import java.text.DateFormat
import java.text.DecimalFormat
import java.text.ParseException
@ -59,24 +53,20 @@ class TaskFormActivity : BaseActivity() {
private val difficultyWrapper: LinearLayout by bindView(R.id.task_difficulty_wrapper)
private val attributeWrapper: LinearLayout by bindView(R.id.task_attribute_wrapper)
private val mainWrapper: LinearLayout by bindView(R.id.task_main_wrapper)
private val taskText: EmojiEditText by bindView(R.id.task_text_edittext)
private val taskNotes: EmojiEditText by bindView(R.id.task_notes_edittext)
private val taskText: MultiAutoCompleteTextView by bindView(R.id.task_text_edittext)
private val taskNotes: MultiAutoCompleteTextView by bindView(R.id.task_notes_edittext)
private val taskDifficultySpinner: Spinner by bindView(R.id.task_difficulty_spinner)
private val taskAttributeSpinner: Spinner by bindView(R.id.task_attribute_spinner)
private val btnDelete: Button by bindView(R.id.btn_delete_task)
private val taskWrapper: LinearLayout by bindView(R.id.task_task_wrapper)
private val positiveCheckBox: CheckBox by bindView(R.id.task_positive_checkbox)
private val negativeCheckBox: CheckBox by bindView(R.id.task_negative_checkbox)
private val actionsLayout: LinearLayout by bindView(R.id.task_actions_wrapper)
private val recyclerView: androidx.recyclerview.widget.RecyclerView by bindView(R.id.checklist_recycler_view)
private val newCheckListEditText: EmojiEditText by bindView(R.id.new_checklist)
private val newCheckListEditText: MultiAutoCompleteTextView by bindView(R.id.new_checklist)
private val addChecklistItemButton: Button by bindView(R.id.add_checklist_button)
private val remindersWrapper: LinearLayout by bindView(R.id.task_reminders_wrapper)
private val newRemindersEditText: EditText by bindView(R.id.new_reminder_edittext)
private val remindersRecyclerView: androidx.recyclerview.widget.RecyclerView by bindView(R.id.reminders_recycler_view)
private val emojiToggle0: ImageButton by bindView(R.id.emoji_toggle_btn0)
private val emojiToggle1: ImageButton by bindView(R.id.emoji_toggle_btn1)
private var emojiToggle2: ImageButton? = null
private val dueDateLayout: LinearLayout by bindView(R.id.task_duedate_layout)
private val dueDatePickerLayout: LinearLayout by bindView(R.id.task_duedate_picker_layout)
private val dueDateCheckBox: CheckBox by bindView(R.id.duedate_checkbox)
@ -123,7 +113,6 @@ class TaskFormActivity : BaseActivity() {
private var taskType: String? = null
private var taskId: String? = null
private var popup: EmojiPopup? = null
private var shouldSaveTask = true
@ -135,8 +124,6 @@ class TaskFormActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
popup = EmojiPopup(emojiToggle0.rootView, this, ContextCompat.getColor(this, R.color.brand))
val bundle = intent.extras ?: return
taskType = bundle.getString(TASK_TYPE_KEY)
@ -242,68 +229,6 @@ class TaskFormActivity : BaseActivity() {
createRemindersRecyclerView()
}
// Emoji keyboard stuff
var isTodo = false
if (taskType == Task.TYPE_TODO) {
isTodo = true
}
// If it's a to-do, change the emojiToggle2 to the actual emojiToggle2 (prevents NPEs when not a to-do task)
emojiToggle2 = if (isTodo) {
findViewById<View>(R.id.emoji_toggle_btn2) as? ImageButton
} else {
emojiToggle0
}
// if showChecklist is inactive the wrapper is wrapper, so the reference can't be found
if (emojiToggle2 == null) {
emojiToggle2 = emojiToggle0
}
popup?.setSizeForSoftKeyboard()
popup?.setOnDismissListener { changeEmojiKeyboardIcon(false) }
popup?.setOnSoftKeyboardOpenCloseListener(object : EmojiPopup.OnSoftKeyboardOpenCloseListener {
override fun onKeyboardOpen(keyBoardHeight: Int) {
}
override fun onKeyboardClose() {
if (popup?.isShowing == true) {
popup?.dismiss()
}
}
})
popup?.setOnEmojiconClickedListener { emojicon ->
if (currentFocus == null || !isEmojiEditText(currentFocus) || emojicon == null) {
return@setOnEmojiconClickedListener
}
val emojiEditText = currentFocus as? EmojiEditText
val start = emojiEditText?.selectionStart ?: 0
val end = emojiEditText?.selectionEnd ?: 0
if (start < 0) {
emojiEditText?.append(emojicon.emoji)
} else {
emojiEditText?.text?.replace(Math.min(start, end),
Math.max(start, end), emojicon.emoji, 0,
emojicon.emoji.length)
}
}
popup?.setOnEmojiconBackspaceClickedListener {
if (isEmojiEditText(currentFocus)) {
val event = KeyEvent(
0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL)
currentFocus?.dispatchKeyEvent(event)
}
}
emojiToggle0.setOnClickListener(EmojiClickListener(taskText))
emojiToggle1.setOnClickListener(EmojiClickListener(taskNotes))
if (isTodo) {
emojiToggle2?.setOnClickListener(EmojiClickListener(newCheckListEditText))
}
enableRepeatables()
@ -573,22 +498,6 @@ class TaskFormActivity : BaseActivity() {
frequencyPicker.value = 1
}
private fun isEmojiEditText(view: View?): Boolean {
return view is EmojiEditText
}
private fun changeEmojiKeyboardIcon(keyboardOpened: Boolean) {
if (keyboardOpened) {
emojiToggle0.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_keyboard_grey600_24dp))
emojiToggle1.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_keyboard_grey600_24dp))
emojiToggle2?.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_keyboard_grey600_24dp))
} else {
emojiToggle0.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_emoticon_grey600_24dp))
emojiToggle1.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_emoticon_grey600_24dp))
emojiToggle2?.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_emoticon_grey600_24dp))
}
}
private fun createCheckListRecyclerView() {
checklistAdapter = CheckListAdapter()
@ -1020,8 +929,6 @@ class TaskFormActivity : BaseActivity() {
if (currentFocus != null) {
imm?.hideSoftInputFromWindow(currentFocus.windowToken, 0)
}
popup?.dismiss()
popup = null
}
private inner class DateEditTextListener internal constructor(internal var datePickerText: EditText) : View.OnClickListener, DatePickerDialog.OnDateSetListener {
@ -1080,29 +987,6 @@ class TaskFormActivity : BaseActivity() {
}
}
private inner class EmojiClickListener internal constructor(internal var view: EmojiEditText) : View.OnClickListener {
override fun onClick(v: View) {
if (popup?.isShowing == false) {
if (popup?.isKeyBoardOpen == true) {
popup?.showAtBottom()
changeEmojiKeyboardIcon(true)
} else {
view.isFocusableInTouchMode = true
view.requestFocus()
popup?.showAtBottomPending()
val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
inputMethodManager?.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT)
changeEmojiKeyboardIcon(true)
}
} else {
popup?.dismiss()
changeEmojiKeyboardIcon(false)
}
}
}
companion object {
const val TASK_ID_KEY = "taskId"
const val USER_ID_KEY = "userId"

View file

@ -5,10 +5,8 @@ import android.os.Build
import android.text.Editable
import android.text.TextWatcher
import android.util.AttributeSet
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.*
import androidx.core.content.ContextCompat
import androidx.core.view.updateLayoutParams
@ -19,7 +17,6 @@ import com.habitrpg.android.habitica.ui.helpers.AutocompleteAdapter
import com.habitrpg.android.habitica.ui.helpers.ChatInputTokenizer
import com.habitrpg.android.habitica.ui.helpers.NavbarUtils
import com.habitrpg.android.habitica.ui.helpers.bindView
import net.pherth.android.emoji_library.EmojiPopup
import javax.inject.Inject
@ -32,11 +29,7 @@ class ChatBarView : FrameLayout {
private val chatEditText: MultiAutoCompleteTextView by bindView(R.id.chatEditText)
private val textIndicator: TextView by bindView(R.id.text_indicator)
private val indicatorSpacing: View by bindView(R.id.indicator_spacing)
private val emojiButton: ImageButton by bindView(R.id.emojiButton)
private val spacing: Space by bindView(R.id.spacing)
private val popup: EmojiPopup by lazy {
EmojiPopup(emojiButton.rootView, context, ContextCompat.getColor(context, R.color.brand))
}
private var navBarAccountedHeightCalculated = false
internal var maxChatLength = 3000
@ -83,40 +76,6 @@ class ChatBarView : FrameLayout {
sendButton.setOnClickListener { sendButtonPressed() }
emojiButton.setOnClickListener(EmojiClickListener(chatEditText))
popup.setSizeForSoftKeyboard()
popup.setOnDismissListener { changeEmojiKeyboardIcon(false) }
popup.setOnSoftKeyboardOpenCloseListener(object : EmojiPopup.OnSoftKeyboardOpenCloseListener {
override fun onKeyboardOpen(keyBoardHeight: Int) {
}
override fun onKeyboardClose() {
if (popup.isShowing) {
popup.dismiss()
}
}
})
popup.setOnEmojiconClickedListener { emojicon ->
val start = chatEditText.selectionStart
val end = chatEditText.selectionEnd
if (start < 0) {
chatEditText.append(emojicon.emoji)
} else {
chatEditText.text?.replace(Math.min(start, end),
Math.max(start, end), emojicon.emoji, 0,
emojicon.emoji.length)
}
}
popup.setOnEmojiconBackspaceClickedListener {
val event = KeyEvent(
0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL)
chatEditText.dispatchKeyEvent(event)
}
resizeForDrawingUnderNavbar()
autocompleteAdapter = AutocompleteAdapter(context, socialRepository, autocompleteContext, groupID)
@ -183,34 +142,4 @@ class ChatBarView : FrameLayout {
sendAction?.invoke(chatText)
}
}
private fun changeEmojiKeyboardIcon(keyboardOpened: Boolean) {
if (keyboardOpened) {
emojiButton.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_keyboard_grey600_24dp))
} else {
emojiButton.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_emoticon_grey600_24dp))
}
}
private inner class EmojiClickListener internal constructor(internal var view: MultiAutoCompleteTextView) : View.OnClickListener {
override fun onClick(v: View) {
if (!popup.isShowing) {
if (popup.isKeyBoardOpen == true) {
popup.showAtBottom()
changeEmojiKeyboardIcon(true)
} else {
view.isFocusableInTouchMode = true
view.requestFocus()
popup.showAtBottomPending()
val inputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
inputMethodManager?.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT)
changeEmojiKeyboardIcon(true)
}
} else {
popup.dismiss()
changeEmojiKeyboardIcon(false)
}
}
}
}

View file

@ -1,3 +1 @@
This update brings a new navigation architecture, which is the groundwork for additional features like in-app linking and deep links. If there are any views that do not open correctly anymore or any new issues that seem releated to navigation, please let us know.
This update also has a new way to load challenge data, so please test that the challenge list still displays.
This update brings username and emoji autocomplete, deep linking (open https://habitica.com urls from anywhere on your device with the app), bigger emojis and bugfixes.