adding a new "No sound" item at the alarmsound picker

This commit is contained in:
tibbi 2018-04-11 11:59:53 +02:00
parent 817c465bee
commit c4f2f07b4d
36 changed files with 53 additions and 16 deletions

View file

@ -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'
}

View file

@ -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,8 +115,8 @@ class SelectAlarmSoundDialog(val activity: BaseSimpleActivity, val currentUri: S
}
}
dialog.dismiss()
} else {
try {
}
else -> try {
mediaPlayer.stop()
mediaPlayer = MediaPlayer().apply {
setAudioStreamType(audioStream)
@ -127,7 +129,6 @@ class SelectAlarmSoundDialog(val activity: BaseSimpleActivity, val currentUri: S
activity.showErrorToast(e)
}
}
}
private fun removeAlarmSound(alarmSound: AlarmSound) {
val token = object : TypeToken<ArrayList<AlarmSound>>() {}.type

View file

@ -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)

View file

@ -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

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>