Set layout direction on widget

pull/437/head
Alex Baker 8 years ago
parent 44e894f97b
commit f8508940a8

@ -71,6 +71,10 @@ public class Locale {
return directionality == View.LAYOUT_DIRECTION_RTL ? RIGHT_TO_LEFT_MARK : LEFT_TO_RIGHT_MARK; return directionality == View.LAYOUT_DIRECTION_RTL ? RIGHT_TO_LEFT_MARK : LEFT_TO_RIGHT_MARK;
} }
public int getDirectionality() {
return appDirectionality;
}
public String getOverride() { public String getOverride() {
return override; return override;
} }

@ -18,6 +18,7 @@ import org.tasks.R;
import org.tasks.injection.BroadcastComponent; import org.tasks.injection.BroadcastComponent;
import org.tasks.injection.InjectingAppWidgetProvider; import org.tasks.injection.InjectingAppWidgetProvider;
import org.tasks.intents.TaskIntents; import org.tasks.intents.TaskIntents;
import org.tasks.locale.Locale;
import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.themes.ThemeBase; 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_CLEAR_TOP;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; 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 com.todoroo.astrid.api.AstridApiConstants.BROADCAST_EVENT_REFRESH;
import static org.tasks.intents.TaskIntents.getEditTaskIntent; import static org.tasks.intents.TaskIntents.getEditTaskIntent;
@ -41,6 +43,7 @@ public class TasksWidget extends InjectingAppWidgetProvider {
@Inject Preferences preferences; @Inject Preferences preferences;
@Inject DefaultFilterProvider defaultFilterProvider; @Inject DefaultFilterProvider defaultFilterProvider;
@Inject ThemeCache themeCache; @Inject ThemeCache themeCache;
@Inject Locale locale;
public static final String COMPLETE_TASK = "COMPLETE_TASK"; public static final String COMPLETE_TASK = "COMPLETE_TASK";
public static final String EDIT_TASK = "EDIT_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)); ThemeBase theme = themeCache.getThemeBase(preferences.getInt(WidgetConfigActivity.PREF_THEME + id, 0));
ThemeColor color = themeCache.getThemeColor(preferences.getInt(WidgetConfigActivity.PREF_COLOR + id, 0)); ThemeColor color = themeCache.getThemeColor(preferences.getInt(WidgetConfigActivity.PREF_COLOR + id, 0));
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.scrollable_widget); 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)) { if (preferences.getBoolean(WidgetConfigActivity.PREF_HIDE_HEADER + id, false)) {
remoteViews.setViewVisibility(R.id.widget_header, View.GONE); remoteViews.setViewVisibility(R.id.widget_header, View.GONE);
} else { } else {

@ -3,9 +3,11 @@
** **
** See the file "LICENSE" for the full license governing this code. ** See the file "LICENSE" for the full license governing this code.
--> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout <RelativeLayout
android:id="@+id/widget_header" android:id="@+id/widget_header"
@ -17,43 +19,43 @@
android:id="@+id/widget_header_background" android:id="@+id/widget_header_background"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:scaleType="fitXY"/> android:scaleType="fitXY" />
<ImageButton <ImageButton
android:id="@+id/widget_button" android:id="@+id/widget_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/ic_add_24dp"
android:paddingEnd="10dp" android:paddingEnd="10dp"
android:paddingRight="10dp" android:paddingRight="10dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_add_24dp"
android:tint="@android:color/white" /> android:tint="@android:color/white" />
<TextView <TextView
android:id="@+id/widget_title" android:id="@+id/widget_title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/widget_button" android:layout_toLeftOf="@id/widget_button"
android:layout_toStartOf="@id/widget_button" android:layout_toStartOf="@id/widget_button"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:gravity="center_vertical"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="2" android:maxLines="2"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingStart="10dp" android:paddingStart="10dp"
android:textAlignment="viewStart"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="18sp"/> android:textSize="18sp" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:layout_below="@id/widget_header"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -61,7 +63,7 @@
android:id="@+id/widget_background" android:id="@+id/widget_background"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:scaleType="fitXY"/> android:scaleType="fitXY" />
<ListView <ListView
android:id="@+id/list_view" android:id="@+id/list_view"
@ -76,4 +78,4 @@
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </LinearLayout>

@ -5,7 +5,6 @@
** See the file "LICENSE" for the full license governing this code. ** See the file "LICENSE" for the full license governing this code.
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"

@ -38,6 +38,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:singleLine="true" android:singleLine="true"
android:textAlignment="viewStart"
android:textSize="16sp" /> android:textSize="16sp" />
<TextView <TextView
@ -47,6 +48,7 @@
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_vertical" android:gravity="center_vertical"
android:singleLine="true" android:singleLine="true"
android:textAlignment="viewStart"
android:textSize="12sp" android:textSize="12sp"
android:visibility="gone" /> android:visibility="gone" />

Loading…
Cancel
Save