Fix clipping

This commit is contained in:
gmbnt 2020-03-16 10:08:08 +11:00
parent 96ba2d56d9
commit 83feb26225
2 changed files with 10 additions and 7 deletions

View File

@ -61,10 +61,9 @@
<org.thoughtcrime.securesms.loki.redesign.views.NewConversationButtonSetView <org.thoughtcrime.securesms.loki.redesign.views.NewConversationButtonSetView
android:id="@+id/newConversationButtonSet" android:id="@+id/newConversationButtonSet"
android:layout_width="252dp" android:layout_width="252dp"
android:layout_height="156dp" android:layout_height="212dp"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true" />
android:layout_marginBottom="@dimen/new_conversation_button_bottom_offset" />
</RelativeLayout> </RelativeLayout>

View File

@ -31,14 +31,15 @@ class NewConversationButtonSetView : RelativeLayout {
// region Convenience // region Convenience
private val sessionButtonExpandedPosition: PointF get() { return PointF(width.toFloat() / 2 - sessionButton.expandedSize / 2, 0.0f) } private val sessionButtonExpandedPosition: PointF get() { return PointF(width.toFloat() / 2 - sessionButton.expandedSize / 2, 0.0f) }
private val closedGroupButtonExpandedPosition: PointF get() { return PointF(width.toFloat() - closedGroupButton.expandedSize, height.toFloat() - closedGroupButton.expandedSize) } private val closedGroupButtonExpandedPosition: PointF get() { return PointF(width.toFloat() - closedGroupButton.expandedSize, height.toFloat() - bottomMargin - closedGroupButton.expandedSize) }
private val openGroupButtonExpandedPosition: PointF get() { return PointF(0.0f, height.toFloat() - openGroupButton.expandedSize) } private val openGroupButtonExpandedPosition: PointF get() { return PointF(0.0f, height.toFloat() - bottomMargin - openGroupButton.expandedSize) }
private val buttonRestPosition: PointF get() { return PointF(width.toFloat() / 2 - mainButton.expandedSize / 2, height.toFloat() - mainButton.expandedSize) } private val buttonRestPosition: PointF get() { return PointF(width.toFloat() / 2 - mainButton.expandedSize / 2, height.toFloat() - bottomMargin - mainButton.expandedSize) }
// endregion // endregion
// region Settings // region Settings
private val maxDragDistance by lazy { toPx(56, resources).toFloat() } private val maxDragDistance by lazy { toPx(56, resources).toFloat() }
private val dragMargin by lazy { toPx(16, resources).toFloat() } private val dragMargin by lazy { toPx(16, resources).toFloat() }
private val bottomMargin by lazy { resources.getDimension(R.dimen.new_conversation_button_bottom_offset) }
// endregion // endregion
// region Components // region Components
@ -172,30 +173,33 @@ class NewConversationButtonSetView : RelativeLayout {
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { setUpViewHierarchy() } constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { setUpViewHierarchy() }
private fun setUpViewHierarchy() { private fun setUpViewHierarchy() {
disableClipping()
// Set up session button // Set up session button
addView(sessionButton) addView(sessionButton)
sessionButton.alpha = 0.0f sessionButton.alpha = 0.0f
val sessionButtonLayoutParams = sessionButton.layoutParams as LayoutParams val sessionButtonLayoutParams = sessionButton.layoutParams as LayoutParams
sessionButtonLayoutParams.addRule(CENTER_IN_PARENT, TRUE) sessionButtonLayoutParams.addRule(CENTER_IN_PARENT, TRUE)
sessionButtonLayoutParams.addRule(ALIGN_PARENT_BOTTOM, TRUE) sessionButtonLayoutParams.addRule(ALIGN_PARENT_BOTTOM, TRUE)
sessionButtonLayoutParams.bottomMargin = bottomMargin.toInt()
// Set up closed group button // Set up closed group button
addView(closedGroupButton) addView(closedGroupButton)
closedGroupButton.alpha = 0.0f closedGroupButton.alpha = 0.0f
val closedGroupButtonLayoutParams = closedGroupButton.layoutParams as LayoutParams val closedGroupButtonLayoutParams = closedGroupButton.layoutParams as LayoutParams
closedGroupButtonLayoutParams.addRule(CENTER_IN_PARENT, TRUE) closedGroupButtonLayoutParams.addRule(CENTER_IN_PARENT, TRUE)
closedGroupButtonLayoutParams.addRule(ALIGN_PARENT_BOTTOM, TRUE) closedGroupButtonLayoutParams.addRule(ALIGN_PARENT_BOTTOM, TRUE)
closedGroupButtonLayoutParams.bottomMargin = bottomMargin.toInt()
// Set up open group button // Set up open group button
addView(openGroupButton) addView(openGroupButton)
openGroupButton.alpha = 0.0f openGroupButton.alpha = 0.0f
val openGroupButtonLayoutParams = openGroupButton.layoutParams as LayoutParams val openGroupButtonLayoutParams = openGroupButton.layoutParams as LayoutParams
openGroupButtonLayoutParams.addRule(CENTER_IN_PARENT, TRUE) openGroupButtonLayoutParams.addRule(CENTER_IN_PARENT, TRUE)
openGroupButtonLayoutParams.addRule(ALIGN_PARENT_BOTTOM, TRUE) openGroupButtonLayoutParams.addRule(ALIGN_PARENT_BOTTOM, TRUE)
openGroupButtonLayoutParams.bottomMargin = bottomMargin.toInt()
// Set up main button // Set up main button
addView(mainButton) addView(mainButton)
val mainButtonLayoutParams = mainButton.layoutParams as LayoutParams val mainButtonLayoutParams = mainButton.layoutParams as LayoutParams
mainButtonLayoutParams.addRule(CENTER_IN_PARENT, TRUE) mainButtonLayoutParams.addRule(CENTER_IN_PARENT, TRUE)
mainButtonLayoutParams.addRule(ALIGN_PARENT_BOTTOM, TRUE) mainButtonLayoutParams.addRule(ALIGN_PARENT_BOTTOM, TRUE)
mainButtonLayoutParams.bottomMargin = bottomMargin.toInt()
} }
// endregion // endregion