mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-17 22:08:00 +01:00
tweak the volume setter a bit
This commit is contained in:
parent
af84b8e9e3
commit
622ebde68f
1 changed files with 2 additions and 2 deletions
|
@ -138,7 +138,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
||||||
val diffY = mTouchDownY - event.y
|
val diffY = mTouchDownY - event.y
|
||||||
|
|
||||||
if (Math.abs(diffY) > Math.abs(diffX)) {
|
if (Math.abs(diffY) > Math.abs(diffX)) {
|
||||||
var percent = ((diffY / ViewPagerActivity.screenHeight) * 100).toInt() * 2
|
var percent = ((diffY / ViewPagerActivity.screenHeight) * 100).toInt() * 3
|
||||||
percent = Math.min(100, Math.max(-100, percent))
|
percent = Math.min(100, Math.max(-100, percent))
|
||||||
volumePercentChanged(percent)
|
volumePercentChanged(percent)
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
||||||
private fun volumePercentChanged(percent: Int) {
|
private fun volumePercentChanged(percent: Int) {
|
||||||
val stream = AudioManager.STREAM_MUSIC
|
val stream = AudioManager.STREAM_MUSIC
|
||||||
val maxVolume = context.audioManager.getStreamMaxVolume(stream)
|
val maxVolume = context.audioManager.getStreamMaxVolume(stream)
|
||||||
val percentPerPoint = Math.ceil(100 / maxVolume.toDouble()).toInt()
|
val percentPerPoint = 100 / maxVolume
|
||||||
val addPoints = percent / percentPerPoint
|
val addPoints = percent / percentPerPoint
|
||||||
val newVolume = Math.min(maxVolume, Math.max(0, mTouchDownVolume + addPoints))
|
val newVolume = Math.min(maxVolume, Math.max(0, mTouchDownVolume + addPoints))
|
||||||
context.audioManager.setStreamVolume(stream, newVolume, 0)
|
context.audioManager.setStreamVolume(stream, newVolume, 0)
|
||||||
|
|
Loading…
Reference in a new issue