conversation: ui refactoring

* show selected contact number
* use recycler view for better performance
* material design revamp

Tuleap: #102
Change-Id: I06fdabc97122bb40d026f5e49bd1d8a5ecb99ae7
diff --git a/ring-android/app/build.gradle b/ring-android/app/build.gradle
index dc6e374..6501a32 100644
--- a/ring-android/app/build.gradle
+++ b/ring-android/app/build.gradle
@@ -8,6 +8,7 @@
     compile 'com.android.support:design:23.1.+'
     compile 'com.android.support:cardview-v7:23.1.+'
     compile 'com.android.support:preference-v14:23.1.+'
+    compile 'com.android.support:recyclerview-v7:23.1.+'
     compile 'com.jayway.android.robotium:robotium-solo:5.4.1'
     compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
     compile 'com.googlecode.libphonenumber:libphonenumber:7.0.11'
diff --git a/ring-android/app/src/main/java/cx/ring/client/ConversationActivity.java b/ring-android/app/src/main/java/cx/ring/client/ConversationActivity.java
index 3769158..e1dfee8 100644
--- a/ring-android/app/src/main/java/cx/ring/client/ConversationActivity.java
+++ b/ring-android/app/src/main/java/cx/ring/client/ConversationActivity.java
@@ -32,6 +32,9 @@
 import android.os.RemoteException;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.DefaultItemAnimator;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
 import android.text.format.DateUtils;
 import android.util.Log;
 import android.util.Pair;
@@ -81,7 +84,7 @@
     private Conversation conversation = null;
     private SipUri preferredNumber = null;
 
-    private ListView histList = null;
+    private RecyclerView histList = null;
     private View msgSendBtn = null;
     private EditText msgEditTxt = null;
     private ViewGroup bottomPane = null;
@@ -92,6 +95,8 @@
     private NumberAdapter numberAdapter = null;
 
     static private Pair<Conversation, SipUri> getConversation(LocalService s, Intent i) {
+        if (s == null || i == null || i.getData() == null)
+            return new Pair<>(null, null);
         String conv_id = i.getData().getLastPathSegment();
         SipUri number = new SipUri(i.getStringExtra("number"));
         Log.w(TAG, "getConversation " + conv_id + " " + number);
@@ -164,7 +169,7 @@
             numberSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                 @Override
                 public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
-                    msgEditTxt.setHint("Send text to " + ((CallContact.Phone)numberAdapter.getItem(position)).getNumber().getRawUriString());
+                    msgEditTxt.setHint(getString(R.string.action_send_msg, ((CallContact.Phone)numberAdapter.getItem(position)).getNumber().getRawUriString()));
                 }
 
                 @Override
@@ -176,6 +181,8 @@
             preferredNumber = conversation.getContact().getPhones().get(0).getNumber();
         }
 
+        msgEditTxt.setHint(getString(R.string.action_send_msg, preferredNumber.getRawUriString()));
+
         invalidateOptionsMenu();
     }
 
@@ -209,6 +216,7 @@
         public void onReceive(Context context, Intent intent) {
             Log.w(TAG, "onReceive " + intent.getAction() + " " + intent.getDataString());
             refreshView();
+            histList.smoothScrollToPosition(adapter.getItemCount() - 1);
         }
     };
 
@@ -249,8 +257,13 @@
         //conversation = getIntent().getParcelableExtra("conversation");
 
         adapter = new ConversationAdapter(this);
-        histList = (ListView) findViewById(R.id.hist_list);
+        LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
+        mLayoutManager.setStackFromEnd(true);
+
+        histList = (RecyclerView) findViewById(R.id.hist_list);
+        histList.setLayoutManager(mLayoutManager);
         histList.setAdapter(adapter);
+        histList.setItemAnimator(new DefaultItemAnimator());
 
         numberSpinner = (Spinner) findViewById(R.id.number_selector);
 
@@ -305,10 +318,10 @@
             numbers = c.getPhones();
         }
 
-        public void updateDataset(CallContact c) {
+        /*public void updateDataset(CallContact c) {
             numbers = c.getPhones();
             notifyDataSetChanged();
-        }
+        }*/
 
         @Override
         public int getCount() {
@@ -357,18 +370,50 @@
         }
     }
 
-    private class ConversationAdapter extends BaseAdapter {
+    public static class ViewHolder extends RecyclerView.ViewHolder {
+        public ViewGroup txtEntry;
+        public TextView msgTxt;
+        public TextView msgDetailTxt;
+        public ImageView photo;
+        public ViewGroup callEntry;
+        public TextView histTxt;
+        public TextView histDetailTxt;
+        public ViewHolder(ViewGroup v, int type) {
+            super(v);
+            if (type == 2) {
+                callEntry = (ViewGroup) v.findViewById(R.id.call_entry);
+                histTxt = (TextView) v.findViewById(R.id.call_hist_txt);
+                histDetailTxt = (TextView) v.findViewById(R.id.call_details_txt);
+            } else {
+                txtEntry = (ViewGroup) v.findViewById(R.id.txt_entry);
+                msgTxt = (TextView) v.findViewById(R.id.msg_txt);
+                msgDetailTxt = (TextView) v.findViewById(R.id.msg_details_txt);
+                if (type == 0)
+                    photo = (ImageView) v.findViewById(R.id.photo);
+            }
+        }
+    }
+
+    private class ConversationAdapter extends RecyclerView.Adapter<ViewHolder> {
         final private Context context;
         final private ArrayList<Conversation.ConversationElement> texts = new ArrayList<>();
         private ExecutorService infos_fetcher = Executors.newCachedThreadPool();
 
-        public void updateDataset(ArrayList<Conversation.ConversationElement> list) {
+        public void updateDataset(final ArrayList<Conversation.ConversationElement> list) {
             Log.i(TAG, "updateDataset " + list.size());
-            if (list.size() == 0 && texts.size() == 0)
+            if (list.size() == texts.size())
                 return;
-            texts.clear();
-            texts.addAll(list);
-            notifyDataSetChanged();
+            int lastPos = texts.size();
+            int newItmes = list.size() - lastPos;
+            if (lastPos == 0 || newItmes < 0) {
+                texts.clear();
+                texts.addAll(list);
+                notifyDataSetChanged();
+            } else {
+                for (int i = lastPos; i < list.size(); i++)
+                    texts.add(list.get(i));
+                notifyItemRangeInserted(lastPos, newItmes);
+            }
         }
 
         ConversationAdapter(Context ctx) {
@@ -376,39 +421,38 @@
         }
 
         @Override
-        public int getCount() {
+        public int getItemCount() {
             return texts.size();
         }
 
         @Override
-        public Conversation.ConversationElement getItem(int position) {
-            return texts.get(position);
-        }
-
-        @Override
         public long getItemId(int position) {
             return 0;
         }
 
         @Override
-        public View getView(int position, View convertView, ViewGroup parent)
-        {
-            if (convertView == null)
-                convertView = LayoutInflater.from(context).inflate(R.layout.item_textmsg, parent, false);
+        public int getItemViewType(int position) {
+            Conversation.ConversationElement txt = texts.get(position);
+            if (txt.text != null) {
+                if (txt.text.isIncoming())
+                    return 0;
+                else
+                    return 1;
+            }
+            return 2;
+        }
 
-            ViewGroup txtEntry = (ViewGroup) convertView.findViewById(R.id.txt_entry);
-            TextView msgTxt = (TextView) convertView.findViewById(R.id.msg_txt);
-            TextView msgDetailTxt = (TextView) convertView.findViewById(R.id.msg_details_txt);
-            ImageView photo = (ImageView) convertView.findViewById(R.id.photo);
+        @Override
+        public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+            int res = viewType == 0 ? R.layout.item_conv_msg_peer : (viewType == 1 ? R.layout.item_conv_msg_me : R.layout.item_conv_call);
+            ViewGroup v = (ViewGroup)LayoutInflater.from(parent.getContext()).inflate(res, parent, false);
+            // set the view's size, margins, paddings and layout parameters
+            ViewHolder vh = new ViewHolder(v, viewType);
+            return vh;
+        }
 
-            ViewGroup txtEntryRight = (ViewGroup) convertView.findViewById(R.id.txt_entry_right);
-            TextView msgTxtRight = (TextView) convertView.findViewById(R.id.msg_txt_right);
-            TextView msgDetailTxtRight = (TextView) convertView.findViewById(R.id.msg_details_txt_right);
-
-            ViewGroup callEntry = (ViewGroup) convertView.findViewById(R.id.call_entry);
-            TextView histTxt = (TextView) convertView.findViewById(R.id.call_hist_txt);
-            TextView histDetailTxt = (TextView) convertView.findViewById(R.id.call_details_txt);
-
+        @Override
+        public void onBindViewHolder(ViewHolder h, int position) {
             Conversation.ConversationElement txt = texts.get(position);
             if (txt.text != null) {
                 boolean sep = false;
@@ -429,43 +473,24 @@
                     }
                 }
 
-                callEntry.setVisibility(View.GONE);
-                TextView message;
-                TextView details;
 
                 if (txt.text.isIncoming()) {
-                    txtEntry.setVisibility(View.VISIBLE);
-                    txtEntryRight.setVisibility(View.GONE);
-                    message = msgTxt;
-                    details = msgDetailTxt;
-                    photo.setImageBitmap(null);
+                    h.photo.setImageBitmap(null);
                     if (/*sep && */!sep_same)
-                        infos_fetcher.execute(new ContactPictureTask(context, photo, txt.text.getContact()));
-                } else {
-                    txtEntry.setVisibility(View.GONE);
-                    txtEntryRight.setVisibility(View.VISIBLE);
-                    message = msgTxtRight;
-                    details = msgDetailTxtRight;
+                        infos_fetcher.execute(new ContactPictureTask(context, h.photo, txt.text.getContact()));
                 }
-
-                message.setText(txt.text.getMessage());
+                h.msgTxt.setText(txt.text.getMessage());
                 if (sep) {
-                    details.setVisibility(View.VISIBLE);
-                    details.setText(DateUtils.getRelativeTimeSpanString(txt.text.getTimestamp(), new Date().getTime(), 0, 0));
+                    h.msgDetailTxt.setVisibility(View.VISIBLE);
+                    h.msgDetailTxt.setText(DateUtils.getRelativeTimeSpanString(txt.text.getTimestamp(), new Date().getTime(), 0, 0));
                 } else {
-                    details.setVisibility(View.GONE);
+                    h.msgDetailTxt.setVisibility(View.GONE);
                 }
             } else {
-                callEntry.setVisibility(View.VISIBLE);
-                txtEntry.setVisibility(View.GONE);
-                txtEntryRight.setVisibility(View.GONE);
-                msgTxt.setText("");
-                histTxt.setText(txt.call.isIncoming() ? getString(R.string.notif_incoming_call_title, txt.call.getNumber())
+                h.histTxt.setText(txt.call.isIncoming() ? getString(R.string.notif_incoming_call_title, txt.call.getNumber())
                                                        : getString(R.string.notif_outgoing_call_title, txt.call.getNumber()));
-                histDetailTxt.setText(DateFormat.getDateTimeInstance().format(txt.call.getStartDate()));
+                h.histDetailTxt.setText(DateFormat.getDateTimeInstance().format(txt.call.getStartDate()));
             }
-
-            return convertView;
         }
     }
 
diff --git a/ring-android/app/src/main/java/cx/ring/model/Conference.java b/ring-android/app/src/main/java/cx/ring/model/Conference.java
index 618e02f..8f13f6e 100644
--- a/ring-android/app/src/main/java/cx/ring/model/Conference.java
+++ b/ring-android/app/src/main/java/cx/ring/model/Conference.java
@@ -57,7 +57,7 @@
     public static String DEFAULT_ID = "-1";
 
     public boolean isRinging() {
-        return participants.get(0).isRinging();
+        return !participants.isEmpty() && participants.get(0).isRinging();
     }
 
     public interface state {
diff --git a/ring-android/app/src/main/java/cx/ring/model/Conversation.java b/ring-android/app/src/main/java/cx/ring/model/Conversation.java
index 1117a27..2988049 100644
--- a/ring-android/app/src/main/java/cx/ring/model/Conversation.java
+++ b/ring-android/app/src/main/java/cx/ring/model/Conversation.java
@@ -47,9 +47,9 @@
 
     public CallContact contact;
     /** accountId -> histroy entries */
-    final private Map<String, HistoryEntry> history = new HashMap<>();
-
+    private final Map<String, HistoryEntry> history = new HashMap<>();
     public final ArrayList<Conference> current_calls;
+    private final ArrayList<ConversationElement> agregate_history = new ArrayList<>(32);
 
     // runtime flag set to true if the user
     public boolean mVisible = false;
@@ -156,6 +156,7 @@
             e.addHistoryCall(c, contact);
             history.put(accountId, e);
         }
+        agregate_history.add(new ConversationElement(c));
     }
     public void addTextMessage(TextMessage txt) {
         if (txt.getCallId() != null && !txt.getCallId().isEmpty()) {
@@ -174,23 +175,17 @@
             e.addTextMessage(txt);
             history.put(accountId, e);
         }
+        agregate_history.add(new ConversationElement(txt));
     }
 
     public ArrayList<ConversationElement> getHistory() {
-        ArrayList<ConversationElement> all = new ArrayList<>();
-        for (HistoryEntry e : history.values()) {
-            for (HistoryCall c : e.getCalls().values())
-                all.add(new ConversationElement(c));
-            for (TextMessage t : e.getTextMessages().values())
-                all.add(new ConversationElement(t));
-        }
-        Collections.sort(all, new Comparator<ConversationElement>() {
+        Collections.sort(agregate_history, new Comparator<ConversationElement>() {
             @Override
             public int compare(ConversationElement lhs, ConversationElement rhs) {
-                return (int)((lhs.getDate() - rhs.getDate())/1000l);
+                return (int)((lhs.getDate() - rhs.getDate())/1000L);
             }
         });
-        return all;
+        return agregate_history;
     }
 
     public Set<String> getAccountsUsed() {
diff --git a/ring-android/app/src/main/res/drawable/textmsg_me_background.xml b/ring-android/app/src/main/res/drawable/textmsg_me_background.xml
new file mode 100644
index 0000000..709d1e7
--- /dev/null
+++ b/ring-android/app/src/main/res/drawable/textmsg_me_background.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <stroke
+        android:width="0dp"
+        android:color="@android:color/transparent" />
+
+    <solid android:color="#cfd8dc" />
+
+    <padding
+        android:left="1dp"
+        android:right="1dp"
+        android:top="1dp" />
+
+    <corners android:radius="5dp" />
+
+</shape>
\ No newline at end of file
diff --git a/ring-android/app/src/main/res/layout/frag_conversation.xml b/ring-android/app/src/main/res/layout/frag_conversation.xml
index 6b44ebb..37e2607 100644
--- a/ring-android/app/src/main/res/layout/frag_conversation.xml
+++ b/ring-android/app/src/main/res/layout/frag_conversation.xml
@@ -1,30 +1,31 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:background="#ebeff0"
     android:orientation="vertical"
     tools:context=".client.ConversationActivity">
 
-    <ListView
+    <android.support.v7.widget.RecyclerView
         android:id="@+id/hist_list"
         android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="1"
-        android:background="#ebeff0"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentTop="true"
         android:clipToPadding="false"
         android:divider="@null"
         android:listSelector="@android:color/transparent"
-        android:paddingBottom="8dp"
+        android:paddingBottom="72dp"
         android:paddingTop="8dp"
-        android:stackFromBottom="true"
-        android:transcriptMode="alwaysScroll"
-        tools:listitem="@layout/item_textmsg" />
+        tools:listitem="@layout/item_conv_msg_peer" />
 
     <RelativeLayout
         android:id="@+id/ongoingcall_pane"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="48dp"
         android:layout_gravity="center_horizontal"
         android:background="#e3c1c1">
 
@@ -40,44 +41,53 @@
             android:textColor="@color/text_color_primary" />
     </RelativeLayout>
 
-    <ImageView
-        android:id="@+id/divider"
+    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
         android:layout_width="fill_parent"
-        android:layout_height="1dp"
-        android:layout_gravity="center_horizontal"
-        android:background="#bdbdbd" />
-
-    <LinearLayout
-        android:layout_width="match_parent"
         android:layout_height="48dp"
-        android:background="@android:color/white"
-        android:orientation="horizontal">
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentRight="true"
+        android:layout_marginBottom="16dp"
+        android:layout_marginLeft="8dp"
+        android:layout_marginRight="8dp"
+        card_view:cardCornerRadius="2dp">
 
-        <Spinner
-            android:id="@+id/number_selector"
-            android:layout_width="wrap_content"
+        <LinearLayout
+            android:layout_width="fill_parent"
             android:layout_height="fill_parent"
-            tools:listitem="@layout/item_number_selected"
-            android:visibility="visible" />
+            android:orientation="horizontal">
 
-        <EditText
-            android:id="@+id/msg_input_txt"
-            android:layout_width="0dp"
-            android:layout_height="fill_parent"
-            android:layout_weight="1"
-            android:hyphenationFrequency="normal"
-            android:imeOptions="actionSend"
-            android:inputType="textShortMessage" />
+            <Spinner
+                android:id="@+id/number_selector"
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:visibility="visible"
+                tools:listitem="@layout/item_number_selected" />
 
-        <ImageButton
-            android:id="@+id/msg_send"
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
-            android:background="@android:color/transparent"
-            android:contentDescription="@string/send_message"
-            android:padding="8dp"
-            android:src="@drawable/ic_send_black_24dp"
-            android:tint="@android:color/darker_gray" />
-    </LinearLayout>
+            <EditText
+                android:id="@+id/msg_input_txt"
+                android:layout_width="0dp"
+                android:layout_height="fill_parent"
+                android:layout_weight="1"
+                android:background="@null"
+                android:hint="@string/write_a_message"
+                android:hyphenationFrequency="normal"
+                android:imeOptions="actionSend"
+                android:inputType="textShortMessage"
+                android:paddingLeft="8dp">
+                <requestFocus />
+            </EditText>
 
-</LinearLayout>
\ No newline at end of file
+            <ImageButton
+                android:id="@+id/msg_send"
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:background="?selectableItemBackgroundBorderless"
+                android:contentDescription="@string/send_message"
+                android:padding="8dp"
+                android:src="@drawable/ic_send_black_24dp"
+                android:tint="@android:color/darker_gray" />
+        </LinearLayout>
+    </android.support.v7.widget.CardView>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/ring-android/app/src/main/res/layout/item_conv_call.xml b/ring-android/app/src/main/res/layout/item_conv_call.xml
new file mode 100644
index 0000000..07af1ae
--- /dev/null
+++ b/ring-android/app/src/main/res/layout/item_conv_call.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+Copyright (C) 2004-2016 Savoir-faire Linux Inc.
+
+Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
+
+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 3 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_gravity="right|bottom"
+    android:layout_marginBottom="8dp"
+    android:layout_marginTop="8dp"
+    android:background="#ced8da"
+    android:descendantFocusability="blocksDescendants"
+    android:focusable="false"
+    android:padding="12dp">
+
+    <TextView
+        android:id="@+id/call_hist_txt"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:ellipsize="marquee"
+        android:marqueeRepeatLimit="marquee_forever"
+        android:scrollHorizontally="true"
+        android:singleLine="false"
+        android:text="Appel manqué"
+        android:textColor="@color/text_color_primary"
+        android:textSize="14sp" />
+
+    <TextView
+        android:id="@+id/call_details_txt"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="false"
+        android:layout_below="@+id/call_hist_txt"
+        android:text="Adrien - 12 mars"
+        android:textColor="@color/text_color_secondary"
+        android:textSize="12sp" />
+
+</RelativeLayout>
diff --git a/ring-android/app/src/main/res/layout/item_conv_msg_me.xml b/ring-android/app/src/main/res/layout/item_conv_msg_me.xml
new file mode 100644
index 0000000..d902c95
--- /dev/null
+++ b/ring-android/app/src/main/res/layout/item_conv_msg_me.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+Copyright (C) 2004-2016 Savoir-faire Linux Inc.
+
+Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
+
+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 3 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/txt_entry"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_gravity="right"
+    android:background="@android:color/transparent"
+    android:focusable="false"
+    android:paddingBottom="4dp"
+    android:paddingEnd="@dimen/padding_large"
+    android:paddingLeft="@dimen/padding_large"
+    android:paddingRight="@dimen/padding_large"
+    android:paddingStart="@dimen/padding_large"
+    android:paddingTop="4dp">
+
+    <TextView
+        android:id="@+id/msg_txt"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentEnd="true"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentTop="true"
+        android:layout_marginLeft="48dp"
+        android:layout_marginStart="48dp"
+        android:autoLink="all"
+        android:background="@drawable/textmsg_me_background"
+        android:ellipsize="marquee"
+        android:focusable="true"
+        android:marqueeRepeatLimit="marquee_forever"
+        android:padding="12dp"
+        android:scrollHorizontally="true"
+        android:singleLine="false"
+        android:textColor="@color/text_color_primary"
+        android:textIsSelectable="true"
+        android:textSize="16sp" />
+
+    <TextView
+        android:id="@+id/msg_details_txt"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignEnd="@+id/msg_txt"
+        android:layout_alignRight="@+id/msg_txt"
+        android:layout_below="@+id/msg_txt"
+        android:layout_marginBottom="8dp"
+        android:textColor="@color/text_color_secondary"
+        android:textSize="14sp" />
+</RelativeLayout>
+
diff --git a/ring-android/app/src/main/res/layout/item_conv_msg_peer.xml b/ring-android/app/src/main/res/layout/item_conv_msg_peer.xml
new file mode 100644
index 0000000..d2c1818
--- /dev/null
+++ b/ring-android/app/src/main/res/layout/item_conv_msg_peer.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+Copyright (C) 2004-2016 Savoir-faire Linux Inc.
+
+Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
+
+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 3 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/txt_entry"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:background="@android:color/transparent"
+    android:focusable="false"
+    android:paddingBottom="4dp"
+    android:paddingEnd="@dimen/padding_large"
+    android:paddingLeft="@dimen/padding_large"
+    android:paddingRight="@dimen/padding_large"
+    android:paddingStart="@dimen/padding_large"
+    android:paddingTop="4dp">
+
+    <ImageView
+        android:id="@+id/photo"
+        android:layout_width="40dp"
+        android:layout_height="40dp"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentStart="true"
+        android:layout_alignParentTop="true"
+        android:layout_marginEnd="16dp"
+        android:layout_marginRight="16dp"
+        android:background="@null"
+        android:scaleType="centerCrop" />
+
+    <TextView
+        android:id="@+id/msg_txt"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentTop="true"
+        android:layout_marginEnd="48dp"
+        android:layout_marginRight="48dp"
+        android:layout_toEndOf="@+id/photo"
+        android:layout_toRightOf="@+id/photo"
+        android:autoLink="all"
+        android:background="@drawable/textmsg_background"
+        android:ellipsize="marquee"
+        android:focusable="true"
+        android:marqueeRepeatLimit="marquee_forever"
+        android:padding="12dp"
+        android:scrollHorizontally="true"
+        android:singleLine="false"
+        android:textColor="@color/text_color_primary"
+        android:textIsSelectable="true"
+        android:textSize="16sp" />
+
+    <TextView
+        android:id="@+id/msg_details_txt"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/msg_txt"
+        android:layout_marginBottom="8dp"
+        android:layout_toEndOf="@id/photo"
+        android:layout_toRightOf="@+id/photo"
+        android:textColor="@color/text_color_secondary"
+        android:textSize="14sp" />
+
+</RelativeLayout>
diff --git a/ring-android/app/src/main/res/layout/item_message.xml b/ring-android/app/src/main/res/layout/item_message.xml
deleted file mode 100644
index a9042a3..0000000
--- a/ring-android/app/src/main/res/layout/item_message.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content" >
-
-    <LinearLayout
-        android:id="@+id/wrapper"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content" >
-
-        <TextView
-            android:id="@+id/comment"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:layout_margin="5dip"
-            android:background="@drawable/item_generic_selector"
-            android:paddingLeft="10dip"
-            android:autoLink="all"
-            android:textColor="@android:color/primary_text_light" />
-    </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
diff --git a/ring-android/app/src/main/res/layout/item_textmsg.xml b/ring-android/app/src/main/res/layout/item_textmsg.xml
deleted file mode 100644
index 52545fe..0000000
--- a/ring-android/app/src/main/res/layout/item_textmsg.xml
+++ /dev/null
@@ -1,170 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!--
-Copyright (C) 2004-2016 Savoir-faire Linux Inc.
-
-Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
-
-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 3 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., 675 Mass Ave, Cambridge, MA 02139, USA.
--->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content">
-
-    <RelativeLayout
-        android:id="@+id/txt_entry_right"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:background="@android:color/transparent"
-        android:focusable="false"
-        android:layout_gravity="right"
-        android:paddingRight="@dimen/padding_large"
-        android:paddingEnd="@dimen/padding_large"
-        android:paddingLeft="@dimen/padding_large"
-        android:paddingStart="@dimen/padding_large"
-        android:paddingTop="4dp"
-        android:paddingBottom="4dp"
-        android:visibility="gone">
-
-        <TextView
-            android:id="@+id/msg_txt_right"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:background="@drawable/textmsg_background"
-            android:ellipsize="marquee"
-            android:marqueeRepeatLimit="marquee_forever"
-            android:padding="12dp"
-            android:scrollHorizontally="true"
-            android:singleLine="false"
-            android:textColor="@color/text_color_primary"
-            android:textSize="16sp"
-            android:focusable="true"
-            android:textIsSelectable="true"
-            android:layout_alignParentTop="true"
-            android:layout_alignParentRight="true"
-            android:layout_alignParentEnd="true"
-            android:layout_marginLeft="48dp"
-            android:layout_marginStart="48dp"
-            android:autoLink="all" />
-
-        <TextView
-            android:id="@+id/msg_details_txt_right"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textColor="@color/text_color_secondary"
-            android:textSize="14sp"
-            android:layout_below="@+id/msg_txt_right"
-            android:layout_alignRight="@+id/msg_txt_right"
-            android:layout_alignEnd="@+id/msg_txt_right"
-            android:layout_marginBottom="8dp" />
-    </RelativeLayout>
-
-    <RelativeLayout
-        android:id="@+id/txt_entry"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:background="@android:color/transparent"
-        android:focusable="false"
-        android:paddingTop="4dp"
-        android:paddingBottom="4dp"
-        android:paddingRight="@dimen/padding_large"
-        android:paddingEnd="@dimen/padding_large"
-        android:paddingLeft="@dimen/padding_large"
-        android:paddingStart="@dimen/padding_large"
-        android:visibility="gone">
-
-        <ImageView
-            android:id="@+id/photo"
-            android:layout_width="40dp"
-            android:layout_height="40dp"
-            android:layout_alignParentLeft="true"
-            android:layout_alignParentStart="true"
-            android:layout_alignParentTop="true"
-            android:layout_marginRight="16dp"
-            android:layout_marginEnd="16dp"
-            android:background="@null"
-            android:scaleType="centerCrop" />
-
-        <TextView
-            android:id="@+id/msg_txt"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentTop="true"
-            android:layout_toEndOf="@+id/photo"
-            android:layout_toRightOf="@+id/photo"
-            android:background="@drawable/textmsg_background"
-            android:ellipsize="marquee"
-            android:marqueeRepeatLimit="marquee_forever"
-            android:padding="12dp"
-            android:scrollHorizontally="true"
-            android:singleLine="false"
-            android:textColor="@color/text_color_primary"
-            android:textSize="16sp"
-            android:focusable="true"
-            android:textIsSelectable="true"
-            android:layout_marginRight="48dp"
-            android:layout_marginEnd="48dp"
-            android:autoLink="all" />
-
-        <TextView
-            android:id="@+id/msg_details_txt"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_below="@+id/msg_txt"
-            android:layout_toRightOf="@+id/photo"
-            android:textColor="@color/text_color_secondary"
-            android:textSize="14sp"
-            android:layout_marginBottom="8dp"
-            android:layout_toEndOf="@id/photo" />
-
-    </RelativeLayout>
-
-    <RelativeLayout
-        android:id="@+id/call_entry"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:focusable="false"
-        android:descendantFocusability="blocksDescendants"
-        android:background="#ced8da"
-        android:padding="12dp"
-        android:layout_marginBottom="8dp"
-        android:layout_gravity="right|bottom"
-        android:layout_marginTop="8dp"
-        android:visibility="visible">
-
-        <TextView
-            android:id="@+id/call_hist_txt"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:ellipsize="marquee"
-            android:marqueeRepeatLimit="marquee_forever"
-            android:scrollHorizontally="true"
-            android:singleLine="false"
-            android:text="Appel manqué"
-            android:textColor="@color/text_color_primary"
-            android:textSize="14sp"
-            />
-
-        <TextView
-            android:id="@+id/call_details_txt"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentLeft="false"
-            android:text="Adrien - 12 mars"
-            android:textColor="@color/text_color_secondary"
-            android:textSize="12sp"
-            android:layout_below="@+id/call_hist_txt" />
-
-    </RelativeLayout>
-</FrameLayout>
diff --git a/ring-android/app/src/main/res/values/strings.xml b/ring-android/app/src/main/res/values/strings.xml
index de0181d..013e228 100644
--- a/ring-android/app/src/main/res/values/strings.xml
+++ b/ring-android/app/src/main/res/values/strings.xml
@@ -24,6 +24,7 @@
     <string name="app_name" translatable="false">Ring</string>
     <string name="app_author" translatable="false" >Savoir-faire Linux Inc.</string>
     <string name="app_website" translatable="false">http://ring.cx</string>
+    <string name="copyright" translatable="false">Copyright © \u00A9 2004&#8211;2016 Savoir-faire Linux Inc.</string>
 
     <!-- RingActivity -->
     <string name="close_msg">Press back again to leave</string>
@@ -110,7 +111,7 @@
     <string name="action_call_hold">Hold</string>
     <string name="action_call_hangup">Hang up</string>
     <string name="action_settings">Settings</string>
-    <string name="copyright">Copyright \u00A9 2004&#8211;2016 Savoir-faire Linux Inc.</string>
+    <string name="action_send_msg">"Send text to %1$s"</string>
     <string name="web_site">Website</string>
     <string name="help_gestures"> This view will help users with different interactions during calls. Different actions will be described; Long press, fling, swype etc.</string>
     <string name="send_message">Send message</string>
@@ -126,5 +127,6 @@
     <string name="ab_action_contact_add">Add to contacts</string>
     <string name="ab_action_audio_call">Audio call</string>
     <string name="share_via">Share via</string>
+    <string name="write_a_message">Write a message</string>
 
 </resources>