mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-06-05 22:19:17 +02:00
fixing some warnings
This commit is contained in:
parent
5bb05c04c0
commit
7eba711e35
@ -17,7 +17,6 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
|||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.isVisible
|
import com.simplemobiletools.commons.extensions.isVisible
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.commons.helpers.mydebug
|
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import kotlinx.android.synthetic.main.item_alarm.view.*
|
import kotlinx.android.synthetic.main.item_alarm.view.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -266,7 +266,6 @@ fun Context.getTimerNotification(pendingIntent: PendingIntent, addDeleteIntent:
|
|||||||
try {
|
try {
|
||||||
notificationManager.deleteNotificationChannel(channelId)
|
notificationManager.deleteNotificationChannel(channelId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val audioAttributes = AudioAttributes.Builder()
|
val audioAttributes = AudioAttributes.Builder()
|
||||||
@ -302,7 +301,7 @@ fun Context.getTimerNotification(pendingIntent: PendingIntent, addDeleteIntent:
|
|||||||
.setDefaults(Notification.DEFAULT_LIGHTS)
|
.setDefaults(Notification.DEFAULT_LIGHTS)
|
||||||
.setCategory(Notification.CATEGORY_EVENT)
|
.setCategory(Notification.CATEGORY_EVENT)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setSound(Uri.parse(soundUri), AudioManager.STREAM_ALARM)
|
.setSound(Uri.parse(soundUri), STREAM_ALARM)
|
||||||
.setChannelId(channelId)
|
.setChannelId(channelId)
|
||||||
.addAction(R.drawable.ic_cross_vector, getString(R.string.dismiss), if (addDeleteIntent) reminderActivityIntent else getHideTimerPendingIntent())
|
.addAction(R.drawable.ic_cross_vector, getString(R.string.dismiss), if (addDeleteIntent) reminderActivityIntent else getHideTimerPendingIntent())
|
||||||
|
|
||||||
@ -346,7 +345,7 @@ fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm): No
|
|||||||
val audioAttributes = AudioAttributes.Builder()
|
val audioAttributes = AudioAttributes.Builder()
|
||||||
.setUsage(AudioAttributes.USAGE_ALARM)
|
.setUsage(AudioAttributes.USAGE_ALARM)
|
||||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||||
.setLegacyStreamType(AudioManager.STREAM_ALARM)
|
.setLegacyStreamType(STREAM_ALARM)
|
||||||
.setFlags(AudioAttributes.FLAG_AUDIBILITY_ENFORCED)
|
.setFlags(AudioAttributes.FLAG_AUDIBILITY_ENFORCED)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
setupViews()
|
setupViews()
|
||||||
|
|
||||||
val configTextColor = context!!.config.textColor
|
val configTextColor = requireContext().config.textColor
|
||||||
if (storedTextColor != configTextColor) {
|
if (storedTextColor != configTextColor) {
|
||||||
(view.alarms_list.adapter as AlarmsAdapter).updateTextColor(configTextColor)
|
(view.alarms_list.adapter as AlarmsAdapter).updateTextColor(configTextColor)
|
||||||
}
|
}
|
||||||
@ -54,12 +54,12 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun storeStateVariables() {
|
private fun storeStateVariables() {
|
||||||
storedTextColor = context!!.config.textColor
|
storedTextColor = requireContext().config.textColor
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
view.apply {
|
view.apply {
|
||||||
context!!.updateTextColors(alarm_fragment)
|
requireContext().updateTextColors(alarm_fragment)
|
||||||
alarm_fab.setOnClickListener {
|
alarm_fab.setOnClickListener {
|
||||||
val newAlarm = context.createNewAlarm(DEFAULT_ALARM_MINUTES, 0)
|
val newAlarm = context.createNewAlarm(DEFAULT_ALARM_MINUTES, 0)
|
||||||
newAlarm.isEnabled = true
|
newAlarm.isEnabled = true
|
||||||
@ -106,14 +106,14 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun alarmToggled(id: Int, isEnabled: Boolean) {
|
override fun alarmToggled(id: Int, isEnabled: Boolean) {
|
||||||
if (context!!.dbHelper.updateAlarmEnabledState(id, isEnabled)) {
|
if (requireContext().dbHelper.updateAlarmEnabledState(id, isEnabled)) {
|
||||||
val alarm = alarms.firstOrNull { it.id == id } ?: return
|
val alarm = alarms.firstOrNull { it.id == id } ?: return
|
||||||
alarm.isEnabled = isEnabled
|
alarm.isEnabled = isEnabled
|
||||||
checkAlarmState(alarm)
|
checkAlarmState(alarm)
|
||||||
} else {
|
} else {
|
||||||
activity!!.toast(R.string.unknown_error_occurred)
|
requireActivity().toast(R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
context!!.updateWidgets()
|
requireContext().updateWidgets()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkAlarmState(alarm: Alarm) {
|
private fun checkAlarmState(alarm: Alarm) {
|
||||||
|
@ -40,7 +40,7 @@ class ClockFragment : Fragment() {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
setupDateTime()
|
setupDateTime()
|
||||||
|
|
||||||
val configTextColor = context!!.config.textColor
|
val configTextColor = requireContext().config.textColor
|
||||||
if (storedTextColor != configTextColor) {
|
if (storedTextColor != configTextColor) {
|
||||||
(view.time_zones_list.adapter as? TimeZonesAdapter)?.updateTextColor(configTextColor)
|
(view.time_zones_list.adapter as? TimeZonesAdapter)?.updateTextColor(configTextColor)
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ class ClockFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun storeStateVariables() {
|
private fun storeStateVariables() {
|
||||||
storedTextColor = context!!.config.textColor
|
storedTextColor = requireContext().config.textColor
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDateTime() {
|
private fun setupDateTime() {
|
||||||
@ -67,7 +67,7 @@ class ClockFragment : Fragment() {
|
|||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
view.apply {
|
view.apply {
|
||||||
context!!.updateTextColors(clock_fragment)
|
requireContext().updateTextColors(clock_fragment)
|
||||||
clock_fab.setOnClickListener {
|
clock_fab.setOnClickListener {
|
||||||
fabClicked()
|
fabClicked()
|
||||||
}
|
}
|
||||||
@ -80,9 +80,9 @@ class ClockFragment : Fragment() {
|
|||||||
val hours = (passedSeconds / 3600) % 24
|
val hours = (passedSeconds / 3600) % 24
|
||||||
val minutes = (passedSeconds / 60) % 60
|
val minutes = (passedSeconds / 60) % 60
|
||||||
val seconds = passedSeconds % 60
|
val seconds = passedSeconds % 60
|
||||||
view.clock_time.text = context!!.getFormattedTime(passedSeconds, context!!.config.showSeconds, true)
|
view.clock_time.text = requireContext().getFormattedTime(passedSeconds, requireContext().config.showSeconds, true)
|
||||||
|
|
||||||
if (!context!!.config.use24HourFormat) {
|
if (!requireContext().config.use24HourFormat) {
|
||||||
view.clock_time.textSize = resources.getDimension(R.dimen.clock_text_size_smaller) / resources.displayMetrics.density
|
view.clock_time.textSize = resources.getDimension(R.dimen.clock_text_size_smaller) / resources.displayMetrics.density
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,29 +102,29 @@ class ClockFragment : Fragment() {
|
|||||||
|
|
||||||
private fun updateDate() {
|
private fun updateDate() {
|
||||||
calendar = Calendar.getInstance()
|
calendar = Calendar.getInstance()
|
||||||
val formattedDate = context!!.getFormattedDate(calendar)
|
val formattedDate = requireContext().getFormattedDate(calendar)
|
||||||
view.clock_date.text = formattedDate
|
view.clock_date.text = formattedDate
|
||||||
(view.time_zones_list.adapter as? TimeZonesAdapter)?.todayDateString = formattedDate
|
(view.time_zones_list.adapter as? TimeZonesAdapter)?.todayDateString = formattedDate
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateAlarm() {
|
fun updateAlarm() {
|
||||||
view.apply {
|
view.apply {
|
||||||
val nextAlarm = context!!.getNextAlarm()
|
val nextAlarm = requireContext().getNextAlarm()
|
||||||
clock_alarm.beVisibleIf(nextAlarm.isNotEmpty())
|
clock_alarm.beVisibleIf(nextAlarm.isNotEmpty())
|
||||||
clock_alarm.text = nextAlarm
|
clock_alarm.text = nextAlarm
|
||||||
clock_alarm.colorLeftDrawable(context!!.config.textColor)
|
clock_alarm.colorLeftDrawable(requireContext().config.textColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTimeZones() {
|
private fun updateTimeZones() {
|
||||||
val selectedTimeZones = context!!.config.selectedTimeZones
|
val selectedTimeZones = requireContext().config.selectedTimeZones
|
||||||
view.time_zones_list.beVisibleIf(selectedTimeZones.isNotEmpty())
|
view.time_zones_list.beVisibleIf(selectedTimeZones.isNotEmpty())
|
||||||
if (selectedTimeZones.isEmpty()) {
|
if (selectedTimeZones.isEmpty()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val selectedTimeZoneIDs = selectedTimeZones.map { it.toInt() }
|
val selectedTimeZoneIDs = selectedTimeZones.map { it.toInt() }
|
||||||
val timeZones = context!!.getAllTimeZonesModified().filter { selectedTimeZoneIDs.contains(it.id) } as ArrayList<MyTimeZone>
|
val timeZones = requireContext().getAllTimeZonesModified().filter { selectedTimeZoneIDs.contains(it.id) } as ArrayList<MyTimeZone>
|
||||||
val currAdapter = view.time_zones_list.adapter
|
val currAdapter = view.time_zones_list.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
TimeZonesAdapter(activity as SimpleActivity, timeZones, view.time_zones_list) {
|
TimeZonesAdapter(activity as SimpleActivity, timeZones, view.time_zones_list) {
|
||||||
|
@ -120,7 +120,7 @@ class StopwatchFragment : Fragment() {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
setupViews()
|
setupViews()
|
||||||
|
|
||||||
val configTextColor = context!!.config.textColor
|
val configTextColor = requireContext().config.textColor
|
||||||
if (storedTextColor != configTextColor) {
|
if (storedTextColor != configTextColor) {
|
||||||
stopwatchAdapter.updateTextColor(configTextColor)
|
stopwatchAdapter.updateTextColor(configTextColor)
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ class StopwatchFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun storeStateVariables() {
|
private fun storeStateVariables() {
|
||||||
storedTextColor = context!!.config.textColor
|
storedTextColor = requireContext().config.textColor
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
@ -168,7 +168,7 @@ class StopwatchFragment : Fragment() {
|
|||||||
sorting = getInt(SORTING, SORT_BY_LAP or SORT_DESCENDING)
|
sorting = getInt(SORTING, SORT_BY_LAP or SORT_DESCENDING)
|
||||||
|
|
||||||
val lapsToken = object : TypeToken<List<Lap>>() {}.type
|
val lapsToken = object : TypeToken<List<Lap>>() {}.type
|
||||||
laps = Gson().fromJson<ArrayList<Lap>>(getString(LAPS), lapsToken)
|
laps = Gson().fromJson(getString(LAPS), lapsToken)
|
||||||
|
|
||||||
if (laps.isNotEmpty()) {
|
if (laps.isNotEmpty()) {
|
||||||
view.stopwatch_sorting_indicators_holder.beVisibleIf(laps.isNotEmpty())
|
view.stopwatch_sorting_indicators_holder.beVisibleIf(laps.isNotEmpty())
|
||||||
@ -183,11 +183,11 @@ class StopwatchFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
val adjustedPrimaryColor = context!!.getAdjustedPrimaryColor()
|
val adjustedPrimaryColor = requireContext().getAdjustedPrimaryColor()
|
||||||
view.apply {
|
view.apply {
|
||||||
context!!.updateTextColors(stopwatch_fragment)
|
requireContext().updateTextColors(stopwatch_fragment)
|
||||||
stopwatch_play_pause.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, adjustedPrimaryColor)
|
stopwatch_play_pause.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, adjustedPrimaryColor)
|
||||||
stopwatch_reset.applyColorFilter(context!!.config.textColor)
|
stopwatch_reset.applyColorFilter(requireContext().config.textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateIcons()
|
updateIcons()
|
||||||
@ -196,7 +196,7 @@ class StopwatchFragment : Fragment() {
|
|||||||
|
|
||||||
private fun updateIcons() {
|
private fun updateIcons() {
|
||||||
val drawableId = if (isRunning) R.drawable.ic_pause_vector else R.drawable.ic_play_vector
|
val drawableId = if (isRunning) R.drawable.ic_pause_vector else R.drawable.ic_play_vector
|
||||||
val iconColor = if (context!!.getAdjustedPrimaryColor() == Color.WHITE) Color.BLACK else Color.WHITE
|
val iconColor = if (requireContext().getAdjustedPrimaryColor() == Color.WHITE) Color.BLACK else Color.WHITE
|
||||||
view.stopwatch_play_pause.setImageDrawable(resources.getColoredDrawableWithColor(drawableId, iconColor))
|
view.stopwatch_play_pause.setImageDrawable(resources.getColoredDrawableWithColor(drawableId, iconColor))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ class StopwatchFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSortingIndicators() {
|
private fun updateSortingIndicators() {
|
||||||
var bitmap = context!!.resources.getColoredBitmap(R.drawable.ic_sorting_triangle, context!!.getAdjustedPrimaryColor())
|
var bitmap = requireContext().resources.getColoredBitmap(R.drawable.ic_sorting_triangle, requireContext().getAdjustedPrimaryColor())
|
||||||
view.apply {
|
view.apply {
|
||||||
stopwatch_sorting_indicator_1.beInvisibleIf(sorting and SORT_BY_LAP == 0)
|
stopwatch_sorting_indicator_1.beInvisibleIf(sorting and SORT_BY_LAP == 0)
|
||||||
stopwatch_sorting_indicator_2.beInvisibleIf(sorting and SORT_BY_LAP_TIME == 0)
|
stopwatch_sorting_indicator_2.beInvisibleIf(sorting and SORT_BY_LAP_TIME == 0)
|
||||||
@ -293,7 +293,7 @@ class StopwatchFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkHaptic(view: View) {
|
private fun checkHaptic(view: View) {
|
||||||
if (context!!.config.vibrateOnButtonPress) {
|
if (requireContext().config.vibrateOnButtonPress) {
|
||||||
view.performHapticFeedback()
|
view.performHapticFeedback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ class TimerFragment : Fragment() {
|
|||||||
timer_label.setText(config.timerLabel)
|
timer_label.setText(config.timerLabel)
|
||||||
|
|
||||||
requiredActivity.updateTextColors(timer_fragment)
|
requiredActivity.updateTextColors(timer_fragment)
|
||||||
timer_play_pause.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, context!!.getAdjustedPrimaryColor())
|
timer_play_pause.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, requireContext().getAdjustedPrimaryColor())
|
||||||
timer_play_pause.applyColorFilter(if (context!!.getAdjustedPrimaryColor() == Color.WHITE) Color.BLACK else Color.WHITE)
|
timer_play_pause.applyColorFilter(if (requireContext().getAdjustedPrimaryColor() == Color.WHITE) Color.BLACK else Color.WHITE)
|
||||||
timer_reset.applyColorFilter(textColor)
|
timer_reset.applyColorFilter(textColor)
|
||||||
|
|
||||||
timer_initial_time.text = config.timerSeconds.getFormattedDuration()
|
timer_initial_time.text = config.timerSeconds.getFormattedDuration()
|
||||||
@ -96,20 +96,20 @@ class TimerFragment : Fragment() {
|
|||||||
|
|
||||||
timer_sound.setOnClickListener {
|
timer_sound.setOnClickListener {
|
||||||
SelectAlarmSoundDialog(activity as SimpleActivity, config.timerSoundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID,
|
SelectAlarmSoundDialog(activity as SimpleActivity, config.timerSoundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID,
|
||||||
ALARM_SOUND_TYPE_ALARM, true,
|
ALARM_SOUND_TYPE_ALARM, true,
|
||||||
onAlarmPicked = { sound ->
|
onAlarmPicked = { sound ->
|
||||||
if (sound != null) {
|
if (sound != null) {
|
||||||
updateAlarmSound(sound)
|
updateAlarmSound(sound)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onAlarmSoundDeleted = { sound ->
|
onAlarmSoundDeleted = { sound ->
|
||||||
if (config.timerSoundUri == sound.uri) {
|
if (config.timerSoundUri == sound.uri) {
|
||||||
val defaultAlarm = context.getDefaultAlarmSound(ALARM_SOUND_TYPE_ALARM)
|
val defaultAlarm = context.getDefaultAlarmSound(ALARM_SOUND_TYPE_ALARM)
|
||||||
updateAlarmSound(defaultAlarm)
|
updateAlarmSound(defaultAlarm)
|
||||||
}
|
}
|
||||||
|
|
||||||
context.checkAlarmsWithDeletedSoundUri(sound.uri)
|
context.checkAlarmsWithDeletedSoundUri(sound.uri)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_label.onTextChangeListener { text ->
|
timer_label.onTextChangeListener { text ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user