mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-11 23:04:17 +01:00
Color SetStatusDialog and ChooseAccountDialog
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
4af491c7df
commit
d60fdd03c5
@ -74,7 +74,7 @@ public class GenericTextHeaderItem extends AbstractHeaderItem<GenericTextHeaderI
|
|||||||
Log.d(TAG, "We have payloads, so ignoring!");
|
Log.d(TAG, "We have payloads, so ignoring!");
|
||||||
} else {
|
} else {
|
||||||
holder.binding.titleTextView.setText(title);
|
holder.binding.titleTextView.setText(title);
|
||||||
viewThemeUtils.colorTextView(holder.binding.titleTextView);
|
viewThemeUtils.colorTextViewElement(holder.binding.titleTextView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ import com.nextcloud.talk.models.json.status.Status;
|
|||||||
import com.nextcloud.talk.models.json.status.StatusOverall;
|
import com.nextcloud.talk.models.json.status.StatusOverall;
|
||||||
import com.nextcloud.talk.ui.StatusDrawable;
|
import com.nextcloud.talk.ui.StatusDrawable;
|
||||||
import com.nextcloud.talk.users.UserManager;
|
import com.nextcloud.talk.users.UserManager;
|
||||||
|
import com.nextcloud.talk.ui.theme.ViewThemeUtils;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
import com.nextcloud.talk.utils.DisplayUtils;
|
import com.nextcloud.talk.utils.DisplayUtils;
|
||||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew;
|
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew;
|
||||||
@ -87,6 +88,9 @@ public class ChooseAccountDialogFragment extends DialogFragment {
|
|||||||
@Inject
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ViewThemeUtils viewThemeUtils;
|
||||||
|
|
||||||
private DialogChooseAccountBinding binding;
|
private DialogChooseAccountBinding binding;
|
||||||
private View dialogView;
|
private View dialogView;
|
||||||
|
|
||||||
@ -120,6 +124,9 @@ public class ChooseAccountDialogFragment extends DialogFragment {
|
|||||||
binding.currentAccount.ticker.setVisibility(View.GONE);
|
binding.currentAccount.ticker.setVisibility(View.GONE);
|
||||||
binding.currentAccount.account.setText((Uri.parse(user.getBaseUrl()).getHost()));
|
binding.currentAccount.account.setText((Uri.parse(user.getBaseUrl()).getHost()));
|
||||||
|
|
||||||
|
viewThemeUtils.colorImageView(binding.currentAccount.accountMenu);
|
||||||
|
|
||||||
|
|
||||||
if (user.getBaseUrl() != null &&
|
if (user.getBaseUrl() != null &&
|
||||||
(user.getBaseUrl().startsWith("http://") || user.getBaseUrl().startsWith("https://"))) {
|
(user.getBaseUrl().startsWith("http://") || user.getBaseUrl().startsWith("https://"))) {
|
||||||
binding.currentAccount.userIcon.setVisibility(View.VISIBLE);
|
binding.currentAccount.userIcon.setVisibility(View.VISIBLE);
|
||||||
|
@ -34,12 +34,15 @@ import android.view.inputmethod.InputMethodManager
|
|||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import android.widget.AdapterView.OnItemSelectedListener
|
import android.widget.AdapterView.OnItemSelectedListener
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.widget.doAfterTextChanged
|
import androidx.core.widget.doAfterTextChanged
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import autodagger.AutoInjector
|
import autodagger.AutoInjector
|
||||||
import com.bluelinelabs.logansquare.LoganSquare
|
import com.bluelinelabs.logansquare.LoganSquare
|
||||||
|
import com.google.android.material.card.MaterialCardView
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.adapters.PredefinedStatusClickListener
|
import com.nextcloud.talk.adapters.PredefinedStatusClickListener
|
||||||
import com.nextcloud.talk.adapters.PredefinedStatusListAdapter
|
import com.nextcloud.talk.adapters.PredefinedStatusListAdapter
|
||||||
@ -53,6 +56,7 @@ import com.nextcloud.talk.models.json.status.Status
|
|||||||
import com.nextcloud.talk.models.json.status.StatusType
|
import com.nextcloud.talk.models.json.status.StatusType
|
||||||
import com.nextcloud.talk.models.json.status.predefined.PredefinedStatus
|
import com.nextcloud.talk.models.json.status.predefined.PredefinedStatus
|
||||||
import com.nextcloud.talk.models.json.status.predefined.PredefinedStatusOverall
|
import com.nextcloud.talk.models.json.status.predefined.PredefinedStatusOverall
|
||||||
|
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||||
import com.nextcloud.talk.utils.ApiUtils
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
import com.nextcloud.talk.utils.DisplayUtils
|
import com.nextcloud.talk.utils.DisplayUtils
|
||||||
import com.vanniktech.emoji.EmojiPopup
|
import com.vanniktech.emoji.EmojiPopup
|
||||||
@ -105,6 +109,9 @@ class SetStatusDialogFragment :
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var ncApi: NcApi
|
lateinit var ncApi: NcApi
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var viewThemeUtils: ViewThemeUtils
|
||||||
|
|
||||||
lateinit var credentials: String
|
lateinit var credentials: String
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -234,8 +241,8 @@ class SetStatusDialogFragment :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.clearStatus.setTextColor(resources.getColor(R.color.colorPrimary))
|
viewThemeUtils.colorMaterialButtonText(binding.clearStatus)
|
||||||
binding.setStatus.setBackgroundColor(resources.getColor(R.color.colorPrimary))
|
viewThemeUtils.colorMaterialButtonBackground(binding.setStatus)
|
||||||
|
|
||||||
binding.customStatusInput.highlightColor = resources.getColor(R.color.colorPrimary)
|
binding.customStatusInput.highlightColor = resources.getColor(R.color.colorPrimary)
|
||||||
|
|
||||||
@ -258,7 +265,6 @@ class SetStatusDialogFragment :
|
|||||||
|
|
||||||
@Suppress("ComplexMethod")
|
@Suppress("ComplexMethod")
|
||||||
private fun setClearStatusAfterValue(item: Int) {
|
private fun setClearStatusAfterValue(item: Int) {
|
||||||
|
|
||||||
val currentTime = System.currentTimeMillis() / ONE_SECOND_IN_MILLIS
|
val currentTime = System.currentTimeMillis() / ONE_SECOND_IN_MILLIS
|
||||||
|
|
||||||
when (item) {
|
when (item) {
|
||||||
@ -310,7 +316,6 @@ class SetStatusDialogFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun clearAtToUnixTime(clearAt: ClearAt?): Long {
|
private fun clearAtToUnixTime(clearAt: ClearAt?): Long {
|
||||||
|
|
||||||
var returnValue = -1L
|
var returnValue = -1L
|
||||||
|
|
||||||
if (clearAt != null) {
|
if (clearAt != null) {
|
||||||
@ -400,25 +405,19 @@ class SetStatusDialogFragment :
|
|||||||
|
|
||||||
private fun visualizeStatus(statusType: StatusType) {
|
private fun visualizeStatus(statusType: StatusType) {
|
||||||
clearTopStatus()
|
clearTopStatus()
|
||||||
when (statusType) {
|
val views: Triple<MaterialCardView, TextView, ImageView> = when (statusType) {
|
||||||
StatusType.ONLINE -> {
|
StatusType.ONLINE -> Triple(binding.onlineStatus, binding.onlineHeadline, binding.onlineIcon)
|
||||||
binding.onlineStatus.setCardBackgroundColor(resources.getColor(R.color.colorPrimary))
|
StatusType.AWAY -> Triple(binding.awayStatus, binding.awayHeadline, binding.awayIcon)
|
||||||
binding.onlineHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text_dark_background))
|
StatusType.DND -> Triple(binding.dndStatus, binding.dndHeadline, binding.dndIcon)
|
||||||
|
StatusType.INVISIBLE -> Triple(binding.invisibleStatus, binding.invisibleHeadline, binding.invisibleIcon)
|
||||||
|
else -> {
|
||||||
|
Log.d(TAG, "unknown status")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
StatusType.AWAY -> {
|
|
||||||
binding.awayStatus.setCardBackgroundColor(resources.getColor(R.color.colorPrimary))
|
|
||||||
binding.awayHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text_dark_background))
|
|
||||||
}
|
|
||||||
StatusType.DND -> {
|
|
||||||
binding.dndStatus.setCardBackgroundColor(resources.getColor(R.color.colorPrimary))
|
|
||||||
binding.dndHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text_dark_background))
|
|
||||||
}
|
|
||||||
StatusType.INVISIBLE -> {
|
|
||||||
binding.invisibleStatus.setCardBackgroundColor(resources.getColor(R.color.colorPrimary))
|
|
||||||
binding.invisibleHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text_dark_background))
|
|
||||||
}
|
|
||||||
else -> Log.d(TAG, "unknown status")
|
|
||||||
}
|
}
|
||||||
|
viewThemeUtils.colorCardViewBackground(views.first)
|
||||||
|
viewThemeUtils.colorTextViewText(views.second)
|
||||||
|
viewThemeUtils.colorImageViewText(views.third)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clearTopStatus() {
|
private fun clearTopStatus() {
|
||||||
@ -433,11 +432,15 @@ class SetStatusDialogFragment :
|
|||||||
binding.awayHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text))
|
binding.awayHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text))
|
||||||
binding.dndHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text))
|
binding.dndHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text))
|
||||||
binding.invisibleHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text))
|
binding.invisibleHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text))
|
||||||
|
|
||||||
|
binding.onlineIcon.imageTintList = null
|
||||||
|
binding.awayIcon.imageTintList = null
|
||||||
|
binding.dndIcon.imageTintList = null
|
||||||
|
binding.invisibleIcon.imageTintList = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setStatusMessage() {
|
private fun setStatusMessage() {
|
||||||
|
|
||||||
val inputText = binding.customStatusInput.text.toString().ifEmpty { "" }
|
val inputText = binding.customStatusInput.text.toString().ifEmpty { "" }
|
||||||
// The endpoint '/message/custom' expects a valid emoji as string or null
|
// The endpoint '/message/custom' expects a valid emoji as string or null
|
||||||
val statusIcon = binding.emoji.text.toString().ifEmpty { null }
|
val statusIcon = binding.emoji.text.toString().ifEmpty { null }
|
||||||
@ -446,7 +449,6 @@ class SetStatusDialogFragment :
|
|||||||
selectedPredefinedStatus!!.message != inputText ||
|
selectedPredefinedStatus!!.message != inputText ||
|
||||||
selectedPredefinedStatus!!.icon != binding.emoji.text.toString()
|
selectedPredefinedStatus!!.icon != binding.emoji.text.toString()
|
||||||
) {
|
) {
|
||||||
|
|
||||||
ncApi.setCustomStatusMessage(
|
ncApi.setCustomStatusMessage(
|
||||||
credentials,
|
credentials,
|
||||||
ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl),
|
ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl),
|
||||||
@ -476,12 +478,13 @@ class SetStatusDialogFragment :
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
val clearAt = clearAtToUnixTime(selectedPredefinedStatus!!.clearAt)
|
val clearAt = clearAtToUnixTime(selectedPredefinedStatus!!.clearAt)
|
||||||
|
|
||||||
ncApi.setPredefinedStatusMessage(
|
ncApi.setPredefinedStatusMessage(
|
||||||
credentials, ApiUtils.getUrlForSetPredefinedStatus(currentUser?.baseUrl),
|
credentials,
|
||||||
selectedPredefinedStatus!!.id, if (clearAt == -1L) null else clearAt
|
ApiUtils.getUrlForSetPredefinedStatus(currentUser?.baseUrl),
|
||||||
|
selectedPredefinedStatus!!.id,
|
||||||
|
if (clearAt == -1L) null else clearAt
|
||||||
)
|
)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())?.subscribe(object : Observer<GenericOverall> {
|
.observeOn(AndroidSchedulers.mainThread())?.subscribe(object : Observer<GenericOverall> {
|
||||||
@ -506,7 +509,6 @@ class SetStatusDialogFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(predefinedStatus: PredefinedStatus) {
|
override fun onClick(predefinedStatus: PredefinedStatus) {
|
||||||
|
|
||||||
selectedPredefinedStatus = predefinedStatus
|
selectedPredefinedStatus = predefinedStatus
|
||||||
|
|
||||||
clearAt = clearAtToUnixTime(predefinedStatus.clearAt)
|
clearAt = clearAtToUnixTime(predefinedStatus.clearAt)
|
||||||
|
@ -29,6 +29,7 @@ import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
// TODO cache theme, keyed by server url
|
// TODO cache theme, keyed by server url
|
||||||
|
// TODO reload UI when account changes
|
||||||
internal class ServerThemeProviderImpl @Inject constructor(
|
internal class ServerThemeProviderImpl @Inject constructor(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val userProvider: CurrentUserProviderNew
|
private val userProvider: CurrentUserProviderNew
|
||||||
|
@ -24,8 +24,11 @@ package com.nextcloud.talk.ui.theme
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import com.google.android.material.button.MaterialButton
|
||||||
|
import com.google.android.material.card.MaterialCardView
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -47,20 +50,67 @@ class ViewThemeUtils @Inject constructor(val theme: ServerTheme) {
|
|||||||
else -> theme.colorElementBright
|
else -> theme.colorElementBright
|
||||||
}
|
}
|
||||||
|
|
||||||
fun themeFAB(fab: FloatingActionButton) {
|
private fun withElementColor(view: View, block: (Int) -> Unit) {
|
||||||
fab.backgroundTintList = ColorStateList.valueOf(getElementColor(fab.context))
|
block(getElementColor(view.context))
|
||||||
fab.imageTintList = ColorStateList.valueOf(theme.colorText)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun colorTextView(textView: TextView) {
|
fun themeFAB(fab: FloatingActionButton) {
|
||||||
textView.setTextColor(getElementColor(textView.context))
|
withElementColor(fab) { color ->
|
||||||
|
fab.backgroundTintList = ColorStateList.valueOf(color)
|
||||||
|
fab.imageTintList = ColorStateList.valueOf(theme.colorText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun colorTextViewElement(textView: TextView) {
|
||||||
|
withElementColor(textView) { color ->
|
||||||
|
textView.setTextColor(color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun colorTextViewText(textView: TextView) {
|
||||||
|
textView.setTextColor(theme.colorText)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Colors the background as element color and the foreground as text color.
|
* Colors the background as element color and the foreground as text color.
|
||||||
*/
|
*/
|
||||||
fun colorImageViewButton(imageView: ImageView) {
|
fun colorImageViewButton(imageView: ImageView) {
|
||||||
|
withElementColor(imageView) { color ->
|
||||||
|
imageView.imageTintList = ColorStateList.valueOf(theme.colorText)
|
||||||
|
imageView.backgroundTintList = ColorStateList.valueOf(color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tints the image with element color
|
||||||
|
*/
|
||||||
|
fun colorImageView(imageView: ImageView) {
|
||||||
|
withElementColor(imageView) { color ->
|
||||||
|
imageView.imageTintList = ColorStateList.valueOf(color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tints the image with text color
|
||||||
|
*/
|
||||||
|
fun colorImageViewText(imageView: ImageView) {
|
||||||
imageView.imageTintList = ColorStateList.valueOf(theme.colorText)
|
imageView.imageTintList = ColorStateList.valueOf(theme.colorText)
|
||||||
imageView.backgroundTintList = ColorStateList.valueOf(getElementColor(imageView.context))
|
}
|
||||||
|
|
||||||
|
fun colorMaterialButtonText(button: MaterialButton) {
|
||||||
|
colorTextViewElement(button)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun colorMaterialButtonBackground(button: MaterialButton) {
|
||||||
|
withElementColor(button) { color ->
|
||||||
|
button.setBackgroundColor(color)
|
||||||
|
button.setTextColor(theme.colorText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun colorCardViewBackground(card: MaterialCardView) {
|
||||||
|
withElementColor(card) { color ->
|
||||||
|
card.setCardBackgroundColor(color)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
app:cardElevation="0dp">
|
app:cardElevation="0dp">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
tools:background="@color/white"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:background="@color/white"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
Loading…
Reference in New Issue
Block a user