From f8508940a8bc2486b06a22a76a8a20c7aa647de2 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Thu, 14 Jul 2016 08:35:48 -0500 Subject: [PATCH] Set layout direction on widget --- src/main/java/org/tasks/locale/Locale.java | 4 +++ .../java/org/tasks/widget/TasksWidget.java | 6 ++++ src/main/res/layout/scrollable_widget.xml | 30 ++++++++++--------- src/main/res/layout/widget_loading.xml | 1 - src/main/res/layout/widget_row.xml | 2 ++ 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/tasks/locale/Locale.java b/src/main/java/org/tasks/locale/Locale.java index b10be0921..c7a190760 100644 --- a/src/main/java/org/tasks/locale/Locale.java +++ b/src/main/java/org/tasks/locale/Locale.java @@ -71,6 +71,10 @@ public class Locale { return directionality == View.LAYOUT_DIRECTION_RTL ? RIGHT_TO_LEFT_MARK : LEFT_TO_RIGHT_MARK; } + public int getDirectionality() { + return appDirectionality; + } + public String getOverride() { return override; } diff --git a/src/main/java/org/tasks/widget/TasksWidget.java b/src/main/java/org/tasks/widget/TasksWidget.java index 201f15b55..0bff36dd6 100644 --- a/src/main/java/org/tasks/widget/TasksWidget.java +++ b/src/main/java/org/tasks/widget/TasksWidget.java @@ -18,6 +18,7 @@ import org.tasks.R; import org.tasks.injection.BroadcastComponent; import org.tasks.injection.InjectingAppWidgetProvider; import org.tasks.intents.TaskIntents; +import org.tasks.locale.Locale; import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.Preferences; import org.tasks.themes.ThemeBase; @@ -30,6 +31,7 @@ import timber.log.Timber; import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybeanMR1; import static com.todoroo.astrid.api.AstridApiConstants.BROADCAST_EVENT_REFRESH; import static org.tasks.intents.TaskIntents.getEditTaskIntent; @@ -41,6 +43,7 @@ public class TasksWidget extends InjectingAppWidgetProvider { @Inject Preferences preferences; @Inject DefaultFilterProvider defaultFilterProvider; @Inject ThemeCache themeCache; + @Inject Locale locale; public static final String COMPLETE_TASK = "COMPLETE_TASK"; public static final String EDIT_TASK = "EDIT_TASK"; @@ -100,6 +103,9 @@ public class TasksWidget extends InjectingAppWidgetProvider { ThemeBase theme = themeCache.getThemeBase(preferences.getInt(WidgetConfigActivity.PREF_THEME + id, 0)); ThemeColor color = themeCache.getThemeColor(preferences.getInt(WidgetConfigActivity.PREF_COLOR + id, 0)); RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.scrollable_widget); + if (atLeastJellybeanMR1()) { + remoteViews.setInt(R.id.widget, "setLayoutDirection", locale.getDirectionality()); + } if (preferences.getBoolean(WidgetConfigActivity.PREF_HIDE_HEADER + id, false)) { remoteViews.setViewVisibility(R.id.widget_header, View.GONE); } else { diff --git a/src/main/res/layout/scrollable_widget.xml b/src/main/res/layout/scrollable_widget.xml index a0e08ba56..cff82b975 100644 --- a/src/main/res/layout/scrollable_widget.xml +++ b/src/main/res/layout/scrollable_widget.xml @@ -3,9 +3,11 @@ ** ** See the file "LICENSE" for the full license governing this code. --> - + android:layout_height="fill_parent" + android:orientation="vertical"> + android:scaleType="fitXY" /> + android:textSize="18sp" /> @@ -61,7 +63,7 @@ android:id="@+id/widget_background" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:scaleType="fitXY"/> + android:scaleType="fitXY" /> - + diff --git a/src/main/res/layout/widget_loading.xml b/src/main/res/layout/widget_loading.xml index 09d241053..9007265df 100644 --- a/src/main/res/layout/widget_loading.xml +++ b/src/main/res/layout/widget_loading.xml @@ -5,7 +5,6 @@ ** See the file "LICENSE" for the full license governing this code. -->