diff --git a/res/drawable-mdpi/emo_im_angel.png b/res/drawable-mdpi/emo_im_angel.png new file mode 100644 index 000000000..3efea42df Binary files /dev/null and b/res/drawable-mdpi/emo_im_angel.png differ diff --git a/res/drawable-mdpi/emo_im_cool.png b/res/drawable-mdpi/emo_im_cool.png new file mode 100644 index 000000000..650ed8f62 Binary files /dev/null and b/res/drawable-mdpi/emo_im_cool.png differ diff --git a/res/drawable-mdpi/emo_im_crying.png b/res/drawable-mdpi/emo_im_crying.png new file mode 100644 index 000000000..ad1e50f58 Binary files /dev/null and b/res/drawable-mdpi/emo_im_crying.png differ diff --git a/res/drawable-mdpi/emo_im_happy.png b/res/drawable-mdpi/emo_im_happy.png new file mode 100644 index 000000000..a32472096 Binary files /dev/null and b/res/drawable-mdpi/emo_im_happy.png differ diff --git a/res/drawable-mdpi/emo_im_kissing.png b/res/drawable-mdpi/emo_im_kissing.png new file mode 100644 index 000000000..f18a391b3 Binary files /dev/null and b/res/drawable-mdpi/emo_im_kissing.png differ diff --git a/res/drawable-mdpi/emo_im_laughing.png b/res/drawable-mdpi/emo_im_laughing.png new file mode 100644 index 000000000..963a4ba68 Binary files /dev/null and b/res/drawable-mdpi/emo_im_laughing.png differ diff --git a/res/drawable-mdpi/emo_im_money_mouth.png b/res/drawable-mdpi/emo_im_money_mouth.png new file mode 100644 index 000000000..718c7e3a6 Binary files /dev/null and b/res/drawable-mdpi/emo_im_money_mouth.png differ diff --git a/res/drawable-mdpi/emo_im_sad.png b/res/drawable-mdpi/emo_im_sad.png new file mode 100644 index 000000000..7daac6c0e Binary files /dev/null and b/res/drawable-mdpi/emo_im_sad.png differ diff --git a/res/drawable-mdpi/emo_im_surprised.png b/res/drawable-mdpi/emo_im_surprised.png new file mode 100644 index 000000000..b4b614dc5 Binary files /dev/null and b/res/drawable-mdpi/emo_im_surprised.png differ diff --git a/res/drawable-mdpi/emo_im_tongue_sticking_out.png b/res/drawable-mdpi/emo_im_tongue_sticking_out.png new file mode 100644 index 000000000..9fa6534c9 Binary files /dev/null and b/res/drawable-mdpi/emo_im_tongue_sticking_out.png differ diff --git a/res/drawable-mdpi/emo_im_undecided.png b/res/drawable-mdpi/emo_im_undecided.png new file mode 100644 index 000000000..8b2577af7 Binary files /dev/null and b/res/drawable-mdpi/emo_im_undecided.png differ diff --git a/res/drawable-mdpi/emo_im_winking.png b/res/drawable-mdpi/emo_im_winking.png new file mode 100644 index 000000000..069e9e33f Binary files /dev/null and b/res/drawable-mdpi/emo_im_winking.png differ diff --git a/res/drawable-mdpi/emo_im_wtf.png b/res/drawable-mdpi/emo_im_wtf.png new file mode 100644 index 000000000..0d963ec82 Binary files /dev/null and b/res/drawable-mdpi/emo_im_wtf.png differ diff --git a/res/drawable-mdpi/emo_im_yelling.png b/res/drawable-mdpi/emo_im_yelling.png new file mode 100644 index 000000000..836f60f68 Binary files /dev/null and b/res/drawable-mdpi/emo_im_yelling.png differ diff --git a/src/org/linphone/StatusFragment.java b/src/org/linphone/StatusFragment.java index 513ad125c..9b40f6b54 100644 --- a/src/org/linphone/StatusFragment.java +++ b/src/org/linphone/StatusFragment.java @@ -26,6 +26,7 @@ import org.linphone.core.LinphoneCore.MediaEncryption; import org.linphone.core.LinphoneCore.RegistrationState; import org.linphone.core.LinphoneProxyConfig; import org.linphone.ui.SlidingDrawer; +import org.linphone.ui.SlidingDrawer.OnDrawerOpenListener; import android.app.Activity; import android.os.Bundle; @@ -68,6 +69,12 @@ public class StatusFragment extends Fragment { encryption = (ImageView) view.findViewById(R.id.encryption); drawer = (SlidingDrawer) view.findViewById(R.id.statusBar); + drawer.setOnDrawerOpenListener(new OnDrawerOpenListener() { + @Override + public void onDrawerOpened() { + populateSliderContent(); + } + }); sliderContent = (RelativeLayout) view.findViewById(R.id.content); exit = (TextView) view.findViewById(R.id.exit); exit.setOnClickListener(new OnClickListener() { @@ -128,7 +135,7 @@ public class StatusFragment extends Fragment { hashMapAccountsStateList.add(entitiesHashMap); } Adapter adapterForList = new SimpleAdapter(getActivity(), hashMapAccountsStateList, R.layout.accounts, - new String[] {"Identity", "State"}, + new String[] {"Identity", "State" }, new int[] { R.id.Identity, R.id.State }); accounts.setAdapter((ListAdapter) adapterForList); diff --git a/src/org/linphone/ui/BubbleChat.java b/src/org/linphone/ui/BubbleChat.java index 89dd2996b..7e2ecc437 100644 --- a/src/org/linphone/ui/BubbleChat.java +++ b/src/org/linphone/ui/BubbleChat.java @@ -19,12 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.HashMap; +import java.util.Map.Entry; +import org.linphone.LinphoneUtils; import org.linphone.R; import android.content.Context; import android.graphics.Color; -import android.util.TypedValue; +import android.text.Spannable; +import android.text.SpannableStringBuilder; +import android.text.style.ImageSpan; import android.view.View; import android.widget.RelativeLayout; import android.widget.RelativeLayout.LayoutParams; @@ -34,6 +39,38 @@ import android.widget.TextView; * @author Sylvain Berfini */ public class BubbleChat { + private static final HashMap emoticons = new HashMap(); + static { + emoticons.put(":)", R.drawable.emo_im_happy); + emoticons.put(":-)", R.drawable.emo_im_happy); + emoticons.put(":(", R.drawable.emo_im_sad); + emoticons.put(":-(", R.drawable.emo_im_sad); + emoticons.put(":-P", R.drawable.emo_im_tongue_sticking_out); + emoticons.put(":P", R.drawable.emo_im_tongue_sticking_out); + emoticons.put(";-)", R.drawable.emo_im_winking); + emoticons.put(";)", R.drawable.emo_im_winking); + emoticons.put(":-D", R.drawable.emo_im_laughing); + emoticons.put(":D", R.drawable.emo_im_laughing); + emoticons.put("8-)", R.drawable.emo_im_cool); + emoticons.put("8)", R.drawable.emo_im_cool); + emoticons.put("O:)", R.drawable.emo_im_angel); + emoticons.put("O:-)", R.drawable.emo_im_angel); + emoticons.put(":-*", R.drawable.emo_im_kissing); + emoticons.put(":*", R.drawable.emo_im_kissing); + emoticons.put(":-/", R.drawable.emo_im_undecided); + emoticons.put(":/", R.drawable.emo_im_undecided); + emoticons.put(":-\\", R.drawable.emo_im_undecided); + emoticons.put(":\\", R.drawable.emo_im_undecided); + emoticons.put(":-O", R.drawable.emo_im_surprised); + emoticons.put(":O", R.drawable.emo_im_surprised); + emoticons.put(":-@", R.drawable.emo_im_yelling); + emoticons.put(":@", R.drawable.emo_im_yelling); + emoticons.put("O.o", R.drawable.emo_im_wtf); + emoticons.put("o.O", R.drawable.emo_im_wtf); + emoticons.put(":'(", R.drawable.emo_im_crying); + emoticons.put("$.$", R.drawable.emo_im_money_mouth); + } + private RelativeLayout view; public BubbleChat(Context context, int id, String message, String time, boolean isIncoming, int previousID) { @@ -57,11 +94,11 @@ public class BubbleChat { TextView messageView = new TextView(context); messageView.setId(id); messageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); - messageView.setText(message); + messageView.setText(getSmiledText(context, message)); messageView.setTextColor(Color.BLACK); view.setId(id); - layoutParams.setMargins(0, pixelsToDpi(context, 10), 0, 0); + layoutParams.setMargins(0, LinphoneUtils.pixelsToDpi(context.getResources(), 10), 0, 0); view.setLayoutParams(layoutParams); view.addView(messageView); @@ -113,7 +150,23 @@ public class BubbleChat { cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)); } - private int pixelsToDpi(Context context, int pixels) { - return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) pixels, context.getResources().getDisplayMetrics()); + public static Spannable getSmiledText(Context context, String text) { + SpannableStringBuilder builder = new SpannableStringBuilder(text); + int index; + + for (index = 0; index < builder.length(); index++) { + for (Entry entry : emoticons.entrySet()) { + int length = entry.getKey().length(); + if (index + length > builder.length()) + continue; + if (builder.subSequence(index, index + length).toString().equals(entry.getKey())) { + builder.setSpan(new ImageSpan(context, entry.getValue()), index, index + length, + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + index += length - 1; + break; + } + } + } + return builder; } }