allow dragging the center item at the ReminderActivity
This commit is contained in:
parent
72b31819d8
commit
9352fa0221
|
@ -6,6 +6,7 @@ import android.media.MediaPlayer
|
|||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.view.MotionEvent
|
||||
import android.view.animation.AnimationUtils
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.extensions.*
|
||||
|
@ -16,7 +17,6 @@ import com.simplemobiletools.commons.extensions.*
|
|||
import com.simplemobiletools.commons.helpers.MINUTE_SECONDS
|
||||
import kotlinx.android.synthetic.main.activity_reminder.*
|
||||
|
||||
|
||||
class ReminderActivity : SimpleActivity() {
|
||||
private val INCREASE_VOLUME_DELAY = 3000L
|
||||
|
||||
|
@ -26,6 +26,7 @@ class ReminderActivity : SimpleActivity() {
|
|||
private var alarm: Alarm? = null
|
||||
private var mediaPlayer: MediaPlayer? = null
|
||||
private var lastVolumeValue = 0.1f
|
||||
private var dragDownX = 0f
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -64,8 +65,26 @@ class ReminderActivity : SimpleActivity() {
|
|||
private fun setupButtons() {
|
||||
reminder_draggable_background.startAnimation(AnimationUtils.loadAnimation(this, R.anim.pulsing_animation))
|
||||
reminder_draggable_background.applyColorFilter(getAdjustedPrimaryColor())
|
||||
var minDragX = 0f
|
||||
var maxDragX = 0f
|
||||
|
||||
reminder_stop.setOnClickListener {
|
||||
reminder_dismiss.onGlobalLayout {
|
||||
minDragX = reminder_snooze.left.toFloat()
|
||||
maxDragX = reminder_dismiss.left.toFloat()
|
||||
}
|
||||
|
||||
reminder_draggable.setOnTouchListener { v, event ->
|
||||
when (event.action) {
|
||||
MotionEvent.ACTION_DOWN -> dragDownX = event.x
|
||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> dragDownX = 0f
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
reminder_draggable.x = Math.min(maxDragX, Math.max(minDragX, event.rawX - dragDownX))
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
reminder_dismiss.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 895 B |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
|
@ -32,7 +32,6 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/reminder_snooze"
|
||||
style="@style/MyBorderlessBackgroundStyle"
|
||||
android:layout_width="@dimen/stopwatch_button_small_size"
|
||||
android:layout_height="@dimen/stopwatch_button_small_size"
|
||||
android:padding="@dimen/normal_margin"
|
||||
|
@ -52,7 +51,7 @@
|
|||
android:padding="@dimen/normal_margin"
|
||||
android:src="@drawable/pulsing_background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/reminder_stop"
|
||||
app:layout_constraintEnd_toStartOf="@+id/reminder_dismiss"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/reminder_snooze"
|
||||
app:layout_constraintTop_toBottomOf="@+id/reminder_text"/>
|
||||
|
@ -61,17 +60,17 @@
|
|||
android:id="@+id/reminder_draggable"
|
||||
android:layout_width="@dimen/stopwatch_button_small_size"
|
||||
android:layout_height="@dimen/stopwatch_button_small_size"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:padding="@dimen/normal_margin"
|
||||
android:src="@drawable/ic_alarm"
|
||||
android:src="@drawable/ic_alarm_big"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/reminder_stop"
|
||||
app:layout_constraintEnd_toStartOf="@+id/reminder_dismiss"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/reminder_snooze"
|
||||
app:layout_constraintTop_toBottomOf="@+id/reminder_text"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/reminder_stop"
|
||||
android:id="@+id/reminder_dismiss"
|
||||
android:layout_width="@dimen/stopwatch_button_small_size"
|
||||
android:layout_height="@dimen/stopwatch_button_small_size"
|
||||
android:padding="@dimen/normal_margin"
|
||||
|
|
Loading…
Reference in New Issue