From 9352fa0221e7011bfd05b7669d1dbda5fc9073c2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 8 Jul 2018 15:03:20 +0200 Subject: [PATCH] allow dragging the center item at the ReminderActivity --- .../clock/activities/ReminderActivity.kt | 23 ++++++++++++++++-- .../main/res/drawable-hdpi/ic_alarm_big.png | Bin 0 -> 895 bytes .../main/res/drawable-xhdpi/ic_alarm_big.png | Bin 0 -> 1112 bytes .../main/res/drawable-xxhdpi/ic_alarm_big.png | Bin 0 -> 1616 bytes .../res/drawable-xxxhdpi/ic_alarm_big.png | Bin 0 -> 2238 bytes app/src/main/res/layout/activity_reminder.xml | 11 ++++----- 6 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_alarm_big.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_alarm_big.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_alarm_big.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_alarm_big.png diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt b/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt index deaf3fda..f6dab6b9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt @@ -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() } diff --git a/app/src/main/res/drawable-hdpi/ic_alarm_big.png b/app/src/main/res/drawable-hdpi/ic_alarm_big.png new file mode 100644 index 0000000000000000000000000000000000000000..21ed21a47502e90d5e73c80fb3374e4a326c7c28 GIT binary patch literal 895 zcmV-_1AzRAP)>E}Wl;8_vzFt6Erxn;A~rPZUVxa6JHHy<-rYGLbzs6D7o>rg1&Z z`Bf$`% zT!meaX_QoFbJ|>mosL;aK5T&5Z?3}j!)zcQHpA?c8n(K;*a@?_d{`TERBG5bPWDY` zI1012eCU9=L>?^1FwD=aAtesT9puM!oJZtEA$L-RQ^ma$sTLl_nXV*!gEK^lScC5| z!#PxOVkpkHO2W;UHI;~*_{@vXW0Tc2F*hj*TVrliDq8Ru)i^`Rt5fN1((ZQ*&J@}y z02}Z(00(O}+A#%ZEICTX&6pPyggnmV4LRZk%*{$eE6OmtDvCbd{3^zupDKWF>I#*Y|W^Q6FI{XRAZ`nm=-A&c$oO{2Pqp4 zpq$7=&ZWq+fIOFpM9SD-*x zXv|eiC&V`C3&Ck+fUM&+0*tQzw6*lGFVy5 z=1?^?Y)g}M0ZnXc@o*wJ23Qv`fE*`U4AgNue>>X(aUp-ZojU6p=H^*SGHhu9*q$6E z&oZ}#V<|pEU?j_!Cst()AfK_6g<(T}A!!EtnkNn+OVTfFX#UuXDI|?%i@+T^mZT}{ z<-ZK`Bz?;Ysl~ntSJREh`G6LtGnp3NIO!92c4^>gh$=^UP~S%)^27 zV>s0erw<1*j}X$n^gYX2Wo*XqN(-6I_<>MAuvx_gKAg?05?&%{U}+(95Yy<2 zX&h8u;6q7z*(zZXh9b|Geqk<0q`=qQ%V8{LMJ&Og+{;%K5V_3$!h*bt3}q3kjFlP7 z-|j3gijT>0H%1XSRHd1t#(ZId@Z7eHWb!7(z=;x zfis;PNJjU!Um#&q zGRRQs%?Bp~a*0`JAmL&_PVy`4TaZCCLFtI;~^HRe(Z8_*yZYsy%>hT7|x|W)$GY6FIWG4 zcDi|>nX8$Cz<21!GfodEKT_B0$L5LUc?6lrGFHaN9xF)LFBi+uVxXQ&1A~wj^T8I;##r*NSTeCr&n+;FT+U*$O1d@J;(y%(t!qGjXr6-kJdV#2;A88*rHa+*@L(=-i z7;!#8XKh^1a#b#m>u9I52P_V*L!`i0+?{BgFUg_Y$Cnfkxx(V%&{(5|XxNg0g!+L^ zEj}7Ji{beCjWemYxPC}?9xWrum0000 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_alarm_big.png b/app/src/main/res/drawable-xxhdpi/ic_alarm_big.png new file mode 100644 index 0000000000000000000000000000000000000000..602a74063ad8b0a5c4244d0fa9469f131025617f GIT binary patch literal 1616 zcmV-W2Cw;vP) zDEL337;mtVctnEJCD+)L_CQM#;tlTuZ%Hn(2crOh_rw!!2LKvUR&s-rn9tv?77sX; zwft!aJBWYW!fO6$B}a=f_Gc0QG>gN z2=<2fz_#=y%v=r-BOJ(l!Zf6`*y0eT5oQECd&;?5f73+5MJyvs8#eM(B{kbb!jq&3 z^ASl2!NFY3(|k=!dNYbytYrl=8AUIe@)b{WHT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<`?r5(7Mi?iO*45!9eNL?Xt4=xP}(?s2TovG547 zA+6{RmoQMsk3NkBBEl%@(0xN;c&$XdRI`jkfTfv>m$85D<|ZrY@kDT+MloN;4$E=nBx}Z6n9a`c(WJBhldw{N3iLO<+H6!Qagi zB?@^ZvPP5B12mcpAHDd2Y`n!Jiw7;=4A81HDvaPqvhxMoP$FGG3EKx~b{jSN^D)_~ z;Q_V{)Gm2j?x!|TyX5H6gO|xg15dM0mJPQDvlmYVXt*6O6megmmhJa+XxZM4ZVY89 z#{R2i``v+Bw%C4%DAP|DC6ywQO5tb5{X12kw_#Gi9{mtS1=||tv>qR>Hq)$ M07*qoM6N<$g1a_53IG5A literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/activity_reminder.xml b/app/src/main/res/layout/activity_reminder.xml index 697aff56..95f1eb7a 100644 --- a/app/src/main/res/layout/activity_reminder.xml +++ b/app/src/main/res/layout/activity_reminder.xml @@ -32,7 +32,6 @@ @@ -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"/>