Commit 19fadacc authored by Sébastien Toque's avatar Sébastien Toque

UI Preview: add a landscape layout

parent cf7fe169
......@@ -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"
......
<?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
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment