diff --git a/briar-android/res/values/strings.xml b/briar-android/res/values/strings.xml
index ab5f4d87c..86267720c 100644
--- a/briar-android/res/values/strings.xml
+++ b/briar-android/res/values/strings.xml
@@ -82,8 +82,7 @@
Subscribed, shared with all contacts
Subscribed, shared with chosen contacts
Not subscribed
- New nickname\u2026
- New Nickname
+ New Identity
Create
You don\'t have any contacts. Add a contact now?
Add
diff --git a/briar-android/src/org/briarproject/android/contact/ContactListAdapter.java b/briar-android/src/org/briarproject/android/contact/ContactListAdapter.java
index e02799b6e..42b090fec 100644
--- a/briar-android/src/org/briarproject/android/contact/ContactListAdapter.java
+++ b/briar-android/src/org/briarproject/android/contact/ContactListAdapter.java
@@ -1,5 +1,6 @@
package org.briarproject.android.contact;
+import static android.text.TextUtils.TruncateAt.END;
import static android.view.Gravity.CENTER_VERTICAL;
import static android.widget.LinearLayout.HORIZONTAL;
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
@@ -52,7 +53,8 @@ class ContactListAdapter extends ArrayAdapter {
// Give me all the unused width
name.setLayoutParams(WRAP_WRAP_1);
name.setTextSize(18);
- name.setMaxLines(1);
+ name.setSingleLine();
+ name.setEllipsize(END);
name.setPadding(0, pad, pad, pad);
int unread = item.getUnreadCount();
String contactName = item.getContact().getAuthor().getName();
diff --git a/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java b/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java
index 7fe48d298..f22216ec7 100644
--- a/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java
+++ b/briar-android/src/org/briarproject/android/contact/ConversationAdapter.java
@@ -1,5 +1,6 @@
package org.briarproject.android.contact;
+import static android.view.Gravity.CENTER_VERTICAL;
import static android.widget.LinearLayout.HORIZONTAL;
import static java.text.DateFormat.SHORT;
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
@@ -38,6 +39,7 @@ class ConversationAdapter extends ArrayAdapter {
LinearLayout layout = new LinearLayout(ctx);
layout.setOrientation(HORIZONTAL);
+ layout.setGravity(CENTER_VERTICAL);
if(!header.isRead()) {
Resources res = ctx.getResources();
layout.setBackgroundColor(res.getColor(R.color.unread_background));
diff --git a/briar-android/src/org/briarproject/android/contact/WritePrivateMessageActivity.java b/briar-android/src/org/briarproject/android/contact/WritePrivateMessageActivity.java
index ad9addef7..743cc6d31 100644
--- a/briar-android/src/org/briarproject/android/contact/WritePrivateMessageActivity.java
+++ b/briar-android/src/org/briarproject/android/contact/WritePrivateMessageActivity.java
@@ -2,9 +2,12 @@ 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.widget.LinearLayout.HORIZONTAL;
+import static android.text.TextUtils.TruncateAt.END;
import static android.widget.LinearLayout.VERTICAL;
+import static android.widget.RelativeLayout.ALIGN_PARENT_LEFT;
+import static android.widget.RelativeLayout.ALIGN_PARENT_RIGHT;
+import static android.widget.RelativeLayout.CENTER_VERTICAL;
+import static android.widget.RelativeLayout.LEFT_OF;
import static android.widget.Toast.LENGTH_LONG;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
@@ -20,7 +23,7 @@ import javax.inject.Inject;
import org.briarproject.R;
import org.briarproject.android.BriarActivity;
-import org.briarproject.android.util.ElasticHorizontalSpace;
+import org.briarproject.android.util.CommonLayoutParams;
import org.briarproject.android.util.LayoutUtils;
import org.briarproject.api.AuthorId;
import org.briarproject.api.LocalAuthor;
@@ -46,6 +49,7 @@ import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -94,38 +98,47 @@ implements OnClickListener {
layout.setLayoutParams(MATCH_WRAP);
layout.setOrientation(VERTICAL);
- LinearLayout header = new LinearLayout(this);
+ RelativeLayout header = new RelativeLayout(this);
header.setLayoutParams(MATCH_WRAP);
- header.setOrientation(HORIZONTAL);
- header.setGravity(CENTER_VERTICAL);
int pad = LayoutUtils.getPadding(this);
from = new TextView(this);
+ from.setId(1);
from.setTextSize(18);
+ from.setSingleLine();
+ from.setEllipsize(END);
from.setPadding(pad, pad, pad, pad);
from.setText(R.string.from);
- header.addView(from);
-
- header.addView(new ElasticHorizontalSpace(this));
+ RelativeLayout.LayoutParams leftOf = CommonLayoutParams.wrapWrap();
+ leftOf.addRule(ALIGN_PARENT_LEFT);
+ leftOf.addRule(CENTER_VERTICAL);
+ leftOf.addRule(LEFT_OF, 2);
+ header.addView(from, leftOf);
sendButton = new ImageButton(this);
+ sendButton.setId(2);
sendButton.setBackgroundResource(0);
sendButton.setImageResource(R.drawable.social_send_now);
sendButton.setEnabled(false); // Enabled after loading the group
sendButton.setOnClickListener(this);
- header.addView(sendButton);
+ RelativeLayout.LayoutParams right = CommonLayoutParams.wrapWrap();
+ right.addRule(ALIGN_PARENT_RIGHT);
+ right.addRule(CENTER_VERTICAL);
+ header.addView(sendButton, right);
layout.addView(header);
to = new TextView(this);
to.setTextSize(18);
+ to.setSingleLine();
+ to.setEllipsize(END);
to.setPadding(pad, 0, pad, pad);
String format = getResources().getString(R.string.format_to);
to.setText(String.format(format, contactName));
layout.addView(to);
content = new EditText(this);
- content.setId(1);
+ content.setId(3);
int inputType = TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
| TYPE_TEXT_FLAG_CAP_SENTENCES;
content.setInputType(inputType);
diff --git a/briar-android/src/org/briarproject/android/groups/GroupAdapter.java b/briar-android/src/org/briarproject/android/groups/GroupAdapter.java
index 25195e5d3..09c2ad732 100644
--- a/briar-android/src/org/briarproject/android/groups/GroupAdapter.java
+++ b/briar-android/src/org/briarproject/android/groups/GroupAdapter.java
@@ -1,5 +1,6 @@
package org.briarproject.android.groups;
+import static android.view.Gravity.CENTER_VERTICAL;
import static android.widget.LinearLayout.HORIZONTAL;
import static java.text.DateFormat.SHORT;
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
@@ -38,6 +39,7 @@ class GroupAdapter extends ArrayAdapter {
LinearLayout layout = new LinearLayout(ctx);
layout.setOrientation(HORIZONTAL);
+ layout.setGravity(CENTER_VERTICAL);
if(!header.isRead()) {
Resources res = ctx.getResources();
layout.setBackgroundColor(res.getColor(R.color.unread_background));
diff --git a/briar-android/src/org/briarproject/android/groups/GroupListAdapter.java b/briar-android/src/org/briarproject/android/groups/GroupListAdapter.java
index e9ee80b98..8e9f6c674 100644
--- a/briar-android/src/org/briarproject/android/groups/GroupListAdapter.java
+++ b/briar-android/src/org/briarproject/android/groups/GroupListAdapter.java
@@ -1,5 +1,6 @@
package org.briarproject.android.groups;
+import static android.text.TextUtils.TruncateAt.END;
import static android.view.Gravity.CENTER;
import static android.widget.LinearLayout.HORIZONTAL;
import static java.text.DateFormat.SHORT;
@@ -83,7 +84,8 @@ class GroupListAdapter extends BaseAdapter {
// Give me all the unused width
name.setLayoutParams(WRAP_WRAP_1);
name.setTextSize(18);
- name.setMaxLines(1);
+ name.setSingleLine();
+ name.setEllipsize(END);
name.setPadding(pad, pad, pad, pad);
int unread = item.getUnreadCount();
String groupName = item.getGroup().getName();
diff --git a/briar-android/src/org/briarproject/android/groups/ManageGroupsAdapter.java b/briar-android/src/org/briarproject/android/groups/ManageGroupsAdapter.java
index f6dd5eade..7b3f5656f 100644
--- a/briar-android/src/org/briarproject/android/groups/ManageGroupsAdapter.java
+++ b/briar-android/src/org/briarproject/android/groups/ManageGroupsAdapter.java
@@ -1,5 +1,6 @@
package org.briarproject.android.groups;
+import static android.text.TextUtils.TruncateAt.END;
import static android.view.Gravity.CENTER;
import static android.view.View.INVISIBLE;
import static android.widget.LinearLayout.HORIZONTAL;
@@ -82,7 +83,8 @@ class ManageGroupsAdapter extends BaseAdapter {
TextView name = new TextView(ctx);
name.setTextSize(18);
- name.setMaxLines(1);
+ name.setSingleLine();
+ name.setEllipsize(END);
name.setPadding(0, pad, pad, pad);
name.setText(s.getGroup().getName());
innerLayout.addView(name);
diff --git a/briar-android/src/org/briarproject/android/groups/WriteGroupPostActivity.java b/briar-android/src/org/briarproject/android/groups/WriteGroupPostActivity.java
index 51ccd7d4e..badcb0587 100644
--- a/briar-android/src/org/briarproject/android/groups/WriteGroupPostActivity.java
+++ b/briar-android/src/org/briarproject/android/groups/WriteGroupPostActivity.java
@@ -2,9 +2,13 @@ package org.briarproject.android.groups;
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.widget.LinearLayout.HORIZONTAL;
+import static android.text.TextUtils.TruncateAt.END;
import static android.widget.LinearLayout.VERTICAL;
+import static android.widget.RelativeLayout.ALIGN_PARENT_LEFT;
+import static android.widget.RelativeLayout.ALIGN_PARENT_RIGHT;
+import static android.widget.RelativeLayout.CENTER_VERTICAL;
+import static android.widget.RelativeLayout.LEFT_OF;
+import static android.widget.RelativeLayout.RIGHT_OF;
import static android.widget.Toast.LENGTH_LONG;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
@@ -25,7 +29,7 @@ import org.briarproject.android.identity.CreateIdentityActivity;
import org.briarproject.android.identity.LocalAuthorItem;
import org.briarproject.android.identity.LocalAuthorItemComparator;
import org.briarproject.android.identity.LocalAuthorSpinnerAdapter;
-import org.briarproject.android.util.ElasticHorizontalSpace;
+import org.briarproject.android.util.CommonLayoutParams;
import org.briarproject.android.util.LayoutUtils;
import org.briarproject.api.AuthorId;
import org.briarproject.api.LocalAuthor;
@@ -54,6 +58,7 @@ import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
@@ -106,43 +111,54 @@ implements OnItemSelectedListener, OnClickListener {
layout.setLayoutParams(MATCH_WRAP);
layout.setOrientation(VERTICAL);
- LinearLayout header = new LinearLayout(this);
+ RelativeLayout header = new RelativeLayout(this);
header.setLayoutParams(MATCH_WRAP);
- header.setOrientation(HORIZONTAL);
- header.setGravity(CENTER_VERTICAL);
int pad = LayoutUtils.getPadding(this);
TextView from = new TextView(this);
+ from.setId(1);
from.setTextSize(18);
from.setPadding(pad, pad, 0, pad);
from.setText(R.string.from);
- header.addView(from);
+ RelativeLayout.LayoutParams left = CommonLayoutParams.wrapWrap();
+ left.addRule(ALIGN_PARENT_LEFT);
+ left.addRule(CENTER_VERTICAL);
+ header.addView(from, left);
adapter = new LocalAuthorSpinnerAdapter(this, true);
spinner = new Spinner(this);
+ spinner.setId(2);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
- header.addView(spinner);
-
- header.addView(new ElasticHorizontalSpace(this));
+ RelativeLayout.LayoutParams between = CommonLayoutParams.wrapWrap();
+ between.addRule(CENTER_VERTICAL);
+ between.addRule(RIGHT_OF, 1);
+ between.addRule(LEFT_OF, 3);
+ header.addView(spinner, between);
sendButton = new ImageButton(this);
+ sendButton.setId(3);
sendButton.setBackgroundResource(0);
sendButton.setImageResource(R.drawable.social_send_now);
sendButton.setEnabled(false); // Enabled after loading the group
sendButton.setOnClickListener(this);
- header.addView(sendButton);
+ RelativeLayout.LayoutParams right = CommonLayoutParams.wrapWrap();
+ right.addRule(ALIGN_PARENT_RIGHT);
+ right.addRule(CENTER_VERTICAL);
+ header.addView(sendButton, right);
layout.addView(header);
to = new TextView(this);
to.setTextSize(18);
+ to.setSingleLine();
+ to.setEllipsize(END);
to.setPadding(pad, 0, pad, pad);
to.setText(R.string.to);
layout.addView(to);
content = new EditText(this);
- content.setId(1);
+ content.setId(4);
int inputType = TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
| TYPE_TEXT_FLAG_CAP_SENTENCES;
content.setInputType(inputType);
diff --git a/briar-android/src/org/briarproject/android/identity/LocalAuthorSpinnerAdapter.java b/briar-android/src/org/briarproject/android/identity/LocalAuthorSpinnerAdapter.java
index b8b9e30ce..bed42c379 100644
--- a/briar-android/src/org/briarproject/android/identity/LocalAuthorSpinnerAdapter.java
+++ b/briar-android/src/org/briarproject/android/identity/LocalAuthorSpinnerAdapter.java
@@ -1,5 +1,6 @@
package org.briarproject.android.identity;
+import static android.text.TextUtils.TruncateAt.END;
import static org.briarproject.android.identity.LocalAuthorItem.ANONYMOUS;
import static org.briarproject.android.identity.LocalAuthorItem.NEW;
@@ -9,9 +10,9 @@ import java.util.Comparator;
import java.util.List;
import org.briarproject.R;
+import org.briarproject.android.util.LayoutUtils;
import android.content.Context;
-import android.content.res.Resources;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
@@ -46,7 +47,17 @@ implements SpinnerAdapter {
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
- return getView(position, convertView, parent);
+ TextView name = new TextView(ctx);
+ name.setTextSize(18);
+ name.setSingleLine();
+ name.setEllipsize(END);
+ int pad = LayoutUtils.getPadding(ctx);
+ name.setPadding(pad, pad, pad, pad);
+ LocalAuthorItem item = getItem(position);
+ if(item == ANONYMOUS) name.setText(R.string.anonymous);
+ else if(item == NEW) name.setText(R.string.new_identity_item);
+ else name.setText(item.getLocalAuthor().getName());
+ return name;
}
public LocalAuthorItem getItem(int position) {
@@ -67,11 +78,8 @@ implements SpinnerAdapter {
public View getView(int position, View convertView, ViewGroup parent) {
TextView name = new TextView(ctx);
name.setTextSize(18);
- name.setMaxLines(1);
- Resources res = ctx.getResources();
- // FIXME: Use LayoutUtils.getPadding() here?
- int pad = res.getInteger(R.integer.spinner_padding);
- name.setPadding(pad, pad, pad, pad);
+ name.setSingleLine();
+ name.setEllipsize(END);
LocalAuthorItem item = getItem(position);
if(item == ANONYMOUS) name.setText(R.string.anonymous);
else if(item == NEW) name.setText(R.string.new_identity_item);
diff --git a/briar-android/src/org/briarproject/android/util/AuthorView.java b/briar-android/src/org/briarproject/android/util/AuthorView.java
index fbb2d8e77..bf49325a4 100644
--- a/briar-android/src/org/briarproject/android/util/AuthorView.java
+++ b/briar-android/src/org/briarproject/android/util/AuthorView.java
@@ -1,14 +1,16 @@
package org.briarproject.android.util;
+import static android.text.TextUtils.TruncateAt.END;
+
import org.briarproject.R;
import org.briarproject.api.Author;
import android.content.Context;
import android.widget.ImageView;
-import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
import android.widget.TextView;
-public class AuthorView extends LinearLayout {
+public class AuthorView extends RelativeLayout {
public AuthorView(Context ctx) {
super(ctx);
@@ -17,19 +19,24 @@ public class AuthorView extends LinearLayout {
public void init(String name, Author.Status status) {
Context ctx = getContext();
int pad = LayoutUtils.getPadding(ctx);
- setOrientation(VERTICAL);
+
TextView nameView = new TextView(ctx);
- // Give me all the unused width
+ nameView.setId(1);
nameView.setTextSize(18);
- nameView.setMaxLines(1);
+ nameView.setSingleLine();
+ nameView.setEllipsize(END);
nameView.setPadding(pad, pad, pad, pad);
if(name == null) nameView.setText(R.string.anonymous);
else nameView.setText(name);
- addView(nameView);
- LinearLayout statusLayout = new LinearLayout(ctx);
- statusLayout.setOrientation(HORIZONTAL);
+ LayoutParams leftOf = CommonLayoutParams.wrapWrap();
+ leftOf.addRule(ALIGN_PARENT_LEFT);
+ leftOf.addRule(CENTER_VERTICAL);
+ leftOf.addRule(LEFT_OF, 2);
+ addView(nameView, leftOf);
+
ImageView statusView = new ImageView(ctx);
- statusView.setPadding(pad, 0, pad, pad);
+ statusView.setId(2);
+ statusView.setPadding(0, pad, pad, pad);
switch(status) {
case ANONYMOUS:
statusView.setImageResource(R.drawable.identity_anonymous);
@@ -44,8 +51,9 @@ public class AuthorView extends LinearLayout {
statusView.setImageResource(R.drawable.identity_verified);
break;
}
- statusLayout.addView(statusView);
- statusLayout.addView(new ElasticHorizontalSpace(ctx));
- addView(statusLayout);
+ LayoutParams right = CommonLayoutParams.wrapWrap();
+ right.addRule(ALIGN_PARENT_RIGHT);
+ right.addRule(CENTER_VERTICAL);
+ addView(statusView, right);
}
}
diff --git a/briar-android/src/org/briarproject/android/util/CommonLayoutParams.java b/briar-android/src/org/briarproject/android/util/CommonLayoutParams.java
index 9d9f58e22..343476686 100644
--- a/briar-android/src/org/briarproject/android/util/CommonLayoutParams.java
+++ b/briar-android/src/org/briarproject/android/util/CommonLayoutParams.java
@@ -3,6 +3,7 @@ package org.briarproject.android.util;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
public class CommonLayoutParams {
@@ -20,4 +21,8 @@ public class CommonLayoutParams {
public static final LinearLayout.LayoutParams WRAP_WRAP_1 =
new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, 1);
+
+ public static RelativeLayout.LayoutParams wrapWrap() {
+ return new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
+ }
}