enhance set status dialog m3 themeing

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-09-12 15:07:49 +02:00 committed by Álvaro Brey
parent 50a6937ca4
commit 25bbbea282
No known key found for this signature in database
GPG key ID: 2585783189A62105
3 changed files with 48 additions and 33 deletions

View file

@ -24,6 +24,7 @@ import android.annotation.SuppressLint
import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -31,10 +32,13 @@ 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.annotation.VisibleForTesting
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.card.MaterialCardView
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.nextcloud.client.account.User
@ -135,9 +139,11 @@ class SetStatusDialogFragment :
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
binding = DialogSetStatusBinding.inflate(layoutInflater)
return AlertDialog.Builder(requireContext())
.setView(binding.root)
.create()
val builder = MaterialAlertDialogBuilder(requireContext()).setView(binding.root)
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(binding.statusView.context, builder)
return builder.create()
}
@SuppressLint("DefaultLocale")
@ -200,9 +206,11 @@ class SetStatusDialogFragment :
}
}
binding.clearStatus.setTextColor(themeColorUtils.primaryColor(context, true))
viewThemeUtils.material.colorMaterialButtonText(binding.clearStatus)
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.setStatus)
viewThemeUtils.material.colorTextInputLayout(binding.customStatusInputContainer)
viewThemeUtils.platform.themeDialog(binding.root)
}
private fun updateCurrentStatusViews(it: Status) {
@ -309,34 +317,38 @@ class SetStatusDialogFragment :
}
private fun visualizeStatus(statusType: StatusType) {
when (statusType) {
StatusType.ONLINE -> {
clearTopStatus()
binding.onlineStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
clearTopStatus()
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 -> {
clearTopStatus()
binding.awayStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
}
StatusType.DND -> {
clearTopStatus()
binding.dndStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
}
StatusType.INVISIBLE -> {
clearTopStatus()
binding.invisibleStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
}
else -> clearTopStatus()
}
viewThemeUtils.material.colorCardViewBackground(views.first)
viewThemeUtils.platform.colorPrimaryTextViewElement(views.second)
}
private fun clearTopStatus() {
context?.let {
val grey = it.resources.getColor(R.color.grey_200)
binding.onlineStatus.setBackgroundColor(grey)
binding.awayStatus.setBackgroundColor(grey)
binding.dndStatus.setBackgroundColor(grey)
binding.invisibleStatus.setBackgroundColor(grey)
binding.onlineStatus.setCardBackgroundColor(grey)
binding.awayStatus.setCardBackgroundColor(grey)
binding.dndStatus.setCardBackgroundColor(grey)
binding.invisibleStatus.setCardBackgroundColor(grey)
binding.onlineHeadline.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.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
}
}
@ -375,6 +387,8 @@ class SetStatusDialogFragment :
* Fragment creator
*/
companion object {
private val TAG = SetStatusDialogFragment::class.simpleName
@JvmStatic
fun newInstance(user: User, status: Status?): SetStatusDialogFragment {
val args = Bundle()
@ -382,7 +396,6 @@ class SetStatusDialogFragment :
args.putParcelable(ARG_CURRENT_STATUS_PARAM, status)
val dialogFragment = SetStatusDialogFragment()
dialogFragment.arguments = args
dialogFragment.setStyle(STYLE_NORMAL, R.style.Theme_ownCloud_Dialog)
return dialogFragment
}
}

View file

@ -62,7 +62,8 @@
android:layout_weight="1"
android:orientation="horizontal"
app:cardBackgroundColor="@color/grey_200"
app:cardElevation="0dp">
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/button_corner_radius">
<RelativeLayout
android:layout_width="match_parent"
@ -129,7 +130,8 @@
android:layout_weight="1"
android:orientation="horizontal"
app:cardBackgroundColor="@color/grey_200"
app:cardElevation="0dp">
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/button_corner_radius">
<RelativeLayout
android:layout_width="match_parent"
@ -205,7 +207,8 @@
android:layout_weight="1"
android:orientation="horizontal"
app:cardBackgroundColor="@color/grey_200"
app:cardElevation="0dp">
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/button_corner_radius">
<RelativeLayout
android:layout_width="match_parent"
@ -256,11 +259,11 @@
android:layout_height="@dimen/online_status_item_height"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/standard_half_margin"
android:layout_weight="1"
android:orientation="horizontal"
app:cardBackgroundColor="@color/grey_200"
app:cardElevation="0dp">
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/button_corner_radius">
<RelativeLayout
android:layout_width="match_parent"

View file

@ -297,7 +297,6 @@
<style name="Theme.ownCloud.Dialog" parent="@style/Theme.Material3.DayNight.Dialog.Alert">
<item name="windowNoTitle">false</item>
<item name="colorAccent">@color/color_accent</item>
<item name="android:windowBackground">@color/bg_default</item>
<item name="android:textAllCaps">false</item>
<item name="textInputStyle">@style/Widget.App.TextInputLayout</item>
</style>