From 52cf47619f45b5da1f64162c864b2dbbaab3bf61 Mon Sep 17 00:00:00 2001
From: akwizgran <akwizgran@users.sourceforge.net>
Date: Wed, 26 Feb 2014 18:36:51 +0000
Subject: [PATCH] Layout tweaks, dark action bar, don't send empty messages.

---
 .../res/drawable/bubble_read_left.png         | Bin 496 -> 0 bytes
 .../res/drawable/bubble_read_right.png        | Bin 507 -> 0 bytes
 .../res/drawable/bubble_unread_left.png       | Bin 341 -> 0 bytes
 .../res/drawable/bubble_unread_right.png      | Bin 322 -> 0 bytes
 briar-android/res/values-v11/styles.xml       |   8 +-
 briar-android/res/values/color.xml            |   3 +-
 briar-android/res/values/strings.xml          |   5 +-
 .../android/contact/ConversationActivity.java |  13 +--
 .../android/contact/ConversationAdapter.java  |  76 ++++--------------
 .../contact/WritePrivateMessageActivity.java  |   6 +-
 .../groups/WriteGroupPostActivity.java        |   6 +-
 .../android/util/LayoutUtils.java             |   2 +-
 12 files changed, 41 insertions(+), 78 deletions(-)
 delete mode 100644 briar-android/res/drawable/bubble_read_left.png
 delete mode 100644 briar-android/res/drawable/bubble_read_right.png
 delete mode 100644 briar-android/res/drawable/bubble_unread_left.png
 delete mode 100644 briar-android/res/drawable/bubble_unread_right.png

diff --git a/briar-android/res/drawable/bubble_read_left.png b/briar-android/res/drawable/bubble_read_left.png
deleted file mode 100644
index ec9ebc117d23037a8f4bf87b5c3eb1865fbd4c96..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 496
zcmV<M0T2F(P)<h;3K|Lk000e1NJLTq000yK0015c1^@s6ED}Cz00001b5ch_0Itp)
z=>Px$s!2paR7l6ImAy*?F&M^^`yi$CDu@nF1t$eZ2RFZV!BG%LDGmw_4vxCJh&VVp
zIadDx2cd|Q=pZOg&O+~c&0X>)uY*)d?X{OnvnKp_p1dCqC1X16c6(AO_2i5L#yOt@
zfJXqBrM9pnNoF|b&sytgN-3e1HfsRzsg!ak{Y4eF9LMn*0KD|V2qDE3b~>GvBuVZN
zvC<1G1dO6+2>_aiIPl&vgzW%8Q)`|1#xW?so|N)RYfbuX8e5K{Xj=$zJq(mvVHk$T
zQp#K~LJ09j*t`@%>>?tu0tz9#G)+&_G_6xgbHg%$obz*~RNVxWS(Gpg?*U-h#OA1?
zpv`>$16HfmRnPM-im1zM8^+jy@B1fN<7M=ReQk3lgxE(!H?QKMja{i!4n5C1qLh-n
zYV(fXhLo~lt+0E7Ah>0WZ4p9}QA&+U8OQOa5aLE_?PvXIkp;T|054f<%s5kmAb4er
z%{z|sJ;;8ckSdqUZ;Y{Z*LA=8p|&wPrIh*rfQhbs>!3$Oztw8JYprWmx%_95QdugM
m7G2kUKty|mJy{(9K;sABXylLR396$20000<MNUMnLSTaYMAsAm

diff --git a/briar-android/res/drawable/bubble_read_right.png b/briar-android/res/drawable/bubble_read_right.png
deleted file mode 100644
index 5bacbfa93a03a7afde2ae5001fc57d1b1054b9cd..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 507
zcmV<X0R;YuP)<h;3K|Lk000e1NJLTq000yK0015c1^@s6ED}Cz00001b5ch_0Itp)
z=>Px$wMj%lR7l6I);)_9F&GE%e<sgtmU%-CEUW}k&{DCm^yLFsD`I`x2o@qXf)@6|
zVPWY95d8ouBFNQVVRMCWr3jm3XOo@0*v!gs$g;PY)Zs_|$@3(^Y&JX8TJK<_kvZqi
zIp_8li^auJK*kun_vei<UyU(ml0g7qj3I<@+8A@BwLY5+u2AoN=A8R6pU-b5g9Eg-
z)_!Q)_Ifh7LIG6P+RsX<Ysuhhgb?7I`>vF_KML3%6uPc^tF?ZZ3=ZN?thIYese8%b
z5bnC}os{y~C?EjD7~!0IskMGH3fRZbthKvJsaMP8lKwZ3PFfay{HGy=Qve=py~5-1
zz4yCP$}gjULwgjEF$N;qYntXpG8kh-p64%w5RZ}$CB_KGm={94uBz&JQrYwvi0DaG
zRgc%rrA_xN&-2@LU4KmKlo%rb7$L-+O|Z2qj4>k1vTib&+%3!U{ib_OYcLSem9i`k
zlJ3JE`y+(7RM+*vNy{obj&aV9gb=riqWHN@(bEtkq8aD>a#0k&x9!D$Am{v7(=-<t
xV_nj_+{gSjoldW&VgLXs<)^l7>#;sde*soi!Eeay0#g70002ovPDHLkV1fZS?oa>#

diff --git a/briar-android/res/drawable/bubble_unread_left.png b/briar-android/res/drawable/bubble_unread_left.png
deleted file mode 100644
index 1152c1cbed6de35b5b077e7f33086f769a79e3e6..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 341
zcmV-b0jmCqP)<h;3K|Lk000e1NJLTq000yK0015c1^@s6ED}Cz00001b5ch_0Itp)
z=>Px$4@pEpR7l6I)z2zLQ5c5twGB>@iIj;lU`!bv*I-7OxCZ4W3|xb`D^OA{K}s1I
zn8<_)C1*gM$G}#n-8uX0z1H_$z^`}x{Za~wx}cs%VN2?TYB2`P12@(w#g>6Pz+w<s
z2X1X77h6-G#+zk>z=rzbl=Q`hz_Tssb2WzQ`=n*|2Gt$ldluFS1oqVrJ7yMksE)cc
zYX#K`I4~pAz~erxT0!6x_{s(6CKXI6rK+k@3jEuS)SsM|ZHKZKb|{TI_*r~y8tAV2
z))no#r`y0N46K`O0<U3U-E<3hXj^{H2fM01hJpWM6Sxl<0b@;9)axc%`l1%qtB^6;
nfG_z=7&rjV!oYe@2kOZ$yqMfuipU{;00000NkvXXu0mjfd0>&6

diff --git a/briar-android/res/drawable/bubble_unread_right.png b/briar-android/res/drawable/bubble_unread_right.png
deleted file mode 100644
index 29b4a618625b7aef1b8416c61df1995c74839d9f..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 322
zcmV-I0lof-P)<h;3K|Lk000e1NJLTq000yK0015c1^@s6ED}Cz00001b5ch_0Itp)
z=>Px#{7FPXR7l6I)<G)8Q547V`!`Tz@=_+sfHC!k&l=1q6Kha5VPFmBR-j(W5~P%Y
zfr(6*Q1S-k`!#UWO-kPXcNXyJoX)xD+@hYS^CcC2#i=?-f&v%7ToM$x0v01+178BG
zNl^6;Sc!m5JOFD+P~aXIB|+6^brb=c?!T*>5wM9DU?&FF@+ZJvD#I4vRl6jpdJqMH
zH{j@}H#5y+=(_J}?VVvQ_e0%Jmb~4&DK)d#KWFhD*b}f78Ejyp4pVRW5m@iN9O|sy
zs2i#Ebqg#<P5^K{^;!L;o9Dn%<cz9k>O!wGT1!M7M}7_!JXU8@Uy(x~gOyS~0hXTJ
UTioCTVgLXD07*qoM6N<$g6|E4!~g&Q

diff --git a/briar-android/res/values-v11/styles.xml b/briar-android/res/values-v11/styles.xml
index f5476f167a..3d35b1d09d 100644
--- a/briar-android/res/values-v11/styles.xml
+++ b/briar-android/res/values-v11/styles.xml
@@ -1,4 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-	<style name="LightTheme" parent="android:Theme.Holo.Light" />
+	<style name="LightTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+        <item name="android:actionBarStyle">@style/CustomActionBar</item>
+    </style>
+    <style name="CustomActionBar"
+           parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse">
+        <item name="android:background">@color/action_bar_background</item>
+    </style>
 </resources>
\ No newline at end of file
diff --git a/briar-android/res/values/color.xml b/briar-android/res/values/color.xml
index 384421bf8d..c306f6ddbb 100644
--- a/briar-android/res/values/color.xml
+++ b/briar-android/res/values/color.xml
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
+    <color name="action_bar_background">#2D3E50</color>
     <color name="home_screen_background">#FFFFFF</color>
     <color name="content_background">#FFFFFF</color>
     <color name="conversation_background">#DDDDDD</color>
     <color name="unread_background">#FFFFFF</color>
     <color name="read_background">#EEEEEE</color>
+    <color name="compose_background">#FFFFFF</color>
 	<color name="horizontal_border">#CCCCCC</color>
 	<color name="no_posts">#AAAAAA</color>
-	<color name="no_messages">#AAAAAA</color>
 </resources>
\ No newline at end of file
diff --git a/briar-android/res/values/strings.xml b/briar-android/res/values/strings.xml
index f2cf76982f..32bc6f1a99 100644
--- a/briar-android/res/values/strings.xml
+++ b/briar-android/res/values/strings.xml
@@ -45,7 +45,8 @@
     <string name="codes_do_not_match">Codes do not match</string>
     <string name="interfering">This could mean that someone is trying to interfere with your connection</string>
     <string name="contact_added_toast">Contact added</string>
-    <string name="done_button">Done</string>
+    <string name="private_message_hint">Type message</string>
+    <string name="message_sent_toast">Message sent</string>
     <string name="format_from">From: %s</string>
     <string name="format_to">To: %s</string>
     <string name="read_message_title">Private Message</string>
@@ -65,6 +66,7 @@
     <string name="choose_forum_name">Choose a name for your forum:</string>
     <string name="forum_visible_to_all">Share this forum with all contacts</string>
     <string name="forum_visible_to_some">Share this forum with chosen contacts</string>
+    <string name="done_button">Done</string>
     <string name="new_post_title">New Post</string>
     <string name="new_forum_item">New forum\u2026</string>
     <string name="manage_subscriptions_title">Available Forums</string>
@@ -77,7 +79,6 @@
     <string name="no_contacts">You don\'t have any contacts. Add a contact now?</string>
     <string name="add_button">Add</string>
     <string name="cancel_button">Cancel</string>
-    <string name="message_sent_toast">Message sent</string>
     <string name="post_sent_toast">Post sent</string>
     <string name="not_implemented_toast">Not implemented yet!</string>
     <string name="private_message_notification_title">New private message</string>
diff --git a/briar-android/src/org/briarproject/android/contact/ConversationActivity.java b/briar-android/src/org/briarproject/android/contact/ConversationActivity.java
index d71b8c2634..10b3fa4639 100644
--- a/briar-android/src/org/briarproject/android/contact/ConversationActivity.java
+++ b/briar-android/src/org/briarproject/android/contact/ConversationActivity.java
@@ -2,6 +2,7 @@ package org.briarproject.android.contact;
 
 import static android.text.InputType.TYPE_CLASS_TEXT;
 import static android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
+import static android.view.Gravity.CENTER_VERTICAL;
 import static android.view.View.GONE;
 import static android.view.View.VISIBLE;
 import static android.view.inputmethod.InputMethodManager.HIDE_IMPLICIT_ONLY;
@@ -140,7 +141,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
 		int background = res.getColor(R.color.conversation_background);
 		list.setBackgroundColor(background);
 		list.setDivider(new ColorDrawable(background));
-		list.setDividerHeight(LayoutUtils.getSeparatorWidth(this));
+		list.setDividerHeight(pad);
 		list.setAdapter(adapter);
 		list.setOnItemClickListener(this);
 		list.setVisibility(GONE);
@@ -155,7 +156,9 @@ implements EventListener, OnClickListener, OnItemClickListener {
 		LinearLayout footer = new LinearLayout(this);
 		footer.setLayoutParams(MATCH_WRAP);
 		footer.setOrientation(HORIZONTAL);
+		footer.setGravity(CENTER_VERTICAL);
 		footer.setPadding(pad, 0, 0, 0);
+		footer.setBackgroundColor(res.getColor(R.color.compose_background));
 
 		content = new EditText(this);
 		content.setId(1);
@@ -163,14 +166,13 @@ implements EventListener, OnClickListener, OnItemClickListener {
 		int inputType = TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
 				| TYPE_TEXT_FLAG_CAP_SENTENCES;
 		content.setInputType(inputType);
+		content.setHint(R.string.private_message_hint);
 		footer.addView(content);
 
 		sendButton = new ImageButton(this);
 		sendButton.setId(2);
 		sendButton.setBackgroundResource(0);
 		sendButton.setImageResource(R.drawable.social_send_now);
-		sendButton.setScaleX(1.5f);
-		sendButton.setScaleY(1.5f);
 		sendButton.setEnabled(false); // Enabled after loading the group
 		sendButton.setOnClickListener(this);
 		footer.addView(sendButton);
@@ -358,6 +360,8 @@ implements EventListener, OnClickListener, OnItemClickListener {
 	}
 
 	public void onClick(View view) {
+		String message = content.getText().toString();
+		if(message.equals("")) return;
 		// Don't use an earlier timestamp than the newest message
 		long timestamp = System.currentTimeMillis();
 		int count = adapter.getCount();
@@ -365,8 +369,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
 			long time = adapter.getItem(i).getHeader().getTimestamp() + 1;
 			if(time > timestamp) timestamp = time;
 		}
-		byte[] body = StringUtils.toUtf8(content.getText().toString());
-		createMessage(body, timestamp);
+		createMessage(StringUtils.toUtf8(message), timestamp);
 		Toast.makeText(this, R.string.message_sent_toast, LENGTH_SHORT).show();
 		content.setText("");
 		// Hide the soft keyboard
diff --git a/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java b/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java
index af0f6dbdfe..3a3ae841ee 100644
--- a/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java
+++ b/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java
@@ -2,31 +2,24 @@ package org.briarproject.android.contact;
 
 import static android.view.Gravity.LEFT;
 import static android.view.Gravity.RIGHT;
-import static android.widget.RelativeLayout.ALIGN_PARENT_LEFT;
-import static android.widget.RelativeLayout.ALIGN_PARENT_RIGHT;
-import static android.widget.RelativeLayout.ALIGN_PARENT_TOP;
-import static android.widget.RelativeLayout.BELOW;
-import static android.widget.RelativeLayout.LEFT_OF;
-import static android.widget.RelativeLayout.RIGHT_OF;
+import static android.widget.LinearLayout.VERTICAL;
+import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
 
 import java.util.ArrayList;
 
 import org.briarproject.R;
-import org.briarproject.android.util.CommonLayoutParams;
 import org.briarproject.android.util.LayoutUtils;
 import org.briarproject.api.db.MessageHeader;
 import org.briarproject.util.StringUtils;
 
 import android.content.Context;
 import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
 import android.text.format.DateUtils;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ArrayAdapter;
 import android.widget.ImageButton;
-import android.widget.ImageView;
-import android.widget.RelativeLayout;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 class ConversationAdapter extends ArrayAdapter<ConversationItem> {
@@ -46,17 +39,26 @@ class ConversationAdapter extends ArrayAdapter<ConversationItem> {
 		Context ctx = getContext();
 		Resources res = ctx.getResources();
 
+		LinearLayout layout = new LinearLayout(ctx);
+		layout.setOrientation(VERTICAL);
+		if(header.isLocal()) layout.setPadding(3 * pad, 0, 0, 0);
+		else layout.setPadding(0, 0, 3 * pad, 0);
+
 		int background;
 		if(header.isRead()) background = res.getColor(R.color.read_background);
 		else background = res.getColor(R.color.unread_background);
 
 		TextView date = new TextView(ctx);
 		date.setId(1);
+		date.setLayoutParams(MATCH_WRAP);
+		if(header.isLocal()) date.setGravity(RIGHT);
+		else date.setGravity(LEFT);
 		date.setTextSize(14);
 		date.setBackgroundColor(background);
 		date.setPadding(pad, pad, pad, 0);
 		long timestamp = header.getTimestamp();
 		date.setText(DateUtils.getRelativeTimeSpanString(ctx, timestamp));
+		layout.addView(date);
 
 		View content;
 		if(item.getBody() == null) {
@@ -73,61 +75,11 @@ class ConversationAdapter extends ArrayAdapter<ConversationItem> {
 			content = attachment;
 		}
 		content.setId(2);
+		content.setLayoutParams(MATCH_WRAP);
 		content.setBackgroundColor(background);
 		content.setPadding(pad, 0, pad, pad);
+		layout.addView(content);
 
-		ImageView bubble = new ImageView(ctx);
-		bubble.setId(3);
-
-		RelativeLayout layout = new RelativeLayout(ctx);
-		if(header.isLocal()) {
-			Drawable d;
-			if(header.isRead())
-				d = res.getDrawable(R.drawable.bubble_read_right);
-			else d = res.getDrawable(R.drawable.bubble_unread_right);
-			bubble.setImageDrawable(d);
-			layout.setPadding(d.getIntrinsicWidth(), 0, 0, 0);
-			// Bubble tip and date at the top right, content below
-			date.setGravity(RIGHT);
-			RelativeLayout.LayoutParams topRight =
-					CommonLayoutParams.relative();
-			topRight.addRule(ALIGN_PARENT_TOP);
-			topRight.addRule(ALIGN_PARENT_RIGHT);
-			layout.addView(bubble, topRight);
-			RelativeLayout.LayoutParams leftOf = CommonLayoutParams.relative();
-			leftOf.addRule(ALIGN_PARENT_TOP);
-			leftOf.addRule(ALIGN_PARENT_LEFT);
-			leftOf.addRule(LEFT_OF, 3);
-			layout.addView(date, leftOf);
-			RelativeLayout.LayoutParams below = CommonLayoutParams.relative();
-			below.addRule(ALIGN_PARENT_LEFT);
-			below.addRule(LEFT_OF, 3);
-			below.addRule(BELOW, 1);
-			layout.addView(content, below);
-		} else {
-			Drawable d;
-			if(header.isRead())
-				d = res.getDrawable(R.drawable.bubble_read_left);
-			else d = res.getDrawable(R.drawable.bubble_unread_left);
-			bubble.setImageDrawable(d);
-			layout.setPadding(0, 0, d.getIntrinsicWidth(), 0);
-			// Bubble tip and date at the top left, content below
-			date.setGravity(LEFT);
-			RelativeLayout.LayoutParams topLeft = CommonLayoutParams.relative();
-			topLeft.addRule(ALIGN_PARENT_TOP);
-			topLeft.addRule(ALIGN_PARENT_LEFT);
-			layout.addView(bubble, topLeft);
-			RelativeLayout.LayoutParams rightOf = CommonLayoutParams.relative();
-			rightOf.addRule(ALIGN_PARENT_TOP);
-			rightOf.addRule(ALIGN_PARENT_RIGHT);
-			rightOf.addRule(RIGHT_OF, 3);
-			layout.addView(date, rightOf);
-			RelativeLayout.LayoutParams below = CommonLayoutParams.relative();
-			below.addRule(ALIGN_PARENT_RIGHT);
-			below.addRule(RIGHT_OF, 3);
-			below.addRule(BELOW, 1);
-			layout.addView(content, below);
-		}
 		return layout;
 	}
 }
\ No newline at end of file
diff --git a/briar-android/src/org/briarproject/android/contact/WritePrivateMessageActivity.java b/briar-android/src/org/briarproject/android/contact/WritePrivateMessageActivity.java
index d0b5269069..d802d6f646 100644
--- a/briar-android/src/org/briarproject/android/contact/WritePrivateMessageActivity.java
+++ b/briar-android/src/org/briarproject/android/contact/WritePrivateMessageActivity.java
@@ -119,8 +119,6 @@ implements OnClickListener {
 		sendButton.setId(2);
 		sendButton.setBackgroundResource(0);
 		sendButton.setImageResource(R.drawable.social_send_now);
-		sendButton.setScaleX(1.5f);
-		sendButton.setScaleY(1.5f);
 		sendButton.setEnabled(false); // Enabled after loading the group
 		sendButton.setOnClickListener(this);
 		RelativeLayout.LayoutParams right = CommonLayoutParams.relative();
@@ -194,7 +192,9 @@ implements OnClickListener {
 	}
 
 	public void onClick(View view) {
-		createMessage(StringUtils.toUtf8(content.getText().toString()));
+		String message = content.getText().toString();
+		if(message.equals("")) return;
+		createMessage(StringUtils.toUtf8(message));
 		Toast.makeText(this, R.string.message_sent_toast, LENGTH_LONG).show();
 		finish();
 	}
diff --git a/briar-android/src/org/briarproject/android/groups/WriteGroupPostActivity.java b/briar-android/src/org/briarproject/android/groups/WriteGroupPostActivity.java
index af6fc08c48..a157936944 100644
--- a/briar-android/src/org/briarproject/android/groups/WriteGroupPostActivity.java
+++ b/briar-android/src/org/briarproject/android/groups/WriteGroupPostActivity.java
@@ -140,8 +140,6 @@ implements OnItemSelectedListener, OnClickListener {
 		sendButton.setId(3);
 		sendButton.setBackgroundResource(0);
 		sendButton.setImageResource(R.drawable.social_send_now);
-		sendButton.setScaleX(1.5f);
-		sendButton.setScaleY(1.5f);
 		sendButton.setEnabled(false); // Enabled after loading the group
 		sendButton.setOnClickListener(this);
 		RelativeLayout.LayoutParams right = CommonLayoutParams.relative();
@@ -270,7 +268,9 @@ implements OnItemSelectedListener, OnClickListener {
 
 	public void onClick(View view) {
 		if(group == null) throw new IllegalStateException();
-		createMessage(StringUtils.toUtf8(content.getText().toString()));
+		String message = content.getText().toString();
+		if(message.equals("")) return;
+		createMessage(StringUtils.toUtf8(message));
 		Toast.makeText(this, R.string.post_sent_toast, LENGTH_LONG).show();
 		finish();
 	}
diff --git a/briar-android/src/org/briarproject/android/util/LayoutUtils.java b/briar-android/src/org/briarproject/android/util/LayoutUtils.java
index 52b1ed9945..f23fd9ab8d 100644
--- a/briar-android/src/org/briarproject/android/util/LayoutUtils.java
+++ b/briar-android/src/org/briarproject/android/util/LayoutUtils.java
@@ -10,7 +10,7 @@ public class LayoutUtils {
 	public static int getSeparatorWidth(Context ctx) {
 		DisplayMetrics metrics = getDisplayMetrics(ctx);
 		int percent = Math.max(metrics.widthPixels, metrics.heightPixels) / 100;
-		return Math.max(2, percent - 7);
+		return Math.max(2, percent - 8);
 	}
 
 	public static int getPadding(Context ctx) {
-- 
GitLab