# HG changeset patch # User Da Risk # Date 1292971859 -3600 # Node ID 696b2880c994b516a3ac5dfc1de4f80802500d58 # Parent 7b8af7616ba904a3f23c794413fe4e6d3b92dc62# Parent 2116f901307e6ef63a9e632396e44e5fab41cb19 merge diff -r 2116f901307e -r 696b2880c994 AndroidManifest.xml --- a/AndroidManifest.xml Wed Dec 15 20:09:56 2010 +0100 +++ b/AndroidManifest.xml Tue Dec 21 23:50:59 2010 +0100 @@ -87,11 +87,12 @@ - - - - + android:name="com.beem.project.beem.BEEM_SERVICE"/> + + + + + diff -r 2116f901307e -r 696b2880c994 res/drawable/avatar_status.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/res/drawable/avatar_status.xml Tue Dec 21 23:50:59 2010 +0100 @@ -0,0 +1,16 @@ + + + + + + + + diff -r 2116f901307e -r 696b2880c994 res/layout/chat.xml --- a/res/layout/chat.xml Wed Dec 15 20:09:56 2010 +0100 +++ b/res/layout/chat.xml Tue Dec 21 23:50:59 2010 +0100 @@ -7,9 +7,10 @@ android:orientation="horizontal" android:gravity="center_vertical" android:background="#222222" android:padding="4px"> + android:src="@drawable/avatar_status" + android:layout_width="48dip" + android:layout_height="48dip" + /> diff -r 2116f901307e -r 696b2880c994 src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Wed Dec 15 20:09:56 2010 +0100 +++ b/src/com/beem/project/beem/BeemService.java Tue Dec 21 23:50:59 2010 +0100 @@ -154,7 +154,7 @@ || mSettings.getBoolean("settings_key_gmail", false)) { mConnectionConfiguration.setSecurityMode(SecurityMode.required); } - mConnectionConfiguration.setDebuggerEnabled(true); + mConnectionConfiguration.setDebuggerEnabled(false); mConnectionConfiguration.setSendPresence(true); // maybe not the universal path, but it works on most devices (Samsung Galaxy, Google Nexus One) mConnectionConfiguration.setTruststoreType("BKS"); diff -r 2116f901307e -r 696b2880c994 src/com/beem/project/beem/ui/Chat.java --- a/src/com/beem/project/beem/ui/Chat.java Wed Dec 15 20:09:56 2010 +0100 +++ b/src/com/beem/project/beem/ui/Chat.java Tue Dec 21 23:50:59 2010 +0100 @@ -61,6 +61,8 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -83,6 +85,8 @@ import android.widget.ListView; import android.widget.TextView; +import java.io.ByteArrayInputStream; + import com.beem.project.beem.R; import com.beem.project.beem.service.Contact; import com.beem.project.beem.service.Message; @@ -121,6 +125,7 @@ private ListView mMessagesListView; private EditText mInputField; private Button mSendButton; + private LayerDrawable mAvatarStatusDrawable; private final Map mStatusIconsMap = new HashMap(); private final List mListMessages = new ArrayList(); @@ -158,6 +163,8 @@ mContactStatusMsgTextView = (TextView) findViewById(R.id.chat_contact_status_msg); mContactChatState = (TextView) findViewById(R.id.chat_contact_chat_state); mContactStatusIcon = (ImageView) findViewById(R.id.chat_contact_status_icon); + mAvatarStatusDrawable = (LayerDrawable) mContactStatusIcon.getDrawable(); + mAvatarStatusDrawable.setLayerInset(1, 36, 36, 0, 0); mMessagesListView = (ListView) findViewById(R.id.chat_messages); mMessagesListView.setAdapter(mMessagesListAdapter); mInputField = (EditText) findViewById(R.id.chat_input); @@ -562,10 +569,34 @@ * Update the contact status icon. */ private void updateContactStatusIcon() { + Drawable avatar = getAvatarDrawable(mContact.getAvatarId()); + mAvatarStatusDrawable.setDrawableByLayerId(R.id.avatar, avatar); mContactStatusIcon.setImageLevel(mContact.getStatus()); } /** + * Get a Drawable containing the avatar icon. + * + * @param avatarId the avatar id to retrieve or null to get default + * @return a Drawable + */ + private Drawable getAvatarDrawable(String avatarId) { + Drawable avatarDrawable = null; + try { + byte[] avatar = mXmppFacade.getAvatar(avatarId); + if (avatar != null) { + ByteArrayInputStream in = new ByteArrayInputStream(avatar); + avatarDrawable = Drawable.createFromStream(in, avatarId); + } + } catch (RemoteException e) { + Log.e(TAG, "Error while setting the avatar", e); + } + if (avatarDrawable == null) + avatarDrawable = getResources().getDrawable(R.drawable.beem_launcher_icon_silver); + return avatarDrawable; + } + + /** * Prepare the status icons map. */ private void prepareIconsStatus() { diff -r 2116f901307e -r 696b2880c994 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Wed Dec 15 20:09:56 2010 +0100 +++ b/src/com/beem/project/beem/ui/ContactList.java Tue Dec 21 23:50:59 2010 +0100 @@ -60,7 +60,6 @@ import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.SharedPreferences; -import android.graphics.drawable.LevelListDrawable; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -87,6 +86,7 @@ import android.widget.ListView; import android.widget.TextView; import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; import com.beem.project.beem.R; import com.beem.project.beem.service.Contact; @@ -656,30 +656,41 @@ private void bindView(View view, Contact curContact) { if (curContact != null) { TextView v = (TextView) view.findViewById(R.id.contactlistpseudo); - LevelListDrawable mStatusDrawable = (LevelListDrawable) getResources() - .getDrawable(R.drawable.status_icon); - mStatusDrawable.setLevel(curContact.getStatus()); - v.setCompoundDrawablesWithIntrinsicBounds(mStatusDrawable, null, null, null); v.setText(curContact.getName()); v = (TextView) view.findViewById(R.id.contactlistmsgperso); v.setText(curContact.getMsgState()); - Drawable d = null; - try { - String avatarId = curContact.getAvatarId(); - byte[] avatar = mXmppFacade.getAvatar(avatarId); - if (avatar != null) { - ByteArrayInputStream in = new ByteArrayInputStream(avatar); - d = Drawable.createFromStream(in, avatarId); - } - } catch (RemoteException e) { - Log.e(TAG, "Error while setting the avatar", e); + ImageView img = (ImageView) view.findViewById(R.id.avatar); + String avatarId = curContact.getAvatarId(); + int contactStatus = curContact.getStatus(); + Drawable avatar = getAvatarStatusDrawable(curContact.getAvatarId()); + img.setImageDrawable(avatar); + img.setImageLevel(contactStatus); + } + } + + /** + * Get a LayerDrawable containing the avatar and the status icon. + * The status icon will change with the level of the drawable. + * @param avatarId the avatar id to retrieve or null to get default + * @return a LayerDrawable + */ + private Drawable getAvatarStatusDrawable(String avatarId) { + Drawable avatarDrawable = null; + try { + byte[] avatar = mXmppFacade.getAvatar(avatarId); + if (avatar != null) { + ByteArrayInputStream in = new ByteArrayInputStream(avatar); + avatarDrawable = Drawable.createFromStream(in, avatarId); } - ImageView img = (ImageView) view.findViewById(R.id.avatar); - if (d != null) - img.setImageDrawable(d); - else - img.setImageResource(R.drawable.beem_launcher_icon_silver); + } catch (RemoteException e) { + Log.e(TAG, "Error while setting the avatar", e); } + if (avatarDrawable == null) + avatarDrawable = getResources().getDrawable(R.drawable.beem_launcher_icon_silver); + LayerDrawable ld = (LayerDrawable) getResources().getDrawable(R.drawable.avatar_status); + ld.setLayerInset(1, 36, 36, 0, 0); + ld.setDrawableByLayerId(R.id.avatar, avatarDrawable); + return ld; } /** diff -r 2116f901307e -r 696b2880c994 tools/checkstyle.xml --- a/tools/checkstyle.xml Wed Dec 15 20:09:56 2010 +0100 +++ b/tools/checkstyle.xml Tue Dec 21 23:50:59 2010 +0100 @@ -1,208 +1,341 @@ - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - + + + + + - - - - - - - - - - - - + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +