[Android] Fix widgets RTL layout

Geoffrey Métais git at videolan.org
Wed Apr 20 18:02:32 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Apr 20 17:58:24 2016 +0200| [0eef40bbcc3ef4a8cd55c59c844b6c6687e173ae] | committer: Geoffrey Métais

Fix widgets RTL layout

> https://code.videolan.org/videolan/vlc-android/commit/0eef40bbcc3ef4a8cd55c59c844b6c6687e173ae
---

 .../src/org/videolan/vlc/widget/VLCAppWidgetProvider.java     | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/widget/VLCAppWidgetProvider.java b/vlc-android/src/org/videolan/vlc/widget/VLCAppWidgetProvider.java
index 84e9f33..5c00735 100644
--- a/vlc-android/src/org/videolan/vlc/widget/VLCAppWidgetProvider.java
+++ b/vlc-android/src/org/videolan/vlc/widget/VLCAppWidgetProvider.java
@@ -29,6 +29,8 @@ import android.content.Context;
 import android.content.Intent;
 import android.graphics.Bitmap;
 import android.os.Build;
+import android.text.TextUtils;
+import android.view.View;
 import android.widget.RemoteViews;
 
 import org.videolan.libvlc.util.AndroidUtil;
@@ -38,6 +40,8 @@ import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.MainActivity;
 import org.videolan.vlc.util.Strings;
 
+import java.util.Locale;
+
 abstract public class VLCAppWidgetProvider extends AppWidgetProvider {
     public static final String TAG = "VLC/VLCAppWidgetProvider";
     public static final String ACTION_REMOTE_BACKWARD = Strings.buildPkgString("remote.Backward");
@@ -66,7 +70,7 @@ abstract public class VLCAppWidgetProvider extends AppWidgetProvider {
         context.sendBroadcast(i);
     }
 
-    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
     @Override
     public void onReceive(Context context, Intent intent) {
         String action = intent.getAction();
@@ -98,6 +102,11 @@ abstract public class VLCAppWidgetProvider extends AppWidgetProvider {
             views.setOnClickPendingIntent(R.id.forward, piForward);
             views.setOnClickPendingIntent(R.id.cover, piVlc);
             partial = false;
+            if (AndroidUtil.isJellyBeanMR1OrLater() && TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL) {
+                boolean black = this instanceof VLCAppWidgetProviderBlack;
+                views.setImageViewResource(R.id.forward, black ? R.drawable.ic_widget_previous_w : R.drawable.ic_widget_previous);
+                views.setImageViewResource(R.id.backward, black ? R.drawable.ic_widget_next_w : R.drawable.ic_widget_next);
+            }
         }
 
         if (ACTION_WIDGET_UPDATE.equals(action)) {



More information about the Android mailing list