Fundamental ios-like ui change for incall view.

Minor bug fixes:
- back from contact picker;
- video + conference workaround.
This commit is contained in:
Guillaume Beraudo 2011-11-24 10:55:08 +01:00
parent db02aec518
commit 13c37c0799
22 changed files with 181 additions and 118 deletions

BIN
res/drawable/incall_add.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
res/drawable/incall_back.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
res/drawable/incall_contact.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
res/drawable/incall_dialpad.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
res/drawable/incall_merge.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
res/drawable/incall_micro.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
res/drawable/incall_pause.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
res/drawable/incall_speaker.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ui="http://schemas.android.com/apk/res/org.linphone"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
@ -19,15 +21,19 @@
<View android:layout_weight="1" android:layout_width="0px" android:layout_height="0px" android:visibility="invisible"/> <View android:layout_weight="1" android:layout_width="0px" android:layout_height="0px" android:visibility="invisible"/>
<LinearLayout android:id="@+id/conf_speaker_mic_row" <LinearLayout android:id="@+id/conf_speaker_mic_row"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_width="fill_parent" android:layout_height="wrap_content"> android:layout_width="fill_parent" android:layout_height="wrap_content">
<ToggleButton android:id="@+id/toggleMuteMic" style="@style/conf_toggle_button" <org.linphone.ui.ToggleImageButton android:id="@+id/toggleMuteMic"
android:textOn="@string/mutemic_button_txt" android:textOff="@string/mutemic_button_txt" /> style="@style/incall_control"
<ToggleButton android:id="@+id/toggleSpeaker" style="@style/conf_toggle_button" ui:checked="@drawable/incall_micro_inverse"
android:textOn="@string/speaker_button_txt" android:textOff="@string/speaker_button_txt" /> ui:unchecked="@drawable/incall_micro"
<ToggleButton android:id="@+id/toggleBluetooth" style="@style/conf_toggle_button" ui:bgdrawables="true" />
android:textOn="@string/bluetooth_button_txt" android:textOff="@string/bluetooth_button_txt"
android:visibility="gone"/> <org.linphone.ui.ToggleImageButton android:id="@+id/toggleSpeaker"
style="@style/incall_control"
ui:checked="@drawable/incall_speaker_inverse"
ui:unchecked="@drawable/incall_speaker"
ui:bgdrawables="true" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout
android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" xmlns:ui="http://schemas.android.com/apk/res/org.linphone"
android:layout_height="fill_parent" android:layout_width="match_parent"
android:paddingLeft="8dp" android:layout_height="fill_parent"
android:paddingRight="8dp"> android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<LinearLayout android:id="@+id/conf_header" android:layout_alignParentTop="true" <LinearLayout android:id="@+id/conf_header" android:layout_alignParentTop="true"
android:orientation="vertical" android:layout_marginBottom="10dip" android:orientation="vertical" android:layout_marginBottom="10dip"
@ -21,57 +22,70 @@
<LinearLayout android:id="@+id/incall_controls_layout"
android:layout_alignParentBottom="true" android:orientation="vertical"
<LinearLayout android:id="@+id/conf_speaker_mic_row"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ToggleButton android:id="@+id/toggleMuteMic" style="@style/conf_toggle_button"
android:textOn="@string/mutemic_button_txt" android:textOff="@string/mutemic_button_txt" />
<ToggleButton android:id="@+id/toggleSpeaker" style="@style/conf_toggle_button"
android:textOn="@string/speaker_button_txt" android:textOff="@string/speaker_button_txt" />
<ToggleButton android:id="@+id/toggleBluetooth" style="@style/conf_toggle_button"
android:textOn="@string/bluetooth_button_txt" android:textOff="@string/bluetooth_button_txt"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout android:id="@+id/conf_terminate_row"
android:layout_above="@id/conf_speaker_mic_row"
android:layout_width="fill_parent" android:layout_height="wrap_content"> android:layout_width="fill_parent" android:layout_height="wrap_content">
<Button android:text="@string/AddCallButtonText" android:id="@+id/addCall"
style="@style/conf_icon_text_button" android:drawableTop="@drawable/plus" />
<Button android:id="@+id/incallHang" style="@style/conf_icon_text_button" <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
android:drawableTop="@drawable/stopcall_red" android:text="@string/hangup"/> <org.linphone.ui.ToggleImageButton android:id="@+id/toggleMuteMic"
style="@style/incall_control"
ui:checked="@drawable/incall_micro_inverse"
ui:unchecked="@drawable/incall_micro"
ui:bgdrawables="true" />
<Button android:id="@+id/incallNumpadShow" style="@style/conf_icon_text_button" <ImageButton android:id="@+id/incallNumpadShow"
android:text="@string/show_send_dtmfs_button" android:drawableTop="@drawable/numpad_big" /> style="@style/incall_control"
</LinearLayout> android:background="@drawable/incall_dialpad" />
<LinearLayout android:id="@+id/conf_advanced_buttons" <org.linphone.ui.ToggleImageButton android:id="@+id/toggleSpeaker"
android:layout_width="fill_parent" android:layout_height="wrap_content" style="@style/incall_control"
android:layout_above="@id/conf_terminate_row"> ui:checked="@drawable/incall_speaker_inverse"
<Button android:id="@+id/conf_simple_video" style="@style/conf_icon_text_button" ui:unchecked="@drawable/incall_speaker"
android:drawableTop="@drawable/conf_video" ui:bgdrawables="true" />
android:text="@string/conf_simple_video_bt_txt"/> </LinearLayout>
<Button android:id="@+id/conf_simple_merge" style="@style/conf_icon_text_button"
android:drawableTop="@drawable/conf_merge" <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
android:text="@string/conf_simple_merge_bt_txt"/> <ImageButton android:id="@+id/addCall"
<Button android:id="@+id/conf_simple_transfer" style="@style/conf_icon_text_button" style="@style/incall_control"
android:drawableTop="@drawable/conf_transfer" android:background="@drawable/incall_add" />
android:text="@string/conf_simple_transfer_bt_txt" />
<ImageButton android:id="@+id/conf_simple_merge"
style="@style/incall_control"
android:visibility="gone"
android:background="@drawable/incall_merge" />
<org.linphone.ui.ToggleImageButton android:id="@+id/conf_simple_pause"
style="@style/incall_control"
ui:checked="@drawable/incall_pause_inverse"
ui:unchecked="@drawable/incall_pause"
ui:bgdrawables="true" />
<ImageButton android:id="@+id/conf_simple_video"
style="@style/incall_control"
android:background="@drawable/incall_back" />
</LinearLayout> </LinearLayout>
<ImageButton
android:id="@+id/incallHang"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/clavier_bg"
android:minHeight="60dip"
android:src="@drawable/stopcall_red" />
</LinearLayout>
<RelativeLayout android:id="@+id/picture_wrapper"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_above="@id/incall_controls_layout">
<ImageView android:id="@+id/incall_picture" android:visibility="gone" <ImageView android:id="@+id/incall_picture" android:visibility="gone"
android:layout_centerInParent="true" android:paddingBottom="15px"
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center" android:scaleType="fitCenter" android:layout_gravity="center" android:scaleType="fitCenter"
android:minWidth="192px" android:minHeight="192px" android:minWidth="192px" android:minHeight="192px"
android:paddingBottom="60px"
/> />
</RelativeLayout>
<ListView android:id="@android:id/list" <ListView android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -80,7 +94,7 @@
android:dividerHeight="10dip" android:dividerHeight="10dip"
android:divider="@android:color/transparent" android:divider="@android:color/transparent"
android:layout_below="@id/conf_header" android:layout_below="@id/conf_header"
android:layout_above="@id/conf_advanced_buttons" android:layout_above="@id/picture_wrapper"
android:layout_alignWithParentIfMissing="true" android:layout_alignWithParentIfMissing="true"
android:fadeScrollbars="false" android:fadeScrollbars="false"
/> />

View file

@ -9,4 +9,27 @@
<item name="android:paddingRight">15sp</item> <item name="android:paddingRight">15sp</item>
</style> </style>
</resources> <style name="incall_control" parent="@android:style/Widget.ImageButton">
<item name="android:height">104px</item>
<item name="android:width">164px</item>
<item name="android:layout_height">104px</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:scaleType">fitCenter</item>
<item name="android:adjustViewBounds">true</item>
</style>
<declare-styleable name="ToggleImageButton">
<attr name="android:scaleType" />
<attr name="android:height" />
<attr name="android:width" />
<attr name="android:layout_width" />
<attr name="android:layout_height" />
<attr name="android:layout_weight" />
<attr name="android:id" />
<attr name="checked" format="integer" />
<attr name="unchecked" format="integer" />
<attr name="bgdrawables" format="boolean" />
</declare-styleable>
</resources>

View file

@ -11,7 +11,6 @@
<string name="waiting_for_startup">Starting up...</string> <string name="waiting_for_startup">Starting up...</string>
<string name="couldnt_accept_call">An error occurred while accepting call</string> <string name="couldnt_accept_call">An error occurred while accepting call</string>
<string name="uri_picking_canceled">Canceled</string>
<string name="error_adding_new_call">Error adding new call</string> <string name="error_adding_new_call">Error adding new call</string>
<string name="transfer_started">Transfer initiated</string> <string name="transfer_started">Transfer initiated</string>
<string name="transfer_dialog_title">Transfer call to</string> <string name="transfer_dialog_title">Transfer call to</string>

View file

@ -39,9 +39,9 @@ import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.Checkable;
import android.widget.Chronometer; import android.widget.Chronometer;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ToggleButton;
/** /**
* @author Guillaume Beraudo * @author Guillaume Beraudo
@ -53,8 +53,8 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li
private List<LinphoneCall> mSpecificCalls = Collections.emptyList(); private List<LinphoneCall> mSpecificCalls = Collections.emptyList();
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private ToggleButton mMuteMicButton; private Checkable mMuteMicButton;
private ToggleButton mSpeakerButton; private Checkable mSpeakerButton;
protected abstract boolean isActive(); protected abstract boolean isActive();
protected abstract void setActive(boolean active); protected abstract void setActive(boolean active);
@ -70,10 +70,13 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
setListAdapter(mListAdapter = createCalleeListAdapter()); setListAdapter(mListAdapter = createCalleeListAdapter());
mMuteMicButton = (ToggleButton) findViewById(R.id.toggleMuteMic); View muteMic = findViewById(R.id.toggleMuteMic);
mMuteMicButton.setOnClickListener(this); muteMic.setOnClickListener(this);
mSpeakerButton = (ToggleButton) findViewById(R.id.toggleSpeaker); mMuteMicButton = (Checkable) muteMic;
mSpeakerButton.setOnClickListener(this);
View speaker = findViewById(R.id.toggleSpeaker);
speaker.setOnClickListener(this);
mSpeakerButton = (Checkable) speaker;
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@ -190,10 +193,10 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.toggleMuteMic: case R.id.toggleMuteMic:
lc().muteMic(((ToggleButton) v).isChecked()); lc().muteMic(((Checkable) v).isChecked());
break; break;
case R.id.toggleSpeaker: case R.id.toggleSpeaker:
if (((ToggleButton) v).isChecked()) { if (((Checkable) v).isChecked()) {
LinphoneManager.getInstance().routeAudioToSpeaker(); LinphoneManager.getInstance().routeAudioToSpeaker();
} else { } else {
LinphoneManager.getInstance().routeAudioToReceiver(); LinphoneManager.getInstance().routeAudioToReceiver();
@ -206,7 +209,7 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li
@Override @Override
public void onAudioStateChanged(final AudioState state) { public void onAudioStateChanged(final AudioState state) {
mSpeakerButton.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
switch (state) { switch (state) {

View file

@ -28,7 +28,6 @@ import android.content.ContentUris;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Contacts;
import android.text.TextUtils; import android.text.TextUtils;
@ -158,7 +157,7 @@ public class ContactPickerActivityNew extends AbstractContactPickerActivityNew {
} }
} }
LinphoneActivity.instance().getTabHost().setCurrentTabByTag(LinphoneActivity.DIALER_TAB); ((ContactPicked) getParent()).goToDialer();
} }

View file

@ -49,11 +49,11 @@ import android.view.ViewGroup;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener; import android.view.View.OnLongClickListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Checkable;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListAdapter; import android.widget.ListAdapter;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.widget.ToggleButton;
/** /**
* @author Guillaume Beraudo * @author Guillaume Beraudo
@ -96,11 +96,7 @@ public class IncallActivity extends AbstractCalleesActivity implements
findViewById(R.id.incallNumpadShow).setOnClickListener(this); findViewById(R.id.incallNumpadShow).setOnClickListener(this);
findViewById(R.id.conf_simple_merge).setOnClickListener(this); findViewById(R.id.conf_simple_merge).setOnClickListener(this);
View transferView = findViewById(R.id.conf_simple_transfer); findViewById(R.id.conf_simple_pause).setOnClickListener(this);
transferView.setOnClickListener(this);
if (!mAllowTransfers) {
transferView.setVisibility(View.GONE);
}
findViewById(R.id.incallHang).setOnClickListener(this); findViewById(R.id.incallHang).setOnClickListener(this);
mMultipleCallsLimit = lc().getMaxCalls(); mMultipleCallsLimit = lc().getMaxCalls();
@ -212,7 +208,7 @@ public class IncallActivity extends AbstractCalleesActivity implements
if (!lc().isMicMuted()) { if (!lc().isMicMuted()) {
mUnMuteOnReturnFromUriPicker = true; mUnMuteOnReturnFromUriPicker = true;
lc().muteMic(true); lc().muteMic(true);
((ToggleButton) findViewById(R.id.toggleMuteMic)).setChecked(true); ((Checkable) findViewById(R.id.toggleMuteMic)).setChecked(true);
} }
} }
@ -248,7 +244,7 @@ public class IncallActivity extends AbstractCalleesActivity implements
lc().terminateAllCalls(); lc().terminateAllCalls();
} }
// activity wille be closed automatically by LinphoneActivity when no more calls exist // activity will be closed automatically by LinphoneActivity when no more calls exist
} }
public void onClick(View v) { public void onClick(View v) {
@ -269,12 +265,12 @@ public class IncallActivity extends AbstractCalleesActivity implements
case R.id.conf_simple_merge: case R.id.conf_simple_merge:
lc().addAllToConference(); lc().addAllToConference();
break; break;
case R.id.conf_simple_transfer: case R.id.conf_simple_pause:
LinphoneCall tCall = lc().getCurrentCall(); LinphoneCall call = lc().getCurrentCall();
if (tCall != null) { if (call != null) {
prepareForTransferingExistingOrNewCall(tCall); lc().pauseCall(call);
} else { } else {
Toast.makeText(this, R.string.conf_simple_no_current_call, Toast.LENGTH_SHORT).show(); ((Checkable) v).setChecked(true);
} }
break; break;
case R.id.conf_simple_video: case R.id.conf_simple_video:
@ -291,9 +287,17 @@ public class IncallActivity extends AbstractCalleesActivity implements
// mic, speaker // mic, speaker
super.onClick(v); super.onClick(v);
} }
} }
private void doTransfer() {
LinphoneCall tCall = lc().getCurrentCall();
if (tCall != null) {
prepareForTransferingExistingOrNewCall(tCall);
} else {
Toast.makeText(this, R.string.conf_simple_no_current_call, Toast.LENGTH_SHORT).show();
}
}
private void prepareForTransferingExistingOrNewCall(final LinphoneCall call) { private void prepareForTransferingExistingOrNewCall(final LinphoneCall call) {
// Include inconf calls // Include inconf calls
final List<LinphoneCall> existingCalls = LinphoneUtils.getLinphoneCalls(lc()); final List<LinphoneCall> existingCalls = LinphoneUtils.getLinphoneCalls(lc());
@ -545,30 +549,26 @@ public class IncallActivity extends AbstractCalleesActivity implements
return getString(id); return getString(id);
} }
private void updateAdvancedButtons() { private void updatePauseMergeButtons() {
LinphoneCall activeCall = lc().getCurrentCall(); View controls = findViewById(R.id.incall_controls_layout);
View bar = findViewById(R.id.conf_advanced_buttons);
if (activeCall == null) { int nbCalls = lc().getCallsNb();
bar.setVisibility(GONE); View pauseView = controls.findViewById(R.id.conf_simple_pause);
return; View mergeView = controls.findViewById(R.id.conf_simple_merge);
if (nbCalls <= 1) {
((Checkable) pauseView).setChecked(lc().getCurrentCall() == null);
mergeView.setVisibility(GONE);
pauseView.setVisibility(VISIBLE);
} else {
int nonConfCallsNb = LinphoneUtils.countNonConferenceCalls(lc());
boolean enableMerge = nonConfCallsNb >=2;
enableMerge |= nonConfCallsNb >=1 && lc().getConferenceSize() > 0;
mergeView.setEnabled(enableMerge);
pauseView.setVisibility(GONE);
mergeView.setVisibility(VISIBLE);
} }
int nonConfCallsNb = LinphoneUtils.countNonConferenceCalls(lc());
// in this part, we know nonConfCallsNb > 0 as the active call cannot be a conf call
View merge = bar.findViewById(R.id.conf_simple_merge);
boolean enableMerge = nonConfCallsNb >=2 || lc().getConferenceSize() > 0;
enableMerge = true;
merge.setEnabled(enableMerge);
View transfer = bar.findViewById(R.id.conf_simple_transfer);
boolean enableTransfer = mAllowTransfers && activeCall != null;
transfer.setEnabled(enableTransfer);
// video always enabled when a call active (though may not be shown)
bar.setVisibility(VISIBLE);
} }
private void updateConfItem() { private void updateConfItem() {
@ -586,7 +586,7 @@ public class IncallActivity extends AbstractCalleesActivity implements
} }
protected void updateUI() { protected void updateUI() {
updateAdvancedButtons(); updatePauseMergeButtons();
updateCalleeImage(); updateCalleeImage();
updateSoundLock(); updateSoundLock();
updateAddCallButton(); updateAddCallButton();
@ -634,7 +634,7 @@ public class IncallActivity extends AbstractCalleesActivity implements
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (mUnMuteOnReturnFromUriPicker) { if (mUnMuteOnReturnFromUriPicker) {
lc().muteMic(false); lc().muteMic(false);
((ToggleButton) findViewById(R.id.toggleMuteMic)).setChecked(false); ((Checkable) findViewById(R.id.toggleMuteMic)).setChecked(false);
} }
String uri = null; String uri = null;
@ -643,7 +643,6 @@ public class IncallActivity extends AbstractCalleesActivity implements
} }
if (resultCode != RESULT_OK || TextUtils.isEmpty(uri)) { if (resultCode != RESULT_OK || TextUtils.isEmpty(uri)) {
mCallToTransfer = null; mCallToTransfer = null;
Toast.makeText(this, R.string.uri_picking_canceled, Toast.LENGTH_LONG).show();
eventuallyResumeConfOrCallOnPickerReturn(true); eventuallyResumeConfOrCallOnPickerReturn(true);
return; return;
} }

View file

@ -486,7 +486,7 @@ public class LinphoneActivity extends TabActivity implements
startIncallActivity(); startIncallActivity();
} }
} }
if (state == LinphoneCall.State.StreamsRunning && Version.isVideoCapable()) { if (state == LinphoneCall.State.StreamsRunning && Version.isVideoCapable() && !call.isInConference()) {
boolean videoEnabled = call.getCurrentParamsCopy().getVideoEnabled(); boolean videoEnabled = call.getCurrentParamsCopy().getVideoEnabled();
if (videoEnabled) { if (videoEnabled) {
startVideoActivity(call, 1000); startVideoActivity(call, 1000);

View file

@ -25,6 +25,7 @@ import java.lang.reflect.Method;
import org.linphone.LinphoneManager.NewOutgoingCallUiListener; import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
import org.linphone.LinphoneSimpleListener.LinphoneServiceListener; import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.Log; import org.linphone.core.Log;
import org.linphone.core.OnlineStatus; import org.linphone.core.OnlineStatus;
import org.linphone.core.LinphoneCall.State; import org.linphone.core.LinphoneCall.State;
@ -268,7 +269,8 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
mNotif.when=System.currentTimeMillis(); mNotif.when=System.currentTimeMillis();
String text = getString(textId); String text = getString(textId);
if (text.contains("%s")) { if (text.contains("%s")) {
String id = LinphoneManager.getLc().getDefaultProxyConfig().getIdentity(); LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
String id = lpc != null ? lpc.getIdentity() : "";
text = String.format(text, id); text = String.format(text, id);
} }

View file

@ -69,7 +69,7 @@ public class UriPickerActivity extends TabActivity implements ContactPicked {
startActivityInTab("contact", startActivityInTab("contact",
new Intent().setClass(this, Version.sdkAboveOrEqual(5) ? new Intent().setClass(this, Version.sdkAboveOrEqual(Version.API05_ECLAIR_20) ?
ContactPickerActivityNew.class : ContactPickerActivityOld.class), ContactPickerActivityNew.class : ContactPickerActivityOld.class),
R.string.tab_contact, R.drawable.contact_orange); R.string.tab_contact, R.drawable.contact_orange);

View file

@ -25,6 +25,7 @@ import android.graphics.drawable.Drawable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.Checkable;
import android.widget.ImageButton; import android.widget.ImageButton;
/** /**
@ -35,18 +36,19 @@ import android.widget.ImageButton;
* @author Guillaume Beraudo * @author Guillaume Beraudo
* *
*/ */
public class ToggleImageButton extends ImageButton implements OnClickListener { public class ToggleImageButton extends ImageButton implements Checkable, OnClickListener {
// private static final String ns = "http://schemas.android.com/apk/res/linphone"; private static final String ns = "http://schemas.android.com/apk/res/org.linphone";
private static final String ns = null;
private boolean checked; private boolean checked;
private Drawable stateChecked; private Drawable stateChecked;
private Drawable stateUnChecked; private Drawable stateUnChecked;
private boolean drawablesForBackground;
private OnCheckedChangeListener onCheckedChangeListener; private OnCheckedChangeListener onCheckedChangeListener;
public ToggleImageButton(Context context, AttributeSet attrs) { public ToggleImageButton(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
stateChecked = getResources().getDrawable(attrs.getAttributeResourceValue(ns, "checked", -1)); stateChecked = getResources().getDrawable(attrs.getAttributeResourceValue(ns, "checked", -1));
stateUnChecked = getResources().getDrawable(attrs.getAttributeResourceValue(ns, "unchecked", -1)); stateUnChecked = getResources().getDrawable(attrs.getAttributeResourceValue(ns, "unchecked", -1));
drawablesForBackground = attrs.getAttributeBooleanValue(ns, "bgdrawables", false);
setBackgroundColor(Color.TRANSPARENT); setBackgroundColor(Color.TRANSPARENT);
setOnClickListener(this); setOnClickListener(this);
@ -66,7 +68,12 @@ public class ToggleImageButton extends ImageButton implements OnClickListener {
private void handleCheckChanged() { private void handleCheckChanged() {
setImageDrawable(checked?stateChecked:stateUnChecked); Drawable d = checked? stateChecked : stateUnChecked;
if (drawablesForBackground) {
setBackgroundDrawable(d);
} else {
setImageDrawable(d);
}
requestLayout(); requestLayout();
invalidate(); invalidate();
if (onCheckedChangeListener != null) onCheckedChangeListener.onCheckedChanged(this, checked); if (onCheckedChangeListener != null) onCheckedChangeListener.onCheckedChanged(this, checked);
@ -82,7 +89,18 @@ public class ToggleImageButton extends ImageButton implements OnClickListener {
} }
public void onClick(View v) { public void onClick(View v) {
checked = !checked; toggle();
handleCheckChanged();
} }
@Override
public void toggle() {
setChecked(!isChecked());
}
@Override
public boolean performClick() {
toggle();
return super.performClick();
}
} }