mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-11 14:54:09 +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!");
|
||||
} else {
|
||||
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.ui.StatusDrawable;
|
||||
import com.nextcloud.talk.users.UserManager;
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils;
|
||||
import com.nextcloud.talk.utils.ApiUtils;
|
||||
import com.nextcloud.talk.utils.DisplayUtils;
|
||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew;
|
||||
@ -87,6 +88,9 @@ public class ChooseAccountDialogFragment extends DialogFragment {
|
||||
@Inject
|
||||
NcApi ncApi;
|
||||
|
||||
@Inject
|
||||
ViewThemeUtils viewThemeUtils;
|
||||
|
||||
private DialogChooseAccountBinding binding;
|
||||
private View dialogView;
|
||||
|
||||
@ -120,6 +124,9 @@ public class ChooseAccountDialogFragment extends DialogFragment {
|
||||
binding.currentAccount.ticker.setVisibility(View.GONE);
|
||||
binding.currentAccount.account.setText((Uri.parse(user.getBaseUrl()).getHost()));
|
||||
|
||||
viewThemeUtils.colorImageView(binding.currentAccount.accountMenu);
|
||||
|
||||
|
||||
if (user.getBaseUrl() != null &&
|
||||
(user.getBaseUrl().startsWith("http://") || user.getBaseUrl().startsWith("https://"))) {
|
||||
binding.currentAccount.userIcon.setVisibility(View.VISIBLE);
|
||||
|
@ -34,12 +34,15 @@ import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.AdapterView
|
||||
import android.widget.AdapterView.OnItemSelectedListener
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import autodagger.AutoInjector
|
||||
import com.bluelinelabs.logansquare.LoganSquare
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.adapters.PredefinedStatusClickListener
|
||||
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.predefined.PredefinedStatus
|
||||
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.DisplayUtils
|
||||
import com.vanniktech.emoji.EmojiPopup
|
||||
@ -105,6 +109,9 @@ class SetStatusDialogFragment :
|
||||
@Inject
|
||||
lateinit var ncApi: NcApi
|
||||
|
||||
@Inject
|
||||
lateinit var viewThemeUtils: ViewThemeUtils
|
||||
|
||||
lateinit var credentials: String
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -234,8 +241,8 @@ class SetStatusDialogFragment :
|
||||
}
|
||||
}
|
||||
|
||||
binding.clearStatus.setTextColor(resources.getColor(R.color.colorPrimary))
|
||||
binding.setStatus.setBackgroundColor(resources.getColor(R.color.colorPrimary))
|
||||
viewThemeUtils.colorMaterialButtonText(binding.clearStatus)
|
||||
viewThemeUtils.colorMaterialButtonBackground(binding.setStatus)
|
||||
|
||||
binding.customStatusInput.highlightColor = resources.getColor(R.color.colorPrimary)
|
||||
|
||||
@ -258,7 +265,6 @@ class SetStatusDialogFragment :
|
||||
|
||||
@Suppress("ComplexMethod")
|
||||
private fun setClearStatusAfterValue(item: Int) {
|
||||
|
||||
val currentTime = System.currentTimeMillis() / ONE_SECOND_IN_MILLIS
|
||||
|
||||
when (item) {
|
||||
@ -310,7 +316,6 @@ class SetStatusDialogFragment :
|
||||
}
|
||||
|
||||
private fun clearAtToUnixTime(clearAt: ClearAt?): Long {
|
||||
|
||||
var returnValue = -1L
|
||||
|
||||
if (clearAt != null) {
|
||||
@ -400,25 +405,19 @@ class SetStatusDialogFragment :
|
||||
|
||||
private fun visualizeStatus(statusType: StatusType) {
|
||||
clearTopStatus()
|
||||
when (statusType) {
|
||||
StatusType.ONLINE -> {
|
||||
binding.onlineStatus.setCardBackgroundColor(resources.getColor(R.color.colorPrimary))
|
||||
binding.onlineHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text_dark_background))
|
||||
val views: Triple<MaterialCardView, TextView, ImageView> = when (statusType) {
|
||||
StatusType.ONLINE -> Triple(binding.onlineStatus, binding.onlineHeadline, binding.onlineIcon)
|
||||
StatusType.AWAY -> Triple(binding.awayStatus, binding.awayHeadline, binding.awayIcon)
|
||||
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() {
|
||||
@ -433,11 +432,15 @@ class SetStatusDialogFragment :
|
||||
binding.awayHeadline.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.onlineIcon.imageTintList = null
|
||||
binding.awayIcon.imageTintList = null
|
||||
binding.dndIcon.imageTintList = null
|
||||
binding.invisibleIcon.imageTintList = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun setStatusMessage() {
|
||||
|
||||
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 }
|
||||
@ -446,7 +449,6 @@ class SetStatusDialogFragment :
|
||||
selectedPredefinedStatus!!.message != inputText ||
|
||||
selectedPredefinedStatus!!.icon != binding.emoji.text.toString()
|
||||
) {
|
||||
|
||||
ncApi.setCustomStatusMessage(
|
||||
credentials,
|
||||
ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl),
|
||||
@ -476,12 +478,13 @@ class SetStatusDialogFragment :
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
val clearAt = clearAtToUnixTime(selectedPredefinedStatus!!.clearAt)
|
||||
|
||||
ncApi.setPredefinedStatusMessage(
|
||||
credentials, ApiUtils.getUrlForSetPredefinedStatus(currentUser?.baseUrl),
|
||||
selectedPredefinedStatus!!.id, if (clearAt == -1L) null else clearAt
|
||||
credentials,
|
||||
ApiUtils.getUrlForSetPredefinedStatus(currentUser?.baseUrl),
|
||||
selectedPredefinedStatus!!.id,
|
||||
if (clearAt == -1L) null else clearAt
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())?.subscribe(object : Observer<GenericOverall> {
|
||||
@ -506,7 +509,6 @@ class SetStatusDialogFragment :
|
||||
}
|
||||
|
||||
override fun onClick(predefinedStatus: PredefinedStatus) {
|
||||
|
||||
selectedPredefinedStatus = predefinedStatus
|
||||
|
||||
clearAt = clearAtToUnixTime(predefinedStatus.clearAt)
|
||||
|
@ -29,6 +29,7 @@ import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
||||
import javax.inject.Inject
|
||||
|
||||
// TODO cache theme, keyed by server url
|
||||
// TODO reload UI when account changes
|
||||
internal class ServerThemeProviderImpl @Inject constructor(
|
||||
private val context: Context,
|
||||
private val userProvider: CurrentUserProviderNew
|
||||
|
@ -24,8 +24,11 @@ package com.nextcloud.talk.ui.theme
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.content.res.Configuration
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
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 javax.inject.Inject
|
||||
|
||||
@ -47,20 +50,67 @@ class ViewThemeUtils @Inject constructor(val theme: ServerTheme) {
|
||||
else -> theme.colorElementBright
|
||||
}
|
||||
|
||||
fun themeFAB(fab: FloatingActionButton) {
|
||||
fab.backgroundTintList = ColorStateList.valueOf(getElementColor(fab.context))
|
||||
fab.imageTintList = ColorStateList.valueOf(theme.colorText)
|
||||
private fun withElementColor(view: View, block: (Int) -> Unit) {
|
||||
block(getElementColor(view.context))
|
||||
}
|
||||
|
||||
fun colorTextView(textView: TextView) {
|
||||
textView.setTextColor(getElementColor(textView.context))
|
||||
fun themeFAB(fab: FloatingActionButton) {
|
||||
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.
|
||||
*/
|
||||
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.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">
|
||||
|
||||
<RelativeLayout
|
||||
tools:background="@color/white"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
|
@ -18,6 +18,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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:background="@color/white"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
Loading…
Reference in New Issue
Block a user