Merge remote-tracking branch 'public/master' into bellesip

Conflicts:
	jni/libneon/libneon_jni.cc
	src/org/linphone/LinphoneManager.java
	submodules/linphone
This commit is contained in:
Jehan Monnier 2013-03-26 17:12:21 +01:00
commit 14ef36071b
53 changed files with 462 additions and 217 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -3,9 +3,9 @@
<item android:state_pressed="true"
android:drawable="@drawable/options_over" />
<item android:state_enabled="false"
android:drawable="@drawable/options_disabled" />
android:drawable="@drawable/options_disabled" />
<item android:state_selected="true"
android:drawable="@drawable/options_selected" />
android:drawable="@drawable/options_selected" />
<item
android:drawable="@drawable/options_default" />
</selector>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/route_bluetooth_off_over" />
<item android:state_enabled="false"
android:drawable="@drawable/route_bluetooth_off_disabled" />
<item
android:drawable="@drawable/route_bluetooth_off_default" />
</selector>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/route_bluetooth_off_over" />
<item android:state_enabled="false"
android:drawable="@drawable/route_bluetooth_off_disabled" />
<item
android:drawable="@drawable/route_bluetooth_on_default" />
</selector>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/route_phone_off_over" />
<item android:state_enabled="false"
android:drawable="@drawable/route_phone_off_disabled" />
<item
android:drawable="@drawable/route_phone_off_default" />
</selector>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/route_phone_off_over" />
<item android:state_enabled="false"
android:drawable="@drawable/route_phone_off_disabled" />
<item
android:drawable="@drawable/route_phone_on_default" />
</selector>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/route_speaker_off_over" />
<item android:state_enabled="false"
android:drawable="@drawable/route_speaker_off_disabled" />
<item
android:drawable="@drawable/route_speaker_off_default" />
</selector>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/route_speaker_off_over" />
<item android:state_enabled="false"
android:drawable="@drawable/route_speaker_off_disabled" />
<item
android:drawable="@drawable/route_speaker_on_default" />
</selector>

12
res/drawable/routes.xml Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/routes_over" />
<item android:state_selected="true"
android:drawable="@drawable/routes_selected" />
<item android:state_enabled="false"
android:drawable="@drawable/routes_disabled" />
<item
android:drawable="@drawable/routes_default" />
</selector>

View file

@ -55,10 +55,10 @@
<LinearLayout
android:id="@+id/menu"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone"
android:gravity="bottom"
android:orientation="horizontal" >
@ -126,6 +126,59 @@
android:layout_height="wrap_content"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/routesLayout"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:id="@+id/routeBluetooth"
android:visibility="invisible"
android:background="@drawable/route_bluetooth_off"
android:text="@string/button_bluetooth"
android:gravity="center"
android:paddingTop="35dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/routeReceiver"
android:visibility="invisible"
android:background="@drawable/route_receiver_off"
android:text="@string/button_receiver"
android:gravity="center"
android:paddingTop="35dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/routeSpeaker"
android:visibility="invisible"
android:background="@drawable/route_speaker_off"
android:text="@string/button_speaker"
android:gravity="center"
android:paddingTop="35dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/audioRoute"
android:background="@drawable/routes"
android:text="@string/button_route"
android:gravity="center"
android:paddingTop="30dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -58,31 +58,87 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone"
android:gravity="right"
android:orientation="vertical" >
android:orientation="vertical">
<TextView
android:id="@+id/transfer"
android:background="@drawable/options_transfer"
android:text="@string/button_transfer"
android:gravity="center"
android:paddingTop="40dp"
android:visibility="invisible"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/addCall"
android:background="@drawable/options_add_call_alt"
android:text="@string/button_add_call"
android:gravity="center"
android:paddingTop="40dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right|bottom"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right|bottom"
android:orientation="vertical">
<TextView
android:id="@+id/routeBluetooth"
android:visibility="invisible"
android:background="@drawable/route_bluetooth_off"
android:text="@string/button_bluetooth"
android:gravity="center"
android:paddingTop="40dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/routeReceiver"
android:visibility="invisible"
android:background="@drawable/route_receiver_off"
android:text="@string/button_receiver"
android:gravity="center"
android:paddingTop="40dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/routeSpeaker"
android:visibility="invisible"
android:background="@drawable/route_speaker_off"
android:text="@string/button_speaker"
android:gravity="center"
android:paddingTop="40dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right|bottom"
android:orientation="vertical">
<TextView
android:id="@+id/transfer"
android:background="@drawable/options_transfer"
android:text="@string/button_transfer"
android:gravity="center"
android:paddingTop="40dp"
android:visibility="invisible"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/addCall"
android:background="@drawable/options_add_call_alt"
android:text="@string/button_add_call"
android:gravity="center"
android:paddingTop="40dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
@ -122,6 +178,18 @@
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/audioRoute"
android:visibility="gone"
android:background="@drawable/routes"
android:text="@string/button_route"
android:gravity="center"
android:paddingTop="45dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/options"
android:background="@drawable/options"

View file

@ -34,11 +34,11 @@
android:textColor="@android:color/black"
android:id="@+id/AboutText"/>
<Button android:id="@+id/about_report_issue"
<Button android:id="@+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_report_issue"
android:visibility="gone"
android:text="@string/menu_exit"
android:visibility="visible"
android:layout_marginTop="30sp"/>
</LinearLayout>

View file

@ -55,11 +55,11 @@
<LinearLayout
android:id="@+id/menu"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="right"
android:visibility="gone"
android:orientation="vertical" >
<LinearLayout
@ -71,19 +71,74 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_weight="0.25"/>
android:layout_weight="0.5"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_weight="0.5"/>
<TextView
android:id="@+id/routeBluetooth"
android:visibility="invisible"
android:background="@drawable/route_bluetooth_off"
android:text="@string/button_bluetooth"
android:gravity="center"
android:paddingTop="40dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_weight="0.5"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_weight="0.5"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_weight="0.5"/>
<TextView
android:id="@+id/routeReceiver"
android:visibility="invisible"
android:background="@drawable/route_receiver_off"
android:text="@string/button_receiver"
android:gravity="center"
android:paddingTop="40dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
<TextView
android:id="@+id/transfer"
android:visibility="invisible"
android:background="@drawable/options_transfer"
android:text="@string/button_transfer"
android:gravity="center"
android:paddingTop="40dp"
android:textColor="@drawable/text_incall_button_color"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.75" />
android:layout_weight="0.5" />
</LinearLayout>
@ -96,19 +151,37 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_weight="0.25"/>
android:layout_weight="0.5"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_weight="0.5"/>
<TextView
android:id="@+id/routeSpeaker"
android:visibility="invisible"
android:background="@drawable/route_speaker_off"
android:text="@string/button_speaker"
android:gravity="center"
android:paddingTop="40dp"
android:textColor="@drawable/text_incall_button_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
<TextView
android:id="@+id/addCall"
android:visibility="invisible"
android:background="@drawable/options_add_call_alt"
android:text="@string/button_add_call"
android:gravity="center"
android:paddingTop="40dp"
android:textColor="@drawable/text_incall_button_color"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.75" />
android:layout_weight="0.5" />
</LinearLayout>
@ -150,6 +223,18 @@
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/audioRoute"
android:background="@drawable/routes"
android:text="@string/button_route"
android:gravity="center"
android:paddingTop="45dp"
android:textColor="@drawable/text_incall_button_color"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/options"
android:background="@drawable/options"

View file

@ -315,6 +315,9 @@
<string name="button_video">Vidéo</string>
<string name="button_micro">Micro</string>
<string name="button_speaker">HP</string>
<string name="button_route">Route</string>
<string name="button_receiver">Ecouteur</string>
<string name="button_bluetooth">Bluetooth</string>
<string name="button_options">Options</string>
<string name="button_send_message">Envoyer</string>

View file

@ -363,6 +363,9 @@
<string name="button_video">Video</string>
<string name="button_micro">Micro</string>
<string name="button_speaker">Speaker</string>
<string name="button_route">Route</string>
<string name="button_receiver">Receiver</string>
<string name="button_bluetooth">Bluetooth</string>
<string name="button_options">Options</string>
<string name="button_send_message">Send</string>

View file

@ -18,34 +18,21 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import org.linphone.mediastream.Log;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
/**
* @author Sylvain Berfini
*/
public class AboutFragment extends Fragment implements OnClickListener {
private Handler mHandler = new Handler();
private FragmentsAvailable about = FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -63,12 +50,10 @@ public class AboutFragment extends Fragment implements OnClickListener {
Log.e(e, "cannot get version name");
}
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getActivity());
if (pref.getBoolean(getString(R.string.pref_debug_key), false)) {
View issue = view.findViewById(R.id.about_report_issue);
issue.setOnClickListener(this);
issue.setVisibility(View.VISIBLE);
}
View issue = view.findViewById(R.id.exit);
issue.setOnClickListener(this);
issue.setVisibility(View.VISIBLE);
return view;
}
@ -81,110 +66,10 @@ public class AboutFragment extends Fragment implements OnClickListener {
}
}
private Thread thread;
@Override
public void onClick(View v) {
if (thread != null) return;
Toast.makeText(getActivity(), getString(R.string.about_reading_logs), Toast.LENGTH_LONG).show();
thread = new ReadLogThread();
thread.start();
}
private File writeLogs(String logs, File directory) {
File tempFile = null;
try {
tempFile = File.createTempFile("bugreport", ".txt", directory);
tempFile.deleteOnExit();
FileWriter writer = new FileWriter(tempFile);
writer.append(logs);
writer.close();
return tempFile;
} catch (IOException e) {
Toast.makeText(getActivity(), getString(R.string.about_error_generating_bugreport_attachement), Toast.LENGTH_LONG).show();
Log.e(e, "couldn't write to temporary file");
return null;
}
}
private void onLogsRead(String logs) {
if (logs == null) {
Toast.makeText(getActivity(), getString(R.string.about_logs_not_found), Toast.LENGTH_SHORT).show();
} else {
File tempFile = writeLogs(logs, null);
if (tempFile == null) {
// If writing to temporary file to default location failed
// Write one to our storage place
tempFile = writeLogs(logs, getActivity().getFilesDir());
}
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{getString(R.string.about_bugreport_email)});
intent.putExtra(Intent.EXTRA_SUBJECT,"Bug report " + getString(R.string.app_name) + "-android");
intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.about_bugreport_email_text));
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(tempFile));
intent = Intent.createChooser(intent,getString(R.string.about_mailer_chooser_text));
startActivityForResult(intent, 0);
}
}
private class ReadLogThread extends Thread {
@Override
public void run() {
final String logs = readLogs();
mHandler.post(new Runnable() {
@Override
public void run() {
onLogsRead(logs);
thread=null;
}
});
super.run();
}
}
private String readLogs() {
StringBuilder sb1 = null;
StringBuilder sb2 = null;
BufferedReader br = null;
Process p = null;
try {
p = Runtime.getRuntime().exec(new String[] {"logcat", "-d"});
br = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
String line;
while ((line = br.readLine()) != null) {
if (line.contains(LinphoneService.START_LINPHONE_LOGS)) {
if (sb1 != null) {
sb2 = sb1;
}
sb1 = new StringBuilder();
}
if (sb1 != null) {
sb1.append(line).append('\n');
}
}
if (sb1 == null) return null;
if (sb2 != null) {
sb1.append(sb2);
}
return sb1.toString();
} catch (IOException e) {
Log.e(e, "Error while reading logs");
return null;
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {}
}
if (p != null) {
p.destroy();
}
if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().exit();
}
}
}

View file

@ -14,10 +14,6 @@ import android.os.Build;
public class BluetoothManager extends BroadcastReceiver {
@SuppressWarnings("deprecation")
public void onReceive(Context context, Intent intent) {
boolean routeToBT = context.getResources().getBoolean(R.bool.route_audio_to_bluetooth_if_available);
if (!routeToBT)
return;
String action = intent.getAction();
LinphoneManager lm = LinphoneManager.getInstance();
@ -26,7 +22,6 @@ public class BluetoothManager extends BroadcastReceiver {
Log.e("Bluetooth Received Event" + " ACTION_ACL_DISCONNECTED" );
if (lm != null) {
lm.isBluetoothScoConnected = false;
lm.scoDisconnected();
lm.routeAudioToReceiver();
}
@ -35,7 +30,6 @@ public class BluetoothManager extends BroadcastReceiver {
Log.e("Bluetooth Received Event" + " ACTION_ACL_CONNECTED" );
if (lm != null) {
lm.isBluetoothScoConnected = true;
lm.scoConnected();
}
}
@ -44,12 +38,10 @@ public class BluetoothManager extends BroadcastReceiver {
Log.e("Bluetooth sco state changed : " + state);
if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
if (lm != null) {
lm.isBluetoothScoConnected = true;
lm.scoConnected();
}
} else if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) {
if (lm != null) {
lm.isBluetoothScoConnected = false;
lm.scoDisconnected();
lm.routeAudioToReceiver();
}
@ -61,7 +53,6 @@ public class BluetoothManager extends BroadcastReceiver {
0); //BluetoothAdapter.STATE_DISCONNECTED
Log.e("Bluetooth state changed: " + currentConnState);
if (lm != null && currentConnState == 2) { //BluetoothAdapter.STATE_CONNECTED
lm.isBluetoothScoConnected = true;
lm.startBluetooth();
}
}

View file

@ -87,6 +87,8 @@ public class InCallActivity extends FragmentActivity implements
private Runnable mControls;
private ImageView pause, hangUp, dialer, switchCamera, conference;
private TextView video, micro, speaker, options, addCall, transfer;
private TextView audioRoute, routeSpeaker, routeReceiver, routeBluetooth;
private LinearLayout routeLayout;
private StatusFragment status;
private AudioCallFragment audioCallFragment;
private VideoCallFragment videoCallFragment;
@ -166,10 +168,6 @@ public class InCallActivity extends FragmentActivity implements
callFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commitAllowingStateLoss();
}
boolean routeToBT = getResources().getBoolean(R.bool.route_audio_to_bluetooth_if_available);
if (routeToBT && LinphoneManager.isInstanciated() && !isSpeakerEnabled)
LinphoneManager.getInstance().routeToBluetoothIfAvailable();
}
@Override
@ -219,6 +217,20 @@ public class InCallActivity extends FragmentActivity implements
dialer.setEnabled(false);
numpad = (Numpad) findViewById(R.id.numpad);
try {
routeLayout = (LinearLayout) findViewById(R.id.routesLayout);
audioRoute = (TextView) findViewById(R.id.audioRoute);
audioRoute.setOnClickListener(this);
routeSpeaker = (TextView) findViewById(R.id.routeSpeaker);
routeSpeaker.setOnClickListener(this);
routeReceiver = (TextView) findViewById(R.id.routeReceiver);
routeReceiver.setOnClickListener(this);
routeBluetooth = (TextView) findViewById(R.id.routeBluetooth);
routeBluetooth.setOnClickListener(this);
} catch (NullPointerException npe) {
Log.e("Audio routes menu disabled on tablets for now");
}
switchCamera = (ImageView) findViewById(R.id.switchCamera);
switchCamera.setOnClickListener(this);
@ -255,10 +267,39 @@ public class InCallActivity extends FragmentActivity implements
}
}
if (isSpeakerEnabled) {
speaker.setBackgroundResource(R.drawable.speaker_on);
if (LinphoneManager.getInstance().isBluetoothScoConnected) {
try {
routeLayout.setVisibility(View.VISIBLE);
} catch (NullPointerException npe) {}
audioRoute.setVisibility(View.VISIBLE);
speaker.setVisibility(View.GONE);
} else {
speaker.setBackgroundResource(R.drawable.speaker_off);
try {
routeLayout.setVisibility(View.GONE);
} catch (NullPointerException npe) {}
audioRoute.setVisibility(View.GONE);
speaker.setVisibility(View.VISIBLE);
}
try {
if (isSpeakerEnabled) {
speaker.setBackgroundResource(R.drawable.speaker_on);
routeSpeaker.setBackgroundResource(R.drawable.route_speaker_on);
routeReceiver.setBackgroundResource(R.drawable.route_receiver_off);
routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_off);
} else {
speaker.setBackgroundResource(R.drawable.speaker_off);
routeSpeaker.setBackgroundResource(R.drawable.route_speaker_off);
if (LinphoneManager.getInstance().isUsingBluetoothAudioRoute) {
routeReceiver.setBackgroundResource(R.drawable.route_receiver_off);
routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_on);
} else {
routeReceiver.setBackgroundResource(R.drawable.route_receiver_on);
routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_off);
}
}
} catch (NullPointerException npe) {
Log.e("Audio routes menu disabled on tablets for now");
}
if (isMicMuted) {
@ -360,8 +401,32 @@ public class InCallActivity extends FragmentActivity implements
}
else if (id == R.id.options) {
hideOrDisplayCallOptions();
}
}
else if (id == R.id.audioRoute) {
hideOrDisplayAudioRoutes();
}
else if (id == R.id.routeBluetooth) {
LinphoneManager.getInstance().routeAudioToBluetooth();
routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_on);
routeReceiver.setBackgroundResource(R.drawable.route_receiver_off);
routeSpeaker.setBackgroundResource(R.drawable.route_speaker_off);
hideOrDisplayAudioRoutes();
}
else if (id == R.id.routeReceiver) {
LinphoneManager.getInstance().routeAudioToReceiver();
routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_off);
routeReceiver.setBackgroundResource(R.drawable.route_receiver_on);
routeSpeaker.setBackgroundResource(R.drawable.route_speaker_off);
hideOrDisplayAudioRoutes();
}
else if (id == R.id.routeSpeaker) {
LinphoneManager.getInstance().routeAudioToSpeaker();
routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_off);
routeReceiver.setBackgroundResource(R.drawable.route_receiver_off);
routeSpeaker.setBackgroundResource(R.drawable.route_speaker_on);
hideOrDisplayAudioRoutes();
}
else if (id == R.id.callStatus) {
LinphoneCall call = (LinphoneCall) v.getTag();
pauseOrResumeCall(call);
@ -483,10 +548,6 @@ public class InCallActivity extends FragmentActivity implements
} else {
LinphoneManager.getInstance().routeAudioToReceiver();
speaker.setBackgroundResource(R.drawable.speaker_off);
boolean routeToBT = getResources().getBoolean(R.bool.route_audio_to_bluetooth_if_available);
if (!routeToBT)
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
}
}
@ -878,6 +939,38 @@ public class InCallActivity extends FragmentActivity implements
addCall.startAnimation(animation);
}
private void hideOrDisplayAudioRoutes()
{
if (isSpeakerEnabled) {
speaker.setBackgroundResource(R.drawable.speaker_on);
routeSpeaker.setBackgroundResource(R.drawable.route_speaker_on);
routeReceiver.setBackgroundResource(R.drawable.route_receiver_off);
routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_off);
} else {
speaker.setBackgroundResource(R.drawable.speaker_off);
routeSpeaker.setBackgroundResource(R.drawable.route_speaker_off);
if (LinphoneManager.getInstance().isUsingBluetoothAudioRoute) {
routeReceiver.setBackgroundResource(R.drawable.route_receiver_off);
routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_on);
} else {
routeReceiver.setBackgroundResource(R.drawable.route_receiver_on);
routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_off);
}
}
if (routeSpeaker.getVisibility() == View.VISIBLE) {
routeSpeaker.setVisibility(View.INVISIBLE);
routeBluetooth.setVisibility(View.INVISIBLE);
routeReceiver.setVisibility(View.INVISIBLE);
audioRoute.setSelected(false);
} else {
routeSpeaker.setVisibility(View.VISIBLE);
routeBluetooth.setVisibility(View.VISIBLE);
routeReceiver.setVisibility(View.VISIBLE);
audioRoute.setSelected(true);
}
}
private void hideOrDisplayCallOptions() {
boolean isOrientationLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
@ -895,6 +988,7 @@ public class InCallActivity extends FragmentActivity implements
hideAnimatedPortraitCallOptions();
}
}
options.setSelected(false);
} else {
if (isAnimationDisabled) {
if (isTransferAllowed) {
@ -909,6 +1003,7 @@ public class InCallActivity extends FragmentActivity implements
showAnimatedPortraitCallOptions();
}
}
options.setSelected(true);
transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null);
}
}
@ -977,13 +1072,7 @@ public class InCallActivity extends FragmentActivity implements
switchVideo(isVideoEnabled, false);
}
boolean routeToBT = getResources().getBoolean(R.bool.route_audio_to_bluetooth_if_available);
if (routeToBT && LinphoneManager.isInstanciated() && !isSpeakerEnabled) {
LinphoneManager.getInstance().routeToBluetoothIfAvailable();
} else {
// The following should not be needed except some devices need it (e.g. Galaxy S).
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
}
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
isMicMuted = LinphoneManager.getLc().isMicMuted();
enableAndRefreshInCallActions();

View file

@ -155,6 +155,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
private BluetoothProfile.ServiceListener mProfileListener;
private BroadcastReceiver bluetoothReiceiver = new BluetoothManager();
public boolean isBluetoothScoConnected;
public boolean isUsingBluetoothAudioRoute;
private static List<LinphoneSimpleListener> simpleListeners = new ArrayList<LinphoneSimpleListener>();
public static void addListener(LinphoneSimpleListener listener) {
@ -204,30 +205,27 @@ public final class LinphoneManager implements LinphoneCoreListener {
private BroadcastReceiver mKeepAliveReceiver = new KeepAliveReceiver();
private void routeAudioToSpeakerHelper(boolean speakerOn) {
boolean routeToBluetoothEnabled = false;
isUsingBluetoothAudioRoute = false;
if (mAudioManager != null) {
mAudioManager.setMode(AudioManager.MODE_NORMAL);
mAudioManager.stopBluetoothSco();
mAudioManager.setBluetoothScoOn(false);
}
if (!speakerOn) {
boolean routeToBT = mServiceContext.getResources().getBoolean(R.bool.route_audio_to_bluetooth_if_available);
if (!routeToBT || (routeToBT && !routeToBluetoothIfAvailable())) {
mLc.enableSpeaker(false);
scoDisconnected();
} else {
Log.d("Routing audio to bluetooth headset");
routeToBluetoothEnabled = true;
}
mLc.enableSpeaker(false);
} else {
mLc.enableSpeaker(true);
scoDisconnected();
}
for (LinphoneOnAudioChangedListener listener : getSimpleListeners(LinphoneOnAudioChangedListener.class)) {
listener.onAudioStateChanged(speakerOn ? AudioState.SPEAKER : (routeToBluetoothEnabled ? AudioState.BLUETOOTH : AudioState.EARPIECE));
listener.onAudioStateChanged(speakerOn ? AudioState.SPEAKER : AudioState.EARPIECE);
}
}
public void routeAudioToSpeaker() {
routeAudioToSpeakerHelper(true);
}
public String getUserAgent() throws NameNotFoundException {
StringBuilder userAgent = new StringBuilder();
userAgent.append("LinphoneAndroid/" + mServiceContext.getPackageManager().getPackageInfo(mServiceContext.getPackageName(),0).versionCode);
@ -256,7 +254,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
if (profile == BluetoothProfile.HEADSET) {
mBluetoothHeadset = (BluetoothHeadset) proxy;
Log.d("Bluetooth headset connected");
routeToBluetoothIfAvailable();
isBluetoothScoConnected = true;
}
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@ -264,6 +262,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
if (profile == BluetoothProfile.HEADSET) {
mBluetoothHeadset = null;
Log.d("Bluetooth headset disconnected");
isBluetoothScoConnected = false;
routeAudioToReceiver();
}
}
@ -276,40 +275,42 @@ public final class LinphoneManager implements LinphoneCoreListener {
int state = currentValue == null ? 0 : currentValue.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, 0);
if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
isBluetoothScoConnected = true;
scoConnected();
}
}
}
else {
} else {
isBluetoothScoConnected = false;
scoDisconnected();
routeAudioToReceiver();
}
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean routeToBluetoothIfAvailable() {
public boolean routeAudioToBluetooth() {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter.isEnabled() && mAudioManager.isBluetoothScoAvailableOffCall()) {
mAudioManager.setBluetoothScoOn(true);
mAudioManager.startBluetoothSco();
if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
boolean connected = false;
isUsingBluetoothAudioRoute = false;
if (mBluetoothHeadset != null) {
List<BluetoothDevice> devices = mBluetoothHeadset.getConnectedDevices();
for (final BluetoothDevice dev : devices) {
connected |= mBluetoothHeadset.getConnectionState(dev) == BluetoothHeadset.STATE_CONNECTED;
isUsingBluetoothAudioRoute |= mBluetoothHeadset.getConnectionState(dev) == BluetoothHeadset.STATE_CONNECTED;
}
}
if (!connected) {
if (!isUsingBluetoothAudioRoute) {
Log.d("No bluetooth device available");
scoDisconnected();
} else {
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
for (LinphoneOnAudioChangedListener listener : getSimpleListeners(LinphoneOnAudioChangedListener.class)) {
listener.onAudioStateChanged(AudioState.SPEAKER);
}
}
return connected;
} else {
return isBluetoothScoConnected;
}
return isUsingBluetoothAudioRoute;
}
return false;
@ -317,12 +318,13 @@ public final class LinphoneManager implements LinphoneCoreListener {
public void scoConnected() {
Log.e("Bluetooth sco connected!");
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
routeToBluetoothIfAvailable();
isBluetoothScoConnected = true;
}
public void scoDisconnected() {
Log.e("Bluetooth sco disconnected!");
isUsingBluetoothAudioRoute = false;
isBluetoothScoConnected = false;
if (mAudioManager != null) {
mAudioManager.setMode(AudioManager.MODE_NORMAL);
mAudioManager.stopBluetoothSco();
@ -410,8 +412,8 @@ public final class LinphoneManager implements LinphoneCoreListener {
}
}
public void resetCameraFromPreferences() {
boolean useFrontCam = getPrefBoolean(R.string.pref_video_use_front_camera_key, false);
private void resetCameraFromPreferences() {
boolean useFrontCam = getPrefBoolean(R.string.pref_video_use_front_camera_key, mR.getBoolean(R.bool.pref_video_use_front_camera_default));
int camId = 0;
AndroidCamera[] cameras = AndroidCameraConfiguration.retrieveCameras();
@ -583,7 +585,8 @@ public final class LinphoneManager implements LinphoneCoreListener {
lFilter.addAction(Intent.ACTION_SCREEN_OFF);
mServiceContext.registerReceiver(mKeepAliveReceiver, lFilter);
startBluetooth();
resetCameraFromPreferences();
}
catch (Exception e) {
Log.e(e, "Cannot start linphone");

View file

@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import org.linphone.LinphoneManager;
import org.linphone.R;
import org.linphone.mediastream.Log;
import org.linphone.mediastream.video.capture.hwconf.Hacks;
import android.app.Activity;
import android.content.Context;

@ -1 +1 @@
Subproject commit 43ad4169d316649ed2e31eba1f9b19792d5cc492
Subproject commit 2e7d9876c076edd425827694162020ad2f7ad21f

@ -1 +1 @@
Subproject commit 2212cf0fce0030623984a6682db97410b14f0d6a
Subproject commit 2fede18b16402eec3779599b46e21d742d85ee02