From afe7c695affbbe40a9827a6fe1e40fe5d54b17c1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 14 Mar 2018 15:54:58 +0100 Subject: [PATCH] add a stop button to the reminder activity --- app/build.gradle | 2 +- .../clock/activities/MainActivity.kt | 4 ++-- .../clock/activities/ReminderActivity.kt | 17 ++++++++++++++--- .../clock/fragments/TimerFragment.kt | 1 - app/src/main/res/layout/activity_reminder.xml | 10 ++++++++++ 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4b6943fe..71c9c539 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,7 +41,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:3.15.15' + implementation 'com.simplemobiletools:commons:3.15.17' implementation 'com.facebook.stetho:stetho:1.5.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.shawnlin:number-picker:2.4.6' diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/clock/activities/MainActivity.kt index cea49884..2850334f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/activities/MainActivity.kt @@ -161,8 +161,8 @@ class MainActivity : SimpleActivity() { val faqItems = arrayListOf( FAQItem(R.string.faq_1_title, R.string.faq_1_text), FAQItem(R.string.faq_1_title_commons, R.string.faq_1_text_commons), - FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons), - FAQItem(R.string.faq_4_title_commons, R.string.faq_4_text_commons) + FAQItem(R.string.faq_4_title_commons, R.string.faq_4_text_commons), + FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons) ) startAboutActivity(R.string.app_name, LICENSE_STETHO or LICENSE_NUMBER_PICKER, BuildConfig.VERSION_NAME, faqItems) 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 6802dbfb..cae23471 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt @@ -1,10 +1,13 @@ package com.simplemobiletools.clock.activities import android.os.Bundle +import android.os.Handler import com.simplemobiletools.clock.R import com.simplemobiletools.clock.extensions.hideTimerNotification import com.simplemobiletools.clock.extensions.showOverLockscreen import com.simplemobiletools.clock.extensions.showTimerNotification +import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor +import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor import com.simplemobiletools.commons.extensions.updateTextColors import kotlinx.android.synthetic.main.activity_reminder.* @@ -15,13 +18,21 @@ class ReminderActivity : SimpleActivity() { setContentView(R.layout.activity_reminder) showOverLockscreen() updateTextColors(reminder_holder) + reminder_title.text = getString(R.string.timer) reminder_text.text = getString(R.string.time_expired) - showTimerNotification() + reminder_stop.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, getAdjustedPrimaryColor()) + reminder_stop.setOnClickListener { + finish() + } + + Handler().postDelayed({ + showTimerNotification() + }, 1000L) } - override fun onDestroy() { - super.onDestroy() + override fun onStop() { + super.onStop() hideTimerNotification() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/TimerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/TimerFragment.kt index db81fa06..5fda5a98 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/TimerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/TimerFragment.kt @@ -19,7 +19,6 @@ import com.simplemobiletools.clock.extensions.* import com.simplemobiletools.commons.extensions.* import kotlinx.android.synthetic.main.fragment_timer.view.* - class TimerFragment : Fragment() { private val UPDATE_INTERVAL = 1000L diff --git a/app/src/main/res/layout/activity_reminder.xml b/app/src/main/res/layout/activity_reminder.xml index 97b8c198..dded5957 100644 --- a/app/src/main/res/layout/activity_reminder.xml +++ b/app/src/main/res/layout/activity_reminder.xml @@ -25,4 +25,14 @@ android:textSize="@dimen/big_text_size" tools:text="14:00"/> + +