mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Layout tweaks, dark action bar, don't send empty messages.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 496 B |
Binary file not shown.
|
Before Width: | Height: | Size: 507 B |
Binary file not shown.
|
Before Width: | Height: | Size: 341 B |
Binary file not shown.
|
Before Width: | Height: | Size: 322 B |
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user