Initial support to softvolume.

This commit is contained in:
Guillaume Beraudo 2011-04-11 12:18:47 +02:00
parent c79ee4f210
commit 7c0cdb7036
8 changed files with 78 additions and 1 deletions

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="pref_audio_soft_volume_key">pref_audio_soft_volume_key</string>
<string name="pref_ipv6_key">pref_ipv6_key</string>
<string name="pref_transport_udp_key">pref_transport_udp_key</string>

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="pref_audio_soft_volume_title">Use software volume</string>
<string name="pref_ipv6_title">Use ipv6 instead of ipv4</string>
<string name="error_while_accepting_pending_call">Error while accepting pending call</string>

View file

@ -115,6 +115,9 @@
<CheckBoxPreference android:key="@string/pref_debug_key"
android:title="@string/pref_debug" android:enabled="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_audio_soft_volume_key"
android:title="@string/pref_audio_soft_volume_title" />
<PreferenceScreen android:title="@string/pref_network_title">
<CheckBoxPreference android:key="@string/pref_ipv6_key"
android:title="@string/pref_ipv6_title" android:defaultValue="false" />

View file

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

View file

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

View file

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

View file

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

@ -1 +1 @@
Subproject commit f8713446f524ef2308dfc46d7e550c21ec44a08c
Subproject commit e8318e75125045566366707d10f1ca8d08536da6