Fix UI in call view

This commit is contained in:
Erwan Croze 2017-06-05 15:43:04 +02:00
parent 80c5c0226f
commit 9b28d555fe
2 changed files with 28 additions and 14 deletions

View file

@ -129,6 +129,12 @@ public class BluetoothManager extends BroadcastReceiver {
} }
} }
private void refreshCallView() {
if (CallActivity.isInstanciated()) {
CallActivity.instance().refreshInCallActions();
}
}
private boolean ensureInit() { private boolean ensureInit() {
if (mBluetoothAdapter == null) { if (mBluetoothAdapter == null) {
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
@ -257,6 +263,8 @@ public class BluetoothManager extends BroadcastReceiver {
if (LinphoneManager.isInstanciated()) { if (LinphoneManager.isInstanciated()) {
LinphoneManager.getInstance().routeAudioToReceiver(); LinphoneManager.getInstance().routeAudioToReceiver();
} }
refreshCallView();
} }
public void destroy() { public void destroy() {
@ -287,9 +295,14 @@ public class BluetoothManager extends BroadcastReceiver {
Log.d("[Bluetooth] SCO state: disconnected"); Log.d("[Bluetooth] SCO state: disconnected");
// LinphoneManager.getInstance().audioStateChanged(AudioState.SPEAKER); // LinphoneManager.getInstance().audioStateChanged(AudioState.SPEAKER);
isScoConnected = false; isScoConnected = false;
} else if (state == AudioManager.SCO_AUDIO_STATE_CONNECTING) {
Log.d("[Bluetooth] SCO state: connecting");
// LinphoneManager.getInstance().audioStateChanged(AudioState.BLUETOOTH);
isScoConnected = true;
} else { } else {
Log.d("[Bluetooth] SCO state: " + state); Log.d("[Bluetooth] SCO state: " + state);
} }
refreshCallView();
} }
else if (BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED.equals(action)) { else if (BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED.equals(action)) {
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, BluetoothAdapter.STATE_DISCONNECTED); int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, BluetoothAdapter.STATE_DISCONNECTED);

View file

@ -546,18 +546,20 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
} }
try { try {
if (isSpeakerEnabled) { routeSpeaker.setImageResource(R.drawable.route_speaker);
routeSpeaker.setImageResource(R.drawable.route_speaker_selected); if (BluetoothManager.getInstance().isUsingBluetoothAudioRoute()) {
isSpeakerEnabled = false; // We need this if isSpeakerEnabled wasn't set correctly
routeEarpiece.setImageResource(R.drawable.route_earpiece); routeEarpiece.setImageResource(R.drawable.route_earpiece);
routeBluetooth.setImageResource(R.drawable.route_bluetooth_selected);
return;
} else {
routeEarpiece.setImageResource(R.drawable.route_earpiece_selected);
routeBluetooth.setImageResource(R.drawable.route_bluetooth); routeBluetooth.setImageResource(R.drawable.route_bluetooth);
} }
routeSpeaker.setImageResource(R.drawable.route_speaker); if (isSpeakerEnabled) {
if (BluetoothManager.getInstance().isUsingBluetoothAudioRoute()) { routeSpeaker.setImageResource(R.drawable.route_speaker_selected);
routeEarpiece.setImageResource(R.drawable.route_earpiece); routeEarpiece.setImageResource(R.drawable.route_earpiece);
routeBluetooth.setImageResource(R.drawable.route_bluetooth_selected);
} else {
routeEarpiece.setImageResource(R.drawable.route_earpiece_selected);
routeBluetooth.setImageResource(R.drawable.route_bluetooth); routeBluetooth.setImageResource(R.drawable.route_bluetooth);
} }
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
@ -1008,8 +1010,7 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
} }
} }
private void hideOrDisplayAudioRoutes() private void hideOrDisplayAudioRoutes() {
{
if (routeSpeaker.getVisibility() == View.VISIBLE) { if (routeSpeaker.getVisibility() == View.VISIBLE) {
routeSpeaker.setVisibility(View.INVISIBLE); routeSpeaker.setVisibility(View.INVISIBLE);
routeBluetooth.setVisibility(View.INVISIBLE); routeBluetooth.setVisibility(View.INVISIBLE);