diff --git a/res/drawable/avatar_shadow.png b/res/drawable/avatar_shadow.png new file mode 100644 index 000000000..7a8aac483 Binary files /dev/null and b/res/drawable/avatar_shadow.png differ diff --git a/res/drawable/avatar_shadow_left.png b/res/drawable/avatar_shadow_left.png new file mode 100644 index 000000000..a8733f7a0 Binary files /dev/null and b/res/drawable/avatar_shadow_left.png differ diff --git a/res/drawable/avatar_shadow_right.png b/res/drawable/avatar_shadow_right.png new file mode 100644 index 000000000..96c8327bf Binary files /dev/null and b/res/drawable/avatar_shadow_right.png differ diff --git a/res/layout/active_call.xml b/res/layout/active_call.xml index 8d4919a52..a729896da 100644 --- a/res/layout/active_call.xml +++ b/res/layout/active_call.xml @@ -1,5 +1,6 @@ - @@ -15,7 +16,7 @@ android:id="@+id/contactNameOrNumber" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_weight="0.4" + android:layout_weight="0.5" android:gravity="center_vertical|left" android:paddingLeft="20dp" android:textColor="@android:color/white" @@ -23,8 +24,8 @@ - + android:paddingBottom="10sp" /> \ No newline at end of file diff --git a/res/layout/avatar.xml b/res/layout/avatar.xml new file mode 100644 index 000000000..9f0b1161e --- /dev/null +++ b/res/layout/avatar.xml @@ -0,0 +1,29 @@ + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/chat.xml b/res/layout/chat.xml index 84104801c..49e79ecb8 100644 --- a/res/layout/chat.xml +++ b/res/layout/chat.xml @@ -1,5 +1,6 @@ - + - + - + @@ -27,12 +28,11 @@ android:orientation="vertical" android:paddingTop="30dip"> - + @@ -12,4 +13,9 @@ + + + + + \ No newline at end of file diff --git a/src/org/linphone/AudioCallFragment.java b/src/org/linphone/AudioCallFragment.java index f6187253a..630f9f783 100644 --- a/src/org/linphone/AudioCallFragment.java +++ b/src/org/linphone/AudioCallFragment.java @@ -21,6 +21,7 @@ import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall.State; import org.linphone.core.LinphoneCoreFactory; +import org.linphone.ui.AvatarWithShadow; import android.app.Activity; import android.content.res.Resources; @@ -106,9 +107,9 @@ public class AudioCallFragment extends Fragment { } private void displayOrHideContactPicture(LinearLayout callView, Uri pictureUri, boolean hide) { - ImageView contactPicture = (ImageView) callView.findViewById(R.id.contactPicture); + AvatarWithShadow contactPicture = (AvatarWithShadow) callView.findViewById(R.id.contactPicture); if (pictureUri != null) { - LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture, Uri.parse(pictureUri.toString()), R.drawable.unknown_small); + LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture.getView(), Uri.parse(pictureUri.toString()), R.drawable.unknown_small); } if (hide) { contactPicture.setVisibility(View.GONE); diff --git a/src/org/linphone/ChatFragment.java b/src/org/linphone/ChatFragment.java index beb21a886..06d9b50ec 100644 --- a/src/org/linphone/ChatFragment.java +++ b/src/org/linphone/ChatFragment.java @@ -23,6 +23,7 @@ import org.linphone.LinphoneSimpleListener.LinphoneOnMessageReceivedListener; import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneChatRoom; import org.linphone.core.LinphoneCore; +import org.linphone.ui.AvatarWithShadow; import org.linphone.ui.BubbleChat; import android.net.Uri; @@ -73,9 +74,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneO contactName.setText(name); } - ImageView contactPicture = (ImageView) view.findViewById(R.id.contactPicture); + AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); if (pictureUri != null) { - LinphoneUtils.setImagePictureFromUri(view.getContext(), contactPicture, Uri.parse(pictureUri), R.drawable.unknown_small); + LinphoneUtils.setImagePictureFromUri(view.getContext(), contactPicture.getView(), Uri.parse(pictureUri), R.drawable.unknown_small); } ImageView sendMessage = (ImageView) view.findViewById(R.id.sendMessage); diff --git a/src/org/linphone/ContactFragment.java b/src/org/linphone/ContactFragment.java index 17759c1a2..2a41bb84b 100644 --- a/src/org/linphone/ContactFragment.java +++ b/src/org/linphone/ContactFragment.java @@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. import java.io.InputStream; import org.linphone.compatibility.Compatibility; +import org.linphone.ui.AvatarWithShadow; import android.graphics.BitmapFactory; import android.os.Bundle; @@ -28,7 +29,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.TableLayout; import android.widget.TextView; @@ -44,12 +44,12 @@ public class ContactFragment extends Fragment { contact = (Contact) getArguments().getSerializable("Contact"); View view = inflater.inflate(R.layout.contact, container, false); - ImageView contactPicture = (ImageView) view.findViewById(R.id.contactPicture); + AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); if (contact.getPhotoUri() != null) { InputStream input = Compatibility.getContactPictureInputStream(getActivity().getContentResolver(), contact.getID()); contactPicture.setImageBitmap(BitmapFactory.decodeStream(input)); } else { - contactPicture.setImageResource(R.drawable.unknown_small); + contactPicture.setBackgroundResource(R.drawable.unknown_small); } chatListener = getChatListener(); diff --git a/src/org/linphone/HistoryDetailFragment.java b/src/org/linphone/HistoryDetailFragment.java index 87b221a14..c3af4bf65 100644 --- a/src/org/linphone/HistoryDetailFragment.java +++ b/src/org/linphone/HistoryDetailFragment.java @@ -18,6 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import org.linphone.compatibility.Compatibility; +import org.linphone.ui.AvatarWithShadow; import android.content.Intent; import android.net.Uri; @@ -34,7 +35,8 @@ import android.widget.TextView; * @author Sylvain Berfini */ public class HistoryDetailFragment extends Fragment implements OnClickListener { - private ImageView contactPicture, dialBack, chat, addToContacts; + private ImageView dialBack, chat, addToContacts; + private AvatarWithShadow contactPicture; private TextView contactName, callDirection, time, date, dialBackUri; private String sipUri, displayName, pictureUri; @@ -50,9 +52,9 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener { View view = inflater.inflate(R.layout.history_detail, container, false); - contactPicture = (ImageView) view.findViewById(R.id.contactPicture); + contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); if (pictureUri != null) { - LinphoneUtils.setImagePictureFromUri(view.getContext(), contactPicture, Uri.parse(pictureUri), R.drawable.unknown_small); + LinphoneUtils.setImagePictureFromUri(view.getContext(), contactPicture.getView(), Uri.parse(pictureUri), R.drawable.unknown_small); } dialBack = (ImageView) view.findViewById(R.id.dialBack); diff --git a/src/org/linphone/IncomingCallActivity.java b/src/org/linphone/IncomingCallActivity.java index f75bd5a06..763f36f41 100644 --- a/src/org/linphone/IncomingCallActivity.java +++ b/src/org/linphone/IncomingCallActivity.java @@ -25,6 +25,7 @@ import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall.State; import org.linphone.core.Log; +import org.linphone.ui.AvatarWithShadow; import org.linphone.ui.LinphoneSliders; import org.linphone.ui.LinphoneSliders.LinphoneSliderTriggered; @@ -33,7 +34,6 @@ import android.net.Uri; import android.os.Bundle; import android.view.KeyEvent; import android.view.WindowManager; -import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; @@ -47,7 +47,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat private TextView mNameView; private TextView mNumberView; - private ImageView mPictureView; + private AvatarWithShadow mPictureView; private LinphoneCall mCall; private LinphoneSliders mIncomingCallWidget; @@ -57,7 +57,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat mNameView = (TextView) findViewById(R.id.incoming_caller_name); mNumberView = (TextView) findViewById(R.id.incoming_caller_number); - mPictureView = (ImageView) findViewById(R.id.incoming_picture); + mPictureView = (AvatarWithShadow) findViewById(R.id.incoming_picture); // set this flag so this activity will stay in front of the keyguard int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; @@ -93,7 +93,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat LinphoneAddress address = mCall.getRemoteAddress(); // May be greatly sped up using a drawable cache Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(address, getContentResolver()); - LinphoneUtils.setImagePictureFromUri(this, mPictureView, uri, R.drawable.unknown_small); + LinphoneUtils.setImagePictureFromUri(this, mPictureView.getView(), uri, R.drawable.unknown_small); // To be done after findUriPictureOfContactAndSetDisplayName called mNameView.setText(address.getDisplayName()); @@ -132,7 +132,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat private void answer() { if (!LinphoneManager.getInstance().acceptCall(mCall)) { // the above method takes care of Samsung Galaxy S - Toast.makeText(this, R.string.couldnt_accept_call, Toast.LENGTH_LONG); + Toast.makeText(this, R.string.couldnt_accept_call, Toast.LENGTH_LONG).show(); } else { if (mCall.getCurrentParamsCopy().getVideoEnabled()) LinphoneActivity.instance().startVideoActivity(mCall); diff --git a/src/org/linphone/ui/AvatarWithShadow.java b/src/org/linphone/ui/AvatarWithShadow.java new file mode 100644 index 000000000..b83d4b557 --- /dev/null +++ b/src/org/linphone/ui/AvatarWithShadow.java @@ -0,0 +1,60 @@ +package org.linphone.ui; +/* +AvatarWithShadow.java +Copyright (C) 2012 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +import org.linphone.R; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Bitmap; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ImageView; +import android.widget.LinearLayout; + +/** + * @author Sylvain Berfini + */ +public class AvatarWithShadow extends LinearLayout { + private ImageView contactPicture; + + public AvatarWithShadow(Context context, AttributeSet attrs) { + super(context, attrs); + + TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.AvatarWithShadow); + int pictureResId = array.getResourceId(R.styleable.AvatarWithShadow_picture, 0); + array.recycle(); + + View view = LayoutInflater.from(context).inflate(R.layout.avatar, this); + contactPicture = (ImageView) view.findViewById(R.id.picture); + contactPicture.setImageResource(pictureResId); + } + + public ImageView getView() { + return contactPicture; + } + + public void setImageBitmap(Bitmap bitmap) { + contactPicture.setImageBitmap(bitmap); + } + + public void setBackgroundResource(int res) { + contactPicture.setBackgroundResource(res); + } +}