summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Sapperstein <asapperstein@google.com>2014-01-23 13:19:45 -0800
committerAndrew Sapperstein <asapperstein@google.com>2014-01-23 13:19:45 -0800
commit890afa256f9c30003b9690135922903354b51a67 (patch)
tree3f50693625969957ce8dbfbdc1771c37d6aa3f74
parent2b7f4f1f757bfa29b4c752fba27f5fd060c606f3 (diff)
downloadandroid_packages_apps_UnifiedEmail-890afa256f9c30003b9690135922903354b51a67.tar.gz
android_packages_apps_UnifiedEmail-890afa256f9c30003b9690135922903354b51a67.tar.bz2
android_packages_apps_UnifiedEmail-890afa256f9c30003b9690135922903354b51a67.zip
RTL - properly align from address in compose.
b/12687526. Change-Id: I5f09303674da08b7870a84ef6477d7bfac4015cd
-rw-r--r--res/layout/custom_from_dropdown_item.xml1
-rw-r--r--res/layout/custom_from_item.xml11
-rw-r--r--res/layout/from_dropdown_item.xml1
-rw-r--r--res/layout/from_item.xml3
-rw-r--r--res/values-ldrtl/styles-ldrtl.xml4
-rw-r--r--res/values/dimen.xml1
-rw-r--r--res/values/styles.xml4
-rw-r--r--src/com/android/mail/compose/ComposeActivity.java7
-rw-r--r--src/com/android/mail/compose/FromAddressSpinner.java10
-rw-r--r--src/com/android/mail/compose/FromAddressSpinnerAdapter.java20
-rw-r--r--tests/src/com/android/mail/compose/ComposeActivityTest.java13
11 files changed, 50 insertions, 25 deletions
diff --git a/res/layout/custom_from_dropdown_item.xml b/res/layout/custom_from_dropdown_item.xml
index 684dadf05..e13843f75 100644
--- a/res/layout/custom_from_dropdown_item.xml
+++ b/res/layout/custom_from_dropdown_item.xml
@@ -21,6 +21,7 @@
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:paddingLeft="24dip"
+ android:paddingRight="24dip"
android:layout_gravity="center_vertical"
android:paddingTop="10dip"
android:paddingBottom="10dip">
diff --git a/res/layout/custom_from_item.xml b/res/layout/custom_from_item.xml
index ccffd480c..e7dcd9d03 100644
--- a/res/layout/custom_from_item.xml
+++ b/res/layout/custom_from_item.xml
@@ -17,14 +17,15 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
android:layout_height="wrap_content"
- android:layout_width="match_parent">
+ android:layout_width="match_parent"
+ android:orientation="horizontal"
+ android:paddingLeft="6dip"
+ android:paddingRight="6dip">
<TextView android:id="@+id/spinner_account_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingLeft="6dip"
android:singleLine="true"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium"/>
@@ -32,8 +33,8 @@
<TextView android:id="@+id/spinner_account_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingLeft="6dip"
android:singleLine="true"
- android:ellipsize="end"/>
+ android:ellipsize="end"
+ style="@style/SpinnerAccountAddressStyle" />
</LinearLayout>
diff --git a/res/layout/from_dropdown_item.xml b/res/layout/from_dropdown_item.xml
index 892ee14b1..f4451279f 100644
--- a/res/layout/from_dropdown_item.xml
+++ b/res/layout/from_dropdown_item.xml
@@ -29,6 +29,7 @@
android:layout_weight="1"
android:ellipsize="end"
android:paddingLeft="8dip"
+ android:paddingRight="8dip"
android:gravity="center_vertical" />
</LinearLayout>
diff --git a/res/layout/from_item.xml b/res/layout/from_item.xml
index 62ed7f4a3..9c90d1474 100644
--- a/res/layout/from_item.xml
+++ b/res/layout/from_item.xml
@@ -23,4 +23,5 @@
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingLeft="8dip"
- android:gravity="center_vertical"/> \ No newline at end of file
+ android:paddingRight="8dip"
+ android:gravity="center_vertical"/>
diff --git a/res/values-ldrtl/styles-ldrtl.xml b/res/values-ldrtl/styles-ldrtl.xml
index bd3a08d72..e4d28b05b 100644
--- a/res/values-ldrtl/styles-ldrtl.xml
+++ b/res/values-ldrtl/styles-ldrtl.xml
@@ -377,4 +377,8 @@
</style>
<!-- END Conversation list styles -->
+ <style name="SpinnerAccountAddressStyle">
+ <item name="android:paddingStart">@dimen/custom_from_inner_padding</item>
+ </style>
+
</resources>
diff --git a/res/values/dimen.xml b/res/values/dimen.xml
index d121151cd..4b7fde0ce 100644
--- a/res/values/dimen.xml
+++ b/res/values/dimen.xml
@@ -187,4 +187,5 @@
<dimen name="badge_padding_extra_width">6dip</dimen>
<dimen name="badge_rounded_corner_radius">2dip</dimen>
+ <dimen name="custom_from_inner_padding">6dip</dimen>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 3445a96e9..e5de1a686 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -920,4 +920,8 @@
<item name="android:textStyle">bold</item>
</style>
+ <style name="SpinnerAccountAddressStyle">
+ <item name="android:paddingLeft">@dimen/custom_from_inner_padding</item>
+ </style>
+
</resources>
diff --git a/src/com/android/mail/compose/ComposeActivity.java b/src/com/android/mail/compose/ComposeActivity.java
index fd82c9870..b2bd5c16f 100644
--- a/src/com/android/mail/compose/ComposeActivity.java
+++ b/src/com/android/mail/compose/ComposeActivity.java
@@ -45,6 +45,7 @@ import android.os.HandlerThread;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import android.provider.BaseColumns;
+import android.support.v4.text.BidiFormatter;
import android.text.Editable;
import android.text.Html;
import android.text.SpannableString;
@@ -295,6 +296,8 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
private boolean mRespondedInline;
private boolean mPerformedSendOrDiscard = false;
+ private final BidiFormatter mBidiFormatter = BidiFormatter.getInstance();
+
/**
* Can be called from a non-UI thread.
*/
@@ -770,7 +773,7 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
// Update the from spinner as other accounts
// may now be available.
if (mFromSpinner != null && mAccount != null) {
- mFromSpinner.initialize(mComposeMode, mAccount, mAccounts, mRefMessage);
+ mFromSpinner.initialize(mComposeMode, mAccount, mAccounts, mRefMessage, mBidiFormatter);
}
}
@@ -982,7 +985,7 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
if (action == EDIT_DRAFT && mDraft.draftType == UIProvider.DraftType.COMPOSE) {
action = COMPOSE;
}
- mFromSpinner.initialize(action, mAccount, mAccounts, mRefMessage);
+ mFromSpinner.initialize(action, mAccount, mAccounts, mRefMessage, mBidiFormatter);
if (bundle != null) {
if (bundle.containsKey(EXTRA_SELECTED_REPLY_FROM_ACCOUNT)) {
diff --git a/src/com/android/mail/compose/FromAddressSpinner.java b/src/com/android/mail/compose/FromAddressSpinner.java
index 7d82d1ec8..aeed90b7f 100644
--- a/src/com/android/mail/compose/FromAddressSpinner.java
+++ b/src/com/android/mail/compose/FromAddressSpinner.java
@@ -16,6 +16,7 @@
package com.android.mail.compose;
import android.content.Context;
+import android.support.v4.text.BidiFormatter;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
@@ -90,7 +91,7 @@ public class FromAddressSpinner extends Spinner implements OnItemSelectedListene
* @param syncingAccounts
*/
public void initialize(int action, Account currentAccount, Account[] syncingAccounts,
- Message refMessage) {
+ Message refMessage, BidiFormatter bidiFormatter) {
final List<Account> accounts = AccountUtils.mergeAccountLists(mAccounts,
syncingAccounts, true /* prioritizeAccountList */);
if (action == ComposeActivity.COMPOSE) {
@@ -111,11 +112,11 @@ public class FromAddressSpinner extends Spinner implements OnItemSelectedListene
}
mAccounts = ImmutableList.of(replyAccount);
}
- initFromSpinner();
+ initFromSpinner(bidiFormatter);
}
@VisibleForTesting
- protected void initFromSpinner() {
+ protected void initFromSpinner(BidiFormatter bidiFormatter) {
// If there are not yet any accounts in the cached synced accounts
// because this is the first time mail was opened, and it was opened
// directly to the compose activity, don't bother populating the reply
@@ -123,7 +124,8 @@ public class FromAddressSpinner extends Spinner implements OnItemSelectedListene
if (mAccounts == null || mAccounts.size() == 0) {
return;
}
- FromAddressSpinnerAdapter adapter = new FromAddressSpinnerAdapter(getContext());
+ FromAddressSpinnerAdapter adapter =
+ new FromAddressSpinnerAdapter(getContext(), bidiFormatter);
mReplyFromAccounts.clear();
for (Account account : mAccounts) {
diff --git a/src/com/android/mail/compose/FromAddressSpinnerAdapter.java b/src/com/android/mail/compose/FromAddressSpinnerAdapter.java
index 88528fd2d..980d419d3 100644
--- a/src/com/android/mail/compose/FromAddressSpinnerAdapter.java
+++ b/src/com/android/mail/compose/FromAddressSpinnerAdapter.java
@@ -16,6 +16,7 @@
package com.android.mail.compose;
import android.content.Context;
+import android.support.v4.text.BidiFormatter;
import android.text.TextUtils;
import android.text.util.Rfc822Tokenizer;
import android.view.LayoutInflater;
@@ -46,11 +47,14 @@ public class FromAddressSpinnerAdapter extends ArrayAdapter<ReplyFromAccount> {
public static int ACCOUNT_ADDRESS = 1;
+ private final BidiFormatter mBidiFormatter;
+
private LayoutInflater mInflater;
- public FromAddressSpinnerAdapter(Context context) {
+ public FromAddressSpinnerAdapter(Context context, BidiFormatter bidiFormatter) {
super(context, R.layout.from_item, R.id.spinner_account_address);
sFormatString = getContext().getString(R.string.formatted_email_address);
+ mBidiFormatter = bidiFormatter;
}
protected LayoutInflater getInflater() {
@@ -78,13 +82,14 @@ public class FromAddressSpinnerAdapter extends ArrayAdapter<ReplyFromAccount> {
int res = fromItem.isCustomFrom ? R.layout.custom_from_item : R.layout.from_item;
View fromEntry = convertView == null ? getInflater().inflate(res, null) : convertView;
if (fromItem.isCustomFrom) {
- ((TextView) fromEntry.findViewById(R.id.spinner_account_name)).setText(fromItem.name);
+ ((TextView) fromEntry.findViewById(R.id.spinner_account_name)).setText(
+ mBidiFormatter.unicodeWrap(fromItem.name));
((TextView) fromEntry.findViewById(R.id.spinner_account_address))
.setText(formatAddress(fromItem.address));
} else {
((TextView) fromEntry.findViewById(R.id.spinner_account_address))
- .setText(fromItem.address);
+ .setText(mBidiFormatter.unicodeWrap(fromItem.address));
}
return fromEntry;
}
@@ -97,21 +102,22 @@ public class FromAddressSpinnerAdapter extends ArrayAdapter<ReplyFromAccount> {
View fromEntry = getInflater().inflate(res, null);
if (fromItem.isCustomFrom) {
((TextView) fromEntry.findViewById(R.id.spinner_account_name))
- .setText(fromItem.name);
+ .setText(mBidiFormatter.unicodeWrap(fromItem.name));
((TextView) fromEntry.findViewById(R.id.spinner_account_address))
.setText(formatAddress(fromItem.address));
} else {
((TextView) fromEntry.findViewById(R.id.spinner_account_address))
- .setText(fromItem.address);
+ .setText(mBidiFormatter.unicodeWrap(fromItem.address));
}
return fromEntry;
}
- private static CharSequence formatAddress(String address) {
+ private CharSequence formatAddress(String address) {
if (TextUtils.isEmpty(address)) {
return "";
}
- return String.format(sFormatString, Rfc822Tokenizer.tokenize(address)[0].getAddress());
+ return String.format(sFormatString,
+ mBidiFormatter.unicodeWrap(Rfc822Tokenizer.tokenize(address)[0].getAddress()));
}
public void addAccounts(List<ReplyFromAccount> replyFromAccounts) {
diff --git a/tests/src/com/android/mail/compose/ComposeActivityTest.java b/tests/src/com/android/mail/compose/ComposeActivityTest.java
index d2cc308df..52066e982 100644
--- a/tests/src/com/android/mail/compose/ComposeActivityTest.java
+++ b/tests/src/com/android/mail/compose/ComposeActivityTest.java
@@ -22,6 +22,7 @@ import android.content.Intent;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
+import android.support.v4.text.BidiFormatter;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.Html;
@@ -149,7 +150,7 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos
activity.mFromSpinner.setCurrentAccount(currentAccount);
activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL,
- currentAccount.account, EMPTY_ACCOUNT_LIST, null);
+ currentAccount.account, EMPTY_ACCOUNT_LIST, null, BidiFormatter.getInstance());
runTestOnUiThread(new Runnable() {
@Override
public void run() {
@@ -183,7 +184,7 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos
activity.mFromSpinner.setCurrentAccount(currentAccount);
activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL,
- currentAccount.account, EMPTY_ACCOUNT_LIST, null);
+ currentAccount.account, EMPTY_ACCOUNT_LIST, null, BidiFormatter.getInstance());
runTestOnUiThread(new Runnable() {
@Override
public void run() {
@@ -222,7 +223,7 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos
activity.mFromSpinner.setCurrentAccount(currentAccount);
activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL,
- currentAccount.account, EMPTY_ACCOUNT_LIST, null);
+ currentAccount.account, EMPTY_ACCOUNT_LIST, null, BidiFormatter.getInstance());
runTestOnUiThread(new Runnable() {
@Override
public void run() {
@@ -550,7 +551,7 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos
mAccount.name, mAccount.name, mAccount.name, true, false);
activity.mFromSpinner.setCurrentAccount(currentAccount);
activity.mFromSpinner.initialize(ComposeActivity.REPLY, currentAccount.account,
- EMPTY_ACCOUNT_LIST, null);
+ EMPTY_ACCOUNT_LIST, null, BidiFormatter.getInstance());
runTestOnUiThread(new Runnable() {
@Override
@@ -590,7 +591,7 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos
mAccount.name, mAccount.name, mAccount.name, true, false);
activity.mFromSpinner.setCurrentAccount(currentAccount);
activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL,
- currentAccount.account, EMPTY_ACCOUNT_LIST, null);
+ currentAccount.account, EMPTY_ACCOUNT_LIST, null, BidiFormatter.getInstance());
runTestOnUiThread(new Runnable() {
@Override
public void run() {
@@ -632,7 +633,7 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos
mAccount.name, mAccount.name, mAccount.name, true, false);
activity.mFromSpinner.setCurrentAccount(currentAccount);
activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL,
- currentAccount.account, EMPTY_ACCOUNT_LIST, null);
+ currentAccount.account, EMPTY_ACCOUNT_LIST, null, BidiFormatter.getInstance());
runTestOnUiThread(new Runnable() {
@Override
public void run() {