Fix edit chat incoming bubble

This commit is contained in:
Margaux Clerc 2016-02-24 11:14:31 +01:00
parent 56ec983bdd
commit 89ff575cbb
3 changed files with 114 additions and 98 deletions

View file

@ -1,11 +1,29 @@
<?xml version="1.0" encoding="utf-8"?> <?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"
android:id="@+id/bubble" android:id="@+id/bubble"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="left" android:gravity="left"
android:orientation="horizontal"> android:orientation="horizontal">
<CheckBox
android:id="@+id/delete_message"
android:button="@drawable/checkbox"
android:contentDescription="@string/content_description_delete"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:layout_alignParentRight="true"
android:visibility="gone" />
<LinearLayout
android:id="@+id/message_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/delete_message">
<LinearLayout <LinearLayout
android:background="@drawable/resizable_chat_bubble_incoming" android:background="@drawable/resizable_chat_bubble_incoming"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -92,16 +110,6 @@
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<CheckBox
android:id="@+id/delete"
android:button="@drawable/checkbox"
android:contentDescription="@string/content_description_delete"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:layout_alignParentRight="true"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
</RelativeLayout>

View file

@ -6,7 +6,7 @@
android:orientation="horizontal"> android:orientation="horizontal">
<CheckBox <CheckBox
android:id="@+id/delete" android:id="@+id/delete_message"
android:button="@drawable/checkbox" android:button="@drawable/checkbox"
android:contentDescription="@string/content_description_delete" android:contentDescription="@string/content_description_delete"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
@ -21,7 +21,7 @@
android:background="@drawable/resizable_chat_bubble_outgoing" android:background="@drawable/resizable_chat_bubble_outgoing"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@id/delete" android:layout_toLeftOf="@id/delete_message"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView

View file

@ -24,6 +24,7 @@ import java.io.File;
import android.app.Dialog; import android.app.Dialog;
import android.app.Fragment; import android.app.Fragment;
import android.graphics.Color;
import android.graphics.Matrix; import android.graphics.Matrix;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -64,6 +65,7 @@ import android.provider.MediaStore;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -390,14 +392,20 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
registerForContextMenu(v); registerForContextMenu(v);
RelativeLayout rlayout = new RelativeLayout(context); RelativeLayout rlayout = new RelativeLayout(context);
CheckBox deleteChatBubble = (CheckBox) v.findViewById(R.id.delete); CheckBox deleteChatBubble = (CheckBox) v.findViewById(R.id.delete_message);
if(isEditMode) { if(isEditMode) {
deleteChatBubble.setVisibility(View.VISIBLE); deleteChatBubble.setVisibility(View.VISIBLE);
if(message.isOutgoing()){
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layoutParams.setMargins(0, 10, 0, 10); layoutParams.setMargins(100, 10, 10, 10);
v.setLayoutParams(layoutParams); v.setLayoutParams(layoutParams);
} else {
LinearLayout message_layout = (LinearLayout) v.findViewById(R.id.message_content);
message_layout.setGravity(Gravity.RIGHT);
}
deleteChatBubble.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { deleteChatBubble.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) { public void onCheckedChanged(CompoundButton compoundButton, boolean b) {