mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 04:29:45 +01:00
Merge pull request #1841 from nextcloud/bugfix/1839/fail-to-set-empty-status-message
Bugfix/1839/fail to set empty status message
This commit is contained in:
commit
08dc22c30f
@ -35,6 +35,7 @@ import android.widget.AdapterView
|
||||
import android.widget.AdapterView.OnItemSelectedListener
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import autodagger.AutoInjector
|
||||
@ -59,6 +60,7 @@ import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.android.synthetic.main.dialog_set_status.*
|
||||
import okhttp3.ResponseBody
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
@ -157,7 +159,8 @@ class SetStatusDialogFragment :
|
||||
currentStatus?.let {
|
||||
binding.emoji.setText(it.icon)
|
||||
binding.customStatusInput.text?.clear()
|
||||
binding.customStatusInput.setText(it.message)
|
||||
binding.customStatusInput.setText(it.message?.trim())
|
||||
binding.setStatus.isEnabled = it.message?.isEmpty() == false
|
||||
visualizeStatus(it.status)
|
||||
|
||||
if (it.clearAt > 0) {
|
||||
@ -231,6 +234,10 @@ class SetStatusDialogFragment :
|
||||
binding.setStatus.setBackgroundColor(resources.getColor(R.color.colorPrimary))
|
||||
|
||||
binding.customStatusInput.highlightColor = resources.getColor(R.color.colorPrimary)
|
||||
|
||||
binding.customStatusInput.doAfterTextChanged { text ->
|
||||
binding.setStatus.isEnabled = !text.isNullOrEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod")
|
||||
@ -289,10 +296,10 @@ class SetStatusDialogFragment :
|
||||
@Suppress("ReturnCount")
|
||||
private fun clearAtToUnixTime(clearAt: ClearAt?): Long {
|
||||
if (clearAt != null) {
|
||||
if (clearAt.type.equals("period")) {
|
||||
if (clearAt.type == "period") {
|
||||
return System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + clearAt.time.toLong()
|
||||
} else if (clearAt.type.equals("end-of")) {
|
||||
if (clearAt.time.equals("day")) {
|
||||
} else if (clearAt.type == "end-of") {
|
||||
if (clearAt.time == "day") {
|
||||
val date = Calendar.getInstance().apply {
|
||||
set(Calendar.HOUR_OF_DAY, LAST_HOUR_OF_DAY)
|
||||
set(Calendar.MINUTE, LAST_MINUTE_OF_HOUR)
|
||||
@ -393,15 +400,15 @@ class SetStatusDialogFragment :
|
||||
}
|
||||
|
||||
private fun setStatusMessage() {
|
||||
var inputText = binding.customStatusInput.text.toString()
|
||||
if (inputText.isEmpty()) {
|
||||
inputText = " "
|
||||
}
|
||||
|
||||
val inputText = binding.customStatusInput.text.toString().ifEmpty { "" }
|
||||
// The endpoint '/message/custom' expects a valid emoji as string or null
|
||||
val statusIcon = binding.emoji.text.toString().ifEmpty { null }
|
||||
|
||||
ncApi.setCustomStatusMessage(
|
||||
credentials,
|
||||
ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl),
|
||||
binding.emoji.text.toString(),
|
||||
statusIcon,
|
||||
inputText,
|
||||
clearAt
|
||||
)
|
||||
@ -443,14 +450,14 @@ class SetStatusDialogFragment :
|
||||
binding.clearStatusAfterSpinner.setSelection(0)
|
||||
} else {
|
||||
val clearAt = predefinedStatus.clearAt!!
|
||||
if (clearAt.type.equals("period")) {
|
||||
if (clearAt.type == "period") {
|
||||
when (clearAt.time) {
|
||||
"1800" -> binding.clearStatusAfterSpinner.setSelection(POS_HALF_AN_HOUR)
|
||||
"3600" -> binding.clearStatusAfterSpinner.setSelection(POS_AN_HOUR)
|
||||
"14400" -> binding.clearStatusAfterSpinner.setSelection(POS_FOUR_HOURS)
|
||||
else -> binding.clearStatusAfterSpinner.setSelection(POS_DONT_CLEAR)
|
||||
}
|
||||
} else if (clearAt.type.equals("end-of")) {
|
||||
} else if (clearAt.type == "end-of") {
|
||||
when (clearAt.time) {
|
||||
"day" -> binding.clearStatusAfterSpinner.setSelection(POS_TODAY)
|
||||
"week" -> binding.clearStatusAfterSpinner.setSelection(POS_END_OF_WEEK)
|
||||
|
Loading…
Reference in New Issue
Block a user