diff --git a/app/build.gradle b/app/build.gradle index 99fba768..a1039598 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -64,7 +64,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:9f0c466018' + implementation 'com.github.SimpleMobileTools:Simple-Commons:dfe84c0ee2' implementation 'com.facebook.stetho:stetho:1.5.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.shawnlin:number-picker:2.4.6' diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/adapters/TimerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/clock/adapters/TimerAdapter.kt index c450d021..e2c0fcc6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/adapters/TimerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/adapters/TimerAdapter.kt @@ -13,6 +13,7 @@ import com.simplemobiletools.clock.models.Timer import com.simplemobiletools.clock.models.TimerEvent import com.simplemobiletools.clock.models.TimerState import com.simplemobiletools.commons.adapters.MyRecyclerViewListAdapter +import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.views.MyRecyclerView import kotlinx.android.synthetic.main.item_timer.view.* @@ -120,8 +121,8 @@ class TimerAdapter( timer_play_pause.applyColorFilter(textColor) timer_play_pause.setOnClickListener { - (activity as SimpleActivity).handleNotificationPermission { - if (it) { + (activity as SimpleActivity).handleNotificationPermission { granted -> + if (granted) { when (val state = timer.state) { is TimerState.Idle -> EventBus.getDefault().post(TimerEvent.Start(timer.id!!, timer.seconds.secondsToMillis)) is TimerState.Paused -> EventBus.getDefault().post(TimerEvent.Start(timer.id!!, state.tick)) @@ -129,7 +130,7 @@ class TimerAdapter( is TimerState.Finished -> EventBus.getDefault().post(TimerEvent.Start(timer.id!!, timer.seconds.secondsToMillis)) } } else { - activity.toast(R.string.no_post_notifications_permissions) + PermissionRequiredDialog(activity, R.string.allow_notifications_reminders) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/dialogs/EditAlarmDialog.kt b/app/src/main/kotlin/com/simplemobiletools/clock/dialogs/EditAlarmDialog.kt index 7849f448..7a5d1a18 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/dialogs/EditAlarmDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/dialogs/EditAlarmDialog.kt @@ -18,6 +18,7 @@ import com.simplemobiletools.clock.helpers.TOMORROW_BIT import com.simplemobiletools.clock.helpers.getCurrentDayMinutes import com.simplemobiletools.clock.models.Alarm import com.simplemobiletools.commons.dialogs.ConfirmationDialog +import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.models.AlarmSound @@ -153,8 +154,8 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba alarm.isEnabled = true var alarmId = alarm.id - activity.handleNotificationPermission { - if (it) { + activity.handleNotificationPermission { granted -> + if (granted) { if (alarm.id == 0) { alarmId = activity.dbHelper.insertAlarm(alarm) if (alarmId == -1) { @@ -170,7 +171,7 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba callback(alarmId) alertDialog.dismiss() } else { - activity.toast(R.string.no_post_notifications_permissions) + PermissionRequiredDialog(activity, R.string.allow_notifications_reminders) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/AlarmFragment.kt b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/AlarmFragment.kt index b465635e..2b9f3473 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/AlarmFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/AlarmFragment.kt @@ -15,6 +15,7 @@ import com.simplemobiletools.clock.extensions.* import com.simplemobiletools.clock.helpers.* import com.simplemobiletools.clock.interfaces.ToggleAlarmInterface import com.simplemobiletools.clock.models.Alarm +import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog import com.simplemobiletools.commons.extensions.getProperTextColor import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.updateTextColors @@ -122,8 +123,8 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface { } override fun alarmToggled(id: Int, isEnabled: Boolean) { - (activity as SimpleActivity).handleNotificationPermission { - if (it) { + (activity as SimpleActivity).handleNotificationPermission { granted -> + if (granted) { if (requireContext().dbHelper.updateAlarmEnabledState(id, isEnabled)) { val alarm = alarms.firstOrNull { it.id == id } ?: return@handleNotificationPermission alarm.isEnabled = isEnabled @@ -133,7 +134,7 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface { } requireContext().updateWidgets() } else { - activity?.toast(R.string.no_post_notifications_permissions) + PermissionRequiredDialog(activity as SimpleActivity, R.string.allow_notifications_reminders) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt index 8b16251f..57b52f68 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt @@ -18,6 +18,7 @@ import com.simplemobiletools.clock.helpers.SORT_BY_LAP_TIME import com.simplemobiletools.clock.helpers.SORT_BY_TOTAL_TIME import com.simplemobiletools.clock.helpers.Stopwatch import com.simplemobiletools.clock.models.Lap +import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.SORT_DESCENDING import kotlinx.android.synthetic.main.fragment_stopwatch.view.* @@ -124,11 +125,11 @@ class StopwatchFragment : Fragment() { } private fun togglePlayPause() { - (activity as SimpleActivity).handleNotificationPermission { - if (it) { + (activity as SimpleActivity).handleNotificationPermission { granted -> + if (granted) { Stopwatch.toggle(true) } else { - activity?.toast(R.string.no_post_notifications_permissions) + PermissionRequiredDialog(activity as SimpleActivity, R.string.allow_notifications_reminders) } } }