- Timestamp:
- Dec 14, 2013 1:14:07 AM (11 years ago)
- Location:
- pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/java/android
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/java/android/res/layout/activity_call.xml
r4691 r4693 4 4 android:layout_height="match_parent" 5 5 android:gravity="center" 6 android:paddingBottom="@dimen/activity_vertical_margin" 7 android:paddingLeft="@dimen/activity_horizontal_margin" 8 android:paddingRight="@dimen/activity_horizontal_margin" 9 android:paddingTop="@dimen/activity_vertical_margin" 6 10 android:orientation="vertical" > 7 11 -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/java/android/src/org/pjsip/pjsua2/app/CallActivity.java
r4691 r4693 24 24 import android.view.View; 25 25 import android.widget.Button; 26 import android.widget.EditText;27 26 import android.widget.TextView; 28 27 import android.app.Activity; 29 import android.app.AlertDialog;30 import android.content.DialogInterface;31 28 32 29 import org.pjsip.pjsua2.*; … … 34 31 public class CallActivity extends Activity implements Handler.Callback { 35 32 36 public final Handler handler = new Handler(this);37 33 public static Handler handler_; 34 35 private final Handler handler = new Handler(this); 36 private static CallInfo lastCallInfo; 38 37 39 38 @Override … … 43 42 44 43 handler_ = handler; 45 MyCall call = MainActivity.currentCall; 46 47 final TextView tvPeer = (TextView) findViewById(R.id.textViewPeer); 48 final TextView tvState = (TextView) findViewById(R.id.textViewCallState); 49 final Button buttonAccept = (Button) findViewById(R.id.buttonAccept); 50 final Button buttonHangup = (Button) findViewById(R.id.buttonHangup); 51 52 String remote_uri = "Somebody"; 53 String call_state = ""; 54 try { 55 CallInfo ci = call.getInfo(); 56 remote_uri = ci.getRemoteUri(); 57 if (ci.getRole() == pjsip_role_e.PJSIP_ROLE_UAS) { 58 call_state = "Incoming call.."; 59 } else { 60 buttonAccept.setVisibility(View.GONE); 61 buttonHangup.setText("Cancel"); 62 call_state = ci.getStateText(); 44 if (MainActivity.currentCall != null) { 45 try { 46 lastCallInfo = MainActivity.currentCall.getInfo(); 47 updateCallState(lastCallInfo); 48 } catch (Exception e) { 49 System.out.println(e); 63 50 } 64 } catch (Exception e){65 System.out.println(e);51 } else { 52 updateCallState(lastCallInfo); 66 53 } 67 68 tvPeer.setText(remote_uri);69 tvState.setText(call_state);70 54 } 71 55 … … 110 94 if (m.what == MainActivity.MSG_TYPE.CALL_STATE) { 111 95 112 TextView tvState = (TextView) findViewById(R.id.textViewCallState); 113 Button buttonHangup = (Button) findViewById(R.id.buttonHangup); 114 Button buttonAccept = (Button) findViewById(R.id.buttonAccept); 115 116 CallInfo ci = (CallInfo) m.obj; 117 String call_state = ""; 118 if (ci.getRole() == pjsip_role_e.PJSIP_ROLE_UAC || 119 ci.getState().swigValue() >= pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED.swigValue()) 120 { 121 call_state = ci.getStateText(); 122 tvState.setText(call_state); 123 } 124 125 if (ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED) { 126 buttonHangup.setText("Hangup"); 127 } 128 129 if (ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) { 130 buttonHangup.setText("OK"); 131 buttonAccept.setVisibility(View.GONE); 132 tvState.setText("Call disconnected: " + ci.getLastReason()); 133 MainActivity.currentCall = null; 134 } 96 lastCallInfo = (CallInfo) m.obj; 97 updateCallState(lastCallInfo); 135 98 136 99 } else { … … 144 107 } 145 108 146 109 private void updateCallState(CallInfo ci) { 110 TextView tvPeer = (TextView) findViewById(R.id.textViewPeer); 111 TextView tvState = (TextView) findViewById(R.id.textViewCallState); 112 Button buttonHangup = (Button) findViewById(R.id.buttonHangup); 113 Button buttonAccept = (Button) findViewById(R.id.buttonAccept); 114 String call_state = ""; 115 116 if (ci.getRole() == pjsip_role_e.PJSIP_ROLE_UAC) { 117 buttonAccept.setVisibility(View.GONE); 118 } 119 120 if (ci.getState().swigValue() < pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED.swigValue()) 121 { 122 if (ci.getRole() == pjsip_role_e.PJSIP_ROLE_UAS) { 123 call_state = "Incoming call.."; 124 /* Default button texts are already 'Accept' & 'Reject' */ 125 } else { 126 buttonHangup.setText("Cancel"); 127 call_state = ci.getStateText(); 128 } 129 } 130 else if (ci.getState().swigValue() >= pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED.swigValue()) 131 { 132 buttonAccept.setVisibility(View.GONE); 133 call_state = ci.getStateText(); 134 if (ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED) { 135 buttonHangup.setText("Hangup"); 136 } else if (ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) { 137 buttonHangup.setText("OK"); 138 call_state = "Call disconnected: " + ci.getLastReason(); 139 MainActivity.currentCall = null; 140 } 141 } 142 143 tvPeer.setText(ci.getRemoteUri()); 144 tvState.setText(call_state); 145 } 147 146 } -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/java/android/src/org/pjsip/pjsua2/app/MainActivity.java
r4691 r4693 44 44 45 45 public class MainActivity extends Activity implements Handler.Callback, MyAppObserver { 46 public static MyApp app = n ew MyApp();46 public static MyApp app = null; 47 47 public static MyCall currentCall = null; 48 48 public static MyAccount account = null; … … 81 81 setContentView(R.layout.activity_main); 82 82 83 app.init(this, getFilesDir().getAbsolutePath()); 83 if (app == null) { 84 app = new MyApp(); 85 app.init(this, getFilesDir().getAbsolutePath()); 86 } 87 84 88 if (app.accList.size() == 0) { 85 89 accCfg = new AccountConfig(); … … 177 181 //buddyListView.performItemClick(buddyListView, buddyListSelectedIdx, 178 182 // buddyListView.getItemIdAtPosition(buddyListSelectedIdx)); 183 184 /* Return back Call activity */ 185 notifyCallState(currentCall); 179 186 } 180 187
Note: See TracChangeset
for help on using the changeset viewer.