mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-25 20:23:19 +00:00
Improve styling of ChooseGroupStoryBottomSheet.
This commit is contained in:
@@ -66,6 +66,7 @@ sealed class DSLSettingsText {
|
||||
}
|
||||
|
||||
object TitleLargeModifier : TextAppearanceModifier(R.style.Signal_Text_TitleLarge)
|
||||
object TitleMediumModifier : TextAppearanceModifier(R.style.Signal_Text_TitleMedium)
|
||||
object Body1BoldModifier : TextAppearanceModifier(R.style.TextAppearance_Signal_Body1_Bold)
|
||||
|
||||
open class TextAppearanceModifier(@StyleRes private val textAppearance: Int) : Modifier {
|
||||
|
||||
@@ -64,6 +64,7 @@ class ContactSearchConfiguration private constructor(
|
||||
val includeInactive: Boolean = false,
|
||||
val returnAsGroupStories: Boolean = false,
|
||||
val sortOrder: ContactSearchSortOrder = ContactSearchSortOrder.NATURAL,
|
||||
val shortSummary: Boolean = false,
|
||||
override val includeHeader: Boolean,
|
||||
override val expandConfig: ExpandConfig? = null
|
||||
) : Section(SectionKey.GROUPS)
|
||||
|
||||
@@ -23,7 +23,7 @@ sealed class ContactSearchData(val contactSearchKey: ContactSearchKey) {
|
||||
/**
|
||||
* A row displaying a known recipient.
|
||||
*/
|
||||
data class KnownRecipient(val recipient: Recipient) : ContactSearchData(ContactSearchKey.RecipientSearchKey.KnownRecipient(recipient.id))
|
||||
data class KnownRecipient(val recipient: Recipient, val shortSummary: Boolean = false) : ContactSearchData(ContactSearchKey.RecipientSearchKey.KnownRecipient(recipient.id))
|
||||
|
||||
/**
|
||||
* A row containing a title for a given section
|
||||
|
||||
@@ -73,7 +73,7 @@ object ContactSearchItems {
|
||||
contactSearchData.filterNotNull().map {
|
||||
when (it) {
|
||||
is ContactSearchData.Story -> StoryModel(it, selection.contains(it.contactSearchKey), SignalStore.storyValues().userHasBeenNotifiedAboutStories)
|
||||
is ContactSearchData.KnownRecipient -> RecipientModel(it, selection.contains(it.contactSearchKey))
|
||||
is ContactSearchData.KnownRecipient -> RecipientModel(it, selection.contains(it.contactSearchKey), it.shortSummary)
|
||||
is ContactSearchData.Expand -> ExpandModel(it)
|
||||
is ContactSearchData.Header -> HeaderModel(it)
|
||||
is ContactSearchData.TestRow -> error("This row exists for testing only.")
|
||||
@@ -207,7 +207,7 @@ object ContactSearchItems {
|
||||
/**
|
||||
* Recipient model
|
||||
*/
|
||||
private class RecipientModel(val knownRecipient: ContactSearchData.KnownRecipient, val isSelected: Boolean) : MappingModel<RecipientModel> {
|
||||
private class RecipientModel(val knownRecipient: ContactSearchData.KnownRecipient, val isSelected: Boolean, val shortSummary: Boolean) : MappingModel<RecipientModel> {
|
||||
|
||||
override fun areItemsTheSame(newItem: RecipientModel): Boolean {
|
||||
return newItem.knownRecipient == knownRecipient
|
||||
@@ -230,6 +230,16 @@ object ContactSearchItems {
|
||||
override fun isSelected(model: RecipientModel): Boolean = model.isSelected
|
||||
override fun getData(model: RecipientModel): ContactSearchData.KnownRecipient = model.knownRecipient
|
||||
override fun getRecipient(model: RecipientModel): Recipient = model.knownRecipient.recipient
|
||||
override fun bindNumberField(model: RecipientModel) {
|
||||
val recipient = getRecipient(model)
|
||||
|
||||
if (model.shortSummary && recipient.isGroup) {
|
||||
val count = recipient.participantIds.size
|
||||
number.setText(context.resources.getQuantityString(R.plurals.ContactSearchItems__group_d_members, count, count))
|
||||
} else {
|
||||
super.bindNumberField(model)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -219,7 +219,7 @@ class ContactSearchPagedDataSource(
|
||||
if (section.returnAsGroupStories) {
|
||||
ContactSearchData.Story(contactSearchPagedDataSourceRepository.getRecipientFromGroupRecord(it), 0, DistributionListPrivacyMode.ALL)
|
||||
} else {
|
||||
ContactSearchData.KnownRecipient(contactSearchPagedDataSourceRepository.getRecipientFromGroupRecord(it))
|
||||
ContactSearchData.KnownRecipient(contactSearchPagedDataSourceRepository.getRecipientFromGroupRecord(it), shortSummary = section.shortSummary)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -34,7 +34,6 @@ class ChooseGroupStoryBottomSheet : FixedRoundedCornerBottomSheetDialogFragment(
|
||||
|
||||
private lateinit var confirmButton: View
|
||||
private lateinit var selectedList: RecyclerView
|
||||
private lateinit var backgroundHelper: View
|
||||
private lateinit var divider: View
|
||||
private lateinit var mediator: ContactSearchMediator
|
||||
|
||||
@@ -52,7 +51,6 @@ class ChooseGroupStoryBottomSheet : FixedRoundedCornerBottomSheetDialogFragment(
|
||||
|
||||
confirmButton = bottomBar.findViewById(R.id.share_confirm)
|
||||
selectedList = bottomBar.findViewById(R.id.selected_list)
|
||||
backgroundHelper = bottomBar.findViewById(R.id.background_helper)
|
||||
divider = bottomBar.findViewById(R.id.divider)
|
||||
|
||||
val adapter = ShareSelectionAdapter()
|
||||
@@ -75,7 +73,7 @@ class ChooseGroupStoryBottomSheet : FixedRoundedCornerBottomSheetDialogFragment(
|
||||
addSection(
|
||||
ContactSearchConfiguration.Section.Groups(
|
||||
includeHeader = false,
|
||||
returnAsGroupStories = true,
|
||||
shortSummary = true,
|
||||
sortOrder = ContactSearchSortOrder.RECENCY
|
||||
)
|
||||
)
|
||||
@@ -86,7 +84,7 @@ class ChooseGroupStoryBottomSheet : FixedRoundedCornerBottomSheetDialogFragment(
|
||||
|
||||
mediator.getSelectionState().observe(viewLifecycleOwner) { state ->
|
||||
adapter.submitList(
|
||||
state.filterIsInstance(ContactSearchKey.RecipientSearchKey.Story::class.java)
|
||||
state.filterIsInstance(ContactSearchKey.RecipientSearchKey.KnownRecipient::class.java)
|
||||
.map { it.recipientId }
|
||||
.mapIndexed { index, recipientId ->
|
||||
ShareSelectionMappingModel(
|
||||
@@ -118,9 +116,8 @@ class ChooseGroupStoryBottomSheet : FixedRoundedCornerBottomSheetDialogFragment(
|
||||
animatorSet?.cancel()
|
||||
animatorSet = AnimatorSet().apply {
|
||||
playTogether(
|
||||
ObjectAnimator.ofFloat(confirmButton, View.ALPHA, 1f),
|
||||
ObjectAnimator.ofFloat(confirmButton, View.TRANSLATION_Y, 0f),
|
||||
ObjectAnimator.ofFloat(selectedList, View.TRANSLATION_Y, 0f),
|
||||
ObjectAnimator.ofFloat(backgroundHelper, View.TRANSLATION_Y, 0f),
|
||||
ObjectAnimator.ofFloat(divider, View.TRANSLATION_Y, 0f)
|
||||
)
|
||||
start()
|
||||
@@ -128,14 +125,13 @@ class ChooseGroupStoryBottomSheet : FixedRoundedCornerBottomSheetDialogFragment(
|
||||
}
|
||||
|
||||
private fun animateOutBottomBar() {
|
||||
val translationY = DimensionUnit.DP.toPixels(48f)
|
||||
val translationY = DimensionUnit.SP.toPixels(64f)
|
||||
|
||||
animatorSet?.cancel()
|
||||
animatorSet = AnimatorSet().apply {
|
||||
playTogether(
|
||||
ObjectAnimator.ofFloat(confirmButton, View.ALPHA, 0f),
|
||||
ObjectAnimator.ofFloat(confirmButton, View.TRANSLATION_Y, translationY),
|
||||
ObjectAnimator.ofFloat(selectedList, View.TRANSLATION_Y, translationY),
|
||||
ObjectAnimator.ofFloat(backgroundHelper, View.TRANSLATION_Y, translationY),
|
||||
ObjectAnimator.ofFloat(divider, View.TRANSLATION_Y, translationY)
|
||||
)
|
||||
start()
|
||||
@@ -150,7 +146,7 @@ class ChooseGroupStoryBottomSheet : FixedRoundedCornerBottomSheetDialogFragment(
|
||||
RESULT_SET,
|
||||
ArrayList(
|
||||
mediator.getSelectedContacts()
|
||||
.filterIsInstance(ContactSearchKey.RecipientSearchKey.Story::class.java)
|
||||
.filterIsInstance(ContactSearchKey.RecipientSearchKey.KnownRecipient::class.java)
|
||||
.map { it.recipientId }
|
||||
)
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.thoughtcrime.securesms.components.settings.conversation.preferences.L
|
||||
import org.thoughtcrime.securesms.util.fragments.requireListener
|
||||
|
||||
class ChooseStoryTypeBottomSheet : DSLSettingsBottomSheetFragment(
|
||||
layoutId = R.layout.dsl_settings_bottom_sheet_no_handle
|
||||
layoutId = R.layout.dsl_settings_bottom_sheet
|
||||
) {
|
||||
override fun bindAdapter(adapter: DSLSettingsAdapter) {
|
||||
LargeIconClickPreference.register(adapter)
|
||||
@@ -24,7 +24,7 @@ class ChooseStoryTypeBottomSheet : DSLSettingsBottomSheetFragment(
|
||||
textPref(
|
||||
title = DSLSettingsText.from(
|
||||
stringId = R.string.ChooseStoryTypeBottomSheet__choose_your_story_type,
|
||||
DSLSettingsText.CenterModifier, DSLSettingsText.Body1BoldModifier, DSLSettingsText.BoldModifier
|
||||
DSLSettingsText.CenterModifier, DSLSettingsText.TitleMediumModifier
|
||||
)
|
||||
)
|
||||
|
||||
@@ -37,11 +37,11 @@ class ChooseStoryTypeBottomSheet : DSLSettingsBottomSheetFragment(
|
||||
stringId = R.string.ChooseStoryTypeBottomSheet__visible_only_to
|
||||
),
|
||||
icon = DSLSettingsIcon.from(
|
||||
R.drawable.ic_plus_24,
|
||||
R.color.signal_icon_tint_primary,
|
||||
R.drawable.circle_tintable,
|
||||
R.color.signal_button_secondary_ripple,
|
||||
DimensionUnit.DP.toPixels(8f).toInt()
|
||||
iconId = R.drawable.ic_plus_24,
|
||||
iconTintId = R.color.signal_colorOnSurface,
|
||||
backgroundId = R.drawable.circle_tintable,
|
||||
backgroundTint = R.color.signal_colorSurface5,
|
||||
insetPx = DimensionUnit.DP.toPixels(8f).toInt()
|
||||
),
|
||||
onClick = {
|
||||
dismissAllowingStateLoss()
|
||||
@@ -59,11 +59,11 @@ class ChooseStoryTypeBottomSheet : DSLSettingsBottomSheetFragment(
|
||||
stringId = R.string.ChooseStoryTypeBottomSheet__share_to_an_existing_group
|
||||
),
|
||||
icon = DSLSettingsIcon.from(
|
||||
R.drawable.ic_group_outline_24,
|
||||
R.color.signal_icon_tint_primary,
|
||||
R.drawable.circle_tintable,
|
||||
R.color.signal_button_secondary_ripple,
|
||||
DimensionUnit.DP.toPixels(8f).toInt()
|
||||
iconId = R.drawable.ic_group_outline_24,
|
||||
iconTintId = R.color.signal_colorOnSurface,
|
||||
backgroundId = R.drawable.circle_tintable,
|
||||
backgroundTint = R.color.signal_colorSurface5,
|
||||
insetPx = DimensionUnit.DP.toPixels(8f).toInt()
|
||||
),
|
||||
onClick = {
|
||||
dismissAllowingStateLoss()
|
||||
|
||||
Reference in New Issue
Block a user