[Android] UI Preview: add a landscape layout
Sébastien Toque
git at videolan.org
Sat May 5 22:40:18 CEST 2012
android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sat May 5 17:09:34 2012 +0200| [19fadacca057a0dbe5720a1311da706e7c96d06d] | committer: Sébastien Toque
UI Preview: add a landscape layout
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=19fadacca057a0dbe5720a1311da706e7c96d06d
---
vlc-android/AndroidManifest.xml | 3 +-
vlc-android/res/layout-land/media_info.xml | 81 ++++++++++++++++++++
.../videolan/vlc/gui/video/MediaInfoActivity.java | 33 ++++++---
3 files changed, 105 insertions(+), 12 deletions(-)
diff --git a/vlc-android/AndroidManifest.xml b/vlc-android/AndroidManifest.xml
index aca64fe..97ce12e 100644
--- a/vlc-android/AndroidManifest.xml
+++ b/vlc-android/AndroidManifest.xml
@@ -62,8 +62,7 @@
android:theme="@android:style/Theme.NoTitleBar" />
<activity
android:name=".gui.video.MediaInfoActivity"
- android:theme="@android:style/Theme.NoTitleBar"
- android:configChanges="orientation|screenSize" />
+ android:theme="@android:style/Theme.NoTitleBar" />
<activity
android:name=".gui.video.VideoPlayerActivity"
android:configChanges="orientation|screenSize"
diff --git a/vlc-android/res/layout-land/media_info.xml b/vlc-android/res/layout-land/media_info.xml
new file mode 100644
index 0000000..a06cbfb
--- /dev/null
+++ b/vlc-android/res/layout-land/media_info.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="48dip"
+ android:background="@drawable/header"
+ android:orientation="horizontal" >
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:scaleType="centerInside"
+ android:src="@drawable/header_logo" />
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/video_list_length_bg"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal" >
+
+ <FrameLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1" >
+
+ <ProgressBar
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center" />
+
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ 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"
+ android:onClick="onPlayClick"
+ 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:textAppearance="?android:attr/textAppearanceMedium" />
+ </FrameLayout>
+
+ <ListView
+ android:id="@id/android:list"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:cacheColorHint="#00000000"
+ android:divider="#00000000"
+ android:fastScrollEnabled="true" />
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java
index 1c687fd..3e782b3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java
@@ -43,7 +43,9 @@ import android.widget.ImageView;
import android.widget.TextView;
public class MediaInfoActivity extends ListActivity {
+
public final static String TAG = "VLC/MediaInfoActivity";
+ public static final String KEY = "MediaInfoActivity.image";
private Media mItem;
private Bitmap mImage;
private ImageButton mPlayButton;
@@ -56,6 +58,9 @@ public class MediaInfoActivity extends ListActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.media_info);
+ if (savedInstanceState != null)
+ mImage = savedInstanceState.getParcelable(KEY);
+
String MRL = getIntent().getExtras().getString("itemLocation");
if (MRL == null)
return;
@@ -77,6 +82,12 @@ public class MediaInfoActivity extends ListActivity {
new Thread(mLoadImage).start();
}
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putParcelable(KEY, mImage);
+ }
+
public void onPlayClick(View v) {
Intent intent = new Intent(this, VideoPlayerActivity.class);
intent.putExtra("itemLocation", mItem.getLocation());
@@ -96,20 +107,22 @@ public class MediaInfoActivity extends ListActivity {
mTracks = mLibVlc.readTracksInfo(mItem.getLocation());
mHandler.sendEmptyMessage(NEW_TEXT);
- int width = Math.min(getWindowManager().getDefaultDisplay().getWidth(),
- getWindowManager().getDefaultDisplay().getHeight());
- int height = width * 9 / 16;
+ if (mImage == null) {
+ int width = Math.min(getWindowManager().getDefaultDisplay().getWidth(),
+ getWindowManager().getDefaultDisplay().getHeight());
+ int height = width * 9 / 16;
- // Get the thumbnail.
- mImage = Bitmap.createBitmap(width, height, Config.ARGB_8888);
+ // Get the thumbnail.
+ mImage = Bitmap.createBitmap(width, height, Config.ARGB_8888);
- byte[] b = mLibVlc.getThumbnail(mItem.getLocation(), width, height);
+ byte[] b = mLibVlc.getThumbnail(mItem.getLocation(), width, height);
- if (b == null) // We were not able to create a thumbnail for this item.
- return;
+ if (b == null) // We were not able to create a thumbnail for this item.
+ return;
- mImage.copyPixelsFromBuffer(ByteBuffer.wrap(b));
- mImage = Util.cropBorders(mImage, width, height);
+ mImage.copyPixelsFromBuffer(ByteBuffer.wrap(b));
+ mImage = Util.cropBorders(mImage, width, height);
+ }
mHandler.sendEmptyMessage(NEW_IMAGE);
}
More information about the Android
mailing list