mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-04-05 14:21:03 +02:00
update commons to 3.17.13
This commit is contained in:
parent
0101158131
commit
f24104fbdd
@ -41,7 +41,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:3.17.12'
|
implementation 'com.simplemobiletools:commons:3.17.13'
|
||||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
|
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||||
implementation 'com.shawnlin:number-picker:2.4.6'
|
implementation 'com.shawnlin:number-picker:2.4.6'
|
||||||
|
@ -3,14 +3,11 @@ package com.simplemobiletools.clock.activities
|
|||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.reflect.TypeToken
|
|
||||||
import com.simplemobiletools.clock.BuildConfig
|
import com.simplemobiletools.clock.BuildConfig
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.adapters.ViewPagerAdapter
|
import com.simplemobiletools.clock.adapters.ViewPagerAdapter
|
||||||
@ -22,11 +19,8 @@ import com.simplemobiletools.clock.helpers.*
|
|||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.LICENSE_NUMBER_PICKER
|
import com.simplemobiletools.commons.helpers.LICENSE_NUMBER_PICKER
|
||||||
import com.simplemobiletools.commons.helpers.LICENSE_STETHO
|
import com.simplemobiletools.commons.helpers.LICENSE_STETHO
|
||||||
import com.simplemobiletools.commons.helpers.isKitkatPlus
|
|
||||||
import com.simplemobiletools.commons.models.AlarmSound
|
|
||||||
import com.simplemobiletools.commons.models.FAQItem
|
import com.simplemobiletools.commons.models.FAQItem
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class MainActivity : SimpleActivity() {
|
class MainActivity : SimpleActivity() {
|
||||||
private var storedUseEnglish = false
|
private var storedUseEnglish = false
|
||||||
@ -127,31 +121,13 @@ class MainActivity : SimpleActivity() {
|
|||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, resultData)
|
super.onActivityResult(requestCode, resultCode, resultData)
|
||||||
if (requestCode == PICK_AUDIO_FILE_INTENT_ID && resultCode == RESULT_OK && resultData != null) {
|
if (requestCode == PICK_AUDIO_FILE_INTENT_ID && resultCode == RESULT_OK && resultData != null) {
|
||||||
storeNewAlarmSound(resultData.data)
|
storeNewAlarmSound(resultData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||||
private fun storeNewAlarmSound(uri: Uri) {
|
private fun storeNewAlarmSound(resultData: Intent) {
|
||||||
var filename = getFilenameFromUri(uri)
|
val newAlarmSound = storeNewYourAlarmSound(resultData)
|
||||||
if (filename.isEmpty()) {
|
|
||||||
filename = getString(R.string.alarm)
|
|
||||||
}
|
|
||||||
|
|
||||||
val token = object : TypeToken<ArrayList<AlarmSound>>() {}.type
|
|
||||||
val yourAlarmSounds = Gson().fromJson<ArrayList<AlarmSound>>(config.yourAlarmSounds, token) ?: ArrayList()
|
|
||||||
val newAlarmSoundId = (yourAlarmSounds.maxBy { it.id }?.id ?: YOUR_ALARM_SOUNDS_MIN_ID) + 1
|
|
||||||
val newAlarmSound = AlarmSound(newAlarmSoundId, filename, uri.toString())
|
|
||||||
if (yourAlarmSounds.firstOrNull { it.uri == uri.toString() } == null) {
|
|
||||||
yourAlarmSounds.add(newAlarmSound)
|
|
||||||
}
|
|
||||||
|
|
||||||
config.yourAlarmSounds = Gson().toJson(yourAlarmSounds)
|
|
||||||
|
|
||||||
if (isKitkatPlus()) {
|
|
||||||
val takeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
|
||||||
contentResolver.takePersistableUriPermission(uri, takeFlags)
|
|
||||||
}
|
|
||||||
|
|
||||||
when (view_pager.currentItem) {
|
when (view_pager.currentItem) {
|
||||||
TAB_ALARM -> getViewPagerAdapter()?.updateAlarmTabAlarmSound(newAlarmSound)
|
TAB_ALARM -> getViewPagerAdapter()?.updateAlarmTabAlarmSound(newAlarmSound)
|
||||||
|
@ -37,7 +37,7 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
|||||||
}
|
}
|
||||||
}, onAlarmSoundDeleted = {
|
}, onAlarmSoundDeleted = {
|
||||||
if (alarm.soundUri == it.uri) {
|
if (alarm.soundUri == it.uri) {
|
||||||
val defaultAlarm = context.getDefaultAlarmSound(ALARM_SOUND_TYPE_ALARM, context.getString(R.string.alarm))
|
val defaultAlarm = context.getDefaultAlarmSound(ALARM_SOUND_TYPE_ALARM)
|
||||||
updateSelectedAlarmSound(defaultAlarm)
|
updateSelectedAlarmSound(defaultAlarm)
|
||||||
}
|
}
|
||||||
activity.checkAlarmsWithDeletedSoundUri(it.uri)
|
activity.checkAlarmsWithDeletedSoundUri(it.uri)
|
||||||
|
@ -75,7 +75,7 @@ fun Context.getAllTimeZonesModified(): ArrayList<MyTimeZone> {
|
|||||||
fun Context.getModifiedTimeZoneTitle(id: Int) = getAllTimeZonesModified().firstOrNull { it.id == id }?.title ?: getDefaultTimeZoneTitle(id)
|
fun Context.getModifiedTimeZoneTitle(id: Int) = getAllTimeZonesModified().firstOrNull { it.id == id }?.title ?: getDefaultTimeZoneTitle(id)
|
||||||
|
|
||||||
fun Context.createNewAlarm(timeInMinutes: Int, weekDays: Int): Alarm {
|
fun Context.createNewAlarm(timeInMinutes: Int, weekDays: Int): Alarm {
|
||||||
val defaultAlarmSound = getDefaultAlarmSound(ALARM_SOUND_TYPE_ALARM, getString(R.string.alarm))
|
val defaultAlarmSound = getDefaultAlarmSound(ALARM_SOUND_TYPE_ALARM)
|
||||||
return Alarm(0, timeInMinutes, weekDays, false, false, defaultAlarmSound.title, defaultAlarmSound.uri, "")
|
return Alarm(0, timeInMinutes, weekDays, false, false, defaultAlarmSound.title, defaultAlarmSound.uri, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ fun Context.getReminderActivityIntent(): PendingIntent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Context.checkAlarmsWithDeletedSoundUri(uri: String) {
|
fun Context.checkAlarmsWithDeletedSoundUri(uri: String) {
|
||||||
val defaultAlarmSound = getDefaultAlarmSound(ALARM_SOUND_TYPE_ALARM, getString(R.string.alarm))
|
val defaultAlarmSound = getDefaultAlarmSound(ALARM_SOUND_TYPE_ALARM)
|
||||||
dbHelper.getAlarmsWithUri(uri).forEach {
|
dbHelper.getAlarmsWithUri(uri).forEach {
|
||||||
it.soundTitle = defaultAlarmSound.title
|
it.soundTitle = defaultAlarmSound.title
|
||||||
it.soundUri = defaultAlarmSound.uri
|
it.soundUri = defaultAlarmSound.uri
|
||||||
|
@ -75,7 +75,7 @@ class TimerFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}, onAlarmSoundDeleted = {
|
}, onAlarmSoundDeleted = {
|
||||||
if (config.timerSoundUri == it.uri) {
|
if (config.timerSoundUri == it.uri) {
|
||||||
val defaultAlarm = context.getDefaultAlarmSound(ALARM_SOUND_TYPE_ALARM, getString(R.string.alarm))
|
val defaultAlarm = context.getDefaultAlarmSound(ALARM_SOUND_TYPE_ALARM)
|
||||||
updateAlarmSound(defaultAlarm)
|
updateAlarmSound(defaultAlarm)
|
||||||
}
|
}
|
||||||
context.checkAlarmsWithDeletedSoundUri(it.uri)
|
context.checkAlarmsWithDeletedSoundUri(it.uri)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.simplemobiletools.clock.helpers
|
package com.simplemobiletools.clock.helpers
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.simplemobiletools.clock.R
|
|
||||||
import com.simplemobiletools.commons.extensions.getDefaultAlarmTitle
|
import com.simplemobiletools.commons.extensions.getDefaultAlarmTitle
|
||||||
import com.simplemobiletools.commons.extensions.getDefaultAlarmUri
|
import com.simplemobiletools.commons.extensions.getDefaultAlarmUri
|
||||||
import com.simplemobiletools.commons.helpers.ALARM_SOUND_TYPE_ALARM
|
import com.simplemobiletools.commons.helpers.ALARM_SOUND_TYPE_ALARM
|
||||||
@ -37,7 +36,7 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
set(timerSoundUri) = prefs.edit().putString(TIMER_SOUND_URI, timerSoundUri).apply()
|
set(timerSoundUri) = prefs.edit().putString(TIMER_SOUND_URI, timerSoundUri).apply()
|
||||||
|
|
||||||
var timerSoundTitle: String
|
var timerSoundTitle: String
|
||||||
get() = prefs.getString(TIMER_SOUND_TITLE, context.getDefaultAlarmTitle(ALARM_SOUND_TYPE_ALARM, context.getString(R.string.alarm)))
|
get() = prefs.getString(TIMER_SOUND_TITLE, context.getDefaultAlarmTitle(ALARM_SOUND_TYPE_ALARM))
|
||||||
set(timerSoundTitle) = prefs.edit().putString(TIMER_SOUND_TITLE, timerSoundTitle).apply()
|
set(timerSoundTitle) = prefs.edit().putString(TIMER_SOUND_TITLE, timerSoundTitle).apply()
|
||||||
|
|
||||||
var timerMaxReminderSecs: Int
|
var timerMaxReminderSecs: Int
|
||||||
|
@ -23,7 +23,6 @@ const val DAY_MINUTES = 1440
|
|||||||
const val DEFAULT_MAX_ALARM_REMINDER_SECS = 300
|
const val DEFAULT_MAX_ALARM_REMINDER_SECS = 300
|
||||||
const val DEFAULT_MAX_TIMER_REMINDER_SECS = 60
|
const val DEFAULT_MAX_TIMER_REMINDER_SECS = 60
|
||||||
const val HIDE_REMINDER_ACTIVITY = "hide_reminder_activity"
|
const val HIDE_REMINDER_ACTIVITY = "hide_reminder_activity"
|
||||||
const val YOUR_ALARM_SOUNDS_MIN_ID = 1000
|
|
||||||
|
|
||||||
const val PICK_AUDIO_FILE_INTENT_ID = 9994
|
const val PICK_AUDIO_FILE_INTENT_ID = 9994
|
||||||
const val REMINDER_ACTIVITY_INTENT_ID = 9995
|
const val REMINDER_ACTIVITY_INTENT_ID = 9995
|
||||||
|
Loading…
x
Reference in New Issue
Block a user