[Android] [PATCH] Refresh info page for videos

Geoffrey Métais geoffrey.metais at gmail.com
Tue Dec 9 13:22:34 CET 2014


---
 vlc-android/res/layout-land/media_info.xml         | 36 +++++++++-------------
 vlc-android/res/layout/list_item.xml               |  5 ++-
 vlc-android/res/layout/media_info.xml              | 26 +++++++---------
 .../videolan/vlc/gui/video/MediaInfoFragment.java  | 22 ++++++++++---
 4 files changed, 45 insertions(+), 44 deletions(-)

diff --git a/vlc-android/res/layout-land/media_info.xml b/vlc-android/res/layout-land/media_info.xml
index 6e875e1..7aada9d 100644
--- a/vlc-android/res/layout-land/media_info.xml
+++ b/vlc-android/res/layout-land/media_info.xml
@@ -4,24 +4,17 @@
     android:layout_height="fill_parent"
     android:orientation="vertical" >
 
-    <TextView
-        android:id="@+id/title"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:textColor="?attr/font_default" />
-
     <LinearLayout
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:baselineAligned="false"
-        android:orientation="horizontal" >
+        android:orientation="horizontal"
+        android:background="@color/white" >
 
         <FrameLayout
             android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:layout_gravity="center_vertical"
-            android:layout_weight="1" >
+            android:layout_weight="1">
 
             <ProgressBar
                 style="?android:attr/progressBarStyleLarge"
@@ -33,33 +26,34 @@
                 android:id="@+id/image"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_gravity="center"
-                android:scaleType="fitCenter" />
+                android:layout_gravity="center_horizontal"
+                android:layout_marginBottom="25dp"
+                android:scaleType="centerCrop" />
 
             <ImageButton
                 android:id="@+id/play"
                 android:layout_width="50dip"
                 android:layout_height="50dip"
-                android:layout_gravity="bottom|left"
-                android:layout_margin="10dip"
-                android:background="@drawable/ic_play_circle"
+                android:layout_gravity="bottom|right"
+                android:layout_marginRight="10dip"
+                android:background="@drawable/ic_play_circle_big_o"
                 android:visibility="invisible" />
 
             <TextView
                 android:id="@+id/length"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_gravity="bottom|right"
-                android:layout_margin="10dip"
-                android:background="@drawable/video_list_length_bg"
+                android:layout_gravity="bottom|left"
+                android:layout_marginLeft="10dip"
+                android:layout_marginBottom="25dp"
                 android:textAppearance="?android:attr/textAppearanceMedium"
-                android:textColor="#AFFF" />
+                android:textColor="@color/white"
+                android:visibility="invisible"  />
         </FrameLayout>
-
         <ListView
             android:id="@id/android:list"
             android:layout_width="0dp"
-            android:layout_height="fill_parent"
+            android:layout_height="match_parent"
             android:layout_weight="1"
             android:cacheColorHint="#00000000"
             android:clipToPadding="false"
diff --git a/vlc-android/res/layout/list_item.xml b/vlc-android/res/layout/list_item.xml
index eda9858..a8df3b3 100644
--- a/vlc-android/res/layout/list_item.xml
+++ b/vlc-android/res/layout/list_item.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/layout_item"
-    android:layout_width="fill_parent"
+    android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:orientation="horizontal" >
 
@@ -12,9 +12,8 @@
         android:layout_gravity="center" />
 
     <LinearLayout
-        android:layout_width="0dip"
+        android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_weight="1"
         android:gravity="center_vertical"
         android:orientation="vertical" >
 
diff --git a/vlc-android/res/layout/media_info.xml b/vlc-android/res/layout/media_info.xml
index 02b9262..e4da026 100644
--- a/vlc-android/res/layout/media_info.xml
+++ b/vlc-android/res/layout/media_info.xml
@@ -2,15 +2,9 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
+    android:background="@color/white"
     android:orientation="vertical" >
 
-    <TextView
-        android:id="@+id/title"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:textColor="?attr/font_default" />
-
     <FrameLayout
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" >
@@ -25,27 +19,29 @@
             android:id="@+id/image"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_gravity="center"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginBottom="25dp"
             android:scaleType="fitCenter" />
 
         <ImageButton
             android:id="@+id/play"
             android:layout_width="50dip"
             android:layout_height="50dip"
-            android:layout_gravity="bottom|left"
-            android:layout_margin="10dip"
-            android:background="@drawable/ic_play_circle"
+            android:layout_gravity="bottom|right"
+            android:layout_marginRight="10dip"
+            android:background="@drawable/ic_play_circle_big_o"
             android:visibility="invisible" />
 
         <TextView
             android:id="@+id/length"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_gravity="bottom|right"
-            android:layout_margin="10dip"
-            android:background="@drawable/video_list_length_bg"
+            android:layout_gravity="bottom|left"
+            android:layout_marginLeft="10dip"
+            android:layout_marginBottom="25dp"
             android:textAppearance="?android:attr/textAppearanceMedium"
-            android:textColor="#AFFF" />
+            android:textColor="@color/white"
+            android:visibility="invisible"  />
     </FrameLayout>
 
     <ListView
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
index dfc37c8..98bde10 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -33,6 +33,7 @@ import org.videolan.vlc.util.Strings;
 import org.videolan.vlc.util.VLCInstance;
 import org.videolan.vlc.util.WeakHandler;
 
+import android.content.res.Configuration;
 import android.graphics.Bitmap;
 import android.graphics.Bitmap.Config;
 import android.os.Bundle;
@@ -54,7 +55,6 @@ public class MediaInfoFragment extends ListFragment {
     public final static String TAG = "VLC/MediaInfoFragment";
     private Media mItem;
     private Bitmap mImage;
-    private TextView mTitleView;
     private TextView mLengthView;
     private ImageButton mPlayButton;
     private TrackInfo[] mTracks;
@@ -67,7 +67,6 @@ public class MediaInfoFragment extends ListFragment {
         super.onCreate(savedInstanceState);
         View v = inflater.inflate(R.layout.media_info, container, false);
 
-        mTitleView = (TextView) v.findViewById(R.id.title);
         mLengthView = (TextView) v.findViewById(R.id.length);
         mPlayButton = (ImageButton) v.findViewById(R.id.play);
 
@@ -93,7 +92,6 @@ public class MediaInfoFragment extends ListFragment {
             return;
         }
 
-        mTitleView.setText(mItem.getTitle());
         ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle(mItem.getTitle());
         mLengthView.setText(Strings.millisToString(mItem.getLength()));
 
@@ -121,8 +119,16 @@ public class MediaInfoFragment extends ListFragment {
 
             DisplayMetrics screen = new DisplayMetrics();
             getActivity().getWindowManager().getDefaultDisplay().getMetrics(screen);
-            int width = Math.min(screen.widthPixels, screen.heightPixels);
-            int height = width * 9 / 16;
+            int videoHeight = mItem.getHeight();
+            int videoWidth = mItem.getWidth();
+            int width, height;
+            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+                width = Math.min(screen.widthPixels, screen.heightPixels);
+                height = width * 9 / 16;
+            } else {
+                width = screen.widthPixels /2 ;
+            }
+            height = width * videoHeight/videoWidth;
 
             // Get the thumbnail.
             mImage = Bitmap.createBitmap(width, height, Config.ARGB_8888);
@@ -144,7 +150,13 @@ public class MediaInfoFragment extends ListFragment {
             return;
         ImageView imageView = (ImageView) getView().findViewById(R.id.image);
         imageView.setImageBitmap(mImage);
+        ViewGroup.LayoutParams lp = imageView.getLayoutParams();
+        lp.height = mImage.getHeight();
+        lp.width = mImage.getWidth();
+        imageView.setLayoutParams(lp);
+        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
         mPlayButton.setVisibility(View.VISIBLE);
+        mLengthView.setVisibility(View.VISIBLE);
     }
 
     private void updateText() {
-- 
1.9.1



More information about the Android mailing list