[Android] [PATCH] Option to show videos as list in portrait

Geoffrey Métais geoffrey.metais at gmail.com
Wed Nov 19 16:39:30 CET 2014


---
 vlc-android/res/values/strings.xml                                | 2 ++
 vlc-android/res/xml/preferences.xml                               | 5 +++++
 vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java | 8 ++++++--
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index bf6e2d4..5569d51 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -236,6 +236,8 @@
     <string name="enable_brightness_gesture_summary">Control brightness by gesture during video playback</string>
     <string name="enable_jump_buttons">Enable jump buttons</string>
     <string name="enable_jump_buttons_summary">Show backward and forward buttons on the video interface</string>
+    <string name="force_list_portrait">No grid in portrait mode</string>
+    <string name="force_list_portrait_summary">Show videos in list instead of grid in portrait mode</string>
     <string name="audio_title_alignment">Audio title alignment</string>
     <string name="enable_headset_detection">Detect headset</string>
     <string name="enable_headset_detection_summary">Pause on headset removal; resume on headset insertion</string>
diff --git a/vlc-android/res/xml/preferences.xml b/vlc-android/res/xml/preferences.xml
index 8ec773f..61510ed 100644
--- a/vlc-android/res/xml/preferences.xml
+++ b/vlc-android/res/xml/preferences.xml
@@ -48,6 +48,11 @@
             </PreferenceCategory>
             <PreferenceCategory android:title="@string/interface_other_category" >
                 <CheckBoxPreference
+                    android:defaultValue="false"
+                    android:key="force_list_portrait"
+                    android:summary="@string/force_list_portrait_summary"
+                    android:title="@string/force_list_portrait" />
+                <CheckBoxPreference
                     android:defaultValue="true"
                     android:key="enable_brightness_gesture"
                     android:summary="@string/enable_brightness_gesture_summary"
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index 5b450dc..347a1fe 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -55,6 +55,7 @@ import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
+import android.preference.PreferenceManager;
 import android.support.v4.app.FragmentActivity;
 import android.support.v7.app.ActionBarActivity;
 import android.util.DisplayMetrics;
@@ -211,8 +212,10 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
             Log.w(TAG, "Unable to setup the view");
             return;
         }
-
         Resources res = getResources();
+        boolean listMode = res.getBoolean(R.bool.list_mode);
+        listMode |= res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT &&
+                PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("force_list_portrait", false);
         // Compute the left/right padding dynamically
         DisplayMetrics outMetrics = new DisplayMetrics();
         getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
@@ -222,7 +225,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
                 sidePadding, mGridView.getPaddingBottom());
 
         // Select between grid or list
-            if (!res.getBoolean(R.bool.list_mode)) {
+            if (!listMode) {
             mGridView.setNumColumns(GridView.AUTO_FIT);
             mGridView.setStretchMode(GRID_STRETCH_MODE);
             mGridView.setColumnWidth(res.getDimensionPixelSize(R.dimen.grid_card_width));
@@ -231,6 +234,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
         } else {
             mGridView.setNumColumns(1);
             mGridView.setStretchMode(LIST_STRETCH_MODE);
+            mGridView.setVerticalSpacing(0);
             mVideoAdapter.setListMode(true);
         }
     }
-- 
1.9.1



More information about the Android mailing list