录音模块UI调整
This commit is contained in:
parent
db2f338acd
commit
75ab00be93
|
|
@ -1,6 +1,11 @@
|
||||||
package com.remax.visualnovel.ui.chat.ui
|
package com.remax.visualnovel.ui.chat.ui
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.graphics.Rect
|
||||||
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
|
import androidx.annotation.VisibleForTesting
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.remax.visualnovel.R
|
import com.remax.visualnovel.R
|
||||||
import com.remax.visualnovel.databinding.DialogHoldToTalkBinding
|
import com.remax.visualnovel.databinding.DialogHoldToTalkBinding
|
||||||
import com.remax.visualnovel.widget.dialoglib.LBindingDialog
|
import com.remax.visualnovel.widget.dialoglib.LBindingDialog
|
||||||
|
|
@ -16,10 +21,48 @@ class HoldToTalkDialog(context: Context) :
|
||||||
setBottom()
|
setBottom()
|
||||||
setBgColorToken(R.string.color_transparent)
|
setBgColorToken(R.string.color_transparent)
|
||||||
setMaskValue(0f)
|
setMaskValue(0f)
|
||||||
|
initRootTouchEvent()
|
||||||
show()
|
show()
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun initRootTouchEvent() {
|
||||||
|
with(binding.root) {
|
||||||
|
fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
|
val x = event.x.toInt()
|
||||||
|
val y = event.y.toInt()
|
||||||
|
when (event.actionMasked) {
|
||||||
|
MotionEvent.ACTION_MOVE -> {
|
||||||
|
updateStateUI(event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isInValidArea(event: MotionEvent) : Boolean {
|
||||||
|
val rect = Rect()
|
||||||
|
binding.viewRelease.getHitRect(rect)
|
||||||
|
return rect.contains(event.rawX.toInt(), event.rawY.toInt())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateStateUI(event: MotionEvent) {
|
||||||
|
with (binding) {
|
||||||
|
when (isInValidArea(event)) {
|
||||||
|
true -> {
|
||||||
|
viewRelease.setBackgroundResource(R.mipmap.bg_recording_normal)
|
||||||
|
cancelHintRoot.isVisible = true
|
||||||
|
}
|
||||||
|
|
||||||
|
false -> {
|
||||||
|
viewRelease.setBackgroundResource(R.mipmap.bg_recording_cancel)
|
||||||
|
cancelHintRoot.isVisible = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,36 +7,67 @@
|
||||||
>
|
>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
android:id="@+id/top_bg"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:background="@drawable/shape_dialog_hold_to_talk"
|
android:background="@drawable/shape_dialog_hold_to_talk"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/viewRelease"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
android:id="@+id/viewRelease"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="180dp"
|
||||||
android:background="@color/black"
|
android:layout_marginStart="-2dp"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/viewRelease"
|
android:layout_marginEnd="-2dp"
|
||||||
app:layout_constraintTop_toTopOf="@+id/viewRelease" />
|
android:background="@mipmap/bg_recording_normal"
|
||||||
|
android:layout_marginTop="200dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
<com.remax.visualnovel.widget.ui.buttons.ButtonView
|
<LinearLayout
|
||||||
android:id="@+id/button"
|
android:id="@+id/cancel_hint_root"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="48dp"
|
android:orientation="horizontal"
|
||||||
android:layout_marginTop="80dp"
|
android:textSize="12sp"
|
||||||
app:buttonName="DefaultButton_Primary"
|
android:layout_marginTop="160dp"
|
||||||
app:buttonSizeType="large"
|
android:gravity="center_vertical"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
>
|
||||||
|
<com.remax.visualnovel.widget.uitoken.view.UITokenImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@mipmap/icon_recording_up_hint"
|
||||||
|
android:layout_marginRight="@dimen/dp_5"
|
||||||
|
android:layout_marginTop="@dimen/dp_2"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.remax.visualnovel.widget.uitoken.view.UITokenTextView
|
||||||
|
android:id="@+id/ivRelease"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/swipe_up_to_cancel"
|
||||||
|
app:onlyIconFont="true"
|
||||||
|
app:textColorToken="@string/color_txt_secondary_normal"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<com.airbnb.lottie.LottieAnimationView
|
<com.airbnb.lottie.LottieAnimationView
|
||||||
android:layout_width="140dp"
|
android:id="@+id/recording_anim_view"
|
||||||
|
android:layout_width="100dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/button"
|
android:layout_marginBottom="140dp"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/button"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="@+id/button"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@+id/button"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:lottie_autoPlay="true"
|
app:lottie_autoPlay="true"
|
||||||
app:lottie_loop="true"
|
app:lottie_loop="true"
|
||||||
app:lottie_rawRes="@raw/voice_recording" />
|
app:lottie_rawRes="@raw/voice_recording" />
|
||||||
|
|
@ -45,41 +76,14 @@
|
||||||
android:id="@+id/tvRelease"
|
android:id="@+id/tvRelease"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="@dimen/dp_10"
|
||||||
android:text="@string/release_to_send"
|
android:text="@string/release_to_send"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/button"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:textColorToken="@string/color_txt_secondary_normal"
|
app:textColorToken="@string/color_txt_secondary_normal"
|
||||||
|
android:layout_marginBottom="@dimen/dp_110"
|
||||||
app:textToken="@string/txt_label_m" />
|
app:textToken="@string/txt_label_m" />
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/viewRelease"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="252dp"
|
|
||||||
android:layout_marginStart="-18dp"
|
|
||||||
android:layout_marginEnd="-18dp"
|
|
||||||
android:layout_marginBottom="-140dp"
|
|
||||||
android:background="@drawable/shape_oval_talk"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
<com.remax.visualnovel.widget.uitoken.view.UITokenTextView
|
|
||||||
android:id="@+id/ivRelease"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="60dp"
|
|
||||||
android:layout_marginBottom="48dp"
|
|
||||||
android:text="@string/icon_chat_voice"
|
|
||||||
android:textSize="32sp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tvRelease"
|
|
||||||
app:onlyIconFont="true"
|
|
||||||
app:textColorToken="@string/color_txt_secondary_normal"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:background="@drawable/shape_dialog_hold_to_talk"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/viewRelease"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:background="@color/black"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/viewRelease"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/viewRelease" />
|
||||||
|
|
||||||
|
<com.remax.visualnovel.widget.ui.buttons.ButtonView
|
||||||
|
android:id="@+id/button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="48dp"
|
||||||
|
android:layout_marginTop="180dp"
|
||||||
|
app:buttonName="DefaultButton_Primary"
|
||||||
|
app:buttonSizeType="large"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.airbnb.lottie.LottieAnimationView
|
||||||
|
android:layout_width="140dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/button"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/button"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/button"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/button"
|
||||||
|
app:lottie_autoPlay="true"
|
||||||
|
app:lottie_loop="true"
|
||||||
|
app:lottie_rawRes="@raw/voice_recording" />
|
||||||
|
|
||||||
|
<com.remax.visualnovel.widget.uitoken.view.UITokenTextView
|
||||||
|
android:id="@+id/tvRelease"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="@string/release_to_send"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/button"
|
||||||
|
app:textColorToken="@string/color_txt_secondary_normal"
|
||||||
|
app:textToken="@string/txt_label_m" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/viewRelease"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="252dp"
|
||||||
|
android:layout_marginStart="-18dp"
|
||||||
|
android:layout_marginEnd="-18dp"
|
||||||
|
android:layout_marginBottom="-80dp"
|
||||||
|
android:background="@mipmap/bg_recording_cancel"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
|
<com.remax.visualnovel.widget.uitoken.view.UITokenTextView
|
||||||
|
android:id="@+id/ivRelease"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="60dp"
|
||||||
|
android:layout_marginBottom="48dp"
|
||||||
|
android:text="@string/icon_chat_voice"
|
||||||
|
android:textSize="32sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/tvRelease"
|
||||||
|
app:onlyIconFont="true"
|
||||||
|
app:textColorToken="@string/color_txt_secondary_normal"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 100 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 734 B |
File diff suppressed because one or more lines are too long
|
|
@ -465,6 +465,7 @@
|
||||||
<string name="from">from</string>
|
<string name="from">from</string>
|
||||||
<string name="hold_to_talk">Hold to Talk</string>
|
<string name="hold_to_talk">Hold to Talk</string>
|
||||||
<string name="type_msg_hint">Type a message</string>
|
<string name="type_msg_hint">Type a message</string>
|
||||||
|
<string name="swipe_up_to_cancel">Swipe Up to Cancel</string>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue