From 7c0cdb703690ff6f10b56b9317690e56dd4ca69f Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 11 Apr 2011 12:18:47 +0200 Subject: [PATCH] Initial support to softvolume. --- res/values/non_localizable_strings.xml | 2 + res/values/strings.xml | 2 + res/xml/preferences.xml | 3 ++ src/org/linphone/DialerActivity.java | 9 ++++ src/org/linphone/LinphoneManager.java | 8 ++++ src/org/linphone/SoftVolume.java | 49 +++++++++++++++++++++ src/org/linphone/core/LinphoneCoreImpl.java | 4 ++ submodules/linphone | 2 +- 8 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/org/linphone/SoftVolume.java diff --git a/res/values/non_localizable_strings.xml b/res/values/non_localizable_strings.xml index bbacf7bb1..c26241115 100644 --- a/res/values/non_localizable_strings.xml +++ b/res/values/non_localizable_strings.xml @@ -1,6 +1,8 @@ + pref_audio_soft_volume_key + pref_ipv6_key pref_transport_udp_key diff --git a/res/values/strings.xml b/res/values/strings.xml index 7954b6469..6208f192f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,6 +1,8 @@ + Use software volume + Use ipv6 instead of ipv4 Error while accepting pending call diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index c46f8fe72..0d91a6a90 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -115,6 +115,9 @@ + + diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java index 3edd40939..c98f1bf09 100644 --- a/src/org/linphone/DialerActivity.java +++ b/src/org/linphone/DialerActivity.java @@ -45,6 +45,7 @@ import android.os.Bundle; import android.os.PowerManager; import android.preference.PreferenceManager; import android.util.Log; +import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.TextView; @@ -84,6 +85,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, New private SharedPreferences mPref; private boolean useIncallActivity; private boolean useVideoActivity; + private SoftVolume softVolume; private static final String CURRENT_ADDRESS = "org.linphone.current-address"; private static final String CURRENT_DISPLAYNAME = "org.linphone.current-displayname"; @@ -102,6 +104,8 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, New super.onCreate(savedInstanceState); setContentView(R.layout.dialer); + softVolume = new SoftVolume(this); + useIncallActivity = getResources().getBoolean(R.bool.use_incall_activity); useVideoActivity = getResources().getBoolean(R.bool.use_video_activity); // Don't use Linphone Manager in the onCreate as it takes time in LinphoneService to initialize it. @@ -419,4 +423,9 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, New } + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (softVolume.onKeyDown(keyCode, event)) return true; + return super.onKeyDown(keyCode, event); + } } diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index b4c64ab25..c615f6ce0 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -330,6 +330,9 @@ public final class LinphoneManager implements LinphoneCoreListener { this, linphoneConfigFile, linphoneInitialConfigFile, null); mLc.enableIpv6(mPref.getBoolean(getString(R.string.pref_ipv6_key), false)); + if (mPref.getBoolean(getString(R.string.pref_audio_soft_volume_key), false)) { + adjustSoftwareVolume(0); // Set maximum + } mLc.setPlaybackGain(3); mLc.setRing(null); @@ -843,4 +846,9 @@ public final class LinphoneManager implements LinphoneCoreListener { return mR.getString(R.string.unknown_incoming_call_name); } + + public void adjustSoftwareVolume(int i) { + mLc.adjustSoftwareVolume(i); + } + } diff --git a/src/org/linphone/SoftVolume.java b/src/org/linphone/SoftVolume.java new file mode 100644 index 000000000..43867f300 --- /dev/null +++ b/src/org/linphone/SoftVolume.java @@ -0,0 +1,49 @@ +/* +SoftVolume.java +Copyright (C) 2011 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +package org.linphone; + +import android.content.Context; +import android.preference.PreferenceManager; +import android.view.KeyEvent; + +public class SoftVolume { + + private Context c; + + public SoftVolume(Context context) { + c = context.getApplicationContext(); + } + + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (!PreferenceManager.getDefaultSharedPreferences(c).getBoolean( + c.getString(R.string.pref_audio_soft_volume_key), false)) + return false; + + if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { + LinphoneManager.getInstance().adjustSoftwareVolume(6); + return true; + } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { + LinphoneManager.getInstance().adjustSoftwareVolume(-6); + return true; + } + + return false; + } +} + diff --git a/src/org/linphone/core/LinphoneCoreImpl.java b/src/org/linphone/core/LinphoneCoreImpl.java index 81885d13a..f90812fc4 100644 --- a/src/org/linphone/core/LinphoneCoreImpl.java +++ b/src/org/linphone/core/LinphoneCoreImpl.java @@ -94,6 +94,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native int getSignalingTransportPort(long nativePtr, int code); private native void setSignalingTransportPorts(long nativePtr, int udp, int tcp, int tls); private native void enableIpv6(long nativePtr,boolean enable); + private native void adjustSoftwareVolume(long nativePtr,int db); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -454,5 +455,8 @@ class LinphoneCoreImpl implements LinphoneCore { public void enableIpv6(boolean enable) { enableIpv6(nativePtr,enable); } + public void adjustSoftwareVolume(int i) { + adjustSoftwareVolume(nativePtr, i); + } } diff --git a/submodules/linphone b/submodules/linphone index f8713446f..e8318e751 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit f8713446f524ef2308dfc46d7e550c21ec44a08c +Subproject commit e8318e75125045566366707d10f1ca8d08536da6