Skip to content

Commit

Permalink
1.1.10. fix parsing shredpref to long
Browse files Browse the repository at this point in the history
  • Loading branch information
Øyvind Samuelsen committed Apr 25, 2021
1 parent fa046eb commit f5f1018
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.developments.samu.muteforspotify"
minSdkVersion 23
targetSdkVersion 30
versionCode 33
versionName "1.1.9"
versionCode 34
versionName "1.1.10"
}
kotlinOptions {
jvmTarget = '1.8'
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class SettingsActivity : AppCompatActivity() {
editText.inputType = InputType.TYPE_CLASS_NUMBER or TYPE_NUMBER_FLAG_SIGNED
}
setOnPreferenceChangeListener { preference, newValue ->
(newValue as String).isNotBlank()
with(newValue as String) {
isNotBlank()
toLongOrNull() != null
}
}
}

Expand All @@ -52,7 +55,10 @@ class SettingsActivity : AppCompatActivity() {
editText.inputType = InputType.TYPE_CLASS_NUMBER or TYPE_NUMBER_FLAG_SIGNED
}
setOnPreferenceChangeListener { preference, newValue ->
(newValue as String).isNotBlank()
with(newValue as String) {
isNotBlank()
toLongOrNull() != null
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,19 @@ class LoggerService : Service() {

if (isMuted) {
setUnmuteTimer(
wait = getUnuteDelay() - newSong.playbackPosition - newSong.propagation()
wait = getUnmuteDelay() - newSong.playbackPosition - newSong.propagation()
)
}
setMuteTimer(newSong.systemTimeLeft() + getMuteDelay())
}

private fun getMuteDelay() = prefs.getLong(getString(R.string.settings_mute_key), PREF_MUTE_DELAY_DEFAULT)
private fun getMuteDelay(): Long {
return prefs.getString(getString(R.string.settings_mute_key), PREF_MUTE_DELAY_DEFAULT.toString())?.toLongOrNull() ?: PREF_MUTE_DELAY_DEFAULT
}

private fun getUnuteDelay() = prefs.getLong(getString(R.string.settings_unmute_key), PREF_UNMUTE_DELAY_DEFAULT)
private fun getUnmuteDelay(): Long {
return prefs.getString(getString(R.string.settings_unmute_key), PREF_UNMUTE_DELAY_DEFAULT.toString())?.toLongOrNull() ?: PREF_UNMUTE_DELAY_DEFAULT
}

// Spotify sends an intent of a new playing song before the ad is completed -> wait some hundred ms before unmuting
private fun setUnmuteTimer(wait: Long) {
Expand Down

0 comments on commit f5f1018

Please sign in to comment.