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 Binary files a/briar-android/res/drawable/bubble_read_left.png and /dev/null differ 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 Binary files a/briar-android/res/drawable/bubble_read_right.png and /dev/null differ 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 Binary files a/briar-android/res/drawable/bubble_unread_left.png and /dev/null differ 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 Binary files a/briar-android/res/drawable/bubble_unread_right.png and /dev/null differ diff --git a/briar-android/res/values-v11/styles.xml b/briar-android/res/values-v11/styles.xml index f5476f167a1086f597cbf7495a8624d65fac2cc1..3d35b1d09db047df0ce565820e8b7b81d43b463b 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 384421bf8df44b2638108d93188177abc5c0fabc..c306f6ddbb4fac83da33cfc965b39403cce6c3aa 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 f2cf76982f14f7796a33b8cf4c645178b9ddbec4..32bc6f1a9959bf26008cfd71b6452f93cab3b9bd 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 d71b8c2634e7004dd39a4b36eaa2bf1c33623ae9..10b3fa463945c3a4d0d4caaa8f8528a9050d8731 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 af0f6dbdfe9a5661cb892b725e23e6f7dcabfbad..3a3ae841ee19fb664e59ffac372091be7e35c1cd 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 d0b52690692f780006dbbc643b3d20ae19f3e4b5..d802d6f6469e1dd80f97d3b688defda57aa56549 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 af6fc08c48fb99fc4aa7772f826e1458505be279..a157936944c20f948eb654a7341888d5c8102fbd 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 52b1ed994537e6c67bcd012cb80d2d2dba8af1a2..f23fd9ab8d769c7dbaa3269172e507d782178baa 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) {