From 16c34a95d3aa30ae3ae3893635547516d9ef55aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 20 Feb 2014 14:15:50 +0100 Subject: [PATCH 1/5] First attempt at supporting RTL Following the Android 4.2 changes, which explain how to add native support for RTL, I've replaced Right for End and Left for Start. Enabling RTL to see the results. --- AndroidManifest.xml | 2 +- res/layout-land/appdetails.xml | 4 ++-- res/layout/about.xml | 10 +++++----- res/layout/addrepo.xml | 2 +- res/layout/apklistitem.xml | 12 ++++++------ res/layout/appdetails.xml | 18 +++++++++--------- res/layout/applistitem.xml | 22 +++++++++++----------- res/layout/repo_item.xml | 6 +++--- res/layout/repodetails.xml | 16 ++++++++-------- res/layout/repodiscoveryitem.xml | 4 ++-- res/layout/repodiscoverylist.xml | 4 ++-- res/layout/searchresults.xml | 4 ++-- 12 files changed, 52 insertions(+), 52 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index fa6e046f1..fb848a3aa 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -44,7 +44,7 @@ android:label="@string/app_name" android:allowBackup="true" android:theme="@style/AppThemeDark" - android:supportsRtl="false" > + android:supportsRtl="true" > @@ -38,7 +38,7 @@ @@ -57,7 +57,7 @@ diff --git a/res/layout/addrepo.xml b/res/layout/addrepo.xml index 667bf02fa..4910a3663 100644 --- a/res/layout/addrepo.xml +++ b/res/layout/addrepo.xml @@ -36,7 +36,7 @@ android:id="@+id/overwrite_message" android:layout_width="match_parent" android:layout_height="wrap_content" - android:drawableLeft="@android:drawable/ic_dialog_alert" + android:drawableStart="@android:drawable/ic_dialog_alert" android:drawablePadding="20dp" android:padding="20dp" android:text="@string/repo_delete_to_overwrite" diff --git a/res/layout/apklistitem.xml b/res/layout/apklistitem.xml index 310bbd5bc..4eec65c00 100644 --- a/res/layout/apklistitem.xml +++ b/res/layout/apklistitem.xml @@ -30,7 +30,7 @@ @@ -38,7 +38,7 @@ @@ -46,22 +46,22 @@ diff --git a/res/layout/appdetails.xml b/res/layout/appdetails.xml index 9f3fcd070..612cd6512 100644 --- a/res/layout/appdetails.xml +++ b/res/layout/appdetails.xml @@ -24,7 +24,7 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" - android:layout_toRightOf="@id/icon" + android:layout_toEndOf="@id/icon" android:padding="5dp" android:baselineAligned="false" android:orientation="vertical" > @@ -34,10 +34,10 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" - android:layout_alignParentRight="true" + android:layout_alignParentEnd="true" android:singleLine="true" android:ellipsize="end" - android:layout_marginLeft="6sp" + android:layout_marginStart="6sp" android:textSize="12sp" /> + android:layout_alignParentStart="true" + android:layout_toStartOf="@id/license" /> @@ -69,8 +69,8 @@ android:singleLine="true" android:ellipsize="end" android:textSize="12sp" - android:layout_alignParentLeft="true" - android:layout_toLeftOf="@id/categories" + android:layout_alignParentStart="true" + android:layout_toStartOf="@id/categories" android:layout_below="@id/title" /> diff --git a/res/layout/applistitem.xml b/res/layout/applistitem.xml index f01cc5ed6..941fe112a 100644 --- a/res/layout/applistitem.xml +++ b/res/layout/applistitem.xml @@ -19,9 +19,9 @@ android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:paddingLeft="5dp" - android:paddingRight="5dp" - android:layout_toRightOf="@id/icon" + android:paddingStart="5dp" + android:paddingEnd="5dp" + android:layout_toEndOf="@id/icon" android:layout_centerVertical="true" android:baselineAligned="false" > @@ -31,9 +31,9 @@ android:ellipsize="end" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="6sp" + android:layout_marginStart="6sp" android:layout_alignParentTop="true" - android:layout_alignParentRight="true" /> + android:layout_alignParentEnd="true" /> + android:layout_alignParentStart="true" + android:layout_toStartOf="@id/status" /> + android:layout_alignParentEnd="true" /> + android:layout_alignParentStart="true" + android:layout_toStartOf="@id/license" /> diff --git a/res/layout/repo_item.xml b/res/layout/repo_item.xml index 58d983d18..9c0e10951 100644 --- a/res/layout/repo_item.xml +++ b/res/layout/repo_item.xml @@ -15,7 +15,7 @@ + android:layout_alignParentStart="true" /> + android:layout_toEndOf="@id/img" + android:layout_alignParentStart="true"/> + android:paddingStart="@dimen/padding_side" + android:paddingEnd="@dimen/padding_side"> @@ -19,7 +19,7 @@ android:layout_height="wrap_content" android:layout_below="@+id/reposcanitemname" android:layout_marginTop="2dp" - android:paddingLeft="8sp" + android:paddingStart="8sp" android:maxLines="1" android:text="Repo Address" android:textSize="14sp" /> diff --git a/res/layout/repodiscoverylist.xml b/res/layout/repodiscoverylist.xml index 077636d55..0a8f46052 100644 --- a/res/layout/repodiscoverylist.xml +++ b/res/layout/repodiscoverylist.xml @@ -8,7 +8,7 @@ android:layout_width="match_parent" android:layout_height="50dp" android:layout_alignParentTop="true" - android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" android:layout_centerHorizontal="true" android:paddingTop="8sp" > @@ -18,7 +18,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:layout_marginRight="5dp" + android:layout_marginEnd="5dp" android:indeterminate="true" /> From 66563d30d961aec67c051c8735979092d395f992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 20 Feb 2014 14:15:50 +0100 Subject: [PATCH 2/5] First attempt at supporting RTL Following the Android 4.2 changes, which explain how to add native support for RTL, I've replaced Right for End and Left for Start. Enabling RTL to see the results. --- AndroidManifest.xml | 2 +- res/layout-land/appdetails.xml | 4 ++-- res/layout/about.xml | 10 +++++----- res/layout/addrepo.xml | 2 +- res/layout/apklistitem.xml | 12 ++++++------ res/layout/appdetails.xml | 18 +++++++++--------- res/layout/applistitem.xml | 22 +++++++++++----------- res/layout/repo_item.xml | 6 +++--- res/layout/repodetails.xml | 16 ++++++++-------- res/layout/repodiscoveryitem.xml | 4 ++-- res/layout/repodiscoverylist.xml | 4 ++-- res/layout/searchresults.xml | 4 ++-- 12 files changed, 52 insertions(+), 52 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index fa6e046f1..fb848a3aa 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -44,7 +44,7 @@ android:label="@string/app_name" android:allowBackup="true" android:theme="@style/AppThemeDark" - android:supportsRtl="false" > + android:supportsRtl="true" > @@ -38,7 +38,7 @@ @@ -57,7 +57,7 @@ diff --git a/res/layout/addrepo.xml b/res/layout/addrepo.xml index 667bf02fa..4910a3663 100644 --- a/res/layout/addrepo.xml +++ b/res/layout/addrepo.xml @@ -36,7 +36,7 @@ android:id="@+id/overwrite_message" android:layout_width="match_parent" android:layout_height="wrap_content" - android:drawableLeft="@android:drawable/ic_dialog_alert" + android:drawableStart="@android:drawable/ic_dialog_alert" android:drawablePadding="20dp" android:padding="20dp" android:text="@string/repo_delete_to_overwrite" diff --git a/res/layout/apklistitem.xml b/res/layout/apklistitem.xml index 310bbd5bc..4eec65c00 100644 --- a/res/layout/apklistitem.xml +++ b/res/layout/apklistitem.xml @@ -30,7 +30,7 @@ @@ -38,7 +38,7 @@ @@ -46,22 +46,22 @@ diff --git a/res/layout/appdetails.xml b/res/layout/appdetails.xml index 9f3fcd070..612cd6512 100644 --- a/res/layout/appdetails.xml +++ b/res/layout/appdetails.xml @@ -24,7 +24,7 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" - android:layout_toRightOf="@id/icon" + android:layout_toEndOf="@id/icon" android:padding="5dp" android:baselineAligned="false" android:orientation="vertical" > @@ -34,10 +34,10 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" - android:layout_alignParentRight="true" + android:layout_alignParentEnd="true" android:singleLine="true" android:ellipsize="end" - android:layout_marginLeft="6sp" + android:layout_marginStart="6sp" android:textSize="12sp" /> + android:layout_alignParentStart="true" + android:layout_toStartOf="@id/license" /> @@ -69,8 +69,8 @@ android:singleLine="true" android:ellipsize="end" android:textSize="12sp" - android:layout_alignParentLeft="true" - android:layout_toLeftOf="@id/categories" + android:layout_alignParentStart="true" + android:layout_toStartOf="@id/categories" android:layout_below="@id/title" /> diff --git a/res/layout/applistitem.xml b/res/layout/applistitem.xml index f01cc5ed6..941fe112a 100644 --- a/res/layout/applistitem.xml +++ b/res/layout/applistitem.xml @@ -19,9 +19,9 @@ android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:paddingLeft="5dp" - android:paddingRight="5dp" - android:layout_toRightOf="@id/icon" + android:paddingStart="5dp" + android:paddingEnd="5dp" + android:layout_toEndOf="@id/icon" android:layout_centerVertical="true" android:baselineAligned="false" > @@ -31,9 +31,9 @@ android:ellipsize="end" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="6sp" + android:layout_marginStart="6sp" android:layout_alignParentTop="true" - android:layout_alignParentRight="true" /> + android:layout_alignParentEnd="true" /> + android:layout_alignParentStart="true" + android:layout_toStartOf="@id/status" /> + android:layout_alignParentEnd="true" /> + android:layout_alignParentStart="true" + android:layout_toStartOf="@id/license" /> diff --git a/res/layout/repo_item.xml b/res/layout/repo_item.xml index 58d983d18..9c0e10951 100644 --- a/res/layout/repo_item.xml +++ b/res/layout/repo_item.xml @@ -15,7 +15,7 @@ + android:layout_alignParentStart="true" /> + android:layout_toEndOf="@id/img" + android:layout_alignParentStart="true"/> + android:paddingStart="@dimen/padding_side" + android:paddingEnd="@dimen/padding_side"> @@ -19,7 +19,7 @@ android:layout_height="wrap_content" android:layout_below="@+id/reposcanitemname" android:layout_marginTop="2dp" - android:paddingLeft="8sp" + android:paddingStart="8sp" android:maxLines="1" android:text="Repo Address" android:textSize="14sp" /> diff --git a/res/layout/repodiscoverylist.xml b/res/layout/repodiscoverylist.xml index 077636d55..0a8f46052 100644 --- a/res/layout/repodiscoverylist.xml +++ b/res/layout/repodiscoverylist.xml @@ -8,7 +8,7 @@ android:layout_width="match_parent" android:layout_height="50dp" android:layout_alignParentTop="true" - android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" android:layout_centerHorizontal="true" android:paddingTop="8sp" > @@ -18,7 +18,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:layout_marginRight="5dp" + android:layout_marginEnd="5dp" android:indeterminate="true" /> From 0fba2c255e069457b448f4e32b36ceea65357e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 20 Feb 2014 23:59:17 +0100 Subject: [PATCH 3/5] Add START_OF to LayoutCompat.RelativeLayout --- src/org/fdroid/fdroid/compat/LayoutCompat.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/org/fdroid/fdroid/compat/LayoutCompat.java b/src/org/fdroid/fdroid/compat/LayoutCompat.java index 6a57ad033..a0c0b054e 100644 --- a/src/org/fdroid/fdroid/compat/LayoutCompat.java +++ b/src/org/fdroid/fdroid/compat/LayoutCompat.java @@ -14,9 +14,11 @@ public abstract class LayoutCompat extends Compatibility { private static final LayoutCompat impl = LayoutCompat.create(); + protected abstract int relativeLayoutStartOf(); protected abstract int relativeLayoutEndOf(); public static class RelativeLayout { + public static final int START_OF = impl.relativeLayoutStartOf(); public static final int END_OF = impl.relativeLayoutEndOf(); } @@ -24,6 +26,11 @@ public abstract class LayoutCompat extends Compatibility { class OldLayoutCompatImpl extends LayoutCompat { + @Override + protected int relativeLayoutStartOf() { + return android.widget.RelativeLayout.LEFT_OF; + } + @Override protected int relativeLayoutEndOf() { return android.widget.RelativeLayout.RIGHT_OF; @@ -33,6 +40,11 @@ class OldLayoutCompatImpl extends LayoutCompat { @TargetApi(17) class JellyBeanMr1LayoutCompatImpl extends LayoutCompat { + @Override + protected int relativeLayoutStartOf() { + return android.widget.RelativeLayout.START_OF; + } + @Override protected int relativeLayoutEndOf() { return android.widget.RelativeLayout.END_OF; From 5d0074d821a05fe335cf1d8011b18caea0d1d476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 21 Feb 2014 00:06:46 +0100 Subject: [PATCH 4/5] Add ALIGN_PARENT_* to LayoutCompat.RelativeLayout --- .../fdroid/fdroid/compat/LayoutCompat.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/org/fdroid/fdroid/compat/LayoutCompat.java b/src/org/fdroid/fdroid/compat/LayoutCompat.java index a0c0b054e..33f0ad574 100644 --- a/src/org/fdroid/fdroid/compat/LayoutCompat.java +++ b/src/org/fdroid/fdroid/compat/LayoutCompat.java @@ -16,10 +16,14 @@ public abstract class LayoutCompat extends Compatibility { protected abstract int relativeLayoutStartOf(); protected abstract int relativeLayoutEndOf(); + protected abstract int relativeLayoutAlignParentStart(); + protected abstract int relativeLayoutAlignParentEnd(); public static class RelativeLayout { public static final int START_OF = impl.relativeLayoutStartOf(); public static final int END_OF = impl.relativeLayoutEndOf(); + public static final int ALIGN_PARENT_START = impl.relativeLayoutAlignParentStart(); + public static final int ALIGN_PARENT_END = impl.relativeLayoutAlignParentEnd(); } } @@ -35,6 +39,16 @@ class OldLayoutCompatImpl extends LayoutCompat { protected int relativeLayoutEndOf() { return android.widget.RelativeLayout.RIGHT_OF; } + + @Override + protected int relativeLayoutAlignParentStart() { + return android.widget.RelativeLayout.ALIGN_PARENT_LEFT; + } + + @Override + protected int relativeLayoutAlignParentEnd() { + return android.widget.RelativeLayout.ALIGN_PARENT_RIGHT; + } } @TargetApi(17) @@ -49,4 +63,14 @@ class JellyBeanMr1LayoutCompatImpl extends LayoutCompat { protected int relativeLayoutEndOf() { return android.widget.RelativeLayout.END_OF; } + + @Override + protected int relativeLayoutAlignParentStart() { + return android.widget.RelativeLayout.ALIGN_PARENT_START; + } + + @Override + protected int relativeLayoutAlignParentEnd() { + return android.widget.RelativeLayout.ALIGN_PARENT_END; + } } From 2a03c51207fbe89cba442478858f38a4d9dd3d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 21 Feb 2014 00:08:06 +0100 Subject: [PATCH 5/5] Use LayoutCompat in RepoAdapter --- src/org/fdroid/fdroid/views/RepoAdapter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/org/fdroid/fdroid/views/RepoAdapter.java b/src/org/fdroid/fdroid/views/RepoAdapter.java index c3cd8d60e..307f325de 100644 --- a/src/org/fdroid/fdroid/views/RepoAdapter.java +++ b/src/org/fdroid/fdroid/views/RepoAdapter.java @@ -12,6 +12,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; import org.fdroid.fdroid.R; import org.fdroid.fdroid.compat.SwitchCompat; +import org.fdroid.fdroid.compat.LayoutCompat; import org.fdroid.fdroid.data.Repo; public class RepoAdapter extends CursorAdapter { @@ -92,7 +93,7 @@ public class RepoAdapter extends CursorAdapter { nameView.setText(repo.getName()); RelativeLayout.LayoutParams nameViewLayout = (RelativeLayout.LayoutParams)nameView.getLayoutParams(); - nameViewLayout.addRule(RelativeLayout.LEFT_OF, switchView.getId()); + nameViewLayout.addRule(LayoutCompat.RelativeLayout.START_OF, switchView.getId()); // If we set the signed view to GONE instead of INVISIBLE, then the // height of each list item varies. @@ -112,7 +113,7 @@ public class RepoAdapter extends CursorAdapter { RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT ); - layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + layout.addRule(LayoutCompat.RelativeLayout.ALIGN_PARENT_END); layout.addRule(RelativeLayout.CENTER_VERTICAL); switchView.setLayoutParams(layout); ((RelativeLayout)parent).addView(switchView);