Ability to limit number of calls / hide transfers.

This commit is contained in:
Guillaume Beraudo 2011-10-18 15:44:35 +02:00
parent 95e8740e38
commit c4838ad1fa
6 changed files with 53 additions and 23 deletions

View file

@ -6,7 +6,7 @@
<bool name="use_android_contact_picker">true</bool>
<bool name="useFirstLoginActivity">false</bool>
<bool name="useFirstLoginActivity">false</bool>
<bool name="useMenuSettings">true</bool>
<bool name="useMenuAbout">true</bool>
<bool name="use_incall_activity">false</bool>
@ -17,9 +17,11 @@
<bool name="use_incoming_call_activity">true</bool>
<bool name="show_full_remote_address_on_incoming_call">true</bool>
<bool name="allow_transfers">true</bool>
<bool name="allow_edit_in_dialer">true</bool>
<color name="conf_active_bg_color">#191970</color>
<string name="about_bugreport_email">linphone-android@belledonne-communications.com</string>
</resources>

View file

@ -116,12 +116,15 @@ public class ConferenceActivity extends ListActivity implements
private ToggleButton mMuteMicButton;
private ToggleButton mSpeakerButton;
private boolean useVideoActivity;
private int multipleCallsLimit;
private boolean allowTransfers;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.conferencing);
allowTransfers = getResources().getBoolean(R.bool.allow_transfers);
confHeaderView = findViewById(R.id.conf_header);
confHeaderView.setOnClickListener(this);
@ -129,7 +132,11 @@ public class ConferenceActivity extends ListActivity implements
findViewById(R.id.incallNumpadShow).setOnClickListener(this);
findViewById(R.id.conf_simple_merge).setOnClickListener(this);
findViewById(R.id.conf_simple_transfer).setOnClickListener(this);
View transferView = findViewById(R.id.conf_simple_transfer);
transferView.setOnClickListener(this);
if (!allowTransfers) {
transferView.setVisibility(View.GONE);
}
findViewById(R.id.conf_simple_permute).setOnClickListener(this);
mMuteMicButton = (ToggleButton) findViewById(R.id.toggleMuteMic);
@ -140,6 +147,7 @@ public class ConferenceActivity extends ListActivity implements
waitHelper = new LinphoneManagerWaitHelper(this, this);
waitHelper.doManagerDependentOnCreate();
useVideoActivity = getResources().getBoolean(R.bool.use_video_activity);
// workaroundStatusBarBug();
super.onCreate(savedInstanceState);
}
@ -150,6 +158,7 @@ public class ConferenceActivity extends ListActivity implements
setListAdapter(new CalleeListAdapter(calls));
findViewById(R.id.incallHang).setOnClickListener(this);
multipleCallsLimit = lc().getMaxCalls();
}
@Override
public void onResumeWhenManagerReady() {
@ -162,11 +171,19 @@ public class ConferenceActivity extends ListActivity implements
adapter.linphoneCalls.clear();
adapter.linphoneCalls.addAll(getInitialCalls());
}
adapter.notifyDataSetInvalidated();
adapter.notifyDataSetChanged();
recreateActivity(adapter);
LinphoneManager.startProximitySensorForActivity(this);
mSpeakerButton.setChecked(LinphoneManager.getInstance().isSpeakerOn());
mMuteMicButton.setChecked(LinphoneManager.getLc().isMicMuted());
if (multipleCallsLimit > 0) {
updateAddCallButton();
}
}
private void updateAddCallButton() {
boolean limitReached = lc().getCallsNb() >= multipleCallsLimit;
findViewById(R.id.addCall).setVisibility(limitReached ? GONE : VISIBLE);
}
@Override
@ -464,8 +481,9 @@ public class ConferenceActivity extends ListActivity implements
}
private boolean aConferenceIsPossible() {
if (lc().getCallsNb() < 2)
if (lc().getCallsNb() < 2) {
return false;
}
int count = 0;
for (LinphoneCall call : linphoneCalls) {
final LinphoneCall.State state = call.getState();
@ -595,14 +613,14 @@ public class ConferenceActivity extends ListActivity implements
unhookCallButton.setOnClickListener(l);
removeFromConfButton.setOnClickListener(l);
addVideoButton.setOnClickListener(l);
v.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
View content = getLayoutInflater().inflate(R.layout.conf_choices_dialog, null);
Dialog dialog = new AlertDialog.Builder(ConferenceActivity.this).setView(content).create();
OnClickListener l = new CallActionListener(call, dialog);
enableView(content, R.id.transfer_existing, l, !isInConference && numberOfCalls >=2);
enableView(content, R.id.transfer_new, l, !isInConference);
enableView(content, R.id.transfer_existing, l, allowTransfers && !isInConference && numberOfCalls >=2);
enableView(content, R.id.transfer_new, l, allowTransfers && !isInConference);
enableView(content, R.id.remove_from_conference, l, isInConference);
enableView(content, R.id.merge_to_conference, l, showMergeToConf);
enableView(content, R.id.pause, l,!isInConference && showPause);
@ -665,23 +683,19 @@ public class ConferenceActivity extends ListActivity implements
if (state == State.IncomingReceived || state == State.OutgoingRinging) {
if (!adapter.linphoneCalls.contains(call)) {
adapter.linphoneCalls.add(call);
Collections.sort(adapter.linphoneCalls,
ConferenceActivity.this);
adapter.notifyDataSetInvalidated();
adapter.notifyDataSetChanged();
Collections.sort(adapter.linphoneCalls, ConferenceActivity.this);
recreateActivity(adapter);
} else {
Log.e("Call should not be in the call lists : " + stateStr);
Log.e("Call should not be in the call lists : ", stateStr);
}
} else if (state == State.Paused || state == State.PausedByRemote || state == State.StreamsRunning) {
Collections.sort(adapter.linphoneCalls,
ConferenceActivity.this);
Collections.sort(adapter.linphoneCalls, ConferenceActivity.this);
adapter.notifyDataSetChanged();
} else if (state == State.CallEnd) {
adapter.linphoneCalls.remove(call);
Collections.sort(adapter.linphoneCalls,
ConferenceActivity.this);
adapter.notifyDataSetInvalidated();
adapter.notifyDataSetChanged();
Collections.sort(adapter.linphoneCalls, ConferenceActivity.this);
updateAddCallButton();
recreateActivity(adapter);
}
updateConfState();
@ -689,6 +703,11 @@ public class ConferenceActivity extends ListActivity implements
});
}
private void recreateActivity(CalleeListAdapter adapter) {
adapter.notifyDataSetInvalidated();
adapter.notifyDataSetChanged();
}
public int compare(LinphoneCall c1, LinphoneCall c2) {
if (c1 == c2)
return 0;

View file

@ -123,7 +123,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
Intent notifIntent = new Intent(this, LinphoneActivity.class);
mNotifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, 0);
mNotif.setLatestEventInfo(this, notificationTitle,"", mNotifContentIntent);
LinphoneManager.createAndStart(this, this);
LinphoneManager.getLc().setPresenceInfo(0, null, OnlineStatus.Online);
instance = this; // instance is ready once linphone manager has been created

View file

@ -583,4 +583,9 @@ class LinphoneCoreImpl implements LinphoneCore {
public void setMediaEncryptionMandatory(boolean yesno) {
setMediaEncryptionMandatory(nativePtr, yesno);
}
private native int getMaxCalls(long nativePtr);
public int getMaxCalls() {
return getMaxCalls(nativePtr);
}
}

@ -1 +1 @@
Subproject commit 67daaaa14d1d6ec4322f54c43a372fa51ee312de
Subproject commit 324551708e89dde781dc93a1eeae05532c8717f8

View file

@ -320,6 +320,10 @@ public class TestConferenceActivity extends ConferenceActivity {
}
return null;
}
@Override
public int getMaxCalls() {
return 10;
}
}