mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Add back ability to message from overview screen. Fixes #1075
This commit is contained in:
parent
bcaf8762f5
commit
55bac855db
6 changed files with 70 additions and 23 deletions
|
|
@ -155,7 +155,7 @@ android {
|
|||
multiDexEnabled true
|
||||
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
|
||||
|
||||
versionCode 2384
|
||||
versionCode 2386
|
||||
versionName "2.5"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp">
|
||||
android:paddingRight="20dp"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -18,4 +20,23 @@
|
|||
android:id="@+id/uuidEditText" android:layout_gravity="center_horizontal"
|
||||
android:focusable="true"
|
||||
android:maxLines="1"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_circular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:visibility="visible"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/error_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/spacing_medium"
|
||||
android:layout_marginBottom="@dimen/spacing_medium"
|
||||
android:text="@string/could_not_find_user"
|
||||
android:textColor="@color/red_50"
|
||||
tools:visibility="visible"
|
||||
android:gravity="center_horizontal"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
10
Habitica/res/menu/inbox.xml
Normal file
10
Habitica/res/menu/inbox.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.habitrpg.android.habitica.TaskActivity">
|
||||
|
||||
<item android:id="@+id/send_message"
|
||||
android:icon="@drawable/menu_messages"
|
||||
android:title="@string/send_message"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
||||
|
|
@ -998,4 +998,5 @@
|
|||
<string name="support">Support</string>
|
||||
<string name="wacky"> Wacky </string>
|
||||
<string name="habitica_questions">Habitica Questions</string>
|
||||
<string name="could_not_find_user">Could not find user</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -2,15 +2,12 @@ package com.habitrpg.android.habitica.ui.fragments.social
|
|||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import android.view.*
|
||||
import android.widget.TextView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.SocialRepository
|
||||
import com.habitrpg.android.habitica.databinding.DialogChooseMessageRecipientBinding
|
||||
import com.habitrpg.android.habitica.extensions.getAgoString
|
||||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||
import com.habitrpg.android.habitica.helpers.MainNavigationController
|
||||
|
|
@ -37,8 +34,6 @@ class InboxOverviewFragment : BaseMainFragment(), androidx.swiperefreshlayout.wi
|
|||
@Inject
|
||||
lateinit var configManager: AppConfigManager
|
||||
|
||||
private var chooseRecipientDialogView: View? = null
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
this.hidesToolbar = true
|
||||
|
|
@ -69,6 +64,11 @@ class InboxOverviewFragment : BaseMainFragment(), androidx.swiperefreshlayout.wi
|
|||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
this.activity?.menuInflater?.inflate(R.menu.inbox, menu)
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.send_message -> {
|
||||
|
|
@ -81,19 +81,34 @@ class InboxOverviewFragment : BaseMainFragment(), androidx.swiperefreshlayout.wi
|
|||
|
||||
private fun openNewMessageDialog() {
|
||||
assert(this.activity != null)
|
||||
this.chooseRecipientDialogView = this.activity?.layoutInflater?.inflate(R.layout.dialog_choose_message_recipient, null)
|
||||
val binding = DialogChooseMessageRecipientBinding.inflate(layoutInflater)
|
||||
|
||||
this.activity?.let { thisActivity ->
|
||||
val alert = HabiticaAlertDialog(thisActivity)
|
||||
alert.setTitle(getString(R.string.choose_recipient_title))
|
||||
alert.addButton(getString(R.string.action_continue), true) { _, _ ->
|
||||
val uuidEditText = chooseRecipientDialogView?.findViewById<View>(R.id.uuidEditText) as? EditText
|
||||
openInboxMessages(uuidEditText?.text?.toString() ?: "", "")
|
||||
}
|
||||
alert.addButton(
|
||||
getString(R.string.action_continue),
|
||||
true,
|
||||
false,
|
||||
false
|
||||
) { _, _ ->
|
||||
binding.errorTextView.visibility = View.GONE
|
||||
binding.progressCircular.visibility = View.VISIBLE
|
||||
val username = binding.uuidEditText.text?.toString() ?: ""
|
||||
socialRepository.getMemberWithUsername(username)
|
||||
.subscribe({
|
||||
alert.dismiss()
|
||||
openInboxMessages("", username)
|
||||
binding.progressCircular.visibility = View.GONE
|
||||
}, {
|
||||
binding.errorTextView.visibility = View.VISIBLE
|
||||
binding.progressCircular.visibility = View.GONE
|
||||
})
|
||||
}
|
||||
alert.addButton(getString(R.string.action_cancel), false) { dialog, _ ->
|
||||
thisActivity.dismissKeyboard()
|
||||
}
|
||||
alert.setAdditionalContentView(chooseRecipientDialogView)
|
||||
thisActivity.dismissKeyboard()
|
||||
}
|
||||
alert.setAdditionalContentView(binding.root)
|
||||
alert.show()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -149,10 +149,10 @@ open class HabiticaAlertDialog(context: Context) : AlertDialog(context, R.style.
|
|||
fun getContentView(): View? = additionalContentView
|
||||
|
||||
fun addButton(stringRes: Int, isPrimary: Boolean, isDestructive: Boolean = false, function: ((HabiticaAlertDialog, Int) -> Unit)? = null): Button {
|
||||
return addButton(context.getString(stringRes), isPrimary, isDestructive, function)
|
||||
return addButton(context.getString(stringRes), isPrimary, isDestructive, true, function)
|
||||
}
|
||||
|
||||
fun addButton(string: String, isPrimary: Boolean, isDestructive: Boolean = false, function: ((HabiticaAlertDialog, Int) -> Unit)? = null): Button {
|
||||
fun addButton(string: String, isPrimary: Boolean, isDestructive: Boolean = false, autoDismiss: Boolean = true, function: ((HabiticaAlertDialog, Int) -> Unit)? = null): Button {
|
||||
val button: Button = if (isPrimary) {
|
||||
if (isDestructive) {
|
||||
buttonsWrapper.inflate(R.layout.dialog_habitica_primary_destructive_button) as? Button
|
||||
|
|
@ -169,7 +169,7 @@ open class HabiticaAlertDialog(context: Context) : AlertDialog(context, R.style.
|
|||
button.text = string
|
||||
button.minWidth = 147.dpToPx(context)
|
||||
button.setScaledPadding(context, 20, 0, 20, 0)
|
||||
return addButton(button, true, function) as Button
|
||||
return addButton(button, autoDismiss, function) as Button
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue