mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-22 17:10:43 +03:00
[issue-2610] Add Override Color menu item under More...
This commit is contained in:
parent
0aee15fd04
commit
0e400dca24
3 changed files with 20 additions and 10 deletions
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,7 +1,7 @@
|
||||||
#Fri Jan 15 11:30:47 CET 2021
|
#Fri Jan 15 11:30:47 CET 2021
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionSha256Sum=a7ca23b3ccf265680f2bfd35f1f00b1424f4466292c7337c85d46c9641b3f053
|
#distributionSha256Sum=a7ca23b3ccf265680f2bfd35f1f00b1424f4466292c7337c85d46c9641b3f053
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
|
||||||
|
|
|
@ -46,6 +46,7 @@ class RoomMemberProfileController @Inject constructor(
|
||||||
fun onShowDeviceList()
|
fun onShowDeviceList()
|
||||||
fun onShowDeviceListNoCrossSigning()
|
fun onShowDeviceListNoCrossSigning()
|
||||||
fun onOpenDmClicked()
|
fun onOpenDmClicked()
|
||||||
|
fun onOverrideColorClicked()
|
||||||
fun onJumpToReadReceiptClicked()
|
fun onJumpToReadReceiptClicked()
|
||||||
fun onMentionClicked()
|
fun onMentionClicked()
|
||||||
fun onEditPowerLevel(currentRole: Role)
|
fun onEditPowerLevel(currentRole: Role)
|
||||||
|
@ -180,11 +181,19 @@ class RoomMemberProfileController @Inject constructor(
|
||||||
|
|
||||||
private fun buildMoreSection(state: RoomMemberProfileViewState) {
|
private fun buildMoreSection(state: RoomMemberProfileViewState) {
|
||||||
// More
|
// More
|
||||||
|
buildProfileSection(stringProvider.getString(R.string.room_profile_section_more))
|
||||||
|
|
||||||
|
buildProfileAction(
|
||||||
|
id = "overrideColor",
|
||||||
|
editable = false,
|
||||||
|
title = stringProvider.getString(R.string.room_member_override_color),
|
||||||
|
dividerColor = dividerColor,
|
||||||
|
action = { callback?.onOverrideColorClicked() }
|
||||||
|
)
|
||||||
|
|
||||||
if (!state.isMine) {
|
if (!state.isMine) {
|
||||||
val membership = state.asyncMembership() ?: return
|
val membership = state.asyncMembership() ?: return
|
||||||
|
|
||||||
buildProfileSection(stringProvider.getString(R.string.room_profile_section_more))
|
|
||||||
|
|
||||||
buildProfileAction(
|
buildProfileAction(
|
||||||
id = "direct",
|
id = "direct",
|
||||||
editable = false,
|
editable = false,
|
||||||
|
|
|
@ -243,7 +243,7 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||||
onAvatarClicked(view, userMatrixItem)
|
onAvatarClicked(view, userMatrixItem)
|
||||||
}
|
}
|
||||||
headerViews.memberProfileNameView.setOnClickListener { _ ->
|
headerViews.memberProfileNameView.setOnClickListener { _ ->
|
||||||
onProfileNameClicked(userMatrixItem)
|
onOverrideColorClicked()
|
||||||
}
|
}
|
||||||
views.matrixProfileToolbarAvatarImageView.setOnClickListener { view ->
|
views.matrixProfileToolbarAvatarImageView.setOnClickListener { view ->
|
||||||
onAvatarClicked(view, userMatrixItem)
|
onAvatarClicked(view, userMatrixItem)
|
||||||
|
@ -331,14 +331,15 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||||
navigator.openBigImageViewer(requireActivity(), view, userMatrixItem)
|
navigator.openBigImageViewer(requireActivity(), view, userMatrixItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onProfileNameClicked(userMatrixItem: MatrixItem) {
|
override fun onOverrideColorClicked(): Unit = withState(viewModel) { state ->
|
||||||
val inflater = requireActivity().layoutInflater
|
val inflater = requireActivity().layoutInflater
|
||||||
val layout = inflater.inflate(R.layout.dialog_base_edit_text, null)
|
val layout = inflater.inflate(R.layout.dialog_base_edit_text, null)
|
||||||
val views = DialogBaseEditTextBinding.bind(layout)
|
val views = DialogBaseEditTextBinding.bind(layout)
|
||||||
val session = injector().activeSessionHolder().getActiveSession()
|
val session = injector().activeSessionHolder().getActiveSession()
|
||||||
val overrideColorsSetting = session.getAccountDataEvent(UserAccountDataTypes.TYPE_OVERRIDE_COLORS)
|
val overrideColorsSetting = session.getAccountDataEvent(UserAccountDataTypes.TYPE_OVERRIDE_COLORS)
|
||||||
val overrideColorSpecs = overrideColorsSetting?.content?.toMap().orEmpty()
|
val overrideColorSpecs = overrideColorsSetting?.content?.toMap().orEmpty()
|
||||||
val overrideColorSpec = overrideColorSpecs[userMatrixItem.id]?.toString()
|
val userId = state.userId;
|
||||||
|
val overrideColorSpec = overrideColorSpecs[userId]?.toString()
|
||||||
views.editText.setText(overrideColorSpec)
|
views.editText.setText(overrideColorSpec)
|
||||||
views.editText.hint = "#000000"
|
views.editText.hint = "#000000"
|
||||||
|
|
||||||
|
@ -349,16 +350,16 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||||
val newOverrideColorSpec = views.editText.text.toString()
|
val newOverrideColorSpec = views.editText.text.toString()
|
||||||
if (newOverrideColorSpec != overrideColorSpec) {
|
if (newOverrideColorSpec != overrideColorSpec) {
|
||||||
val newOverrideColorSpecs = overrideColorSpecs.toMutableMap()
|
val newOverrideColorSpecs = overrideColorSpecs.toMutableMap()
|
||||||
if (matrixItemColorProvider.setOverrideColor(userMatrixItem.id, newOverrideColorSpec)) {
|
if (matrixItemColorProvider.setOverrideColor(userId, newOverrideColorSpec)) {
|
||||||
newOverrideColorSpecs[userMatrixItem.id] = newOverrideColorSpec
|
newOverrideColorSpecs[userId] = newOverrideColorSpec
|
||||||
} else {
|
} else {
|
||||||
newOverrideColorSpecs.remove(userMatrixItem.id)
|
newOverrideColorSpecs.remove(userId)
|
||||||
}
|
}
|
||||||
session.updateAccountData(
|
session.updateAccountData(
|
||||||
type = UserAccountDataTypes.TYPE_OVERRIDE_COLORS,
|
type = UserAccountDataTypes.TYPE_OVERRIDE_COLORS,
|
||||||
content = newOverrideColorSpecs
|
content = newOverrideColorSpecs
|
||||||
)
|
)
|
||||||
headerViews.memberProfileNameView.setTextColor(matrixItemColorProvider.getColor(userMatrixItem))
|
invalidate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
|
Loading…
Reference in a new issue