Commit fb8c3fd9 authored by Edward Wang's avatar Edward Wang Committed by Jean-Baptiste Kempf

Update Android code to support SDK 7

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent ef03b7ee
......@@ -2,12 +2,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="0.0-alpha"
package="org.videolan.vlc.android"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="8" />
package="org.videolan.vlc.android">
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/icon"
android:label="@string/app_name">
android:label="@string/app_name" android:debuggable="true">
<activity
android:label="@string/app_name"
android:icon="@drawable/icon"
......
<?xml version="1.0" encoding="UTF-8"?>
<project name="VLC" default="default">
<project name="VLC" default="help">
<!-- The local.properties file is created and updated by the 'android'
tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<loadproperties srcFile="local.properties" />
<!-- The build.properties file can be created by you and is never touched
by the 'android' tool. This is the place to change some of the
default property values used by the Ant rules.
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
......@@ -17,6 +16,9 @@
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
......@@ -24,28 +26,25 @@
application and should be checked into Version Control Systems.
-->
<property file="build.properties" />
<property file="ant.properties" />
<!-- The default.properties file is created and updated by the 'android'
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<property file="project.properties" />
<!-- Custom Android task to deal with the project target, and import the
proper rules.
This requires ant 1.6.0 or above. -->
<path id="android.antlibs">
<pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
<pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
<pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
</path>
<loadproperties srcFile="project.properties" />
<taskdef name="setup"
classname="com.android.ant.SetupTask"
classpathref="android.antlibs" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
unless="sdk.dir"
/>
<target name="default" />
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
......@@ -55,32 +54,32 @@
<target name="-pre-compile">
</target>
[This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir}]
/* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->
<!-- Execute the Android Setup task that will setup some properties
specific to the target, and import the build rules files.
The rules file is imported from
<SDK>/platforms/<target_platform>/ant/ant_rules_r#.xml
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<setup> task.
<import> task.
- customize it to your needs.
- Customize the whole script.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, *after* the <setup> task
- disable the import of the rules by changing the setup task
below to <setup import="false" />.
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<setup />
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>
......@@ -8,4 +8,4 @@
# project structure.
# Project target.
target=android-8
target=android-7
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<HorizontalScrollView
android:id="@+id/header"
android:scrollbars="none"
android:fadingEdge="none"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_with_shadow">
<LinearLayout
......@@ -59,36 +59,36 @@
</LinearLayout>
</HorizontalScrollView>
<View
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#f0f0f0" />
<org.videolan.vlc.android.widget.FlingViewGroup
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/songs_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fastScrollEnabled="true" />
<ListView
android:id="@+id/artists_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fastScrollEnabled="true" />
<ListView
android:id="@+id/albums_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ListView
android:id="@+id/genres_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fastScrollEnabled="true" />
<ListView
android:id="@+id/playklists_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fastScrollEnabled="true" />
</org.videolan.vlc.android.widget.FlingViewGroup>
</LinearLayout>
......@@ -2,26 +2,26 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_with_shadow">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="48dip"
android:orientation="horizontal"
android:background="@drawable/header">
<ImageView
android:src="@drawable/header_logo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="fill_parent"
android:scaleType="centerInside" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1">
<ImageView
android:layout_height="match_parent"
android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1"
android:background="#00ffffff"
......@@ -30,7 +30,7 @@
android:id="@+id/cover" />
<LinearLayout
android:layout_width="90dip"
android:layout_height="match_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:paddingLeft="15dip"
android:orientation="vertical">
......@@ -58,7 +58,7 @@
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_marginLeft="15dip"
android:layout_marginTop="10dip"
android:layout_marginRight="15dip">
......@@ -81,7 +81,7 @@
android:id="@+id/length" />
</LinearLayout>
<SeekBar
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="4dip"
android:maxHeight="4dip"
......@@ -93,7 +93,7 @@
android:paddingRight="15dip"
android:id="@+id/timeline" />
<TextView
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/title"
android:textColor="#ffffff"
......@@ -105,7 +105,7 @@
android:layout_marginBottom="4dip"
android:id="@+id/title" />
<TextView
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/artist"
android:textColor="#888888"
......@@ -117,7 +117,7 @@
android:layout_marginBottom="4dip"
android:id="@+id/artist" />
<TextView
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/album"
android:textColor="#888888"
......@@ -128,7 +128,7 @@
android:ellipsize="marquee"
android:id="@+id/album" />
<LinearLayout
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
......
......@@ -2,20 +2,20 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_with_shadow">
<SeekBar
android:id="@+id/timeline"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:minHeight="2dip"
android:maxHeight="2dip"
android:progressDrawable="@drawable/po_seekbar"
android:thumb="@drawable/spacer" />
<LinearLayout
android:id="@+id/mini_player"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:orientation="horizontal"
android:gravity="center_vertical">
......
......@@ -4,7 +4,7 @@
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
\ No newline at end of file
......@@ -2,7 +2,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_height="fill_parent"
android:paddingLeft="5dip"
android:paddingTop="5dip"
android:paddingBottom="5dip">
......
......@@ -6,7 +6,7 @@
android:layout_height="fill_parent"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#444444"
android:gravity="center_vertical"
......@@ -25,17 +25,17 @@
android:text="@string/info_title" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/beta_warning"
android:padding="10dip" />
<View
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
......@@ -54,7 +54,7 @@
android:text="@string/not_show_again" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_horizontal"
......
......@@ -2,18 +2,18 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_with_shadow">
<TextView
android:id="@+id/text"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_marginLeft="18dip"
android:textSize="16dip"
android:textColor="#ffffff" />
<View
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#f0f0f0" />
</LinearLayout>
\ No newline at end of file
......@@ -5,14 +5,14 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="48dip"
android:orientation="horizontal"
android:background="@drawable/header">
<ImageView
android:src="@drawable/header_logo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="fill_parent"
android:scaleType="centerInside" />
<View
android:layout_width="0dip"
......@@ -70,6 +70,6 @@
<org.videolan.vlc.android.widget.AudioMiniPlayer
android:id="@+id/audio_mini_player"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:visibility="gone" />
</LinearLayout>
......@@ -6,11 +6,11 @@
android:scrollbars="none">
<FrameLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:paddingTop="60dip">
<ProgressBar
......@@ -20,18 +20,18 @@
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="230dip"
android:id="@+id/image"
android:scaleType="fitCenter"
android:visibility="invisible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="180dip">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#66000000">
<TextView
......@@ -43,7 +43,7 @@
android:layout_marginLeft="10dip" />
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:gravity="right"
android:id="@+id/length"
android:layout_marginRight="10dip"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent">
android:layout_width="fill_parent">
<TextView
android:id="@+id/player_overlay_time"
android:layout_width="0dip"
......@@ -29,7 +29,7 @@
android:paddingRight="10dip" />
</LinearLayout>
<SeekBar
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="4dip"
android:maxHeight="4dip"
......@@ -43,7 +43,7 @@
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent">
android:layout_width="fill_parent">
<ImageButton
android:id="@+id/player_overlay_size"
android:background="@drawable/ic_size"
......
......@@ -5,7 +5,7 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="48dip"
android:orientation="horizontal"
android:paddingTop="5dip"
......@@ -32,7 +32,7 @@
</LinearLayout>
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fastScrollEnabled="true" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fastScrollEnabled="true" />
<FrameLayout
android:id="@id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/video_list_empty_loadfile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<ProgressBar
android:layout_width="20dip"
......@@ -29,8 +29,8 @@
</LinearLayout>
<LinearLayout
android:id="@+id/video_list_empty_nofile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:visibility="invisible">
<TextView
......
......@@ -40,7 +40,7 @@
<ImageView
android:id="@+id/ml_item_more"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="fill_parent"
android:src="@drawable/ic_next"
android:paddingRight="12dip"
android:paddingLeft="5dip" />
......
<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="info_dialog" parent="@android:style/Theme.Dialog">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowNoTitle">true</item>
......
package org.videolan.vlc.android;
import java.lang.reflect.Method;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
......@@ -173,18 +176,28 @@ public class VideoPlayerActivity extends Activity {
private void lockScreen() {
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
switch (display.getRotation()) {
case Surface.ROTATION_0:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case Surface.ROTATION_90:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case Surface.ROTATION_270:
// FIXME: API Level 9+ (not tested on a device with API Level < 9)
setRequestedOrientation(8); // SCREEN_ORIENTATION_REVERSE_LANDSCAPE
break;
int rotation = display.getOrientation();
if(Build.VERSION.SDK_INT >= 8 /* Android 2.2 has getRotation */) {
try {
Method m = display.getClass().getDeclaredMethod("getRotation");
rotation = (Integer)m.invoke(display);
} catch(Exception e) {
rotation = Surface.ROTATION_0;
}
} else {
rotation = display.getOrientation();
}
switch (rotation) {
case Surface.ROTATION_0:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case Surface.ROTATION_90:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case Surface.ROTATION_270:
// FIXME: API Level 9+ (not tested on a device with API Level < 9)
setRequestedOrientation(8); // SCREEN_ORIENTATION_REVERSE_LANDSCAPE
break;
}