Attachments: fix themes for selection view

This commit is contained in:
ganfra 2019-10-16 10:04:33 +02:00
parent a1a71e2f1d
commit 05a069be04
6 changed files with 34 additions and 17 deletions

View File

@ -124,8 +124,9 @@ class AttachmentTypeSelectorView(context: Context,
}
override fun dismiss() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
animateWindowOutCircular(anchor, contentView)
val capturedAnchor = anchor
if (capturedAnchor != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
animateWindowOutCircular(capturedAnchor, contentView)
} else {
animateWindowOutTranslate(contentView)
}
@ -142,13 +143,13 @@ class AttachmentTypeSelectorView(context: Context,
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private fun animateWindowInCircular(anchor: View?, contentView: View) {
private fun animateWindowInCircular(anchor: View, contentView: View) {
val coordinates = getClickCoordinates(anchor, contentView)
val animator = ViewAnimationUtils.createCircularReveal(contentView,
coordinates.first,
coordinates.second,
0f,
max(contentView.width, contentView.height).toFloat())
coordinates.first,
coordinates.second,
0f,
max(contentView.width, contentView.height).toFloat())
animator.duration = ANIMATION_DURATION.toLong()
animator.start()
}
@ -160,13 +161,13 @@ class AttachmentTypeSelectorView(context: Context,
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private fun animateWindowOutCircular(anchor: View?, contentView: View) {
private fun animateWindowOutCircular(anchor: View, contentView: View) {
val coordinates = getClickCoordinates(anchor, contentView)
val animator = ViewAnimationUtils.createCircularReveal(getContentView(),
coordinates.first,
coordinates.second,
max(getContentView().width, getContentView().height).toFloat(),
0f)
coordinates.first,
coordinates.second,
max(getContentView().width, getContentView().height).toFloat(),
0f)
animator.duration = ANIMATION_DURATION.toLong()
animator.addListener(object : AnimatorListenerAdapter() {
@ -193,12 +194,12 @@ class AttachmentTypeSelectorView(context: Context,
getContentView().startAnimation(animation)
}
private fun getClickCoordinates(anchor: View?, contentView: View): Pair<Int, Int> {
private fun getClickCoordinates(anchor: View, contentView: View): Pair<Int, Int> {
val anchorCoordinates = IntArray(2)
anchor?.getLocationOnScreen(anchorCoordinates)
anchor.getLocationOnScreen(anchorCoordinates)
val contentCoordinates = IntArray(2)
contentView.getLocationOnScreen(contentCoordinates)
val x = anchorCoordinates[0] - contentCoordinates[0]
val x = anchorCoordinates[0] - contentCoordinates[0] + anchor.width / 2
val y = anchorCoordinates[1] - contentCoordinates[1]
return Pair(x, y)
}

View File

@ -2,7 +2,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="?riotx_header_panel_border_mobile" />
<solid android:color="?riotx_attachment_selector_border" />
<corners android:radius="16dp" />
</shape>
</item>
@ -13,7 +13,7 @@
android:right="1dp"
android:top="1dp">
<shape android:shape="rectangle">
<solid android:color="?riotx_background" />
<solid android:color="?riotx_attachment_selector_background" />
<corners android:radius="16dp" />
</shape>

View File

@ -147,6 +147,16 @@
<color name="riotx_touch_guard_bg_dark">#BF000000</color>
<color name="riotx_touch_guard_bg_black">#BF000000</color>
<attr name="riotx_attachment_selector_background" format="color" />
<color name="riotx_attachment_selector_background_light">#FFFFFFFF</color>
<color name="riotx_attachment_selector_background_dark">#FF22262E</color>
<color name="riotx_attachment_selector_background_black">#FF090A0C</color>
<attr name="riotx_attachment_selector_border" format="color" />
<color name="riotx_attachment_selector_border_light">#FFE9EDF1</color>
<color name="riotx_attachment_selector_border_dark">#FF22262E</color>
<color name="riotx_attachment_selector_border_black">#FF090A0C</color>
<!-- (color from RiotWeb) -->
<attr name="riotx_keys_backup_banner_accent_color" format="color" />
<color name="riotx_keys_backup_banner_accent_color_light">#FFF8E3</color>

View File

@ -30,6 +30,8 @@
<item name="riotx_fab_label_bg">@color/riotx_fab_label_bg_black</item>
<item name="riotx_fab_label_color">@color/riotx_fab_label_color_black</item>
<item name="riotx_touch_guard_bg">@color/riotx_touch_guard_bg_black</item>
<item name="riotx_attachment_selector_background">@color/riotx_attachment_selector_background_black</item>
<item name="riotx_attachment_selector_border">@color/riotx_attachment_selector_border_black</item>
<!-- Drawables -->
<item name="riotx_highlighted_message_background">@drawable/highlighted_message_background_black</item>

View File

@ -28,6 +28,8 @@
<item name="riotx_fab_label_bg">@color/riotx_fab_label_bg_dark</item>
<item name="riotx_fab_label_color">@color/riotx_fab_label_color_dark</item>
<item name="riotx_touch_guard_bg">@color/riotx_touch_guard_bg_dark</item>
<item name="riotx_attachment_selector_background">@color/riotx_attachment_selector_background_dark</item>
<item name="riotx_attachment_selector_border">@color/riotx_attachment_selector_border_dark</item>
<item name="riotx_keys_backup_banner_accent_color">@color/riotx_keys_backup_banner_accent_color_dark</item>

View File

@ -29,6 +29,8 @@
<item name="riotx_fab_label_color">@color/riotx_fab_label_color_light</item>
<item name="riotx_touch_guard_bg">@color/riotx_touch_guard_bg_light</item>
<item name="riotx_keys_backup_banner_accent_color">@color/riotx_keys_backup_banner_accent_color_light</item>
<item name="riotx_attachment_selector_background">@color/riotx_attachment_selector_background_light</item>
<item name="riotx_attachment_selector_border">@color/riotx_attachment_selector_border_light</item>
<!-- Drawables -->
<item name="riotx_highlighted_message_background">@drawable/highlighted_message_background_light</item>