Fix volume increasing/decreasing level by 2 instead of 1 starting API 16

This commit is contained in:
Sylvain Berfini 2014-02-18 17:15:25 +01:00
parent 6c3189f8eb
commit d6de11a800
2 changed files with 3 additions and 4 deletions

View file

@ -1210,7 +1210,7 @@ public class LinphoneManager implements LinphoneCoreListener {
} }
public void adjustVolume(int i) { public void adjustVolume(int i) {
if (Build.VERSION.SDK_INT<15) { if (Build.VERSION.SDK_INT < 15) {
int oldVolume = mAudioManager.getStreamVolume(LINPHONE_VOLUME_STREAM); int oldVolume = mAudioManager.getStreamVolume(LINPHONE_VOLUME_STREAM);
int maxVolume = mAudioManager.getStreamMaxVolume(LINPHONE_VOLUME_STREAM); int maxVolume = mAudioManager.getStreamMaxVolume(LINPHONE_VOLUME_STREAM);
@ -1221,7 +1221,7 @@ public class LinphoneManager implements LinphoneCoreListener {
mLc.setPlaybackGain((nextVolume - maxVolume)* dbStep); mLc.setPlaybackGain((nextVolume - maxVolume)* dbStep);
} else } else
// starting from ICS, volume must be adjusted by the application, at least for STREAM_VOICE_CALL volume stream // starting from ICS, volume must be adjusted by the application, at least for STREAM_VOICE_CALL volume stream
mAudioManager.adjustStreamVolume(LINPHONE_VOLUME_STREAM, i<0?AudioManager.ADJUST_LOWER:AudioManager.ADJUST_RAISE, 0); mAudioManager.adjustStreamVolume(LINPHONE_VOLUME_STREAM, i < 0 ? AudioManager.ADJUST_LOWER : AudioManager.ADJUST_RAISE, 0);
} }
public static Boolean isProximitySensorNearby(final SensorEvent event) { public static Boolean isProximitySensorNearby(final SensorEvent event) {

View file

@ -69,7 +69,6 @@ public final class LinphoneUtils {
private LinphoneUtils(){} private LinphoneUtils(){}
private static boolean preventVolumeBarToDisplay = false;
//private static final String sipAddressRegExp = "^(sip:)?(\\+)?[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}(:[0-9]{2,5})?$"; //private static final String sipAddressRegExp = "^(sip:)?(\\+)?[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}(:[0-9]{2,5})?$";
//private static final String strictSipAddressRegExp = "^sip:(\\+)?[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}$"; //private static final String strictSipAddressRegExp = "^sip:(\\+)?[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}$";
@ -121,7 +120,7 @@ public final class LinphoneUtils {
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
LinphoneManager.getInstance().adjustVolume(-1); LinphoneManager.getInstance().adjustVolume(-1);
} }
return preventVolumeBarToDisplay; return true;
} }