From d5ce3dc4b87e4baa2536f368e37e1695acd1747e Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 5 Jun 2012 17:23:30 +0200 Subject: [PATCH] Changes to make project library compatible --- res/layout/simplified_dialer.xml | 2 +- src/org/linphone/AbstractCalleesActivity.java | 11 ++- .../linphone/ConferenceDetailsActivity.java | 12 ++-- src/org/linphone/HistoryActivity.java | 10 ++- src/org/linphone/IncallActivity.java | 72 +++++++++---------- src/org/linphone/LinphoneActivity.java | 15 ++-- src/org/linphone/VideoCallActivity.java | 70 +++++++++--------- 7 files changed, 93 insertions(+), 99 deletions(-) diff --git a/res/layout/simplified_dialer.xml b/res/layout/simplified_dialer.xml index 264caf1df..7159abdb1 100644 --- a/res/layout/simplified_dialer.xml +++ b/res/layout/simplified_dialer.xml @@ -1,6 +1,6 @@ diff --git a/src/org/linphone/AbstractCalleesActivity.java b/src/org/linphone/AbstractCalleesActivity.java index c20fbe4dd..9c2058d8f 100644 --- a/src/org/linphone/AbstractCalleesActivity.java +++ b/src/org/linphone/AbstractCalleesActivity.java @@ -268,19 +268,16 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li @Override public void onClick(View v) { - switch (v.getId()) { - case R.id.toggleMuteMic: + int id = v.getId(); + if (id == R.id.toggleMuteMic) { lc().muteMic(((Checkable) v).isChecked()); - break; - case R.id.toggleSpeaker: + } + else if (id == R.id.toggleSpeaker) { if (((Checkable) v).isChecked()) { LinphoneManager.getInstance().routeAudioToSpeaker(); } else { LinphoneManager.getInstance().routeAudioToReceiver(); } - break; - default: - break; } } diff --git a/src/org/linphone/ConferenceDetailsActivity.java b/src/org/linphone/ConferenceDetailsActivity.java index a0bb02d8b..f9ebc4763 100644 --- a/src/org/linphone/ConferenceDetailsActivity.java +++ b/src/org/linphone/ConferenceDetailsActivity.java @@ -119,17 +119,17 @@ public class ConferenceDetailsActivity extends AbstractCalleesActivity { this.dialog = dialog; } public void onClick(View v) { - switch (v.getId()) { - case R.id.terminate_call: + int id = v.getId(); + if (id == R.id.terminate_call) { lc().terminateCall(call); - break; - case R.id.remove_from_conference: + } + else if (id == R.id.remove_from_conference) { lc().removeFromConference(call); if (LinphoneUtils.countConferenceCalls(lc()) == 0) { finish(); } - break; - default: + } + else { throw new RuntimeException("unknown id " + v.getId()); } if (dialog != null) dialog.dismiss(); diff --git a/src/org/linphone/HistoryActivity.java b/src/org/linphone/HistoryActivity.java index ffa379697..8be51601e 100644 --- a/src/org/linphone/HistoryActivity.java +++ b/src/org/linphone/HistoryActivity.java @@ -95,15 +95,13 @@ public class HistoryActivity extends ListActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_clear_history: + int id = item.getItemId(); + if (id == R.id.menu_clear_history) { LinphoneManager.getLc().clearCallLogs(); setListAdapter(new CallHistoryAdapter(this)); - - break; - default: + } + else { Log.e("Unknown menu item [",item,"]"); - break; } return false; diff --git a/src/org/linphone/IncallActivity.java b/src/org/linphone/IncallActivity.java index 3f2c3fdaf..f18a81b3e 100644 --- a/src/org/linphone/IncallActivity.java +++ b/src/org/linphone/IncallActivity.java @@ -332,29 +332,29 @@ public class IncallActivity extends AbstractCalleesActivity implements } public void onClick(View v) { - switch (v.getId()) { - case R.id.addCall: + int id = v.getId(); + if (id == R.id.addCall) { finish(); - break; - case R.id.incallHang: + } + else if (id == R.id.incallHang) { terminateCurrentCallOrConferenceOrAll(); - break; - case R.id.conf_header: + } + else if (id == R.id.conf_header) { boolean enterConf = !lc().isInConference(); enterConferenceAndVirtualConfView(enterConf); - break; - case R.id.conf_header_details: + } + else if (id == R.id.conf_header_details) { onLongClick(v); - break; - case R.id.incallNumpadShow: + } + else if (id == R.id.incallNumpadShow) { showDialog(numpadDialogId); - break; - case R.id.conf_simple_merge: + } + else if (id == R.id.conf_simple_merge) { if (!lc().soundResourcesLocked()) { lc().addAllToConference(); } - break; - case R.id.conf_simple_pause: + } + else if (id == R.id.conf_simple_pause) { LinphoneCall call = lc().getCurrentCall(); if (call != null) { lc().pauseCall(call); @@ -366,8 +366,8 @@ public class IncallActivity extends AbstractCalleesActivity implements lc().resumeCall(callToResume); } } - break; - case R.id.conf_simple_video: + } + else if (id == R.id.conf_simple_video) { LinphoneCall vCall = lc().getCurrentCall(); if (vCall != null) { if (!vCall.cameraEnabled() && vCall.getCurrentParamsCopy().getVideoEnabled()) { @@ -378,8 +378,8 @@ public class IncallActivity extends AbstractCalleesActivity implements LinphoneActivity.instance().startVideoActivity(vCall, 0); } } - break; - default: + } + else { // mic, speaker super.onClick(v); } @@ -431,21 +431,21 @@ public class IncallActivity extends AbstractCalleesActivity implements this.dialog = dialog; } public void onClick(View v) { - switch (v.getId()) { - case R.id.merge_to_conference: + int id =v.getId(); + if (id == R.id.merge_to_conference) { lc().addToConference(call); - break; - case R.id.terminate_call: + } + else if (id == R.id.terminate_call) { lc().terminateCall(call); - break; - case R.id.transfer_existing: + } + else if (id == R.id.transfer_existing) { prepareForTransferingExistingOrNewCall(call); - break; - case R.id.transfer_new: + } + else if (id == R.id.transfer_new) { openUriPicker(UriPickerActivity.EXTRA_PICKER_TYPE_TRANSFER, transferCallId); mCallToTransfer = call; - break; - case R.id.addVideo: + } + else if (id == R.id.addVideo) { if (!call.cameraEnabled() && call.getCurrentParamsCopy().getVideoEnabled()) { // NoWebcam mode, we let it this way LinphoneActivity.instance().startVideoActivity(call, 0); @@ -453,17 +453,17 @@ public class IncallActivity extends AbstractCalleesActivity implements else if (!LinphoneManager.getInstance().addVideo()) { LinphoneActivity.instance().startVideoActivity(call, 0); } - break; - case R.id.set_auth_token_verified: + } + else if (id == R.id.set_auth_token_verified) { call.setAuthenticationTokenVerified(true); - break; - case R.id.set_auth_token_not_verified: + } + else if (id == R.id.set_auth_token_not_verified) { call.setAuthenticationTokenVerified(false); - break; - case R.id.encrypted: + } + else if (id == R.id.encrypted) { call.setAuthenticationTokenVerified(!call.isAuthenticationTokenVerified()); - break; - default: + } + else { throw new RuntimeException("unknown id " + v.getId()); } if (dialog != null) dialog.dismiss(); diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index 628065d67..f422159aa 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -263,21 +263,22 @@ public class LinphoneActivity extends TabActivity implements ContactPicked @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_settings: + int id = item.getItemId(); + if (id == R.id.menu_settings) { startprefActivity(); return true; - case R.id.menu_exit: + } + else if (id == R.id.menu_exit) { finish(); stopService(new Intent(ACTION_MAIN) .setClass(this, LinphoneService.class)); - break; - case R.id.menu_about: + } + else if (id == R.id.menu_about) { startActivity(new Intent(ACTION_MAIN) .setClass(this, AboutActivity.class)); - default: + } + else { Log.e("Unknown menu item [",item,"]"); - break; } return false; diff --git a/src/org/linphone/VideoCallActivity.java b/src/org/linphone/VideoCallActivity.java index 49e4b1a5d..e707f430f 100755 --- a/src/org/linphone/VideoCallActivity.java +++ b/src/org/linphone/VideoCallActivity.java @@ -260,12 +260,12 @@ public class VideoCallActivity extends Activity implements @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.videocall_menu_back_to_dialer: + int id = item.getItemId(); + if (id == R.id.videocall_menu_back_to_dialer) { finish(); LinphoneActivity.instance().startIncallActivity(); - break; - case R.id.videocall_menu_change_resolution: + } + else if (id == R.id.videocall_menu_change_resolution) { LinphoneManager.getInstance().changeResolution(); // previous call will cause graph reconstruction -> regive preview // window @@ -273,11 +273,11 @@ public class VideoCallActivity extends Activity implements LinphoneManager.getLc() .setPreviewWindow(mVideoCaptureViewReady); rewriteChangeResolutionItem(item); - break; - case R.id.videocall_menu_terminate_call: + } + else if (id == R.id.videocall_menu_terminate_call) { LinphoneManager.getInstance().terminateCall(); - break; - case R.id.videocall_menu_toggle_camera: + } + else if (id == R.id.videocall_menu_toggle_camera) { boolean camEnabled = LinphoneManager.getInstance() .toggleEnableCamera(); updatePreview(camEnabled); @@ -291,21 +291,20 @@ public class VideoCallActivity extends Activity implements mVideoCaptureViewReady); } else LinphoneManager.getLc().setPreviewWindow(null); - break; - case R.id.videocall_menu_switch_camera: - int id = LinphoneManager.getLc().getVideoDevice(); - id = (id + 1) % AndroidCameraConfiguration.retrieveCameras().length; - LinphoneManager.getLc().setVideoDevice(id); + } + else if (id == R.id.videocall_menu_switch_camera) { + int videoDeviceId = LinphoneManager.getLc().getVideoDevice(); + videoDeviceId = (videoDeviceId + 1) % AndroidCameraConfiguration.retrieveCameras().length; + LinphoneManager.getLc().setVideoDevice(videoDeviceId); CallManager.getInstance().updateCall(); // previous call will cause graph reconstruction -> regive preview // window if (mVideoCaptureViewReady != null) LinphoneManager.getLc() .setPreviewWindow(mVideoCaptureViewReady); - break; - default: + } + else { Log.e("Unknown menu item [", item, "]"); - break; } return true; } @@ -500,48 +499,47 @@ public class VideoCallActivity extends Activity implements public void onClick(View v) { resetControlsLayoutExpiration(); - switch (v.getId()) { - case R.id.incallHang: + int id = v.getId(); + if (id == R.id.incallHang) { terminateCurrentCallOrConferenceOrAll(); - break; - case R.id.toggleSpeaker: + } + else if (id == R.id.toggleSpeaker) { if (((Checkable) v).isChecked()) { LinphoneManager.getInstance().routeAudioToSpeaker(); } else { LinphoneManager.getInstance().routeAudioToReceiver(); } - break; - case R.id.incallNumpadShow: + } + else if (id == R.id.incallNumpadShow) { showDialog(numpadDialogId); - break; - case R.id.toggleMuteMic: + } + else if (id == R.id.toggleMuteMic) { LinphoneManager.getLc().muteMic(((Checkable) v).isChecked()); - break; - case R.id.switch_camera: - int id = LinphoneManager.getLc().getVideoDevice(); - id = (id + 1) % AndroidCameraConfiguration.retrieveCameras().length; - LinphoneManager.getLc().setVideoDevice(id); + } + else if (id == R.id.switch_camera) { + int videoDeviceId = LinphoneManager.getLc().getVideoDevice(); + videoDeviceId = (videoDeviceId + 1) % AndroidCameraConfiguration.retrieveCameras().length; + LinphoneManager.getLc().setVideoDevice(videoDeviceId); CallManager.getInstance().updateCall(); // previous call will cause graph reconstruction -> regive preview // window if (mVideoCaptureViewReady != null) LinphoneManager.getLc() .setPreviewWindow(mVideoCaptureViewReady); - break; - case R.id.conf_simple_pause: + } + else if (id == R.id.conf_simple_pause) { finish(); LinphoneActivity.instance().startIncallActivity(); LinphoneManager.getLc().pauseCall(videoCall); - break; - case R.id.conf_simple_video: + } + else if (id == R.id.conf_simple_video) { LinphoneCallParams params = videoCall.getCurrentParamsCopy(); params.setVideoEnabled(false); LinphoneManager.getLc().updateCall(videoCall, params); - break; - case R.id.back: + } + else if (id == R.id.back) { finish(); LinphoneActivity.instance().startIncallActivity(); - break; } }