adding a new "No sound" item at the alarmsound picker
This commit is contained in:
parent
817c465bee
commit
c4f2f07b4d
36 changed files with 53 additions and 16 deletions
|
@ -6,7 +6,7 @@ buildscript {
|
|||
propMinSdkVersion = 16
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '3.18.17'
|
||||
propVersionName = '3.18.18'
|
||||
kotlin_version = '1.2.31'
|
||||
support_libs = '27.1.0'
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.google.gson.reflect.TypeToken
|
|||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.SILENT
|
||||
import com.simplemobiletools.commons.helpers.isKitkatPlus
|
||||
import com.simplemobiletools.commons.models.AlarmSound
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
|
@ -101,8 +102,9 @@ class SelectAlarmSoundDialog(val activity: BaseSimpleActivity, val currentUri: S
|
|||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
private fun alarmClicked(alarmSound: AlarmSound) {
|
||||
if (alarmSound.id == ADD_NEW_SOUND_ID) {
|
||||
private fun alarmClicked(alarmSound: AlarmSound) = when {
|
||||
alarmSound.uri == SILENT -> mediaPlayer.stop()
|
||||
alarmSound.id == ADD_NEW_SOUND_ID -> {
|
||||
val action = if (isKitkatPlus()) Intent.ACTION_OPEN_DOCUMENT else Intent.ACTION_GET_CONTENT
|
||||
Intent(action).apply {
|
||||
type = "audio/*"
|
||||
|
@ -113,19 +115,18 @@ class SelectAlarmSoundDialog(val activity: BaseSimpleActivity, val currentUri: S
|
|||
}
|
||||
}
|
||||
dialog.dismiss()
|
||||
} else {
|
||||
try {
|
||||
mediaPlayer.stop()
|
||||
mediaPlayer = MediaPlayer().apply {
|
||||
setAudioStreamType(audioStream)
|
||||
setDataSource(activity, Uri.parse(alarmSound.uri))
|
||||
isLooping = loopAudio
|
||||
prepare()
|
||||
start()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
activity.showErrorToast(e)
|
||||
}
|
||||
else -> try {
|
||||
mediaPlayer.stop()
|
||||
mediaPlayer = MediaPlayer().apply {
|
||||
setAudioStreamType(audioStream)
|
||||
setDataSource(activity, Uri.parse(alarmSound.uri))
|
||||
isLooping = loopAudio
|
||||
prepare()
|
||||
start()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
activity.showErrorToast(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -781,10 +781,13 @@ fun BaseSimpleActivity.getAlarmSounds(type: Int, callback: (ArrayList<AlarmSound
|
|||
|
||||
try {
|
||||
val cursor = manager.cursor
|
||||
var curId = 1
|
||||
val silentAlarm = AlarmSound(curId++, getString(R.string.no_sound), SILENT)
|
||||
alarms.add(silentAlarm)
|
||||
|
||||
val defaultAlarm = getDefaultAlarmSound(type)
|
||||
alarms.add(defaultAlarm)
|
||||
|
||||
var curId = 1
|
||||
while (cursor.moveToNext()) {
|
||||
val title = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX)
|
||||
var uri = cursor.getString(RingtoneManager.URI_COLUMN_INDEX)
|
||||
|
|
|
@ -77,6 +77,7 @@ const val USE_SAME_SNOOZE = "use_same_snooze"
|
|||
const val SNOOZE_TIME = "snooze_delay"
|
||||
const val VIBRATE_ON_BUTTON_PRESS = "vibrate_on_button_press"
|
||||
const val YOUR_ALARM_SOUNDS = "your_alarm_sounds"
|
||||
const val SILENT = "silent"
|
||||
|
||||
// licenses
|
||||
internal const val LICENSE_KOTLIN = 1
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
|
|
|
@ -328,6 +328,7 @@
|
|||
<string name="system_sounds">Sons del sistema</string>
|
||||
<string name="your_sounds">Els teus sons</string>
|
||||
<string name="add_new_sound">Afegeix un so nou</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Ajustaments</string>
|
||||
|
|
|
@ -343,6 +343,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Nastavení</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">Systemlyde</string>
|
||||
<string name="your_sounds">Dine lyde</string>
|
||||
<string name="add_new_sound">Tilføj en ny lyd</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Indstillinger</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">Systemtöne</string>
|
||||
<string name="your_sounds">Deine Töne</string>
|
||||
<string name="add_new_sound">Neuen Ton hinzufügen</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Einstellungen</string>
|
||||
|
|
|
@ -325,6 +325,7 @@
|
|||
<string name="system_sounds">Sonidos del sistema</string>
|
||||
<string name="your_sounds">Tus sonidos</string>
|
||||
<string name="add_new_sound">Agrega un nuevo sonido</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Ajustes</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Asetukset</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">Sonneries du système</string>
|
||||
<string name="your_sounds">Vos sonneries</string>
|
||||
<string name="add_new_sound">Ajouter une nouvelle sonnerie</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Paramètres</string>
|
||||
|
|
|
@ -325,6 +325,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Ajustes</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
|
|
|
@ -345,6 +345,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Postavke</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Pengaturan</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Impostazioni</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">設定</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">설정</string>
|
||||
|
|
|
@ -343,6 +343,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Nustatymai</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">Systemlyder</string>
|
||||
<string name="your_sounds">Dine lyder</string>
|
||||
<string name="add_new_sound">Legg til en ny lyd</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Innstillinger</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">Systeemgeluiden</string>
|
||||
<string name="your_sounds">Eigen geluiden</string>
|
||||
<string name="add_new_sound">Nieuw geluid toevoegen</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Instellingen</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Innstillinger</string>
|
||||
|
|
|
@ -341,6 +341,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Ustawienia</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Configurações</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">Sons do sistema</string>
|
||||
<string name="your_sounds">Meus sons</string>
|
||||
<string name="add_new_sound">Adicionar um novo som</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Definições</string>
|
||||
|
|
|
@ -353,6 +353,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Настройки</string>
|
||||
|
|
|
@ -345,6 +345,7 @@
|
|||
<string name="system_sounds">Systémové zvuky</string>
|
||||
<string name="your_sounds">Vaše zvuky</string>
|
||||
<string name="add_new_sound">Pridať nový zvuk</string>
|
||||
<string name="no_sound">Žiadny zvuk</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Nastavenia</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">Systemljud</string>
|
||||
<string name="your_sounds">Dina ljud</string>
|
||||
<string name="add_new_sound">Lägg till ett nytt ljud</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Inställningar</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Ayarlar</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">系统铃声</string>
|
||||
<string name="your_sounds">你的铃声</string>
|
||||
<string name="add_new_sound">添加新的铃声</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">设置</string>
|
||||
|
|
|
@ -325,6 +325,7 @@
|
|||
<string name="system_sounds">系統音效</string>
|
||||
<string name="your_sounds">你的音效</string>
|
||||
<string name="add_new_sound">添加新的音效</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">設定</string>
|
||||
|
|
|
@ -326,6 +326,7 @@
|
|||
<string name="system_sounds">System sounds</string>
|
||||
<string name="your_sounds">Your sounds</string>
|
||||
<string name="add_new_sound">Add a new sound</string>
|
||||
<string name="no_sound">No sound</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
|
|
Loading…
Reference in a new issue