am 7b66bb06: Delete the new Galley3D in Gingerbread because we are doing all our rewrites in Master (Honeycomb).
Merge commit '7b66bb0689c661a0e3c133594944be8007eee080' into gingerbread-plus-aosp
* commit '7b66bb0689c661a0e3c133594944be8007eee080':
Delete the new Galley3D in Gingerbread because we are doing all our rewrites in Master (Honeycomb).
diff --git a/new3d/Android.mk b/new3d/Android.mk
deleted file mode 100644
index 4c07c94..0000000
--- a/new3d/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := GalleryNew3D
-LOCAL_CERTIFICATE := media
-
-LOCAL_OVERRIDES_PACKAGES := Gallery
-
-# We mark this out until LargeBitmap is unhidden.
-#LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
-
-# Use the following include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/new3d/AndroidManifest.xml b/new3d/AndroidManifest.xml
deleted file mode 100644
index 2821ba9..0000000
--- a/new3d/AndroidManifest.xml
+++ /dev/null
@@ -1,155 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<manifest android:versionCode="30682"
- android:versionName="1.1.30682"
- xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.gallery3d">
-
- <original-package android:name="com.android.gallery3d" />
-
- <uses-permission android:name="android.permission.SET_WALLPAPER" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.GET_ACCOUNTS" />
- <uses-permission android:name="android.permission.USE_CREDENTIALS" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.VIBRATE" />
- <uses-permission android:name="android.permission.WAKE_LOCK" />
- <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
- <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
- <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
-
- <supports-screens android:smallScreens="false"
- android:normalScreens="true" android:largeScreens="true"
- android:anyDensity="true" />
-
- <application android:icon="@drawable/icon" android:label="@string/app_name"
- android:debuggable="true">
- <activity android:name="com.android.gallery3d.app.MovieView"
- android:label="@string/movie_view_label"
- android:screenOrientation="landscape"
- android:configChanges="orientation|keyboardHidden"
- android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.BROWSABLE" />
- <data android:scheme="rtsp" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="video/*" />
- <data android:mimeType="application/sdp" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.BROWSABLE" />
- <data android:scheme="http" />
- <data android:mimeType="video/mpeg4" />
- <data android:mimeType="video/mp4" />
- <data android:mimeType="video/3gp" />
- <data android:mimeType="video/3gpp" />
- <data android:mimeType="video/3gpp2" />
- </intent-filter>
- </activity>
- <activity android:name="com.android.gallery3d.app.Gallery" android:label="@string/app_name"
- android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
- android:configChanges="keyboardHidden|orientation"
- android:clearTaskOnLaunch="true" android:noHistory="false"
- android:stateNotNeeded="true">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.GET_CONTENT" />
- <category android:name="android.intent.category.OPENABLE" />
- <data android:mimeType="vnd.android.cursor.dir/image" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.GET_CONTENT" />
- <category android:name="android.intent.category.OPENABLE" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="image/*" />
- <data android:mimeType="video/*" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.PICK" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="image/*" />
- <data android:mimeType="video/*" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.PICK" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.cursor.dir/image" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.cursor.dir/image" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="image/*" />
- </intent-filter>
- <intent-filter>
- <action android:name="com.android.gallery3d.action.REVIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.cursor.dir/image" />
- </intent-filter>
- <intent-filter>
- <action android:name="com.android.gallery3d.action.REVIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="image/*" />
- </intent-filter>
- <intent-filter>
- <action android:name="com.android.gallery3d.action.REVIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="video/*" />
- </intent-filter>
- </activity>
- <activity android:name="com.android.gallery3d.app.SetWallpaper" android:icon="@drawable/icon">
- <intent-filter android:label="@string/camera_setas_wallpaper">
- <action android:name="android.intent.action.ATTACH_DATA" />
- <data android:mimeType="image/*" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <intent-filter android:label="@string/app_name">
- <action android:name="android.intent.action.SET_WALLPAPER" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
- <provider android:label="Picasa Web Albums2"
- android:name="com.android.gallery3d.picasa.PicasaContentProvider"
- android:grantUriPermissions="true"
- android:syncable="true"
- android:authorities="com.android.gallery3d.picasa.contentprovider">
- </provider>
- <service android:label="Picasa Sync Service"
- android:name="com.android.gallery3d.picasa.PicasaService">
- <intent-filter>
- <action android:name="android.content.SyncAdapter" />
- </intent-filter>
- <meta-data android:name="android.content.SyncAdapter" android:resource="@xml/syncadapter" />
- </service>
-
- <receiver android:name="com.android.gallery3d.gadget.PhotoAppWidgetProvider"
- android:label="@string/gadget_title">
- <intent-filter>
- <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
- </intent-filter>
- <meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidget_info" />
- </receiver>
-
- <!-- We configure a widget by asking to pick a photo, then crop it, and store the config internally-->
- <activity android:name="com.android.gallery3d.gadget.PhotoAppWidgetConfigure">
- <intent-filter>
- <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/new3d/res/drawable-hdpi/appwidget_bg.9.png b/new3d/res/drawable-hdpi/appwidget_bg.9.png
deleted file mode 100755
index 3b29eae..0000000
--- a/new3d/res/drawable-hdpi/appwidget_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/btn_camera.png b/new3d/res/drawable-hdpi/btn_camera.png
deleted file mode 100644
index dccc850..0000000
--- a/new3d/res/drawable-hdpi/btn_camera.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/btn_camera_pressed.png b/new3d/res/drawable-hdpi/btn_camera_pressed.png
deleted file mode 100644
index 977468a..0000000
--- a/new3d/res/drawable-hdpi/btn_camera_pressed.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/btn_hud_zoom_in_normal.png b/new3d/res/drawable-hdpi/btn_hud_zoom_in_normal.png
deleted file mode 100644
index 622b416..0000000
--- a/new3d/res/drawable-hdpi/btn_hud_zoom_in_normal.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/btn_hud_zoom_in_pressed.png b/new3d/res/drawable-hdpi/btn_hud_zoom_in_pressed.png
deleted file mode 100644
index 9c14235..0000000
--- a/new3d/res/drawable-hdpi/btn_hud_zoom_in_pressed.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/btn_hud_zoom_out_normal.png b/new3d/res/drawable-hdpi/btn_hud_zoom_out_normal.png
deleted file mode 100644
index e25b5bd..0000000
--- a/new3d/res/drawable-hdpi/btn_hud_zoom_out_normal.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/btn_hud_zoom_out_pressed.png b/new3d/res/drawable-hdpi/btn_hud_zoom_out_pressed.png
deleted file mode 100644
index 5173d40..0000000
--- a/new3d/res/drawable-hdpi/btn_hud_zoom_out_pressed.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/grid_frame.9.png b/new3d/res/drawable-hdpi/grid_frame.9.png
deleted file mode 100644
index a0dd289..0000000
--- a/new3d/res/drawable-hdpi/grid_frame.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/ic_fs_details.png b/new3d/res/drawable-hdpi/ic_fs_details.png
deleted file mode 100644
index 8f3ee26..0000000
--- a/new3d/res/drawable-hdpi/ic_fs_details.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/ic_spinner.png b/new3d/res/drawable-hdpi/ic_spinner.png
deleted file mode 100644
index 6318b7a..0000000
--- a/new3d/res/drawable-hdpi/ic_spinner.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/ic_spinner2.png b/new3d/res/drawable-hdpi/ic_spinner2.png
deleted file mode 100644
index af786c3..0000000
--- a/new3d/res/drawable-hdpi/ic_spinner2.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/ic_spinner3.png b/new3d/res/drawable-hdpi/ic_spinner3.png
deleted file mode 100644
index 07c0981..0000000
--- a/new3d/res/drawable-hdpi/ic_spinner3.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/ic_spinner4.png b/new3d/res/drawable-hdpi/ic_spinner4.png
deleted file mode 100644
index a5ab782..0000000
--- a/new3d/res/drawable-hdpi/ic_spinner4.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/ic_spinner5.png b/new3d/res/drawable-hdpi/ic_spinner5.png
deleted file mode 100644
index 2a1471d..0000000
--- a/new3d/res/drawable-hdpi/ic_spinner5.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/ic_spinner6.png b/new3d/res/drawable-hdpi/ic_spinner6.png
deleted file mode 100644
index 9e1f5d3..0000000
--- a/new3d/res/drawable-hdpi/ic_spinner6.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/ic_spinner7.png b/new3d/res/drawable-hdpi/ic_spinner7.png
deleted file mode 100644
index dbfa735..0000000
--- a/new3d/res/drawable-hdpi/ic_spinner7.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/ic_spinner8.png b/new3d/res/drawable-hdpi/ic_spinner8.png
deleted file mode 100644
index 534a8cf..0000000
--- a/new3d/res/drawable-hdpi/ic_spinner8.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/icon.png b/new3d/res/drawable-hdpi/icon.png
deleted file mode 100644
index a116219..0000000
--- a/new3d/res/drawable-hdpi/icon.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/icon_camera_small.png b/new3d/res/drawable-hdpi/icon_camera_small.png
deleted file mode 100644
index 084c4ec..0000000
--- a/new3d/res/drawable-hdpi/icon_camera_small.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/icon_cancel.png b/new3d/res/drawable-hdpi/icon_cancel.png
deleted file mode 100644
index 8165efd..0000000
--- a/new3d/res/drawable-hdpi/icon_cancel.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/icon_delete.png b/new3d/res/drawable-hdpi/icon_delete.png
deleted file mode 100644
index f2e6bbd..0000000
--- a/new3d/res/drawable-hdpi/icon_delete.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/icon_details.png b/new3d/res/drawable-hdpi/icon_details.png
deleted file mode 100644
index 4a5c276..0000000
--- a/new3d/res/drawable-hdpi/icon_details.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/icon_folder_small.png b/new3d/res/drawable-hdpi/icon_folder_small.png
deleted file mode 100644
index 33ef42b..0000000
--- a/new3d/res/drawable-hdpi/icon_folder_small.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/icon_home_small.png b/new3d/res/drawable-hdpi/icon_home_small.png
deleted file mode 100644
index 479b5d1..0000000
--- a/new3d/res/drawable-hdpi/icon_home_small.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/icon_more.png b/new3d/res/drawable-hdpi/icon_more.png
deleted file mode 100644
index b2502a1..0000000
--- a/new3d/res/drawable-hdpi/icon_more.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/icon_picasa_small.png b/new3d/res/drawable-hdpi/icon_picasa_small.png
deleted file mode 100644
index 2e1a771..0000000
--- a/new3d/res/drawable-hdpi/icon_picasa_small.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/icon_play.png b/new3d/res/drawable-hdpi/icon_play.png
deleted file mode 100644
index 0c61f32..0000000
--- a/new3d/res/drawable-hdpi/icon_play.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/icon_share.png b/new3d/res/drawable-hdpi/icon_share.png
deleted file mode 100644
index 83ff864..0000000
--- a/new3d/res/drawable-hdpi/icon_share.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/landscape.jpg b/new3d/res/drawable-hdpi/landscape.jpg
deleted file mode 100644
index a07208b..0000000
--- a/new3d/res/drawable-hdpi/landscape.jpg
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/menu_bar_bg.9.png b/new3d/res/drawable-hdpi/menu_bar_bg.9.png
deleted file mode 100644
index d352d44..0000000
--- a/new3d/res/drawable-hdpi/menu_bar_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/menu_highlight.9.png b/new3d/res/drawable-hdpi/menu_highlight.9.png
deleted file mode 100644
index 3876e70..0000000
--- a/new3d/res/drawable-hdpi/menu_highlight.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/mode_grid.png b/new3d/res/drawable-hdpi/mode_grid.png
deleted file mode 100644
index 3748833..0000000
--- a/new3d/res/drawable-hdpi/mode_grid.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/mode_stack.png b/new3d/res/drawable-hdpi/mode_stack.png
deleted file mode 100644
index b3b0f41..0000000
--- a/new3d/res/drawable-hdpi/mode_stack.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/pathbar.9.png b/new3d/res/drawable-hdpi/pathbar.9.png
deleted file mode 100644
index 9fc640b..0000000
--- a/new3d/res/drawable-hdpi/pathbar.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/pathbar_pressed.9.png b/new3d/res/drawable-hdpi/pathbar_pressed.9.png
deleted file mode 100644
index bcb185a..0000000
--- a/new3d/res/drawable-hdpi/pathbar_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/pathcap.9.png b/new3d/res/drawable-hdpi/pathcap.9.png
deleted file mode 100644
index 376e89e..0000000
--- a/new3d/res/drawable-hdpi/pathcap.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/pathcap_pressed.9.png b/new3d/res/drawable-hdpi/pathcap_pressed.9.png
deleted file mode 100644
index db4a61b..0000000
--- a/new3d/res/drawable-hdpi/pathcap_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/photo_inner.9.png b/new3d/res/drawable-hdpi/photo_inner.9.png
deleted file mode 100644
index dcd2d22..0000000
--- a/new3d/res/drawable-hdpi/photo_inner.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/popup.9.png b/new3d/res/drawable-hdpi/popup.9.png
deleted file mode 100644
index 154ec9a..0000000
--- a/new3d/res/drawable-hdpi/popup.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/popup_triangle_bottom.png b/new3d/res/drawable-hdpi/popup_triangle_bottom.png
deleted file mode 100644
index a637fdb..0000000
--- a/new3d/res/drawable-hdpi/popup_triangle_bottom.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/potrait.jpg b/new3d/res/drawable-hdpi/potrait.jpg
deleted file mode 100644
index 581c8a5..0000000
--- a/new3d/res/drawable-hdpi/potrait.jpg
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/scroller_new.png b/new3d/res/drawable-hdpi/scroller_new.png
deleted file mode 100644
index ed5fb26..0000000
--- a/new3d/res/drawable-hdpi/scroller_new.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/scroller_pressed_new.png b/new3d/res/drawable-hdpi/scroller_pressed_new.png
deleted file mode 100644
index 5e176ac..0000000
--- a/new3d/res/drawable-hdpi/scroller_pressed_new.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/square.jpg b/new3d/res/drawable-hdpi/square.jpg
deleted file mode 100644
index efb5d4f..0000000
--- a/new3d/res/drawable-hdpi/square.jpg
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/stack_frame.9.png b/new3d/res/drawable-hdpi/stack_frame.9.png
deleted file mode 100644
index 73d56ee..0000000
--- a/new3d/res/drawable-hdpi/stack_frame.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/stack_frame_focus.9.png b/new3d/res/drawable-hdpi/stack_frame_focus.9.png
deleted file mode 100644
index a5028b1..0000000
--- a/new3d/res/drawable-hdpi/stack_frame_focus.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/stack_frame_gold.9.png b/new3d/res/drawable-hdpi/stack_frame_gold.9.png
deleted file mode 100644
index 3137578..0000000
--- a/new3d/res/drawable-hdpi/stack_frame_gold.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/top_menu_bar_bg.9.png b/new3d/res/drawable-hdpi/top_menu_bar_bg.9.png
deleted file mode 100644
index fa38967..0000000
--- a/new3d/res/drawable-hdpi/top_menu_bar_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-hdpi/videooverlay.png b/new3d/res/drawable-hdpi/videooverlay.png
deleted file mode 100644
index 1718832..0000000
--- a/new3d/res/drawable-hdpi/videooverlay.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-mdpi/appwidget_bg.9.png b/new3d/res/drawable-mdpi/appwidget_bg.9.png
deleted file mode 100755
index afe41b6..0000000
--- a/new3d/res/drawable-mdpi/appwidget_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-mdpi/ic_spinner1.png b/new3d/res/drawable-mdpi/ic_spinner1.png
deleted file mode 100644
index 8cd254a..0000000
--- a/new3d/res/drawable-mdpi/ic_spinner1.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-mdpi/ic_spinner2.png b/new3d/res/drawable-mdpi/ic_spinner2.png
deleted file mode 100644
index 951edc3..0000000
--- a/new3d/res/drawable-mdpi/ic_spinner2.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-mdpi/ic_spinner3.png b/new3d/res/drawable-mdpi/ic_spinner3.png
deleted file mode 100644
index b1f9ef5..0000000
--- a/new3d/res/drawable-mdpi/ic_spinner3.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-mdpi/ic_spinner4.png b/new3d/res/drawable-mdpi/ic_spinner4.png
deleted file mode 100644
index b1d09fb..0000000
--- a/new3d/res/drawable-mdpi/ic_spinner4.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-mdpi/ic_spinner5.png b/new3d/res/drawable-mdpi/ic_spinner5.png
deleted file mode 100644
index aa4c21d..0000000
--- a/new3d/res/drawable-mdpi/ic_spinner5.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-mdpi/ic_spinner6.png b/new3d/res/drawable-mdpi/ic_spinner6.png
deleted file mode 100644
index 35d03a7..0000000
--- a/new3d/res/drawable-mdpi/ic_spinner6.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-mdpi/ic_spinner7.png b/new3d/res/drawable-mdpi/ic_spinner7.png
deleted file mode 100644
index 8c422c5..0000000
--- a/new3d/res/drawable-mdpi/ic_spinner7.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-mdpi/ic_spinner8.png b/new3d/res/drawable-mdpi/ic_spinner8.png
deleted file mode 100644
index 3414e2d..0000000
--- a/new3d/res/drawable-mdpi/ic_spinner8.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-mdpi/icon_cancel.png b/new3d/res/drawable-mdpi/icon_cancel.png
deleted file mode 100644
index e9f56aa..0000000
--- a/new3d/res/drawable-mdpi/icon_cancel.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable-mdpi/photo_inner.9.png b/new3d/res/drawable-mdpi/photo_inner.9.png
deleted file mode 100755
index f51eb35..0000000
--- a/new3d/res/drawable-mdpi/photo_inner.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/appwidget_bg.9.png b/new3d/res/drawable/appwidget_bg.9.png
deleted file mode 100755
index afe41b6..0000000
--- a/new3d/res/drawable/appwidget_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/btn_camera.png b/new3d/res/drawable/btn_camera.png
deleted file mode 100644
index 8369d48..0000000
--- a/new3d/res/drawable/btn_camera.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/btn_camera_pressed.png b/new3d/res/drawable/btn_camera_pressed.png
deleted file mode 100644
index e4ce9e0..0000000
--- a/new3d/res/drawable/btn_camera_pressed.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/btn_hud_zoom_in_normal.png b/new3d/res/drawable/btn_hud_zoom_in_normal.png
deleted file mode 100644
index d6b4f4b..0000000
--- a/new3d/res/drawable/btn_hud_zoom_in_normal.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/btn_hud_zoom_in_pressed.png b/new3d/res/drawable/btn_hud_zoom_in_pressed.png
deleted file mode 100644
index 5470383..0000000
--- a/new3d/res/drawable/btn_hud_zoom_in_pressed.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/btn_hud_zoom_out_normal.png b/new3d/res/drawable/btn_hud_zoom_out_normal.png
deleted file mode 100644
index 8293e1e..0000000
--- a/new3d/res/drawable/btn_hud_zoom_out_normal.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/btn_hud_zoom_out_pressed.png b/new3d/res/drawable/btn_hud_zoom_out_pressed.png
deleted file mode 100644
index d24e67d..0000000
--- a/new3d/res/drawable/btn_hud_zoom_out_pressed.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/btn_location_filter_unscaled.png b/new3d/res/drawable/btn_location_filter_unscaled.png
deleted file mode 100644
index 383efd2..0000000
--- a/new3d/res/drawable/btn_location_filter_unscaled.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/camera_crop_height.png b/new3d/res/drawable/camera_crop_height.png
deleted file mode 100644
index b089aec..0000000
--- a/new3d/res/drawable/camera_crop_height.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/camera_crop_width.png b/new3d/res/drawable/camera_crop_width.png
deleted file mode 100644
index 65216af..0000000
--- a/new3d/res/drawable/camera_crop_width.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/default_background.png b/new3d/res/drawable/default_background.png
deleted file mode 100644
index 9ce5190..0000000
--- a/new3d/res/drawable/default_background.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/gallery_zoom_in.png b/new3d/res/drawable/gallery_zoom_in.png
deleted file mode 100755
index f8634da..0000000
--- a/new3d/res/drawable/gallery_zoom_in.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/gallery_zoom_in_touch.png b/new3d/res/drawable/gallery_zoom_in_touch.png
deleted file mode 100755
index 095c7a5..0000000
--- a/new3d/res/drawable/gallery_zoom_in_touch.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/gallery_zoom_out.png b/new3d/res/drawable/gallery_zoom_out.png
deleted file mode 100755
index 72d5d38..0000000
--- a/new3d/res/drawable/gallery_zoom_out.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/gallery_zoom_out_touch.png b/new3d/res/drawable/gallery_zoom_out_touch.png
deleted file mode 100755
index 48c8d93..0000000
--- a/new3d/res/drawable/gallery_zoom_out_touch.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/grid_check_off.png b/new3d/res/drawable/grid_check_off.png
deleted file mode 100644
index 3313d18..0000000
--- a/new3d/res/drawable/grid_check_off.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/grid_check_on.png b/new3d/res/drawable/grid_check_on.png
deleted file mode 100644
index 09cf22d..0000000
--- a/new3d/res/drawable/grid_check_on.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/grid_frame.png b/new3d/res/drawable/grid_frame.png
deleted file mode 100644
index d1a320b..0000000
--- a/new3d/res/drawable/grid_frame.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/grid_placeholder.png b/new3d/res/drawable/grid_placeholder.png
deleted file mode 100644
index 5151730..0000000
--- a/new3d/res/drawable/grid_placeholder.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/ic_fs_details.png b/new3d/res/drawable/ic_fs_details.png
deleted file mode 100644
index 95dabe7..0000000
--- a/new3d/res/drawable/ic_fs_details.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/ic_menu_crop.png b/new3d/res/drawable/ic_menu_crop.png
deleted file mode 100644
index e26fe9b..0000000
--- a/new3d/res/drawable/ic_menu_crop.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/ic_menu_mapmode.png b/new3d/res/drawable/ic_menu_mapmode.png
deleted file mode 100644
index c1a136a..0000000
--- a/new3d/res/drawable/ic_menu_mapmode.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/ic_menu_rotate_left.png b/new3d/res/drawable/ic_menu_rotate_left.png
deleted file mode 100644
index 90cc657..0000000
--- a/new3d/res/drawable/ic_menu_rotate_left.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/ic_menu_rotate_right.png b/new3d/res/drawable/ic_menu_rotate_right.png
deleted file mode 100644
index 75f7f5d..0000000
--- a/new3d/res/drawable/ic_menu_rotate_right.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/ic_menu_set_as.png b/new3d/res/drawable/ic_menu_set_as.png
deleted file mode 100644
index 2c3d893..0000000
--- a/new3d/res/drawable/ic_menu_set_as.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/ic_menu_view_details.png b/new3d/res/drawable/ic_menu_view_details.png
deleted file mode 100644
index aef2db0..0000000
--- a/new3d/res/drawable/ic_menu_view_details.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon.png b/new3d/res/drawable/icon.png
deleted file mode 100644
index 7ea0b8c..0000000
--- a/new3d/res/drawable/icon.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_camera_small.png b/new3d/res/drawable/icon_camera_small.png
deleted file mode 100644
index 5132b81..0000000
--- a/new3d/res/drawable/icon_camera_small.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_camera_small_unscaled.png b/new3d/res/drawable/icon_camera_small_unscaled.png
deleted file mode 100644
index 29436ff..0000000
--- a/new3d/res/drawable/icon_camera_small_unscaled.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_delete.png b/new3d/res/drawable/icon_delete.png
deleted file mode 100644
index 90dea86..0000000
--- a/new3d/res/drawable/icon_delete.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_folder_small.png b/new3d/res/drawable/icon_folder_small.png
deleted file mode 100644
index 18ac991..0000000
--- a/new3d/res/drawable/icon_folder_small.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_folder_small_unscaled.png b/new3d/res/drawable/icon_folder_small_unscaled.png
deleted file mode 100644
index 9e18010..0000000
--- a/new3d/res/drawable/icon_folder_small_unscaled.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_home_small.png b/new3d/res/drawable/icon_home_small.png
deleted file mode 100644
index f8ff493..0000000
--- a/new3d/res/drawable/icon_home_small.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_location_small.png b/new3d/res/drawable/icon_location_small.png
deleted file mode 100644
index 6b29e49..0000000
--- a/new3d/res/drawable/icon_location_small.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_more.png b/new3d/res/drawable/icon_more.png
deleted file mode 100644
index 44d5213..0000000
--- a/new3d/res/drawable/icon_more.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_picasa_small.png b/new3d/res/drawable/icon_picasa_small.png
deleted file mode 100644
index f35b386..0000000
--- a/new3d/res/drawable/icon_picasa_small.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_picasa_small_unscaled.png b/new3d/res/drawable/icon_picasa_small_unscaled.png
deleted file mode 100644
index 166b803..0000000
--- a/new3d/res/drawable/icon_picasa_small_unscaled.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_play.png b/new3d/res/drawable/icon_play.png
deleted file mode 100644
index 2ea9510..0000000
--- a/new3d/res/drawable/icon_play.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/icon_share.png b/new3d/res/drawable/icon_share.png
deleted file mode 100644
index f6b286a..0000000
--- a/new3d/res/drawable/icon_share.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/indicator_autocrop.png b/new3d/res/drawable/indicator_autocrop.png
deleted file mode 100644
index d960b1f..0000000
--- a/new3d/res/drawable/indicator_autocrop.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/mode_grid.png b/new3d/res/drawable/mode_grid.png
deleted file mode 100644
index be42f12..0000000
--- a/new3d/res/drawable/mode_grid.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/mode_stack.png b/new3d/res/drawable/mode_stack.png
deleted file mode 100644
index 362a89f..0000000
--- a/new3d/res/drawable/mode_stack.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/pathbar_bg.png b/new3d/res/drawable/pathbar_bg.png
deleted file mode 100644
index 357f1d7..0000000
--- a/new3d/res/drawable/pathbar_bg.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/pathbar_cap.png b/new3d/res/drawable/pathbar_cap.png
deleted file mode 100644
index a2d5c27..0000000
--- a/new3d/res/drawable/pathbar_cap.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/pathbar_join.png b/new3d/res/drawable/pathbar_join.png
deleted file mode 100644
index 97c4200..0000000
--- a/new3d/res/drawable/pathbar_join.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/photo_inner.9.png b/new3d/res/drawable/photo_inner.9.png
deleted file mode 100755
index f51eb35..0000000
--- a/new3d/res/drawable/photo_inner.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/popup.9.png b/new3d/res/drawable/popup.9.png
deleted file mode 100644
index b9380ba..0000000
--- a/new3d/res/drawable/popup.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/popup_option_selected.9.png b/new3d/res/drawable/popup_option_selected.9.png
deleted file mode 100644
index de41f40..0000000
--- a/new3d/res/drawable/popup_option_selected.9.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/popup_triangle_bottom.png b/new3d/res/drawable/popup_triangle_bottom.png
deleted file mode 100644
index bcf34c3..0000000
--- a/new3d/res/drawable/popup_triangle_bottom.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/scroller_new.png b/new3d/res/drawable/scroller_new.png
deleted file mode 100644
index 40f9e1a..0000000
--- a/new3d/res/drawable/scroller_new.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/scroller_pressed_new.png b/new3d/res/drawable/scroller_pressed_new.png
deleted file mode 100644
index 14cc0b2..0000000
--- a/new3d/res/drawable/scroller_pressed_new.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/selection_lower_bg.png b/new3d/res/drawable/selection_lower_bg.png
deleted file mode 100644
index 859d7eb..0000000
--- a/new3d/res/drawable/selection_lower_bg.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/selection_menu_bg.png b/new3d/res/drawable/selection_menu_bg.png
deleted file mode 100644
index 2dec3b6..0000000
--- a/new3d/res/drawable/selection_menu_bg.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/selection_menu_bg_pressed.png b/new3d/res/drawable/selection_menu_bg_pressed.png
deleted file mode 100644
index a84458a..0000000
--- a/new3d/res/drawable/selection_menu_bg_pressed.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/selection_menu_bg_pressed_left.png b/new3d/res/drawable/selection_menu_bg_pressed_left.png
deleted file mode 100644
index 7565c3d..0000000
--- a/new3d/res/drawable/selection_menu_bg_pressed_left.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/selection_menu_bg_pressed_right.png b/new3d/res/drawable/selection_menu_bg_pressed_right.png
deleted file mode 100644
index efe62f3..0000000
--- a/new3d/res/drawable/selection_menu_bg_pressed_right.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/selection_menu_divider.png b/new3d/res/drawable/selection_menu_divider.png
deleted file mode 100644
index b2658e2..0000000
--- a/new3d/res/drawable/selection_menu_divider.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/stack_frame.png b/new3d/res/drawable/stack_frame.png
deleted file mode 100644
index bde0540..0000000
--- a/new3d/res/drawable/stack_frame.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/stack_frame_focus.png b/new3d/res/drawable/stack_frame_focus.png
deleted file mode 100644
index 192527b..0000000
--- a/new3d/res/drawable/stack_frame_focus.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/stack_frame_gold.png b/new3d/res/drawable/stack_frame_gold.png
deleted file mode 100644
index ffbede6..0000000
--- a/new3d/res/drawable/stack_frame_gold.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/transparent.png b/new3d/res/drawable/transparent.png
deleted file mode 100644
index 95007b9..0000000
--- a/new3d/res/drawable/transparent.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/drawable/videooverlay.png b/new3d/res/drawable/videooverlay.png
deleted file mode 100644
index 8b39eed..0000000
--- a/new3d/res/drawable/videooverlay.png
+++ /dev/null
Binary files differ
diff --git a/new3d/res/layout/cropimage.xml b/new3d/res/layout/cropimage.xml
deleted file mode 100644
index 39effb0..0000000
--- a/new3d/res/layout/cropimage.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal">
- <view class="com.cooliris.media.CropImageView" android:id="@+id/image"
- android:background="#55000000"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_x="0dip"
- android:layout_y="0dip"
- />
- <RelativeLayout android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:paddingLeft="10dip"
- android:paddingRight="10dip"
- android:layout_alignParentBottom="true"
- android:layout_centerHorizontal="true">
- <Button
- android:id="@+id/save"
- android:layout_width="100dip"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:text="@string/crop_save_text"
- />
- <Button
- android:id="@+id/discard"
- android:layout_width="100dip"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:text="@string/crop_discard_text"
- />
- </RelativeLayout>
- </RelativeLayout>
-</FrameLayout>
diff --git a/new3d/res/layout/main.xml b/new3d/res/layout/main.xml
deleted file mode 100644
index d518833..0000000
--- a/new3d/res/layout/main.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <com.android.gallery3d.ui.GLRootView
- android:id="@+id/gl_root_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
-</LinearLayout>
diff --git a/new3d/res/layout/movie_view.xml b/new3d/res/layout/movie_view.xml
deleted file mode 100644
index a10228b..0000000
--- a/new3d/res/layout/movie_view.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/root"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <VideoView android:id="@+id/surface_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_centerInParent="true" />
-
- <LinearLayout android:id="@+id/progress_indicator"
- android:orientation="vertical"
- android:layout_centerInParent="true"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <ProgressBar android:id="@android:id/progress"
- style="?android:attr/progressBarStyleLarge"
- android:layout_gravity="center"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <TextView android:paddingTop="5dip"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="@string/loading_video" android:textSize="14sp"
- android:textColor="#ffffffff" />
- </LinearLayout>
-
-</RelativeLayout>
diff --git a/new3d/res/layout/photo_frame.xml b/new3d/res/layout/photo_frame.xml
deleted file mode 100755
index 9740354..0000000
--- a/new3d/res/layout/photo_frame.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/appwidget_bg">
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="3dip">
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="1px"
- android:foreground="@drawable/photo_inner">
-
- <ImageView
- android:id="@+id/photo"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop"
- android:cropToPadding="true" />
-
- </FrameLayout>
-
- </FrameLayout>
-
-</FrameLayout>
diff --git a/new3d/res/values-cs/strings.xml b/new3d/res/values-cs/strings.xml
deleted file mode 100644
index bd546b4..0000000
--- a/new3d/res/values-cs/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galerie"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"leden"</item>
- <item msgid="4680813504147866612">"únor"</item>
- <item msgid="1934595560893153574">"březen"</item>
- <item msgid="9020107212348500338">"duben"</item>
- <item msgid="5734859077892484949">"květen"</item>
- <item msgid="8546985030184126468">"červen"</item>
- <item msgid="3639654472839533748">"červenec"</item>
- <item msgid="8434242278630875235">"srpen"</item>
- <item msgid="8493511009771049442">"září"</item>
- <item msgid="685181459001441496">"říjen"</item>
- <item msgid="6662413035764778250">"listopad"</item>
- <item msgid="3784870986696899313">"prosinec"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Rámeček fotografie"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Filmy"</string>
- <string name="loading_video" msgid="4013492720121891585">"Načítání videa..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Pokračovat v přehrávání videa"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Pokračovat v přehrávání od %s?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Pokračovat v přehrávání"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Začít znovu"</string>
- <string name="camera" msgid="2730811566218090802">"Fotoaparát"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Uložit"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Zahodit"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Začněte klepnutím na obličej."</string>
- <string name="saving_image" msgid="7270334453636349407">"Ukládání fotografie..."</string>
- <string name="crop_label" msgid="521114301871349328">"Oříznout fotografii"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Čekejte prosím..."</string>
- <string name="set_image" msgid="2331476809308010401">"Fotografie bude použita jako"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Nastavování tapety, čekejte prosím..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Tapeta"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"Načítání nových alb a fotografií"</string>
- <string name="initializing" msgid="2374228157398540466">"Načítání"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Vyberte položku ze své sbírky"</string>
- <string name="no_items" msgid="3117870234034732172">"Váš výběr neobsahuje žádné položky"</string>
- <string name="pick" msgid="7248789132035843128">"Vybrat"</string>
- <string name="delete" msgid="2839695998251824487">"Smazat"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Potvrdit smazání"</string>
- <string name="cancel" msgid="3637516880917356226">"Zrušit"</string>
- <string name="share" msgid="3619042788254195341">"Sdílet"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"Karta SD byla odpojena, nebo není k dispozici"</string>
- <string name="more" msgid="1526449516720792387">"Další"</string>
- <string name="select_all" msgid="8623593677101437957">"Vybrat vše"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Zrušit výběr všech"</string>
- <string name="slideshow" msgid="4355906903247112975">"Prezentace"</string>
- <string name="menu" msgid="1819649153380636719">"Menu"</string>
- <string name="details" msgid="8415120088556445230">"Podrobnosti"</string>
- <string name="album_selected" msgid="3441280740465738452">"vybrané album"</string>
- <string name="item_selected" msgid="6137767503817908841">"vybraná položka"</string>
- <string name="albums_selected" msgid="1815225920157190983">"vybraná alba"</string>
- <string name="items_selected" msgid="8548754404879264861">"vybrané položky"</string>
- <string name="album" msgid="5198388817734336004">"Album"</string>
- <string name="start" msgid="4316892252528232165">"Spustit"</string>
- <string name="end" msgid="3645506196012005500">"Ukončit"</string>
- <string name="location" msgid="3432705876921618314">"Místo"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Neznámé místo"</string>
- <string name="title" msgid="7622928349908052569">"Název"</string>
- <string name="type" msgid="4329478642546287192">"Typ"</string>
- <string name="taken_on" msgid="3269486910757192479">"Pořízeno dne"</string>
- <string name="added_on" msgid="5194321063173381814">"Přidáno dne"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Zobrazit na mapě"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Otočit doleva"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Otočit doprava"</string>
- <string name="crop" msgid="7970750655414797277">"Oříznout"</string>
- <string name="set_as" msgid="3636764710790507868">"Nastavit jako"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Nastavit jako tapetu"</string>
- <string name="item" msgid="636303673288563698">"položka"</string>
- <string name="items" msgid="6403254716052150916">"položky"</string>
- <string name="around" msgid="2223906282110417412">"Poblíž místa"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Neznámé datum"</string>
- <string name="video_err" msgid="7917736494827857757">"Video nelze přehrát"</string>
-</resources>
diff --git a/new3d/res/values-da/strings.xml b/new3d/res/values-da/strings.xml
deleted file mode 100644
index 66963d8..0000000
--- a/new3d/res/values-da/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galleri"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"jan."</item>
- <item msgid="4680813504147866612">"feb."</item>
- <item msgid="1934595560893153574">"mar."</item>
- <item msgid="9020107212348500338">"apr."</item>
- <item msgid="5734859077892484949">"maj"</item>
- <item msgid="8546985030184126468">"jun."</item>
- <item msgid="3639654472839533748">"jul."</item>
- <item msgid="8434242278630875235">"aug."</item>
- <item msgid="8493511009771049442">"sep."</item>
- <item msgid="685181459001441496">"okt."</item>
- <item msgid="6662413035764778250">"nov."</item>
- <item msgid="3784870986696899313">"dec."</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Billedramme"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Film"</string>
- <string name="loading_video" msgid="4013492720121891585">"Indlæser video ..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Genoptag video"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Genoptag afspilning fra %s ?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Genoptag afspilning"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Start igen"</string>
- <string name="camera" msgid="2730811566218090802">"Kamera"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Gem"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Kassér"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Tryk på et ansigt for at begynde."</string>
- <string name="saving_image" msgid="7270334453636349407">"Gemmer billede ..."</string>
- <string name="crop_label" msgid="521114301871349328">"Beskær billede"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Vent ..."</string>
- <string name="set_image" msgid="2331476809308010401">"Angiv billedet som"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Angiver tapet. Vent et øjeblik ..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Tapet"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"Indlæser nye albummer og fotos"</string>
- <string name="initializing" msgid="2374228157398540466">"Indlæser"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Vælg et element fra din samling"</string>
- <string name="no_items" msgid="3117870234034732172">"Der er ingen elementer i din samling"</string>
- <string name="pick" msgid="7248789132035843128">"Vælg"</string>
- <string name="delete" msgid="2839695998251824487">"Slet"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Bekræft sletning"</string>
- <string name="cancel" msgid="3637516880917356226">"Annuller"</string>
- <string name="share" msgid="3619042788254195341">"Del"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"SD-kort ikke monteret, eller kortet findes ikke"</string>
- <string name="more" msgid="1526449516720792387">"Flere"</string>
- <string name="select_all" msgid="8623593677101437957">"Vælg alle"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Fravælg alle"</string>
- <string name="slideshow" msgid="4355906903247112975">"Diasshow"</string>
- <string name="menu" msgid="1819649153380636719">"Menu"</string>
- <string name="details" msgid="8415120088556445230">"Detaljer"</string>
- <string name="album_selected" msgid="3441280740465738452">"valgt album"</string>
- <string name="item_selected" msgid="6137767503817908841">"valgt element"</string>
- <string name="albums_selected" msgid="1815225920157190983">"valgte albummer"</string>
- <string name="items_selected" msgid="8548754404879264861">"valgte elementer"</string>
- <string name="album" msgid="5198388817734336004">"Album"</string>
- <string name="start" msgid="4316892252528232165">"Start"</string>
- <string name="end" msgid="3645506196012005500">"Afslut"</string>
- <string name="location" msgid="3432705876921618314">"Placering"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Ukendt placering"</string>
- <string name="title" msgid="7622928349908052569">"Titel"</string>
- <string name="type" msgid="4329478642546287192">"Type"</string>
- <string name="taken_on" msgid="3269486910757192479">"Optaget den"</string>
- <string name="added_on" msgid="5194321063173381814">"Tilføjet den"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Vis på kort"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Roter til venstre"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Roter til højre"</string>
- <string name="crop" msgid="7970750655414797277">"Beskær"</string>
- <string name="set_as" msgid="3636764710790507868">"Indstil som"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Anvend som baggrund"</string>
- <string name="item" msgid="636303673288563698">"element"</string>
- <string name="items" msgid="6403254716052150916">"elementer"</string>
- <string name="around" msgid="2223906282110417412">"Ca."</string>
- <string name="date_unknown" msgid="4277113471036917386">"Dato ukendt"</string>
- <string name="video_err" msgid="7917736494827857757">"Kan ikke afspille video"</string>
-</resources>
diff --git a/new3d/res/values-de/strings.xml b/new3d/res/values-de/strings.xml
deleted file mode 100644
index 1634882..0000000
--- a/new3d/res/values-de/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galerie"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"Jan."</item>
- <item msgid="4680813504147866612">"Feb."</item>
- <item msgid="1934595560893153574">"März"</item>
- <item msgid="9020107212348500338">"Apr."</item>
- <item msgid="5734859077892484949">"Mai"</item>
- <item msgid="8546985030184126468">"Juni"</item>
- <item msgid="3639654472839533748">"Juli"</item>
- <item msgid="8434242278630875235">"Aug."</item>
- <item msgid="8493511009771049442">"Sep."</item>
- <item msgid="685181459001441496">"Okt."</item>
- <item msgid="6662413035764778250">"Nov."</item>
- <item msgid="3784870986696899313">"Dez."</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Bildrahmen"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Filme"</string>
- <string name="loading_video" msgid="4013492720121891585">"Video wird geladen..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Mit Video fortfahren"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Mit Wiedergabe fortfahren ab %s ?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Mit Wiedergabe fortfahren"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Starten"</string>
- <string name="camera" msgid="2730811566218090802">"Kamera"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Speichern"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Verwerfen"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Tippen Sie zum Beginnen auf ein Gesicht."</string>
- <string name="saving_image" msgid="7270334453636349407">"Bild wird gespeichert..."</string>
- <string name="crop_label" msgid="521114301871349328">"Bild zuschneiden"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Bitte warten..."</string>
- <string name="set_image" msgid="2331476809308010401">"Bild festlegen als"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Hintergrund wird eingestellt, bitte warten..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Hintergrund"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"Neue Alben und Fotos werden geladen"</string>
- <string name="initializing" msgid="2374228157398540466">"Wird geladen"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Ein Element aus Ihrer Sammlung auswählen"</string>
- <string name="no_items" msgid="3117870234034732172">"Ihre Galerie ist leer."</string>
- <string name="pick" msgid="7248789132035843128">"Auswählen"</string>
- <string name="delete" msgid="2839695998251824487">"Löschen"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Löschen bestätigen"</string>
- <string name="cancel" msgid="3637516880917356226">"Abbrechen"</string>
- <string name="share" msgid="3619042788254195341">"Weitergeben"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"SD-Karte wurde entfernt oder ist nicht vorhanden."</string>
- <string name="more" msgid="1526449516720792387">"Mehr"</string>
- <string name="select_all" msgid="8623593677101437957">"Alles auswählen"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Auswahl für alle aufheben"</string>
- <string name="slideshow" msgid="4355906903247112975">"Diashow"</string>
- <string name="menu" msgid="1819649153380636719">"Menü"</string>
- <string name="details" msgid="8415120088556445230">"Details"</string>
- <string name="album_selected" msgid="3441280740465738452">"Album ausgewählt"</string>
- <string name="item_selected" msgid="6137767503817908841">"Element ausgewählt"</string>
- <string name="albums_selected" msgid="1815225920157190983">"Alben ausgewählt"</string>
- <string name="items_selected" msgid="8548754404879264861">"Elemente ausgewählt"</string>
- <string name="album" msgid="5198388817734336004">"Album"</string>
- <string name="start" msgid="4316892252528232165">"Starten"</string>
- <string name="end" msgid="3645506196012005500">"Ende"</string>
- <string name="location" msgid="3432705876921618314">"Ort"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Unbekannter Standort"</string>
- <string name="title" msgid="7622928349908052569">"Titel"</string>
- <string name="type" msgid="4329478642546287192">"Typ"</string>
- <string name="taken_on" msgid="3269486910757192479">"Aufgenommen am"</string>
- <string name="added_on" msgid="5194321063173381814">"Hinzugefügt am"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Auf Karte anzeigen"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Nach links drehen"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Nach rechts drehen"</string>
- <string name="crop" msgid="7970750655414797277">"Zuschneiden"</string>
- <string name="set_as" msgid="3636764710790507868">"Festlegen als"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Als Hintergrund festlegen"</string>
- <string name="item" msgid="636303673288563698">"Element"</string>
- <string name="items" msgid="6403254716052150916">"Elemente"</string>
- <string name="around" msgid="2223906282110417412">"Ungefähr an folgender Adresse:"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Datum unbekannt"</string>
- <string name="video_err" msgid="7917736494827857757">"Video kann nicht wiedergegeben werden."</string>
-</resources>
diff --git a/new3d/res/values-el/strings.xml b/new3d/res/values-el/strings.xml
deleted file mode 100644
index 6ccb016..0000000
--- a/new3d/res/values-el/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Συλλογή"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"Ιαν"</item>
- <item msgid="4680813504147866612">"Φεβ"</item>
- <item msgid="1934595560893153574">"Μαρ"</item>
- <item msgid="9020107212348500338">"Απρ"</item>
- <item msgid="5734859077892484949">"Μάι"</item>
- <item msgid="8546985030184126468">"Ιουν"</item>
- <item msgid="3639654472839533748">"Ιουλ"</item>
- <item msgid="8434242278630875235">"Αυγ"</item>
- <item msgid="8493511009771049442">"Σεπ"</item>
- <item msgid="685181459001441496">"Οκτ"</item>
- <item msgid="6662413035764778250">"Νοε"</item>
- <item msgid="3784870986696899313">"Δεκ"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Πλαίσιο εικόνας"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Ταινίες"</string>
- <string name="loading_video" msgid="4013492720121891585">"Φόρτωση βίντεο..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Συνέχιση βίντεο"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Συνέχιση αναπαραγωγής από το %s;"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Συνέχιση αναπαραγωγής"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Έναρξη από την αρχή"</string>
- <string name="camera" msgid="2730811566218090802">"Φωτογραφική μηχανή"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Αποθήκευση"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Απόρριψη"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Πατήστε σε ένα πρόσωπο για να ξεκινήσετε."</string>
- <string name="saving_image" msgid="7270334453636349407">"Αποθήκευση εικόνας..."</string>
- <string name="crop_label" msgid="521114301871349328">"Περικοπή εικόνας"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Περιμένετε..."</string>
- <string name="set_image" msgid="2331476809308010401">"Ορισμός εικόνας ως"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Ρύθμιση ταπετσαρίας, περιμένετε..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Ταπετσαρία"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"Φόρτωση νέων λευκωμάτων και φωτογραφιών"</string>
- <string name="initializing" msgid="2374228157398540466">"Φόρτωση"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Επιλέξτε ένα αντικείμενο από τη συλλογή σας"</string>
- <string name="no_items" msgid="3117870234034732172">"Δεν υπάρχουν στοιχεία στη συλλογή σας"</string>
- <string name="pick" msgid="7248789132035843128">"Επιλογή"</string>
- <string name="delete" msgid="2839695998251824487">"Διαγραφή"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Επιβεβαίωση διαγραφής"</string>
- <string name="cancel" msgid="3637516880917356226">"Ακύρωση"</string>
- <string name="share" msgid="3619042788254195341">"Κοινή χρήση"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"Λείπει ή δεν έχει εισαχθεί η κάρτα SD"</string>
- <string name="more" msgid="1526449516720792387">"Περισσότερα"</string>
- <string name="select_all" msgid="8623593677101437957">"Επιλογή όλων"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Κατάργηση επιλογής όλων"</string>
- <string name="slideshow" msgid="4355906903247112975">"Προβολή διαφανειών"</string>
- <string name="menu" msgid="1819649153380636719">"Μενού"</string>
- <string name="details" msgid="8415120088556445230">"Λεπτομέρειες"</string>
- <string name="album_selected" msgid="3441280740465738452">"λεύκωμα επιλέχθηκε"</string>
- <string name="item_selected" msgid="6137767503817908841">"αντικείμενο επιλέχθηκε"</string>
- <string name="albums_selected" msgid="1815225920157190983">"λευκώματα επιλέχθηκαν"</string>
- <string name="items_selected" msgid="8548754404879264861">"αντικείμενα επιλέχθηκαν"</string>
- <string name="album" msgid="5198388817734336004">"Λεύκωμα"</string>
- <string name="start" msgid="4316892252528232165">"Εκκίνηση"</string>
- <string name="end" msgid="3645506196012005500">"Τέλος"</string>
- <string name="location" msgid="3432705876921618314">"Τοποθεσία"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Άγνωστη τοποθεσία"</string>
- <string name="title" msgid="7622928349908052569">"Τίτλος"</string>
- <string name="type" msgid="4329478642546287192">"Τύπος"</string>
- <string name="taken_on" msgid="3269486910757192479">"Ελήφθη την"</string>
- <string name="added_on" msgid="5194321063173381814">"Προστέθηκε στις"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Εμφάνιση στον χάρτη"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Αριστερή περιστροφή"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Δεξιά περιστροφή"</string>
- <string name="crop" msgid="7970750655414797277">"Περικοπή"</string>
- <string name="set_as" msgid="3636764710790507868">"Ορισμός ως"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Ορισμός ως ταπετσαρία"</string>
- <string name="item" msgid="636303673288563698">"αντικείμενο"</string>
- <string name="items" msgid="6403254716052150916">"αντικείμενα"</string>
- <string name="around" msgid="2223906282110417412">"Κάπου στην/στο"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Άγνωστη ημερομηνία"</string>
- <string name="video_err" msgid="7917736494827857757">"Δεν είναι δυνατή η αναπαραγωγή του βίντεο"</string>
-</resources>
diff --git a/new3d/res/values-es-rUS/strings.xml b/new3d/res/values-es-rUS/strings.xml
deleted file mode 100644
index 447ca57..0000000
--- a/new3d/res/values-es-rUS/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galería"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"Ene."</item>
- <item msgid="4680813504147866612">"Feb."</item>
- <item msgid="1934595560893153574">"Mar."</item>
- <item msgid="9020107212348500338">"Abr."</item>
- <item msgid="5734859077892484949">"Mayo"</item>
- <item msgid="8546985030184126468">"Jun."</item>
- <item msgid="3639654472839533748">"Jul."</item>
- <item msgid="8434242278630875235">"Ago."</item>
- <item msgid="8493511009771049442">"Sep."</item>
- <item msgid="685181459001441496">"Oct."</item>
- <item msgid="6662413035764778250">"Nov."</item>
- <item msgid="3784870986696899313">"Dic."</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Marco de imagen"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Películas"</string>
- <string name="loading_video" msgid="4013492720121891585">"Cargando el video..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Retomar video"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"¿Deseas retomar la reproducción desde %s?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Retomar la reproducción"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Empezar de nuevo"</string>
- <string name="camera" msgid="2730811566218090802">"Cámara"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Guardar"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Eliminar"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Golpea una cara para comenzar."</string>
- <string name="saving_image" msgid="7270334453636349407">"Guardando imagen..."</string>
- <string name="crop_label" msgid="521114301871349328">"Cortar la imagen"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Por favor, espera..."</string>
- <string name="set_image" msgid="2331476809308010401">"Definir imagen como"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Configurando papel tapiz. Espera, por favor..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Papel tapiz"</string>
- <string name="details_ok" msgid="6848594369924424312">"Aceptar"</string>
- <string name="loading_new" msgid="7893793767294787579">"Cargando nuevos álbumes y fotos"</string>
- <string name="initializing" msgid="2374228157398540466">"Cargando"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Seleccionar un elemento de tu colección"</string>
- <string name="no_items" msgid="3117870234034732172">"No hay artículos en tu colección."</string>
- <string name="pick" msgid="7248789132035843128">"Seleccionar"</string>
- <string name="delete" msgid="2839695998251824487">"Eliminar"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Confirmar supresión"</string>
- <string name="cancel" msgid="3637516880917356226">"Cancelar"</string>
- <string name="share" msgid="3619042788254195341">"Compartir"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"No se encuentra la tarjeta SD o está desactivada"</string>
- <string name="more" msgid="1526449516720792387">"Más"</string>
- <string name="select_all" msgid="8623593677101437957">"Seleccionar todo"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Desmarcar todos"</string>
- <string name="slideshow" msgid="4355906903247112975">"Presentación de diapositivas"</string>
- <string name="menu" msgid="1819649153380636719">"Menú"</string>
- <string name="details" msgid="8415120088556445230">"Detalles"</string>
- <string name="album_selected" msgid="3441280740465738452">"álbum seleccionado"</string>
- <string name="item_selected" msgid="6137767503817908841">"elemento seleccionado"</string>
- <string name="albums_selected" msgid="1815225920157190983">"álbumes seleccionados"</string>
- <string name="items_selected" msgid="8548754404879264861">"elementos seleccionados"</string>
- <string name="album" msgid="5198388817734336004">"Álbum"</string>
- <string name="start" msgid="4316892252528232165">"Inicio"</string>
- <string name="end" msgid="3645506196012005500">"Finalizar"</string>
- <string name="location" msgid="3432705876921618314">"Ubicación"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Ubicación desconocida"</string>
- <string name="title" msgid="7622928349908052569">"Título"</string>
- <string name="type" msgid="4329478642546287192">"Tipo"</string>
- <string name="taken_on" msgid="3269486910757192479">"Aceptar"</string>
- <string name="added_on" msgid="5194321063173381814">"Agregado el día"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Mostrar mapa"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Rotar hacia la izquierda"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Rotar hacia la derecha"</string>
- <string name="crop" msgid="7970750655414797277">"Cortar"</string>
- <string name="set_as" msgid="3636764710790507868">"Definir como"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Establecer como fondo de pantalla"</string>
- <string name="item" msgid="636303673288563698">"elemento"</string>
- <string name="items" msgid="6403254716052150916">"elementos"</string>
- <string name="around" msgid="2223906282110417412">"Alrededor"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Fecha desconocida"</string>
- <string name="video_err" msgid="7917736494827857757">"No se puede reproducir el video."</string>
-</resources>
diff --git a/new3d/res/values-es/strings.xml b/new3d/res/values-es/strings.xml
deleted file mode 100644
index b98f295..0000000
--- a/new3d/res/values-es/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galería"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"Ene."</item>
- <item msgid="4680813504147866612">"Feb."</item>
- <item msgid="1934595560893153574">"Mar."</item>
- <item msgid="9020107212348500338">"Abr."</item>
- <item msgid="5734859077892484949">"May."</item>
- <item msgid="8546985030184126468">"Jun."</item>
- <item msgid="3639654472839533748">"Jul."</item>
- <item msgid="8434242278630875235">"Ago."</item>
- <item msgid="8493511009771049442">"Set."</item>
- <item msgid="685181459001441496">"Oct."</item>
- <item msgid="6662413035764778250">"Nov."</item>
- <item msgid="3784870986696899313">"Dic."</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Picture frame"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Películas"</string>
- <string name="loading_video" msgid="4013492720121891585">"Cargando vídeo…"</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Reanudar vídeo"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Reanudar reproducción a partir de %s ?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Reanudar reproducción"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Volver a reproducir"</string>
- <string name="camera" msgid="2730811566218090802">"Cámara"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Guardar"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Descartar"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Toca una cara para empezar."</string>
- <string name="saving_image" msgid="7270334453636349407">"Guardando imagen..."</string>
- <string name="crop_label" msgid="521114301871349328">"Recortar imagen"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Por favor, espera..."</string>
- <string name="set_image" msgid="2331476809308010401">"Establecer imagen como"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Estableciendo fondo de pantalla..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Fondo de pantalla"</string>
- <string name="details_ok" msgid="6848594369924424312">"Aceptar"</string>
- <string name="loading_new" msgid="7893793767294787579">"Cargando nuevos álbumes y fotos"</string>
- <string name="initializing" msgid="2374228157398540466">"Cargando"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Selecciona un elemento de tu colección."</string>
- <string name="no_items" msgid="3117870234034732172">"No hay ningún elemento en tu colección."</string>
- <string name="pick" msgid="7248789132035843128">"Seleccionar"</string>
- <string name="delete" msgid="2839695998251824487">"Borrar"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Confirmar eliminación"</string>
- <string name="cancel" msgid="3637516880917356226">"Cancelar"</string>
- <string name="share" msgid="3619042788254195341">"Compartir"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"Tarjeta SD desinstalada o no incluida"</string>
- <string name="more" msgid="1526449516720792387">"Más"</string>
- <string name="select_all" msgid="8623593677101437957">"Seleccionar todo"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Desmarcar todo"</string>
- <string name="slideshow" msgid="4355906903247112975">"Presentación"</string>
- <string name="menu" msgid="1819649153380636719">"Menú"</string>
- <string name="details" msgid="8415120088556445230">"Detalles"</string>
- <string name="album_selected" msgid="3441280740465738452">"álbum seleccionado"</string>
- <string name="item_selected" msgid="6137767503817908841">"elemento seleccionado"</string>
- <string name="albums_selected" msgid="1815225920157190983">"álbumes seleccionados"</string>
- <string name="items_selected" msgid="8548754404879264861">"elementos seleccionados"</string>
- <string name="album" msgid="5198388817734336004">"Álbum"</string>
- <string name="start" msgid="4316892252528232165">"Iniciar"</string>
- <string name="end" msgid="3645506196012005500">"Finalizar"</string>
- <string name="location" msgid="3432705876921618314">"Ubicación"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Ubicación desconocida"</string>
- <string name="title" msgid="7622928349908052569">"Título"</string>
- <string name="type" msgid="4329478642546287192">"Tipo"</string>
- <string name="taken_on" msgid="3269486910757192479">"Realizado/a el"</string>
- <string name="added_on" msgid="5194321063173381814">"Añadida el"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Mostrar en el mapa"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Girar a la izquierda"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Girar a la derecha"</string>
- <string name="crop" msgid="7970750655414797277">"Recortar"</string>
- <string name="set_as" msgid="3636764710790507868">"Establecer como"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Establecer como fondo de pantalla"</string>
- <string name="item" msgid="636303673288563698">"elemento"</string>
- <string name="items" msgid="6403254716052150916">"elementos"</string>
- <string name="around" msgid="2223906282110417412">"Alrededor de"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Fecha desconocida"</string>
- <string name="video_err" msgid="7917736494827857757">"No se puede reproducir ningún vídeo."</string>
-</resources>
diff --git a/new3d/res/values-fr/strings.xml b/new3d/res/values-fr/strings.xml
deleted file mode 100644
index ce849da..0000000
--- a/new3d/res/values-fr/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galerie"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"Janv."</item>
- <item msgid="4680813504147866612">"Févr."</item>
- <item msgid="1934595560893153574">"Mars"</item>
- <item msgid="9020107212348500338">"Avr."</item>
- <item msgid="5734859077892484949">"Mai"</item>
- <item msgid="8546985030184126468">"Juin"</item>
- <item msgid="3639654472839533748">"Juil."</item>
- <item msgid="8434242278630875235">"Août"</item>
- <item msgid="8493511009771049442">"Sept."</item>
- <item msgid="685181459001441496">"Oct."</item>
- <item msgid="6662413035764778250">"Nov."</item>
- <item msgid="3784870986696899313">"Déc."</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Cadre d\'image"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Films"</string>
- <string name="loading_video" msgid="4013492720121891585">"Chargement de la vidéo..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Reprendre la vidéo"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Reprendre la lecture à partir de %s ?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Reprendre la lecture"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Démarrer"</string>
- <string name="camera" msgid="2730811566218090802">"Appareil photo"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Enregistrer"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Annuler"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Appuyez sur un visage pour commencer."</string>
- <string name="saving_image" msgid="7270334453636349407">"Enregistrement de l\'image"</string>
- <string name="crop_label" msgid="521114301871349328">"Rogner l\'image"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Veuillez patienter..."</string>
- <string name="set_image" msgid="2331476809308010401">"Utiliser l\'image comme"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Configuration du fond d\'écran en cours. Veuillez patienter..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Fond d\'écran"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"Chargement des nouveaux éléments (albums et photos)"</string>
- <string name="initializing" msgid="2374228157398540466">"Chargement"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Choisissez un élément dans votre collection."</string>
- <string name="no_items" msgid="3117870234034732172">"Aucun élément dans votre collection."</string>
- <string name="pick" msgid="7248789132035843128">"Choisir"</string>
- <string name="delete" msgid="2839695998251824487">"Supprimer"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Confirmer la suppression"</string>
- <string name="cancel" msgid="3637516880917356226">"Annuler"</string>
- <string name="share" msgid="3619042788254195341">"Partager"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"Carte SD désactivée ou non connectée"</string>
- <string name="more" msgid="1526449516720792387">"Plus"</string>
- <string name="select_all" msgid="8623593677101437957">"Tout sélectionner"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Tout désélectionner"</string>
- <string name="slideshow" msgid="4355906903247112975">"Diaporama"</string>
- <string name="menu" msgid="1819649153380636719">"Menu"</string>
- <string name="details" msgid="8415120088556445230">"Détails"</string>
- <string name="album_selected" msgid="3441280740465738452">"album sélectionné"</string>
- <string name="item_selected" msgid="6137767503817908841">"élément sélectionné"</string>
- <string name="albums_selected" msgid="1815225920157190983">"albums sélectionnés"</string>
- <string name="items_selected" msgid="8548754404879264861">"éléments sélectionnés"</string>
- <string name="album" msgid="5198388817734336004">"Album"</string>
- <string name="start" msgid="4316892252528232165">"Démarrer"</string>
- <string name="end" msgid="3645506196012005500">"Fin"</string>
- <string name="location" msgid="3432705876921618314">"Lieu"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Lieu inconnu"</string>
- <string name="title" msgid="7622928349908052569">"Titre"</string>
- <string name="type" msgid="4329478642546287192">"Type"</string>
- <string name="taken_on" msgid="3269486910757192479">"Prise"</string>
- <string name="added_on" msgid="5194321063173381814">"Ajoutée le"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Afficher sur la carte"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Rotation à gauche"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Rotation à droite"</string>
- <string name="crop" msgid="7970750655414797277">"Rogner"</string>
- <string name="set_as" msgid="3636764710790507868">"Définir comme"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Définir comme fond d\'écran"</string>
- <string name="item" msgid="636303673288563698">"élément"</string>
- <string name="items" msgid="6403254716052150916">"éléments"</string>
- <string name="around" msgid="2223906282110417412">"À proximité de"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Date inconnue"</string>
- <string name="video_err" msgid="7917736494827857757">"Impossible de lire la vidéo."</string>
-</resources>
diff --git a/new3d/res/values-it/strings.xml b/new3d/res/values-it/strings.xml
deleted file mode 100644
index e31dbc3..0000000
--- a/new3d/res/values-it/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galleria"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"Gen"</item>
- <item msgid="4680813504147866612">"Feb"</item>
- <item msgid="1934595560893153574">"Mar"</item>
- <item msgid="9020107212348500338">"Apr"</item>
- <item msgid="5734859077892484949">"Mag"</item>
- <item msgid="8546985030184126468">"Giu"</item>
- <item msgid="3639654472839533748">"Lug"</item>
- <item msgid="8434242278630875235">"Ago"</item>
- <item msgid="8493511009771049442">"Set"</item>
- <item msgid="685181459001441496">"Ott"</item>
- <item msgid="6662413035764778250">"Nov"</item>
- <item msgid="3784870986696899313">"Dic"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Cornice immagine"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Film"</string>
- <string name="loading_video" msgid="4013492720121891585">"Caricamento video..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Riprendi video"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Riprendi riproduzione da %s ?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Riprendi riproduzione"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Ricomincia"</string>
- <string name="camera" msgid="2730811566218090802">"Fotocamera"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Salva"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Annulla"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Tocca un viso per iniziare."</string>
- <string name="saving_image" msgid="7270334453636349407">"Salvataggio foto in corso..."</string>
- <string name="crop_label" msgid="521114301871349328">"Ritaglia foto"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Attendi..."</string>
- <string name="set_image" msgid="2331476809308010401">"Imposta foto come"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Impostazione sfondo, attendi..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Sfondo"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"Caricamento di nuovi album e foto in corso"</string>
- <string name="initializing" msgid="2374228157398540466">"Caricamento in corso"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Scegli un elemento dalla raccolta"</string>
- <string name="no_items" msgid="3117870234034732172">"Non sono presenti elementi nella tua raccolta"</string>
- <string name="pick" msgid="7248789132035843128">"Scegli"</string>
- <string name="delete" msgid="2839695998251824487">"Elimina"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Conferma eliminazione"</string>
- <string name="cancel" msgid="3637516880917356226">"Annulla"</string>
- <string name="share" msgid="3619042788254195341">"Condividi"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"Scheda SD non montata o non presente"</string>
- <string name="more" msgid="1526449516720792387">"Altro"</string>
- <string name="select_all" msgid="8623593677101437957">"Seleziona tutto"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Deseleziona tutto"</string>
- <string name="slideshow" msgid="4355906903247112975">"Presentazione"</string>
- <string name="menu" msgid="1819649153380636719">"Menu"</string>
- <string name="details" msgid="8415120088556445230">"Dettagli"</string>
- <string name="album_selected" msgid="3441280740465738452">"album selezionato"</string>
- <string name="item_selected" msgid="6137767503817908841">"elemento selezionato"</string>
- <string name="albums_selected" msgid="1815225920157190983">"album selezionati"</string>
- <string name="items_selected" msgid="8548754404879264861">"elementi selezionati"</string>
- <string name="album" msgid="5198388817734336004">"Album"</string>
- <string name="start" msgid="4316892252528232165">"Inizia"</string>
- <string name="end" msgid="3645506196012005500">"Fine"</string>
- <string name="location" msgid="3432705876921618314">"Luogo"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Luogo sconosciuto"</string>
- <string name="title" msgid="7622928349908052569">"Titolo"</string>
- <string name="type" msgid="4329478642546287192">"Tipo"</string>
- <string name="taken_on" msgid="3269486910757192479">"Foto scattata/Video girato in data"</string>
- <string name="added_on" msgid="5194321063173381814">"Data di aggiunta:"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Mostra sulla mappa"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Ruota a sinistra"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Ruota a destra"</string>
- <string name="crop" msgid="7970750655414797277">"Ritaglia"</string>
- <string name="set_as" msgid="3636764710790507868">"Imposta come"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Imposta come sfondo"</string>
- <string name="item" msgid="636303673288563698">"elemento"</string>
- <string name="items" msgid="6403254716052150916">"elementi"</string>
- <string name="around" msgid="2223906282110417412">"Nei pressi di"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Data sconosciuta"</string>
- <string name="video_err" msgid="7917736494827857757">"Impossibile riprodurre il video"</string>
-</resources>
diff --git a/new3d/res/values-ja/strings.xml b/new3d/res/values-ja/strings.xml
deleted file mode 100644
index ad7fa95..0000000
--- a/new3d/res/values-ja/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"ギャラリー"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"1月"</item>
- <item msgid="4680813504147866612">"2月"</item>
- <item msgid="1934595560893153574">"3月"</item>
- <item msgid="9020107212348500338">"4月"</item>
- <item msgid="5734859077892484949">"5月"</item>
- <item msgid="8546985030184126468">"6月"</item>
- <item msgid="3639654472839533748">"7月"</item>
- <item msgid="8434242278630875235">"8月"</item>
- <item msgid="8493511009771049442">"9月"</item>
- <item msgid="685181459001441496">"10月"</item>
- <item msgid="6662413035764778250">"11月"</item>
- <item msgid="3784870986696899313">"12月"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"写真フレーム"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"動画"</string>
- <string name="loading_video" msgid="4013492720121891585">"動画を読み込み中..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"動画の再開"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"再生を%sから再開しますか?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"再生を再開"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"最初から再生"</string>
- <string name="camera" msgid="2730811566218090802">"カメラ"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"保存"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"キャンセル"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"顔をタップして開始します。"</string>
- <string name="saving_image" msgid="7270334453636349407">"写真を保存中…"</string>
- <string name="crop_label" msgid="521114301871349328">"トリミング"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"お待ちください..."</string>
- <string name="set_image" msgid="2331476809308010401">"写真を設定:"</string>
- <string name="wallpaper" msgid="9222901738515471972">"壁紙を設定しています。しばらくお待ちください..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"壁紙"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"新しいアルバムと写真を読み込み中"</string>
- <string name="initializing" msgid="2374228157398540466">"読み込み中"</string>
- <string name="pick_prompt" msgid="576608096149718121">"コレクションからアイテムを選択してください"</string>
- <string name="no_items" msgid="3117870234034732172">"コレクションにアイテムがありません"</string>
- <string name="pick" msgid="7248789132035843128">"選択"</string>
- <string name="delete" msgid="2839695998251824487">"削除"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"削除の確認"</string>
- <string name="cancel" msgid="3637516880917356226">"キャンセル"</string>
- <string name="share" msgid="3619042788254195341">"共有"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"SDカードがマウントされていないか挿入されていません"</string>
- <string name="more" msgid="1526449516720792387">"その他"</string>
- <string name="select_all" msgid="8623593677101437957">"すべて選択"</string>
- <string name="deselect_all" msgid="7397531298370285581">"選択をすべて解除"</string>
- <string name="slideshow" msgid="4355906903247112975">"スライドショー"</string>
- <string name="menu" msgid="1819649153380636719">"メニュー"</string>
- <string name="details" msgid="8415120088556445230">"詳細情報"</string>
- <string name="album_selected" msgid="3441280740465738452">"冊のアルバムを選択済み"</string>
- <string name="item_selected" msgid="6137767503817908841">"件のアイテムを選択済み"</string>
- <string name="albums_selected" msgid="1815225920157190983">"冊のアルバムを選択済み"</string>
- <string name="items_selected" msgid="8548754404879264861">"件のアイテムを選択済み"</string>
- <string name="album" msgid="5198388817734336004">"アルバム"</string>
- <string name="start" msgid="4316892252528232165">"開始"</string>
- <string name="end" msgid="3645506196012005500">"終了"</string>
- <string name="location" msgid="3432705876921618314">"場所"</string>
- <string name="location_unknown" msgid="6310139243003315255">"不明な場所"</string>
- <string name="title" msgid="7622928349908052569">"タイトル"</string>
- <string name="type" msgid="4329478642546287192">"種類"</string>
- <string name="taken_on" msgid="3269486910757192479">"撮影"</string>
- <string name="added_on" msgid="5194321063173381814">"追加日:"</string>
- <string name="show_on_map" msgid="6157544221201750980">"地図に表示"</string>
- <string name="rotate_left" msgid="7412075232752726934">"左に回転"</string>
- <string name="rotate_right" msgid="7340681085011826618">"右に回転"</string>
- <string name="crop" msgid="7970750655414797277">"トリミング"</string>
- <string name="set_as" msgid="3636764710790507868">"登録"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"壁紙として設定"</string>
- <string name="item" msgid="636303673288563698">"アイテム"</string>
- <string name="items" msgid="6403254716052150916">"アイテム"</string>
- <string name="around" msgid="2223906282110417412">"エリア:"</string>
- <string name="date_unknown" msgid="4277113471036917386">"日付が不明"</string>
- <string name="video_err" msgid="7917736494827857757">"動画を再生できません"</string>
-</resources>
diff --git a/new3d/res/values-ko/strings.xml b/new3d/res/values-ko/strings.xml
deleted file mode 100644
index 2fbde56..0000000
--- a/new3d/res/values-ko/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"갤러리"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"1월"</item>
- <item msgid="4680813504147866612">"2월"</item>
- <item msgid="1934595560893153574">"3월"</item>
- <item msgid="9020107212348500338">"4월"</item>
- <item msgid="5734859077892484949">"5월"</item>
- <item msgid="8546985030184126468">"6월"</item>
- <item msgid="3639654472839533748">"7월"</item>
- <item msgid="8434242278630875235">"8월"</item>
- <item msgid="8493511009771049442">"9월"</item>
- <item msgid="685181459001441496">"10월"</item>
- <item msgid="6662413035764778250">"11월"</item>
- <item msgid="3784870986696899313">"12월"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"사진 액자"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"영화"</string>
- <string name="loading_video" msgid="4013492720121891585">"동영상 로드 중..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"동영상 다시 시작"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"%s에서 재생을 다시 시작하시겠습니까?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"재생 다시 시작"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"시작"</string>
- <string name="camera" msgid="2730811566218090802">"카메라"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"저장"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"취소"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"시작하려면 얼굴을 탭하세요."</string>
- <string name="saving_image" msgid="7270334453636349407">"사진 저장 중..."</string>
- <string name="crop_label" msgid="521114301871349328">"사진 자르기"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"잠시 기다려 주세요..."</string>
- <string name="set_image" msgid="2331476809308010401">"사진을 다음으로 설정"</string>
- <string name="wallpaper" msgid="9222901738515471972">"배경화면을 설정하는 중입니다. 잠시 기다려 주세요..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"배경화면"</string>
- <string name="details_ok" msgid="6848594369924424312">"확인"</string>
- <string name="loading_new" msgid="7893793767294787579">"새 앨범 및 사진 로드 중"</string>
- <string name="initializing" msgid="2374228157398540466">"로드 중"</string>
- <string name="pick_prompt" msgid="576608096149718121">"컬렉션에서 항목 선택"</string>
- <string name="no_items" msgid="3117870234034732172">"컬렉션에 항목이 없습니다."</string>
- <string name="pick" msgid="7248789132035843128">"선택"</string>
- <string name="delete" msgid="2839695998251824487">"삭제"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"삭제 확인"</string>
- <string name="cancel" msgid="3637516880917356226">"취소"</string>
- <string name="share" msgid="3619042788254195341">"공유"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"SD 카드가 마운트 해제되지 않았거나 없습니다."</string>
- <string name="more" msgid="1526449516720792387">"추가 작업"</string>
- <string name="select_all" msgid="8623593677101437957">"모두 선택"</string>
- <string name="deselect_all" msgid="7397531298370285581">"모두 선택취소"</string>
- <string name="slideshow" msgid="4355906903247112975">"슬라이드쇼"</string>
- <string name="menu" msgid="1819649153380636719">"메뉴"</string>
- <string name="details" msgid="8415120088556445230">"세부정보"</string>
- <string name="album_selected" msgid="3441280740465738452">"앨범이 선택됨"</string>
- <string name="item_selected" msgid="6137767503817908841">"항목이 선택됨"</string>
- <string name="albums_selected" msgid="1815225920157190983">"앨범이 선택됨"</string>
- <string name="items_selected" msgid="8548754404879264861">"항목이 선택됨"</string>
- <string name="album" msgid="5198388817734336004">"앨범"</string>
- <string name="start" msgid="4316892252528232165">"시작"</string>
- <string name="end" msgid="3645506196012005500">"종료"</string>
- <string name="location" msgid="3432705876921618314">"위치"</string>
- <string name="location_unknown" msgid="6310139243003315255">"알 수 없는 위치"</string>
- <string name="title" msgid="7622928349908052569">"제목"</string>
- <string name="type" msgid="4329478642546287192">"유형"</string>
- <string name="taken_on" msgid="3269486910757192479">"촬영 날짜"</string>
- <string name="added_on" msgid="5194321063173381814">"추가 날짜"</string>
- <string name="show_on_map" msgid="6157544221201750980">"지도에 표시"</string>
- <string name="rotate_left" msgid="7412075232752726934">"왼쪽으로 회전"</string>
- <string name="rotate_right" msgid="7340681085011826618">"오른쪽으로 회전"</string>
- <string name="crop" msgid="7970750655414797277">"자르기"</string>
- <string name="set_as" msgid="3636764710790507868">"다음으로 설정"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"배경화면으로 설정"</string>
- <string name="item" msgid="636303673288563698">"항목"</string>
- <string name="items" msgid="6403254716052150916">"항목"</string>
- <string name="around" msgid="2223906282110417412">"근처:"</string>
- <string name="date_unknown" msgid="4277113471036917386">"날짜를 알 수 없음"</string>
- <string name="video_err" msgid="7917736494827857757">"동영상을 재생할 수 없음"</string>
-</resources>
diff --git a/new3d/res/values-nb/strings.xml b/new3d/res/values-nb/strings.xml
deleted file mode 100644
index 6fcf29b..0000000
--- a/new3d/res/values-nb/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galleri"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"Jan"</item>
- <item msgid="4680813504147866612">"Feb"</item>
- <item msgid="1934595560893153574">"Mar"</item>
- <item msgid="9020107212348500338">"Apr"</item>
- <item msgid="5734859077892484949">"Mai"</item>
- <item msgid="8546985030184126468">"Jun"</item>
- <item msgid="3639654472839533748">"Jul"</item>
- <item msgid="8434242278630875235">"Aug"</item>
- <item msgid="8493511009771049442">"Sep"</item>
- <item msgid="685181459001441496">"Okt"</item>
- <item msgid="6662413035764778250">"Nov"</item>
- <item msgid="3784870986696899313">"Des"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Bilderamme"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Filmer"</string>
- <string name="loading_video" msgid="4013492720121891585">"Laster video…"</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Fortsett avspilling"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Fortsett avspilling fra %s?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Fortsett avspilling"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Begynn på nytt"</string>
- <string name="camera" msgid="2730811566218090802">"Kamera"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Lagre"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Forkast"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Trykk på et ansikt for å begynne."</string>
- <string name="saving_image" msgid="7270334453636349407">"Lagrer bilde ..."</string>
- <string name="crop_label" msgid="521114301871349328">"Beskjær bilde"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Vent litt ..."</string>
- <string name="set_image" msgid="2331476809308010401">"Angi bilde som"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Setter bakgrunnsbilde, vent litt…"</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Bakgrunnsbilde"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"Laster inn nye albumer og bilder"</string>
- <string name="initializing" msgid="2374228157398540466">"Henter"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Velg et element fra samlingen"</string>
- <string name="no_items" msgid="3117870234034732172">"Det er ingen elementer i samlingen"</string>
- <string name="pick" msgid="7248789132035843128">"Velg"</string>
- <string name="delete" msgid="2839695998251824487">"Slett"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Bekreft sletting"</string>
- <string name="cancel" msgid="3637516880917356226">"Avbryt"</string>
- <string name="share" msgid="3619042788254195341">"Del"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"Minnekortet er koblet fra eller ikke satt inn"</string>
- <string name="more" msgid="1526449516720792387">"Mer"</string>
- <string name="select_all" msgid="8623593677101437957">"Marker alle"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Fjern alle markeringer"</string>
- <string name="slideshow" msgid="4355906903247112975">"Lysbildevisning"</string>
- <string name="menu" msgid="1819649153380636719">"Meny"</string>
- <string name="details" msgid="8415120088556445230">"Detaljer"</string>
- <string name="album_selected" msgid="3441280740465738452">"album valgt"</string>
- <string name="item_selected" msgid="6137767503817908841">"element valgt"</string>
- <string name="albums_selected" msgid="1815225920157190983">"albumer valgt"</string>
- <string name="items_selected" msgid="8548754404879264861">"elementer valgt"</string>
- <string name="album" msgid="5198388817734336004">"Album"</string>
- <string name="start" msgid="4316892252528232165">"Start"</string>
- <string name="end" msgid="3645506196012005500">"Avslutt"</string>
- <string name="location" msgid="3432705876921618314">"Sted"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Ukjent sted"</string>
- <string name="title" msgid="7622928349908052569">"Tittel"</string>
- <string name="type" msgid="4329478642546287192">"Type"</string>
- <string name="taken_on" msgid="3269486910757192479">"Fra"</string>
- <string name="added_on" msgid="5194321063173381814">"Lagt til den"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Vis på kartet"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Roter til venstre"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Roter til høyre"</string>
- <string name="crop" msgid="7970750655414797277">"Beskjær"</string>
- <string name="set_as" msgid="3636764710790507868">"Angi som"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Bruk som bakgrunn"</string>
- <string name="item" msgid="636303673288563698">"element"</string>
- <string name="items" msgid="6403254716052150916">"elementer"</string>
- <string name="around" msgid="2223906282110417412">"Rundt"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Dato ukjent"</string>
- <string name="video_err" msgid="7917736494827857757">"Kunne ikke spille av videoen"</string>
-</resources>
diff --git a/new3d/res/values-nl/strings.xml b/new3d/res/values-nl/strings.xml
deleted file mode 100644
index defa754..0000000
--- a/new3d/res/values-nl/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galerij"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"jan"</item>
- <item msgid="4680813504147866612">"feb"</item>
- <item msgid="1934595560893153574">"mrt"</item>
- <item msgid="9020107212348500338">"apr"</item>
- <item msgid="5734859077892484949">"mei"</item>
- <item msgid="8546985030184126468">"jun"</item>
- <item msgid="3639654472839533748">"jul"</item>
- <item msgid="8434242278630875235">"aug"</item>
- <item msgid="8493511009771049442">"sep"</item>
- <item msgid="685181459001441496">"okt"</item>
- <item msgid="6662413035764778250">"nov"</item>
- <item msgid="3784870986696899313">"dec"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Fotolijstje"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Films"</string>
- <string name="loading_video" msgid="4013492720121891585">"Video laden..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Video hervatten"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Afspelen hervatten vanaf %s ?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Afspelen hervatten"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Opnieuw starten"</string>
- <string name="camera" msgid="2730811566218090802">"Camera"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Opslaan"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Ongedaan maken"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Tik op een gezicht om te beginnen."</string>
- <string name="saving_image" msgid="7270334453636349407">"Foto opslaan..."</string>
- <string name="crop_label" msgid="521114301871349328">"Foto bijsnijden"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Een ogenblik geduld..."</string>
- <string name="set_image" msgid="2331476809308010401">"Foto instellen als"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Achtergrond wordt ingesteld. Een ogenblik geduld..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Achtergrond"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"Nieuwe albums en foto\'s laden"</string>
- <string name="initializing" msgid="2374228157398540466">"Laden"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Kies een item uit uw verzameling"</string>
- <string name="no_items" msgid="3117870234034732172">"Uw verzameling bevat geen items"</string>
- <string name="pick" msgid="7248789132035843128">"Kiezen"</string>
- <string name="delete" msgid="2839695998251824487">"Verwijderen"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Verwijderen bevestigen"</string>
- <string name="cancel" msgid="3637516880917356226">"Annuleren"</string>
- <string name="share" msgid="3619042788254195341">"Delen"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"De SD-kaart is ontkoppeld of niet aanwezig"</string>
- <string name="more" msgid="1526449516720792387">"Meer"</string>
- <string name="select_all" msgid="8623593677101437957">"Alles selecteren"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Selectie van alle items ongedaan maken"</string>
- <string name="slideshow" msgid="4355906903247112975">"Diavoorstelling"</string>
- <string name="menu" msgid="1819649153380636719">"Menu"</string>
- <string name="details" msgid="8415120088556445230">"Details"</string>
- <string name="album_selected" msgid="3441280740465738452">"album geselecteerd"</string>
- <string name="item_selected" msgid="6137767503817908841">"item geselecteerd"</string>
- <string name="albums_selected" msgid="1815225920157190983">"albums geselecteerd"</string>
- <string name="items_selected" msgid="8548754404879264861">"items geselecteerd"</string>
- <string name="album" msgid="5198388817734336004">"Album"</string>
- <string name="start" msgid="4316892252528232165">"Start"</string>
- <string name="end" msgid="3645506196012005500">"Beëindigen"</string>
- <string name="location" msgid="3432705876921618314">"Locatie"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Onbekende locatie"</string>
- <string name="title" msgid="7622928349908052569">"Titel"</string>
- <string name="type" msgid="4329478642546287192">"Type"</string>
- <string name="taken_on" msgid="3269486910757192479">"Genomen op"</string>
- <string name="added_on" msgid="5194321063173381814">"Toegevoegd op"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Op kaart weergeven"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Linksom draaien"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Rechtsom draaien"</string>
- <string name="crop" msgid="7970750655414797277">"Bijsnijden"</string>
- <string name="set_as" msgid="3636764710790507868">"Instellen als"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Instellen als achtergrond"</string>
- <string name="item" msgid="636303673288563698">"item"</string>
- <string name="items" msgid="6403254716052150916">"items"</string>
- <string name="around" msgid="2223906282110417412">"In de buurt van"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Datum onbekend"</string>
- <string name="video_err" msgid="7917736494827857757">"Kan video niet afspelen"</string>
-</resources>
diff --git a/new3d/res/values-pl/strings.xml b/new3d/res/values-pl/strings.xml
deleted file mode 100644
index 28c7af7..0000000
--- a/new3d/res/values-pl/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galeria"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"Sty"</item>
- <item msgid="4680813504147866612">"Lut"</item>
- <item msgid="1934595560893153574">"Mar"</item>
- <item msgid="9020107212348500338">"Kwi"</item>
- <item msgid="5734859077892484949">"Maj"</item>
- <item msgid="8546985030184126468">"Cze"</item>
- <item msgid="3639654472839533748">"Lip"</item>
- <item msgid="8434242278630875235">"Sie"</item>
- <item msgid="8493511009771049442">"Wrz"</item>
- <item msgid="685181459001441496">"Paź"</item>
- <item msgid="6662413035764778250">"Lis"</item>
- <item msgid="3784870986696899313">"Gru"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Ramka ze zdjęciem"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Filmy"</string>
- <string name="loading_video" msgid="4013492720121891585">"Ładowanie filmu..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Wznów film"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Wznowić odtwarzanie od %s?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Wznów odtwarzanie"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Rozpocznij"</string>
- <string name="camera" msgid="2730811566218090802">"Aparat"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Zapisz"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Odrzuć"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Dotknij twarzy, aby rozpocząć"</string>
- <string name="saving_image" msgid="7270334453636349407">"Zapisywanie zdjęcia…"</string>
- <string name="crop_label" msgid="521114301871349328">"Przytnij zdjęcie"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Czekaj…"</string>
- <string name="set_image" msgid="2331476809308010401">"Ustaw zdjęcie jako"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Ustawianie tapety, proszę czekać…"</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Tapeta"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"Wczytywanie nowych albumów i zdjęć"</string>
- <string name="initializing" msgid="2374228157398540466">"Wczytywanie"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Wybierz element z kolekcji"</string>
- <string name="no_items" msgid="3117870234034732172">"Brak elementów"</string>
- <string name="pick" msgid="7248789132035843128">"Wybierz"</string>
- <string name="delete" msgid="2839695998251824487">"Usuń"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Potwierdź usunięcie"</string>
- <string name="cancel" msgid="3637516880917356226">"Anuluj"</string>
- <string name="share" msgid="3619042788254195341">"Udostępnij"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"Brak karty SD lub jest ona odłączona"</string>
- <string name="more" msgid="1526449516720792387">"Więcej"</string>
- <string name="select_all" msgid="8623593677101437957">"Zaznacz wszystko"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Usuń zaznaczenie wszystkich"</string>
- <string name="slideshow" msgid="4355906903247112975">"Pokaz slajdów"</string>
- <string name="menu" msgid="1819649153380636719">"Menu"</string>
- <string name="details" msgid="8415120088556445230">"Szczegóły"</string>
- <string name="album_selected" msgid="3441280740465738452">"wybrany album"</string>
- <string name="item_selected" msgid="6137767503817908841">"wybrany element"</string>
- <string name="albums_selected" msgid="1815225920157190983">"wybranych albumów"</string>
- <string name="items_selected" msgid="8548754404879264861">"wybranych elementów"</string>
- <string name="album" msgid="5198388817734336004">"Album"</string>
- <string name="start" msgid="4316892252528232165">"Start"</string>
- <string name="end" msgid="3645506196012005500">"Zakończ"</string>
- <string name="location" msgid="3432705876921618314">"Lokalizacja"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Nieznana lokalizacja"</string>
- <string name="title" msgid="7622928349908052569">"Tytuł"</string>
- <string name="type" msgid="4329478642546287192">"Typ"</string>
- <string name="taken_on" msgid="3269486910757192479">"Zapisano:"</string>
- <string name="added_on" msgid="5194321063173381814">"Dodano"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Pokaż na mapie"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Obróć w lewo"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Obróć w prawo"</string>
- <string name="crop" msgid="7970750655414797277">"Przytnij"</string>
- <string name="set_as" msgid="3636764710790507868">"Ustaw jako"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Ustaw jako tapetę"</string>
- <string name="item" msgid="636303673288563698">"element"</string>
- <string name="items" msgid="6403254716052150916">"elementy"</string>
- <string name="around" msgid="2223906282110417412">"W pobliżu"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Data nieznana"</string>
- <string name="video_err" msgid="7917736494827857757">"Nie można odtworzyć filmu wideo"</string>
-</resources>
diff --git a/new3d/res/values-pt-rPT/strings.xml b/new3d/res/values-pt-rPT/strings.xml
deleted file mode 100644
index 912e78b..0000000
--- a/new3d/res/values-pt-rPT/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galeria"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"Jan"</item>
- <item msgid="4680813504147866612">"Fev"</item>
- <item msgid="1934595560893153574">"Mar"</item>
- <item msgid="9020107212348500338">"Abr"</item>
- <item msgid="5734859077892484949">"Mai"</item>
- <item msgid="8546985030184126468">"Jun"</item>
- <item msgid="3639654472839533748">"Jul"</item>
- <item msgid="8434242278630875235">"Ago"</item>
- <item msgid="8493511009771049442">"Set"</item>
- <item msgid="685181459001441496">"Out"</item>
- <item msgid="6662413035764778250">"Nov"</item>
- <item msgid="3784870986696899313">"Dez"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Moldura da imagem"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Filmes"</string>
- <string name="loading_video" msgid="4013492720121891585">"A carregar vídeo..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Retomar o vídeo"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Retomar reprodução a partir de %s?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Retomar a reprodução"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Recomeçar"</string>
- <string name="camera" msgid="2730811566218090802">"Câmara"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Guardar"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Rejeitar"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Toque num rosto para começar."</string>
- <string name="saving_image" msgid="7270334453636349407">"A guardar imagem..."</string>
- <string name="crop_label" msgid="521114301871349328">"Recortar imagem"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Aguarde..."</string>
- <string name="set_image" msgid="2331476809308010401">"Definir imagem como"</string>
- <string name="wallpaper" msgid="9222901738515471972">"A definir a imagem de fundo, aguarde..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Imagem de fundo"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"A carregar novos álbuns e fotografias"</string>
- <string name="initializing" msgid="2374228157398540466">"A carregar"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Escolha um item a partir da colecção"</string>
- <string name="no_items" msgid="3117870234034732172">"Não existem itens na sua colecção"</string>
- <string name="pick" msgid="7248789132035843128">"Escolher"</string>
- <string name="delete" msgid="2839695998251824487">"Eliminar"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Confirmar eliminação"</string>
- <string name="cancel" msgid="3637516880917356226">"Cancelar"</string>
- <string name="share" msgid="3619042788254195341">"Partilhar"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"Cartão SD desmontado ou ausente"</string>
- <string name="more" msgid="1526449516720792387">"Mais"</string>
- <string name="select_all" msgid="8623593677101437957">"Seleccionar tudo"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Desmarcar tudo"</string>
- <string name="slideshow" msgid="4355906903247112975">"Apresentação de diapositivos"</string>
- <string name="menu" msgid="1819649153380636719">"Menu"</string>
- <string name="details" msgid="8415120088556445230">"Detalhes"</string>
- <string name="album_selected" msgid="3441280740465738452">"álbum seleccionado"</string>
- <string name="item_selected" msgid="6137767503817908841">"item seleccionado"</string>
- <string name="albums_selected" msgid="1815225920157190983">"álbuns seleccionados"</string>
- <string name="items_selected" msgid="8548754404879264861">"itens seleccionados"</string>
- <string name="album" msgid="5198388817734336004">"Álbum"</string>
- <string name="start" msgid="4316892252528232165">"Iniciar"</string>
- <string name="end" msgid="3645506196012005500">"Terminar"</string>
- <string name="location" msgid="3432705876921618314">"Localização"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Localização desconhecida"</string>
- <string name="title" msgid="7622928349908052569">"Título"</string>
- <string name="type" msgid="4329478642546287192">"Tipo"</string>
- <string name="taken_on" msgid="3269486910757192479">"Criado(a) em"</string>
- <string name="added_on" msgid="5194321063173381814">"Adicionada em"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Mostrar no mapa"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Rodar para a esquerda"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Rodar para a direita"</string>
- <string name="crop" msgid="7970750655414797277">"Recortar"</string>
- <string name="set_as" msgid="3636764710790507868">"Definir como"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Definir como imagem de fundo"</string>
- <string name="item" msgid="636303673288563698">"item"</string>
- <string name="items" msgid="6403254716052150916">"itens"</string>
- <string name="around" msgid="2223906282110417412">"Perto de"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Data desconhecida"</string>
- <string name="video_err" msgid="7917736494827857757">"Não é possível reproduzir vídeo"</string>
-</resources>
diff --git a/new3d/res/values-pt/strings.xml b/new3d/res/values-pt/strings.xml
deleted file mode 100644
index 5f6f51b..0000000
--- a/new3d/res/values-pt/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galeria"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"Jan"</item>
- <item msgid="4680813504147866612">"Fev"</item>
- <item msgid="1934595560893153574">"Mar"</item>
- <item msgid="9020107212348500338">"Abr"</item>
- <item msgid="5734859077892484949">"Mai"</item>
- <item msgid="8546985030184126468">"Jun"</item>
- <item msgid="3639654472839533748">"Jul"</item>
- <item msgid="8434242278630875235">"Ago"</item>
- <item msgid="8493511009771049442">"Set"</item>
- <item msgid="685181459001441496">"Out"</item>
- <item msgid="6662413035764778250">"Nov"</item>
- <item msgid="3784870986696899313">"Dez"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Moldura de uma imagem"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Filmes\n"</string>
- <string name="loading_video" msgid="4013492720121891585">"Carregando vídeo..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Retomar vídeo"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Retomar reprodução de %s ?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Retomar a reprodução"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Reiniciar"</string>
- <string name="camera" msgid="2730811566218090802">"Câmera"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Salvar"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Descartar"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Toque em uma face para começar."</string>
- <string name="saving_image" msgid="7270334453636349407">"Salvando imagem…"</string>
- <string name="crop_label" msgid="521114301871349328">"Cortar imagem"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Aguarde..."</string>
- <string name="set_image" msgid="2331476809308010401">"Definir imagem como\n"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Configurando o plano de fundo, aguarde…"</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Plano de fundo"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"Carregando novos álbuns e fotos"</string>
- <string name="initializing" msgid="2374228157398540466">"Carregando"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Escolha um item da sua coleção"</string>
- <string name="no_items" msgid="3117870234034732172">"Não há itens na sua coleção"</string>
- <string name="pick" msgid="7248789132035843128">"Escolher"</string>
- <string name="delete" msgid="2839695998251824487">"Excluir"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Confirmar exclusão"</string>
- <string name="cancel" msgid="3637516880917356226">"Cancelar"</string>
- <string name="share" msgid="3619042788254195341">"Compartilhar"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"Cartão SD desmontado ou ausente"</string>
- <string name="more" msgid="1526449516720792387">"Mais"</string>
- <string name="select_all" msgid="8623593677101437957">"Selecionar todos"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Desmarcar tudo"</string>
- <string name="slideshow" msgid="4355906903247112975">"Apresentação de slides"</string>
- <string name="menu" msgid="1819649153380636719">"Menu"</string>
- <string name="details" msgid="8415120088556445230">"Detalhes"</string>
- <string name="album_selected" msgid="3441280740465738452">"álbum selecionado"</string>
- <string name="item_selected" msgid="6137767503817908841">"item selecionado"</string>
- <string name="albums_selected" msgid="1815225920157190983">"álbuns selecionados"</string>
- <string name="items_selected" msgid="8548754404879264861">"itens selecionados"</string>
- <string name="album" msgid="5198388817734336004">"Álbum"</string>
- <string name="start" msgid="4316892252528232165">"Iniciar"</string>
- <string name="end" msgid="3645506196012005500">"Finalizar"</string>
- <string name="location" msgid="3432705876921618314">"Local"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Local desconhecido\n"</string>
- <string name="title" msgid="7622928349908052569">"Título"</string>
- <string name="type" msgid="4329478642546287192">"Tipo"</string>
- <string name="taken_on" msgid="3269486910757192479">"Feito(a) em"</string>
- <string name="added_on" msgid="5194321063173381814">"Adicionado em"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Mostrar no mapa"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Girar para a esquerda"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Girar para a direita"</string>
- <string name="crop" msgid="7970750655414797277">"Cortar"</string>
- <string name="set_as" msgid="3636764710790507868">"Definir como"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Definir como plano de fundo"</string>
- <string name="item" msgid="636303673288563698">"item"</string>
- <string name="items" msgid="6403254716052150916">"itens"</string>
- <string name="around" msgid="2223906282110417412">"Perto de"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Data desconhecida"</string>
- <string name="video_err" msgid="7917736494827857757">"Não é possível reproduzir o vídeo"</string>
-</resources>
diff --git a/new3d/res/values-ru/strings.xml b/new3d/res/values-ru/strings.xml
deleted file mode 100644
index b62f8ed..0000000
--- a/new3d/res/values-ru/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Галерея"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"янв"</item>
- <item msgid="4680813504147866612">"фев"</item>
- <item msgid="1934595560893153574">"мар"</item>
- <item msgid="9020107212348500338">"апр"</item>
- <item msgid="5734859077892484949">"май"</item>
- <item msgid="8546985030184126468">"июн"</item>
- <item msgid="3639654472839533748">"июл"</item>
- <item msgid="8434242278630875235">"авг"</item>
- <item msgid="8493511009771049442">"сен"</item>
- <item msgid="685181459001441496">"окт"</item>
- <item msgid="6662413035764778250">"ноя"</item>
- <item msgid="3784870986696899313">"дек"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Рамка фотографии"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Фильмы"</string>
- <string name="loading_video" msgid="4013492720121891585">"Загрузка видео…"</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Продолжение просмотра видео"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Продолжить воспроизведение с %s?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Продолжить воспроизведение"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Начать с начала"</string>
- <string name="camera" msgid="2730811566218090802">"Камера"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Сохранить"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Отменить"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Нажмите лицо, чтобы начать."</string>
- <string name="saving_image" msgid="7270334453636349407">"Сохранение картинки..."</string>
- <string name="crop_label" msgid="521114301871349328">"Обрезать фотографию"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Подождите..."</string>
- <string name="set_image" msgid="2331476809308010401">"Установить картинку как"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Установка обоев, подождите..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Обои"</string>
- <string name="details_ok" msgid="6848594369924424312">"ОК"</string>
- <string name="loading_new" msgid="7893793767294787579">"Загрузка новых альбомов и фотографий"</string>
- <string name="initializing" msgid="2374228157398540466">"Загрузка"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Выбрать элемент из коллекции"</string>
- <string name="no_items" msgid="3117870234034732172">"В вашей коллекции ничего нет."</string>
- <string name="pick" msgid="7248789132035843128">"Выбрать"</string>
- <string name="delete" msgid="2839695998251824487">"Удалить"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Подтвердить удаление"</string>
- <string name="cancel" msgid="3637516880917356226">"Отмена"</string>
- <string name="share" msgid="3619042788254195341">"Отправить"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"SD-карта извлечена или не вставлена"</string>
- <string name="more" msgid="1526449516720792387">"Ещё"</string>
- <string name="select_all" msgid="8623593677101437957">"Выбрать все"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Снять все выделения"</string>
- <string name="slideshow" msgid="4355906903247112975">"Слайд-шоу"</string>
- <string name="menu" msgid="1819649153380636719">"Меню"</string>
- <string name="details" msgid="8415120088556445230">"Сведения"</string>
- <string name="album_selected" msgid="3441280740465738452">"альбом выбран"</string>
- <string name="item_selected" msgid="6137767503817908841">"элемент выбран"</string>
- <string name="albums_selected" msgid="1815225920157190983">"альб. выбрано"</string>
- <string name="items_selected" msgid="8548754404879264861">"элем. выбрано"</string>
- <string name="album" msgid="5198388817734336004">"Альбом"</string>
- <string name="start" msgid="4316892252528232165">"Начать"</string>
- <string name="end" msgid="3645506196012005500">"Завершить"</string>
- <string name="location" msgid="3432705876921618314">"Местоположение"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Неизвестное местоположение"</string>
- <string name="title" msgid="7622928349908052569">"Название"</string>
- <string name="type" msgid="4329478642546287192">"Тип"</string>
- <string name="taken_on" msgid="3269486910757192479">"Дата создания:"</string>
- <string name="added_on" msgid="5194321063173381814">"Дата добавления:"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Показать на карте"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Повернуть влево"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Повернуть вправо"</string>
- <string name="crop" msgid="7970750655414797277">"Обрезать"</string>
- <string name="set_as" msgid="3636764710790507868">"Установить как"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Установить как фоновый рисунок"</string>
- <string name="item" msgid="636303673288563698">"элемент"</string>
- <string name="items" msgid="6403254716052150916">"элем."</string>
- <string name="around" msgid="2223906282110417412">"Возле"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Дата неизвестна"</string>
- <string name="video_err" msgid="7917736494827857757">"Не удается воспроизвести видео"</string>
-</resources>
diff --git a/new3d/res/values-sv/strings.xml b/new3d/res/values-sv/strings.xml
deleted file mode 100644
index 34703d2..0000000
--- a/new3d/res/values-sv/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galleri"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"jan"</item>
- <item msgid="4680813504147866612">"feb"</item>
- <item msgid="1934595560893153574">"mar"</item>
- <item msgid="9020107212348500338">"apr"</item>
- <item msgid="5734859077892484949">"maj"</item>
- <item msgid="8546985030184126468">"jun"</item>
- <item msgid="3639654472839533748">"jul"</item>
- <item msgid="8434242278630875235">"aug"</item>
- <item msgid="8493511009771049442">"sep"</item>
- <item msgid="685181459001441496">"okt"</item>
- <item msgid="6662413035764778250">"nov"</item>
- <item msgid="3784870986696899313">"dec"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Bildram"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Filmer"</string>
- <string name="loading_video" msgid="4013492720121891585">"Läser in video…"</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Fortsätt spela videon"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Fortsätt spela upp från %s?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Fortsätt spela upp"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Börja om"</string>
- <string name="camera" msgid="2730811566218090802">"Kamera"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Spara"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Ignorera"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Peka på ett ansikte när du vill börja."</string>
- <string name="saving_image" msgid="7270334453636349407">"Sparar bild…"</string>
- <string name="crop_label" msgid="521114301871349328">"Beskär bild"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Vänta…"</string>
- <string name="set_image" msgid="2331476809308010401">"Använd bild som"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Anger bakgrund, vänta…"</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Bakgrund"</string>
- <string name="details_ok" msgid="6848594369924424312">"OK"</string>
- <string name="loading_new" msgid="7893793767294787579">"Läser in nya album och foton"</string>
- <string name="initializing" msgid="2374228157398540466">"Läser in"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Välj ett objekt i din samling"</string>
- <string name="no_items" msgid="3117870234034732172">"Det finns inga objekt i din samling"</string>
- <string name="pick" msgid="7248789132035843128">"Välj"</string>
- <string name="delete" msgid="2839695998251824487">"Ta bort"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Bekräfta borttagning"</string>
- <string name="cancel" msgid="3637516880917356226">"Avbryt"</string>
- <string name="share" msgid="3619042788254195341">"Dela"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"SD-kortet är inte initierat eller saknas"</string>
- <string name="more" msgid="1526449516720792387">"Mer"</string>
- <string name="select_all" msgid="8623593677101437957">"Markera alla"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Avmarkera alla"</string>
- <string name="slideshow" msgid="4355906903247112975">"Bildspel"</string>
- <string name="menu" msgid="1819649153380636719">"Meny"</string>
- <string name="details" msgid="8415120088556445230">"Information"</string>
- <string name="album_selected" msgid="3441280740465738452">"album har markerats"</string>
- <string name="item_selected" msgid="6137767503817908841">"objekt har markerats"</string>
- <string name="albums_selected" msgid="1815225920157190983">"album har markerats"</string>
- <string name="items_selected" msgid="8548754404879264861">"objekt har markerats"</string>
- <string name="album" msgid="5198388817734336004">"Album"</string>
- <string name="start" msgid="4316892252528232165">"Start"</string>
- <string name="end" msgid="3645506196012005500">"Avsluta"</string>
- <string name="location" msgid="3432705876921618314">"Plats"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Okänd plats"</string>
- <string name="title" msgid="7622928349908052569">"Titel"</string>
- <string name="type" msgid="4329478642546287192">"Typ"</string>
- <string name="taken_on" msgid="3269486910757192479">"Skapat den"</string>
- <string name="added_on" msgid="5194321063173381814">"Tillagt den"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Visa på karta"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Rotera åt vänster"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Rotera åt höger"</string>
- <string name="crop" msgid="7970750655414797277">"Beskär"</string>
- <string name="set_as" msgid="3636764710790507868">"Använd som"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Använd som bakgrund"</string>
- <string name="item" msgid="636303673288563698">"objekt"</string>
- <string name="items" msgid="6403254716052150916">"objekt"</string>
- <string name="around" msgid="2223906282110417412">"Vid"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Datum okänt"</string>
- <string name="video_err" msgid="7917736494827857757">"Det gick inte att spela videon"</string>
-</resources>
diff --git a/new3d/res/values-tr/strings.xml b/new3d/res/values-tr/strings.xml
deleted file mode 100644
index 6ec9690..0000000
--- a/new3d/res/values-tr/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"Galeri"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"Oca"</item>
- <item msgid="4680813504147866612">"Şub"</item>
- <item msgid="1934595560893153574">"Mar"</item>
- <item msgid="9020107212348500338">"Nis"</item>
- <item msgid="5734859077892484949">"May"</item>
- <item msgid="8546985030184126468">"Haz"</item>
- <item msgid="3639654472839533748">"Tem"</item>
- <item msgid="8434242278630875235">"Ağu"</item>
- <item msgid="8493511009771049442">"Eyl"</item>
- <item msgid="685181459001441496">"Eki"</item>
- <item msgid="6662413035764778250">"Kas"</item>
- <item msgid="3784870986696899313">"Ara"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"Resim çerçevesi"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"Filmler"</string>
- <string name="loading_video" msgid="4013492720121891585">"Video yükleniyor..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"Videoyu sürdür"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"Yürütme şuradan devam ettirilsin mi: %s ?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"Yürütmeyi sürdür"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"Başlat"</string>
- <string name="camera" msgid="2730811566218090802">"Kamera"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"Kaydet"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"Sil"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"Başlamak için bir yüze hafifçe dokunun"</string>
- <string name="saving_image" msgid="7270334453636349407">"Resim kaydediliyor..."</string>
- <string name="crop_label" msgid="521114301871349328">"Resmi kırp"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"Lütfen bekleyin..."</string>
- <string name="set_image" msgid="2331476809308010401">"Resmi şu şekilde ayarla:"</string>
- <string name="wallpaper" msgid="9222901738515471972">"Duvar kağıdı ayarlanıyor, lütfen bekleyin..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"Duvar Kağıdı"</string>
- <string name="details_ok" msgid="6848594369924424312">"Tamam"</string>
- <string name="loading_new" msgid="7893793767294787579">"Yeni albümler ve fotoğraflar yükleniyor"</string>
- <string name="initializing" msgid="2374228157398540466">"Yükleniyor"</string>
- <string name="pick_prompt" msgid="576608096149718121">"Koleksiyonunuzdan bir öğe seçin"</string>
- <string name="no_items" msgid="3117870234034732172">"Koleksiyonunuzda hiçbir öğe bulunmuyor"</string>
- <string name="pick" msgid="7248789132035843128">"Seç"</string>
- <string name="delete" msgid="2839695998251824487">"Sil"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"Silme İşlemini Onayla"</string>
- <string name="cancel" msgid="3637516880917356226">"İptal"</string>
- <string name="share" msgid="3619042788254195341">"Paylaş"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"SD Kart çıkarılmış veya mevcut değil"</string>
- <string name="more" msgid="1526449516720792387">"Diğer"</string>
- <string name="select_all" msgid="8623593677101437957">"Tümünü Seç"</string>
- <string name="deselect_all" msgid="7397531298370285581">"Tüm Seçimleri Kaldır"</string>
- <string name="slideshow" msgid="4355906903247112975">"Slayt Gösterisi"</string>
- <string name="menu" msgid="1819649153380636719">"Menü"</string>
- <string name="details" msgid="8415120088556445230">"Ayrıntılar"</string>
- <string name="album_selected" msgid="3441280740465738452">"albüm seçildi"</string>
- <string name="item_selected" msgid="6137767503817908841">"öğe seçildi"</string>
- <string name="albums_selected" msgid="1815225920157190983">"albüm seçildi"</string>
- <string name="items_selected" msgid="8548754404879264861">"öğe seçildi"</string>
- <string name="album" msgid="5198388817734336004">"Albüm"</string>
- <string name="start" msgid="4316892252528232165">"Başlat"</string>
- <string name="end" msgid="3645506196012005500">"Sonlandır"</string>
- <string name="location" msgid="3432705876921618314">"Konum"</string>
- <string name="location_unknown" msgid="6310139243003315255">"Bilinmeyen konum"</string>
- <string name="title" msgid="7622928349908052569">"Başlık"</string>
- <string name="type" msgid="4329478642546287192">"Tür"</string>
- <string name="taken_on" msgid="3269486910757192479">"Çekim zamanı:"</string>
- <string name="added_on" msgid="5194321063173381814">"Şu tarihte eklendi:"</string>
- <string name="show_on_map" msgid="6157544221201750980">"Haritada göster"</string>
- <string name="rotate_left" msgid="7412075232752726934">"Sola Döndür"</string>
- <string name="rotate_right" msgid="7340681085011826618">"Sağa Döndür"</string>
- <string name="crop" msgid="7970750655414797277">"Kırp"</string>
- <string name="set_as" msgid="3636764710790507868">"Şu şekilde ayarla:"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"Duvar kağıdı olarak ayarla"</string>
- <string name="item" msgid="636303673288563698">"öğe"</string>
- <string name="items" msgid="6403254716052150916">"öğe"</string>
- <string name="around" msgid="2223906282110417412">"Şu civarda:"</string>
- <string name="date_unknown" msgid="4277113471036917386">"Tarih bilinmiyor"</string>
- <string name="video_err" msgid="7917736494827857757">"Video oynatılamıyor"</string>
-</resources>
diff --git a/new3d/res/values-zh-rCN/strings.xml b/new3d/res/values-zh-rCN/strings.xml
deleted file mode 100644
index 37d0dab..0000000
--- a/new3d/res/values-zh-rCN/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"图库"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"1 月"</item>
- <item msgid="4680813504147866612">"2 月"</item>
- <item msgid="1934595560893153574">"3 月"</item>
- <item msgid="9020107212348500338">"4 月"</item>
- <item msgid="5734859077892484949">"5 月"</item>
- <item msgid="8546985030184126468">"6 月"</item>
- <item msgid="3639654472839533748">"7 月"</item>
- <item msgid="8434242278630875235">"8 月"</item>
- <item msgid="8493511009771049442">"9 月"</item>
- <item msgid="685181459001441496">"10 月"</item>
- <item msgid="6662413035764778250">"11 月"</item>
- <item msgid="3784870986696899313">"12 月"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"相框"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"电影"</string>
- <string name="loading_video" msgid="4013492720121891585">"正在载入视频..."</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"继续播放视频"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"从 %s 开始继续播放?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"继续播放"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"重新开始"</string>
- <string name="camera" msgid="2730811566218090802">"相机"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"保存"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"舍弃"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"轻点一张脸开始裁剪。"</string>
- <string name="saving_image" msgid="7270334453636349407">"正在保存照片..."</string>
- <string name="crop_label" msgid="521114301871349328">"修剪照片"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"请稍候..."</string>
- <string name="set_image" msgid="2331476809308010401">"将照片设置为"</string>
- <string name="wallpaper" msgid="9222901738515471972">"正在设置壁纸,请稍候..."</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"壁纸"</string>
- <string name="details_ok" msgid="6848594369924424312">"确定"</string>
- <string name="loading_new" msgid="7893793767294787579">"正在载入新相册和新照片"</string>
- <string name="initializing" msgid="2374228157398540466">"正在载入"</string>
- <string name="pick_prompt" msgid="576608096149718121">"从您的收藏中挑选一个"</string>
- <string name="no_items" msgid="3117870234034732172">"您还没有照片或视频。"</string>
- <string name="pick" msgid="7248789132035843128">"精选"</string>
- <string name="delete" msgid="2839695998251824487">"删除"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"确认删除"</string>
- <string name="cancel" msgid="3637516880917356226">"取消"</string>
- <string name="share" msgid="3619042788254195341">"分享"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"SD 卡已卸载或不存在"</string>
- <string name="more" msgid="1526449516720792387">"更多"</string>
- <string name="select_all" msgid="8623593677101437957">"全选"</string>
- <string name="deselect_all" msgid="7397531298370285581">"取消全选"</string>
- <string name="slideshow" msgid="4355906903247112975">"播放幻灯片"</string>
- <string name="menu" msgid="1819649153380636719">"菜单"</string>
- <string name="details" msgid="8415120088556445230">"详细信息"</string>
- <string name="album_selected" msgid="3441280740465738452">"本相册已选定"</string>
- <string name="item_selected" msgid="6137767503817908841">"项已选定"</string>
- <string name="albums_selected" msgid="1815225920157190983">"本相册已选定"</string>
- <string name="items_selected" msgid="8548754404879264861">"项已选定"</string>
- <string name="album" msgid="5198388817734336004">"相册"</string>
- <string name="start" msgid="4316892252528232165">"启动"</string>
- <string name="end" msgid="3645506196012005500">"结束"</string>
- <string name="location" msgid="3432705876921618314">"地点"</string>
- <string name="location_unknown" msgid="6310139243003315255">"未知地点"</string>
- <string name="title" msgid="7622928349908052569">"标题"</string>
- <string name="type" msgid="4329478642546287192">"类型"</string>
- <string name="taken_on" msgid="3269486910757192479">"拍摄日期"</string>
- <string name="added_on" msgid="5194321063173381814">"添加日期:"</string>
- <string name="show_on_map" msgid="6157544221201750980">"显示在地图上"</string>
- <string name="rotate_left" msgid="7412075232752726934">"向左旋转"</string>
- <string name="rotate_right" msgid="7340681085011826618">"向右旋转"</string>
- <string name="crop" msgid="7970750655414797277">"修剪"</string>
- <string name="set_as" msgid="3636764710790507868">"设置为"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"设置为壁纸"</string>
- <string name="item" msgid="636303673288563698">"项"</string>
- <string name="items" msgid="6403254716052150916">"项"</string>
- <string name="around" msgid="2223906282110417412">"大概位置:"</string>
- <string name="date_unknown" msgid="4277113471036917386">"日期未知"</string>
- <string name="video_err" msgid="7917736494827857757">"无法播放视频"</string>
-</resources>
diff --git a/new3d/res/values-zh-rTW/strings.xml b/new3d/res/values-zh-rTW/strings.xml
deleted file mode 100644
index 299e8e0..0000000
--- a/new3d/res/values-zh-rTW/strings.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name" msgid="1928079047368929634">"圖片庫"</string>
- <string-array name="months_abbreviated">
- <item msgid="9066537518640988368">"1 月"</item>
- <item msgid="4680813504147866612">"2 月"</item>
- <item msgid="1934595560893153574">"3 月"</item>
- <item msgid="9020107212348500338">"4 月"</item>
- <item msgid="5734859077892484949">"5 月"</item>
- <item msgid="8546985030184126468">"6 月"</item>
- <item msgid="3639654472839533748">"7 月"</item>
- <item msgid="8434242278630875235">"8 月"</item>
- <item msgid="8493511009771049442">"9 月"</item>
- <item msgid="685181459001441496">"10 月"</item>
- <item msgid="6662413035764778250">"11 月"</item>
- <item msgid="3784870986696899313">"12 月"</item>
- </string-array>
- <string name="gadget_title" msgid="259405922673466798">"相框"</string>
- <string name="details_ms" msgid="940634969189855292">"%1$02d:%2$02d"</string>
- <string name="details_hms" msgid="3215779248094151255">"%1$d:%2$02d:%3$02d"</string>
- <string name="movie_view_label" msgid="3697303290960009886">"電影"</string>
- <string name="loading_video" msgid="4013492720121891585">"正在載入影片…"</string>
- <string name="resume_playing_title" msgid="8996677350649355013">"繼續播放影片"</string>
- <string name="resume_playing_message" msgid="5184414518126703481">"要從 %s 繼續播放嗎?"</string>
- <string name="resume_playing_resume" msgid="3847915469173852416">"繼續播放"</string>
- <string name="resume_playing_restart" msgid="5471008499835769292">"重新開始"</string>
- <string name="camera" msgid="2730811566218090802">"相機"</string>
- <string name="crop_save_text" msgid="8140440041190264400">"儲存"</string>
- <string name="crop_discard_text" msgid="5303657888280340603">"捨棄"</string>
- <string name="multiface_crop_help" msgid="3127018992717032779">"輕觸所需的臉孔開始裁剪。"</string>
- <string name="saving_image" msgid="7270334453636349407">"正在儲存相片..."</string>
- <string name="crop_label" msgid="521114301871349328">"裁剪相片"</string>
- <string name="running_face_detection" msgid="4094707964259463039">"請稍候..."</string>
- <string name="set_image" msgid="2331476809308010401">"將相片設為"</string>
- <string name="wallpaper" msgid="9222901738515471972">"設定桌布中,請稍候…"</string>
- <string name="camera_setas_wallpaper" msgid="797463183863414289">"桌布"</string>
- <string name="details_ok" msgid="6848594369924424312">"確定"</string>
- <string name="loading_new" msgid="7893793767294787579">"正在載入新相簿和相片"</string>
- <string name="initializing" msgid="2374228157398540466">"載入中"</string>
- <string name="pick_prompt" msgid="576608096149718121">"從圖片集中挑選一個項目"</string>
- <string name="no_items" msgid="3117870234034732172">"您的圖片集裡並沒有任何項目"</string>
- <string name="pick" msgid="7248789132035843128">"挑選"</string>
- <string name="delete" msgid="2839695998251824487">"刪除"</string>
- <string name="confirm_delete" msgid="5731757674837098707">"確認刪除"</string>
- <string name="cancel" msgid="3637516880917356226">"取消"</string>
- <string name="share" msgid="3619042788254195341">"分享"</string>
- <string name="no_sd_card" msgid="2666880203366429182">"已取出或未插入 SD 卡"</string>
- <string name="more" msgid="1526449516720792387">"更多"</string>
- <string name="select_all" msgid="8623593677101437957">"全選"</string>
- <string name="deselect_all" msgid="7397531298370285581">"取消選取全部"</string>
- <string name="slideshow" msgid="4355906903247112975">"投影播放"</string>
- <string name="menu" msgid="1819649153380636719">"選單"</string>
- <string name="details" msgid="8415120088556445230">"詳細資料"</string>
- <string name="album_selected" msgid="3441280740465738452">"本相簿已選取"</string>
- <string name="item_selected" msgid="6137767503817908841">"個項目已選取"</string>
- <string name="albums_selected" msgid="1815225920157190983">"本相簿已選取"</string>
- <string name="items_selected" msgid="8548754404879264861">"個項目已選取"</string>
- <string name="album" msgid="5198388817734336004">"相簿"</string>
- <string name="start" msgid="4316892252528232165">"開始"</string>
- <string name="end" msgid="3645506196012005500">"結束"</string>
- <string name="location" msgid="3432705876921618314">"地點"</string>
- <string name="location_unknown" msgid="6310139243003315255">"未知地點"</string>
- <string name="title" msgid="7622928349908052569">"標題"</string>
- <string name="type" msgid="4329478642546287192">"類型"</string>
- <string name="taken_on" msgid="3269486910757192479">"拍攝時間"</string>
- <string name="added_on" msgid="5194321063173381814">"新增日期:"</string>
- <string name="show_on_map" msgid="6157544221201750980">"在地圖上顯示"</string>
- <string name="rotate_left" msgid="7412075232752726934">"向左旋轉"</string>
- <string name="rotate_right" msgid="7340681085011826618">"向右旋轉"</string>
- <string name="crop" msgid="7970750655414797277">"裁剪"</string>
- <string name="set_as" msgid="3636764710790507868">"設為"</string>
- <string name="set_as_wallpaper" msgid="5704970402417438945">"設為桌布"</string>
- <string name="item" msgid="636303673288563698">"個項目"</string>
- <string name="items" msgid="6403254716052150916">"個項目"</string>
- <string name="around" msgid="2223906282110417412">"靠近"</string>
- <string name="date_unknown" msgid="4277113471036917386">"未知日期"</string>
- <string name="video_err" msgid="7917736494827857757">"無法播放影片"</string>
-</resources>
diff --git a/new3d/res/values/strings.xml b/new3d/res/values/strings.xml
deleted file mode 100644
index e6169bc..0000000
--- a/new3d/res/values/strings.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <string name="app_name">Gallery</string>
- <string-array name="months_abbreviated">
- <item>Jan</item>
- <item>Feb</item>
- <item>Mar</item>
- <item>Apr</item>
- <item>May</item>
- <item>Jun</item>
- <item>Jul</item>
- <item>Aug</item>
- <item>Sep</item>
- <item>Oct</item>
- <item>Nov</item>
- <item>Dec</item>
- </string-array>
- <!-- Title for picture frame gadget to show in list of all available gadgets -->
- <string name="gadget_title">Picture frame</string>
-
- <!-- Used to format short video duration in Details dialog. minutes:seconds e.g. 00:30 -->
- <string name="details_ms">%1$02d:%2$02d</string>
- <!-- Used to format video duration in Details dialog. hours:minutes:seconds e.g. 0:21:30 -->
- <string name="details_hms">%1$d:%2$02d:%3$02d</string>
- <!-- Activity label. This might show up in the activity-picker -->
- <string name="movie_view_label">Movies</string>
- <!-- shown in the video player view while the video is being loaded, before it starts playing -->
- <string name="loading_video">Loading video\u2026</string>
- <!-- Movie View Resume Playing dialog title -->
- <string name="resume_playing_title">Resume video</string>
-
- <!-- Movie View Start Playing dialog title -->
- <string name="resume_playing_message">Resume playing from %s ?</string>
- <!-- Movie View Start Playing button "Resume from bookmark" -->
- <string name="resume_playing_resume">Resume playing</string>
-
- <!-- Movie View Start Playing button "Beginning" -->
- <string name="resume_playing_restart">Start over</string>
- <string name="camera">Camera</string>
-
- <!-- Button indicating that the cropped image should be saved -->
- <string name="crop_save_text">Save</string>
- <!-- Button indicating that the cropped image should be reverted back to the original -->
- <string name="crop_discard_text">Discard</string>
- <!-- Hint that appears when cropping an image with more than one face -->
- <string name="multiface_crop_help">Tap a face to begin.</string>
- <!-- Toast/alert that the image is being saved to the SD card -->
- <string name="saving_image">Saving picture\u2026</string>
- <!-- menu pick: crop the currently selected image -->
- <string name="crop_label">Crop picture</string>
- <!-- Toast/alert that the face detection is being run -->
- <string name="running_face_detection">Please wait\u2026</string>
-
- <!-- Displayed in the title of the dialog for things to do with a picture
- that is to be "set as" (e.g. set as contact photo or set as wallpaper) -->
- <string name="set_image">Set picture as</string>
- <!-- Toast/alert after saving wallpaper -->
- <string name="wallpaper">Setting wallpaper, please wait\u2026</string>
- <string name="camera_setas_wallpaper">Wallpaper</string>
-
- <!-- Details dialog "OK" button. Dismisses dialog. -->
- <string name="details_ok">OK</string>
- <string name="loading_new">Loading new albums and photos</string>
- <string name="initializing">Loading</string>
- <string name="pick_prompt">Pick an item from your collection</string>
- <string name="no_items">There are no items in your collection</string>
- <string name="pick">Pick</string>
- <string name="delete">Delete</string>
- <string name="confirm_delete">Confirm Delete</string>
- <string name="cancel">Cancel</string>
- <string name="share">Share</string>
- <string name="no_sd_card">SD Card unmounted or not present</string>
-
- <!-- String indicating more actions are available -->
- <string name="more">More</string>
- <string name="select_all">Select All</string>
- <string name="deselect_all">Deselect All</string>
- <string name="slideshow">Slideshow</string>
-
- <string name="menu">Menu</string>
- <string name="details">Details</string>
-
- <!-- String appended at the end depending upon what is selected eg. 1 album selected -->
- <string name="album_selected">album selected</string>
- <string name="item_selected">item selected</string>
- <string name="albums_selected">albums selected</string>
- <string name="items_selected">items selected</string>
-
- <string name="album">Album</string>
- <string name="start">Start</string>
- <string name="end">End</string>
- <string name="location">Location</string>
- <string name="location_unknown">Unknown location</string>
- <string name="title">Title</string>
- <string name="type">Type</string>
-
- <!-- String indicating timestamp of photo or video -->
- <string name="taken_on">Taken on</string>
- <string name="added_on">Added on</string>
- <string name="show_on_map">Show on map</string>
- <string name="rotate_left">Rotate Left</string>
- <string name="rotate_right">Rotate Right</string>
- <string name="crop">Crop</string>
- <string name="set_as">Set as</string>
- <string name="set_as_wallpaper">Set as wallpaper</string>
- <string name="item">item</string>
- <string name="items">items</string>
-
- <!-- String indicating an approximate location eg. Around Palo Alto, CA -->
- <string name="around">Around</string>
- <string name="date_unknown">Date unknown</string>
- <string name="video_err">Unable to play video</string>
-</resources>
diff --git a/new3d/res/xml/appwidget_info.xml b/new3d/res/xml/appwidget_info.xml
deleted file mode 100644
index 60c3586..0000000
--- a/new3d/res/xml/appwidget_info.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
- android:minWidth="146dip"
- android:minHeight="146dip"
- android:updatePeriodMillis="0"
- android:initialLayout="@layout/photo_frame"
- android:configure="com.android.gallery3d.gadget.PhotoAppWidgetConfigure"/>
diff --git a/new3d/res/xml/syncadapter.xml b/new3d/res/xml/syncadapter.xml
deleted file mode 100644
index d60bd5a..0000000
--- a/new3d/res/xml/syncadapter.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/**
- * Copyright (c) 2009, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-
-<!-- The attributes in this XML file provide configuration information -->
-<!-- for the SyncAdapter. -->
-
-<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
- android:contentAuthority="com.android.gallery3d.picasa.contentprovider"
- android:accountType="com.google"
-/>
diff --git a/new3d/src/com/android/gallery3d/anim/AlphaAnimation.java b/new3d/src/com/android/gallery3d/anim/AlphaAnimation.java
deleted file mode 100644
index f88b8bb..0000000
--- a/new3d/src/com/android/gallery3d/anim/AlphaAnimation.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-
-package com.android.gallery3d.anim;
-
-import com.android.gallery3d.ui.GLCanvas;
-import com.android.gallery3d.util.Utils;
-
-public class AlphaAnimation extends CanvasAnimation {
- private final float mStartAlpha;
- private final float mEndAlpha;
- private float mCurrentAlpha;
-
- public AlphaAnimation(float from, float to) {
- mStartAlpha = from;
- mEndAlpha = to;
- mCurrentAlpha = from;
- }
-
- @Override
- public void apply(GLCanvas canvas) {
- canvas.multiplyAlpha(mCurrentAlpha);
- }
-
- @Override
- public int getCanvasSaveFlags() {
- return GLCanvas.SAVE_FLAG_ALPHA;
- }
-
- @Override
- protected void onCalculate(float progress) {
- mCurrentAlpha = Utils.clamp(mStartAlpha
- + (mEndAlpha - mStartAlpha) * progress, 0f, 1f);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/anim/Animation.java b/new3d/src/com/android/gallery3d/anim/Animation.java
deleted file mode 100644
index a614971..0000000
--- a/new3d/src/com/android/gallery3d/anim/Animation.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.android.gallery3d.anim;
-
-import android.view.animation.Interpolator;
-
-import com.android.gallery3d.util.Utils;
-
-// Animation calculates a value according to the current input time.
-//
-// 1. First we need to use setDuration(int) to set the duration of the
-// animation. The duration is in milliseconds.
-// 2. Then we should call start(). The actual start time is the first value
-// passed to calculate(long).
-// 3. Each time we want to get an animation value, we call
-// calculate(long currentTimeMillis) to ask the Animation to calculate it.
-// The parameter passed to calculate(long) should be nonnegative.
-// 4. Use get() to get that value.
-//
-// In step 3, onCalculate(float progress) is called so subclasses can calculate
-// the value according to progress (progress is a value in [0,1]).
-//
-// Before onCalculate(float) is called, There is an optional interpolator which
-// can change the progress value. The interpolator can be set by
-// setInterpolator(Interpolator). If the interpolator is used, the value passed
-// to onCalculate may be (for example, the overshoot effect).
-//
-// The isActive() method returns true after the animation start() is called and
-// before calculate is passed a value which reaches the duration of the
-// animation.
-//
-// The start() method can be called again to restart the Animation.
-//
-abstract public class Animation {
- private static final long ANIMATION_START = -1;
- private static final long NO_ANIMATION = -2;
-
- private long mStartTime = NO_ANIMATION;
- private int mDuration;
- private Interpolator mInterpolator;
-
- public void setInterpolator(Interpolator interpolator) {
- mInterpolator = interpolator;
- }
-
- public void setDuration(int duration) {
- mDuration = duration;
- }
-
- public void start() {
- mStartTime = ANIMATION_START;
- }
-
- public void setStartTime(long time) {
- mStartTime = time;
- }
-
- public boolean isActive() {
- return mStartTime != NO_ANIMATION;
- }
-
- public boolean calculate(long currentTimeMillis) {
- if (mStartTime == NO_ANIMATION) return false;
- if (mStartTime == ANIMATION_START) mStartTime = currentTimeMillis;
- int elapse = (int) (currentTimeMillis - mStartTime);
- float x = Utils.clamp((float) elapse / mDuration, 0f, 1f);
- onCalculate(mInterpolator != null
- ? mInterpolator.getInterpolation(x)
- : x);
- if (elapse >= mDuration) {
- mStartTime = NO_ANIMATION;
- return false;
- } else {
- return true;
- }
- }
-
- abstract protected void onCalculate(float progress);
-}
diff --git a/new3d/src/com/android/gallery3d/anim/AnimationSet.java b/new3d/src/com/android/gallery3d/anim/AnimationSet.java
deleted file mode 100644
index c83efaa..0000000
--- a/new3d/src/com/android/gallery3d/anim/AnimationSet.java
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-
-package com.android.gallery3d.anim;
-
-import com.android.gallery3d.ui.GLCanvas;
-
-import java.util.ArrayList;
-
-public class AnimationSet extends CanvasAnimation {
-
- private final ArrayList<CanvasAnimation> mAnimations =
- new ArrayList<CanvasAnimation>();
- private int mSaveFlags = 0;
-
-
- public void addAnimation(CanvasAnimation anim) {
- mAnimations.add(anim);
- mSaveFlags |= anim.getCanvasSaveFlags();
- }
-
- @Override
- public void apply(GLCanvas canvas) {
- for (int i = 0, n = mAnimations.size(); i < n; i++) {
- mAnimations.get(i).apply(canvas);
- }
- }
-
- @Override
- public int getCanvasSaveFlags() {
- return mSaveFlags;
- }
-
- @Override
- protected void onCalculate(float progress) {
- // DO NOTHING
- }
-
- @Override
- public boolean calculate(long currentTimeMillis) {
- boolean more = false;
- for (CanvasAnimation anim : mAnimations) {
- more |= anim.calculate(currentTimeMillis);
- }
- return more;
- }
-
- @Override
- public void start() {
- for (CanvasAnimation anim : mAnimations) {
- anim.start();
- }
- }
-
- @Override
- public boolean isActive() {
- for (CanvasAnimation anim : mAnimations) {
- if (anim.isActive()) return true;
- }
- return false;
- }
-
-}
diff --git a/new3d/src/com/android/gallery3d/anim/CanvasAnimation.java b/new3d/src/com/android/gallery3d/anim/CanvasAnimation.java
deleted file mode 100644
index de24ae4..0000000
--- a/new3d/src/com/android/gallery3d/anim/CanvasAnimation.java
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-
-package com.android.gallery3d.anim;
-
-import com.android.gallery3d.ui.GLCanvas;
-
-public abstract class CanvasAnimation extends Animation {
-
- public abstract int getCanvasSaveFlags();
- public abstract void apply(GLCanvas canvas);
-}
diff --git a/new3d/src/com/android/gallery3d/anim/FloatAnimation.java b/new3d/src/com/android/gallery3d/anim/FloatAnimation.java
deleted file mode 100644
index ef177c9..0000000
--- a/new3d/src/com/android/gallery3d/anim/FloatAnimation.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.android.gallery3d.anim;
-
-public class FloatAnimation extends Animation {
-
- private final float mFrom;
- private final float mTo;
- private float mCurrent;
-
- public FloatAnimation(float from, float to, int duration) {
- mFrom = from;
- mTo = to;
- mCurrent = from;
- setDuration(duration);
- }
-
- @Override
- protected void onCalculate(float progress) {
- mCurrent = mFrom + (mTo - mFrom) * progress;
- }
-
- public float get() {
- return mCurrent;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/anim/IntAnimation.java b/new3d/src/com/android/gallery3d/anim/IntAnimation.java
deleted file mode 100644
index 9bdd5fe..0000000
--- a/new3d/src/com/android/gallery3d/anim/IntAnimation.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.android.gallery3d.anim;
-
-public class IntAnimation extends Animation {
-
- private final int mFrom;
- private final int mTo;
- private int mCurrent;
-
- public IntAnimation(int from, int to, int duration) {
- mFrom = from;
- mTo = to;
- setDuration(duration);
- }
-
- @Override
- protected void onCalculate(float progress) {
- mCurrent = mFrom + (int)((mTo - mFrom) * progress + .5f);
- }
-
- public int get() {
- return mCurrent;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/anim/ScaleAnimation.java b/new3d/src/com/android/gallery3d/anim/ScaleAnimation.java
deleted file mode 100644
index f065cf7..0000000
--- a/new3d/src/com/android/gallery3d/anim/ScaleAnimation.java
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-
-package com.android.gallery3d.anim;
-
-import com.android.gallery3d.ui.GLCanvas;
-
-public class ScaleAnimation extends CanvasAnimation {
- private final float mFromX;
- private final float mFromY;
- private final float mFromZ;
- private final float mToX;
- private final float mToY;
- private final float mToZ;
-
- private float mCurrentX;
- private float mCurrentY;
- private float mCurrentZ;
-
- private final float mPivotX;
- private final float mPivotY;
- private final float mPivotZ;
-
- public ScaleAnimation(float fromX, float toX,
- float fromY, float toY, float pivotX, float pivotY) {
- this(fromX, toX, fromY, toY, 0, 0, pivotX, pivotY, 0);
- }
-
- public ScaleAnimation(float fromX, float toX, float fromY, float toY,
- float fromZ, float toZ, float px, float py, float pz) {
- mFromX = fromX;
- mFromY = fromY;
- mFromZ = fromZ;
- mToX = toX;
- mToY = toY;
- mToZ = toZ;
- mPivotX = px;
- mPivotY = py;
- mPivotZ = pz;
- }
-
- @Override
- public void apply(GLCanvas canvas) {
- if (mPivotX != 0 || mPivotY != 0 || mPivotZ != 0) {
- canvas.translate(mPivotX, mPivotY, mPivotZ);
- canvas.scale(mCurrentX, mCurrentY, mCurrentZ);
- canvas.translate(-mPivotX, -mPivotY, -mPivotZ);
- } else {
- canvas.scale(mCurrentX, mCurrentY, mCurrentZ);
- }
- }
-
- @Override
- public int getCanvasSaveFlags() {
- return GLCanvas.SAVE_FLAG_MATRIX;
- }
-
- @Override
- protected void onCalculate(float progress) {
- mCurrentX = mFromX + (mToX - mFromX) * progress;
- mCurrentY = mFromY + (mToY - mFromY) * progress;
- mCurrentZ = mFromZ + (mToZ - mFromZ) * progress;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/ActivityState.java b/new3d/src/com/android/gallery3d/app/ActivityState.java
deleted file mode 100644
index b35d637..0000000
--- a/new3d/src/com/android/gallery3d/app/ActivityState.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.os.Bundle;
-
-import com.android.gallery3d.ui.GLView;
-
-abstract public class ActivityState {
- protected GalleryContext mContext;
-
- protected ActivityState() {
- }
-
- protected void setContentPane(GLView content) {
- mContext.getGLRoot().setContentPane(content);
- }
-
- void setContext(GalleryContext context) {
- mContext = context;
- }
-
- protected void onBackPressed() {
- mContext.getStateManager().finishState(this);
- }
-
- protected void onSaveState(Bundle outState) {
- }
-
- protected void onCreate(Bundle data, Bundle storedState){}
-
- protected void onPause() {}
-
- protected void onResume() {}
-
- protected void onDestroy() {}
-}
diff --git a/new3d/src/com/android/gallery3d/app/AlbumDataAdapter.java b/new3d/src/com/android/gallery3d/app/AlbumDataAdapter.java
deleted file mode 100644
index 9417c08..0000000
--- a/new3d/src/com/android/gallery3d/app/AlbumDataAdapter.java
+++ /dev/null
@@ -1,243 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-
-package com.android.gallery3d.app;
-
-import android.os.Handler;
-import android.os.Message;
-
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.data.MediaSet;
-import com.android.gallery3d.ui.AlbumView;
-import com.android.gallery3d.ui.SynchronizedHandler;
-import com.android.gallery3d.util.Utils;
-
-import java.util.ArrayList;
-
-public class AlbumDataAdapter implements AlbumView.Model {
- private static final String TAG = "AlbumDataAdapter";
-
- private static final long RELOAD_DELAY = 100; // 100ms
-
- private static final int MSG_UPDATE_DATA = 1;
- private static final int MSG_LOAD_DATA = 2;
-
- private static final int MIN_LOAD_COUNT = 32;
- private static final int MAX_LOAD_COUNT = 64;
-
- // Load the data because the source has been changed
- private static final int LOAD_SOURCE = 1;
- // Load the size for initial content
- private static final int LOAD_SIZE = 2;
- // Load the data for new content range
- private static final int LOAD_RANGE = 4;
-
- private final MediaItem[] mData;
-
- private int mActiveStart;
- private int mActiveEnd;
-
- private int mContentStart;
- private int mContentEnd;
-
- private final MediaSet mSource;
- private final Handler mMainHandler;
- private final Handler mDataHandler;
- private int mSize = 0;
-
- private AlbumView.ModelListener mListener;
-
- public AlbumDataAdapter(GalleryContext context, MediaSet albumSet, int cacheSize) {
- albumSet.setContentListener(new MySourceListener());
-
- mSource = albumSet;
- mData = new MediaItem[cacheSize];
-
- mDataHandler = new Handler(context.getDataManager().getDataLooper()) {
- @Override
- public void handleMessage(Message message) {
- Utils.Assert(message.what == MSG_LOAD_DATA);
- ((ReloadTask) message.obj).loadFromDatabase();
- }
- };
-
- mMainHandler = new SynchronizedHandler(context.getGLRoot()) {
- @Override
- public void handleMessage(Message message) {
- Utils.Assert(message.what == MSG_UPDATE_DATA);
- ((ReloadTask) message.obj).updateContent();
- }
- };
-
- reloadData(LOAD_SIZE, 0, 0, 0);
- }
-
- public MediaItem get(int index) {
- if (!isActive(index)) {
- throw new IllegalArgumentException(String.format(
- "%s not in (%s, %s)", index, mActiveStart, mActiveEnd));
- }
- return mData[index % mData.length];
- }
-
- public boolean isActive(int index) {
- return index >= mActiveStart && index < mActiveEnd;
- }
-
- public int size() {
- return mSize;
- }
-
- private void setContentWindow(int contentStart, int contentEnd) {
- if (contentStart == mContentStart && contentEnd == mContentEnd) return;
- MediaItem[] data = mData;
- int length = data.length;
- if (contentStart >= mContentEnd || mContentStart >= contentEnd) {
- for (int i = mContentStart, n = mContentEnd; i < n; ++i) {
- data[i % length] = null;
- }
- reloadData(LOAD_RANGE, contentStart, contentEnd, 0);
- } else {
- for (int i = mContentStart; i < contentStart; ++i) {
- data[i % length] = null;
- }
- for (int i = contentEnd, n = mContentEnd; i < n; ++i) {
- data[i % length] = null;
- }
- reloadData(LOAD_RANGE, contentStart, mContentStart, 0);
- reloadData(LOAD_RANGE, mContentEnd, contentEnd, 0);
- }
- synchronized (this) {
- mContentStart = contentStart;
- mContentEnd = contentEnd;
- }
- }
-
- public void setActiveWindow(int start, int end) {
- if (start == mActiveStart && end == mActiveEnd) return;
-
- mActiveStart = start;
- mActiveEnd = end;
-
- Utils.Assert(start <= end
- && end - start <= mData.length && end <= mSize);
-
- int length = mData.length;
- mActiveStart = start;
- mActiveEnd = end;
-
- // If no data is visible, keep the cache content
- if (start == end) return;
-
- int contentStart = Utils.clamp((start + end) / 2 - length / 2,
- 0, Math.max(0, mSize - length));
- int contentEnd = Math.min(contentStart + length, mSize);
- if (mContentStart > start || mContentEnd < end
- || Math.abs(contentStart - mContentStart) > MIN_LOAD_COUNT) {
- setContentWindow(contentStart, contentEnd);
- }
- }
-
- private void reloadData(int loadBits, int start, int end, long delay) {
- if (start >= end) loadBits &= ~LOAD_RANGE;
- if (loadBits != 0) {
- new ReloadTask(loadBits, start, end).execute(delay);
- }
- }
-
- private class MySourceListener implements MediaSet.MediaSetListener {
- public void onContentDirty() {
- reloadData(LOAD_SOURCE, mContentStart, mContentEnd, RELOAD_DELAY);
- }
- }
-
- public void setListener(AlbumView.ModelListener listener) {
- mListener = listener;
- }
-
- // TODO: use only one ReloadTask to update content
- private class ReloadTask {
- private int mStart;
- private int mEnd;
- private int mLoadBits;
- private int mUpdateSize = -1;
- private ArrayList<MediaItem> mUpdateItems;
-
- public ReloadTask(int loadBits, int start, int end) {
- mStart = start;
- mEnd = end;
- mLoadBits = loadBits;
- }
-
- public void execute(long delayed) {
- mDataHandler.sendMessageDelayed(
- mDataHandler.obtainMessage(MSG_LOAD_DATA, this), delayed);
- }
-
- public void loadFromDatabase() {
- int loadBits = mLoadBits;
-
- if ((loadBits & LOAD_SOURCE) != 0) {
- if (!mSource.reload()) loadBits &= ~LOAD_SOURCE;
- }
-
- if ((loadBits & (LOAD_SOURCE | LOAD_SIZE)) != 0) {
- mUpdateSize = mSource.getMediaItemCount();
- }
-
- if ((loadBits & LOAD_RANGE) != 0) {
- synchronized (AlbumDataAdapter.this) {
- mStart = Math.max(mContentStart, mStart);
- mEnd = Math.min(mContentEnd, mEnd);
- }
-
- int count = Math.min(MAX_LOAD_COUNT, mEnd - mStart);
- if (count > 0) {
- mUpdateItems = mSource.getMediaItem(mStart, count);
- } else {
- loadBits &= ~LOAD_RANGE;
- mUpdateItems = null;
- }
- }
-
- if (loadBits != 0) {
- mMainHandler.sendMessage(
- mMainHandler.obtainMessage(MSG_UPDATE_DATA, this));
- }
- }
-
- public void updateContent() {
- if (mUpdateSize >= 0 && mSize != mUpdateSize) {
- mSize = mUpdateSize;
- if (mListener != null) mListener.onSizeChanged(mSize);
- }
- if (mUpdateItems == null) return;
-
- int start = Math.max(mStart, mContentStart);
- int end = Math.min(mStart + mUpdateItems.size(), mContentEnd);
- MediaItem data[] = mData;
- int size = data.length;
- int dataIndex = start % size;
- for (int i = start; i < end; ++i) {
- MediaItem updateItem = mUpdateItems.get(i - mStart);
- MediaItem original = data[dataIndex];
- // TODO: we should implement equals() for MediaItem
- // to see if the item has been changed.
- if (original != updateItem) {
- data[dataIndex] = updateItem;
- if (mListener != null && i >= mActiveStart && i < mActiveEnd) {
- mListener.onWindowContentChanged(i, original, updateItem);
- }
- }
- if (++dataIndex == size) dataIndex = 0;
- }
-
- mStart = Math.max(mContentStart, mStart + mUpdateItems.size());
- mEnd = Math.min(mEnd, mContentEnd);
- if (mStart < mEnd && mUpdateItems.size() == MAX_LOAD_COUNT) {
- mLoadBits &= ~(LOAD_SOURCE | LOAD_SIZE);
- mDataHandler.sendMessage(
- mDataHandler.obtainMessage(MSG_LOAD_DATA, this));
- }
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/AlbumPage.java b/new3d/src/com/android/gallery3d/app/AlbumPage.java
deleted file mode 100644
index 7285cdc..0000000
--- a/new3d/src/com/android/gallery3d/app/AlbumPage.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.Bundle;
-import android.os.Message;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.data.MediaSet;
-import com.android.gallery3d.ui.AdaptiveBackground;
-import com.android.gallery3d.ui.AlbumView;
-import com.android.gallery3d.ui.GLView;
-import com.android.gallery3d.ui.HeadUpDisplay;
-import com.android.gallery3d.ui.HudMenu;
-import com.android.gallery3d.ui.SelectionManager;
-import com.android.gallery3d.ui.SlotView;
-import com.android.gallery3d.ui.SynchronizedHandler;
-
-public class AlbumPage extends ActivityState implements SlotView.SlotTapListener {
- public static final String KEY_BUCKET_INDEX = "keyBucketIndex";
-
- private static final int CHANGE_BACKGROUND = 1;
- private static final int MARGIN_HUD_SLOTVIEW = 5;
- private static final int DATA_CACHE_SIZE = 256;
-
- private AdaptiveBackground mBackground;
- private AlbumView mAlbumView;
- private HudMenu mHudMenu;
- private HeadUpDisplay mHud;
- private SynchronizedHandler mHandler;
- private Bitmap mBgImages[];
- private int mBgIndex = 0;
- private int mBucketIndex;
- private AlbumDataAdapter mAlbumDataAdapter;
-
- protected SelectionManager mSelectionManager;
-
- private GLView mRootPane = new GLView() {
- @Override
- protected void onLayout(
- boolean changed, int left, int top, int right, int bottom) {
- mBackground.layout(0, 0, right - left, bottom - top);
- mHud.layout(0, 0, right - left, bottom - top);
-
- int slotViewTop = mHud.getTopBarBottomPosition() + MARGIN_HUD_SLOTVIEW;
- int slotViewBottom = mHud.getBottomBarTopPosition()
- - MARGIN_HUD_SLOTVIEW;
- mAlbumView.layout(0, slotViewTop, right - left, slotViewBottom);
- }
- };
-
- @Override
- public void onBackPressed() {
- if (mSelectionManager.inSelectionMode()) {
- mSelectionManager.leaveSelectionMode();
- } else {
- super.onBackPressed();
- }
- }
-
- public void onSingleTapUp(int slotIndex) {
- if (!mSelectionManager.inSelectionMode()) {
- Bundle data = new Bundle();
- data.putInt(PhotoPage.KEY_SET_INDEX, mBucketIndex);
- data.putInt(PhotoPage.KEY_PHOTO_INDEX, slotIndex);
-
- mContext.getStateManager().startState(PhotoPage.class, data);
- } else {
- long id = mAlbumDataAdapter.get(slotIndex).getUniqueId();
- mSelectionManager.toggle(id);
- mAlbumView.invalidate();
- }
- }
-
- public void onLongTap(int slotIndex) {
- long id = mAlbumDataAdapter.get(slotIndex).getUniqueId();
- mSelectionManager.toggle(id);
- mAlbumView.invalidate();
- }
-
- @Override
- public void onCreate(Bundle data, Bundle restoreState) {
- initializeViews();
- intializeData(data);
-
- mHandler = new SynchronizedHandler(mContext.getGLRoot()) {
- @Override
- public void handleMessage(Message message) {
- switch (message.what) {
- case CHANGE_BACKGROUND:
- changeBackground();
- mHandler.sendEmptyMessageDelayed(
- CHANGE_BACKGROUND, 3000);
- break;
- }
- }
- };
- }
-
- @Override
- public void onPause() {
- mHandler.removeMessages(CHANGE_BACKGROUND);
- mHudMenu.onPause();
- }
-
- private void initializeViews() {
- mBackground = new AdaptiveBackground();
- mRootPane.addComponent(mBackground);
-
- mSelectionManager = new SelectionManager(mContext, false);
- mAlbumView = new AlbumView(mContext, mSelectionManager);
- mRootPane.addComponent(mAlbumView);
- mHud = new HeadUpDisplay(mContext.getAndroidContext());
- mHudMenu = new HudMenu(mContext, mSelectionManager);
- mHud.setMenu(mHudMenu);
- mRootPane.addComponent(mHud);
- mAlbumView.setSlotTapListener(this);
-
- loadBackgroundBitmap(R.drawable.square,
- R.drawable.potrait, R.drawable.landscape);
- mBackground.setImage(mBgImages[mBgIndex]);
- }
-
- private void intializeData(Bundle data) {
- mBucketIndex = data.getInt(KEY_BUCKET_INDEX);
- MediaSet mediaSet = mContext.getDataManager()
- .getRootSet().getSubMediaSet(mBucketIndex);
- mSelectionManager.setSourceMediaSet(mediaSet);
- mAlbumDataAdapter =
- new AlbumDataAdapter(mContext, mediaSet, DATA_CACHE_SIZE);
- mAlbumView.setModel(mAlbumDataAdapter);
- }
-
- private void changeBackground() {
- mBackground.setImage(mBgImages[mBgIndex]);
- if (++mBgIndex == mBgImages.length) mBgIndex = 0;
- }
-
- private void loadBackgroundBitmap(int ... ids) {
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.RGB_565;
- mBgImages = new Bitmap[ids.length];
- Resources res = mContext.getResources();
- for (int i = 0, n = ids.length; i < n; ++i) {
- Bitmap bitmap = BitmapFactory.decodeResource(res, ids[i], options);
- mBgImages[i] = mBackground.getAdaptiveBitmap(bitmap);
- bitmap.recycle();
- }
- }
-
- @Override
- public void onResume() {
- mHandler.sendEmptyMessage(CHANGE_BACKGROUND);
- setContentPane(mRootPane);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/AlbumSetDataAdapter.java b/new3d/src/com/android/gallery3d/app/AlbumSetDataAdapter.java
deleted file mode 100644
index 9493469..0000000
--- a/new3d/src/com/android/gallery3d/app/AlbumSetDataAdapter.java
+++ /dev/null
@@ -1,236 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-
-package com.android.gallery3d.app;
-
-import android.os.Handler;
-import android.os.Message;
-
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.data.MediaSet;
-import com.android.gallery3d.ui.AlbumSetView;
-import com.android.gallery3d.ui.SynchronizedHandler;
-import com.android.gallery3d.util.Utils;
-
-import java.util.ArrayList;
-
-public class AlbumSetDataAdapter implements AlbumSetView.Model {
- private static final String TAG = "AlbumSetDataAdapter";
-
- private static final long RELOAD_DELAY = 100; // 100ms
-
- private static final int MIN_LOAD_COUNT = 4;
- private static final int MAX_COVER_COUNT = 4;
-
- // Load the data because the source has been changed
- private static final int LOAD_SOURCE = 1;
- // Load the initial content
- private static final int LOAD_SIZE = 2;
- // Load the data for new content range
- private static final int LOAD_RANGE = 4;
-
- private static final int MSG_UPDATE_CONTENT = 1;
- private static final int MSG_LOAD_CONTENT = 2;
-
- private static final MediaItem[] EMPTY_MEDIA_ITEMS = new MediaItem[0];
-
- private final MediaItem[][] mData;
-
- private int mActiveStart;
- private int mActiveEnd;
-
- private int mContentStart;
- private int mContentEnd;
-
- private final MediaSet mSource;
- private int mSize;
-
- private AlbumSetView.ModelListener mListener;
-
- private Handler mMainHandler;
- private Handler mDataHandler;
-
- public AlbumSetDataAdapter(GalleryContext context, MediaSet albumSet, int cacheSize) {
- albumSet.setContentListener(new MySourceListener());
-
- mSource = albumSet;
- mData = new MediaItem[cacheSize][];
-
- mMainHandler = new SynchronizedHandler(context.getGLRoot()) {
- @Override
- public void handleMessage(Message message) {
- Utils.Assert(message.what == MSG_UPDATE_CONTENT);
- ((ReloadTask) message.obj).updateContent();
- }
- };
-
- mDataHandler = new Handler(context.getDataManager().getDataLooper()) {
- @Override
- public void handleMessage(Message message) {
- Utils.Assert(message.what == MSG_LOAD_CONTENT);
- ((ReloadTask) message.obj).loadFromDatabase();
- }
- };
-
- reloadData(LOAD_SIZE, 0, 0, 0);
- }
-
- public MediaSet getMediaSet(int index) {
- return mSource.getSubMediaSet(index);
- }
-
- public MediaItem[] getMediaItems(int index) {
- if (index < mActiveStart && index >= mActiveEnd) {
- throw new IllegalArgumentException(String.format(
- "%s not in (%s, %s)", index, mActiveStart, mActiveEnd));
- }
- MediaItem[] result = mData[index % mData.length];
-
- // If the result is not ready yet, return an empty array
- return result == null ? EMPTY_MEDIA_ITEMS : result;
- }
-
- public int size() {
- return mSize;
- }
-
- private void setContentWindow(int contentStart, int contentEnd) {
- if (contentStart == mContentStart && contentEnd == mContentEnd) return;
- MediaItem[][] data = mData;
- int length = data.length;
- if (contentStart >= mContentEnd || mContentStart >= contentEnd) {
- for (int i = mContentStart, n = mContentEnd; i < n; ++i) {
- mData[i % length] = null;
- }
- reloadData(LOAD_RANGE, contentStart, contentEnd, 0);
- } else {
- for (int i = mContentStart; i < contentStart; ++i) {
- mData[i % length] = null;
- }
- for (int i = contentEnd, n = mContentEnd; i < n; ++i) {
- mData[i % length] = null;
- }
- reloadData(LOAD_RANGE, contentStart, mContentStart, 0);
- reloadData(LOAD_RANGE, mContentEnd, contentEnd, 0);
- }
- mContentStart = contentStart;
- mContentEnd = contentEnd;
- }
-
- private void reloadData(int loadBits, int start, int end, long delay) {
- if (start >= end) loadBits &= ~LOAD_RANGE;
- if (loadBits != 0) {
- new ReloadTask(loadBits, start, end).execute(delay);
- }
- }
-
- public void setActiveWindow(int start, int end) {
- if (start == mActiveStart && end == mActiveEnd) return;
-
- mActiveStart = start;
- mActiveEnd = end;
-
- Utils.Assert(start <= end
- && end - start <= mData.length && end <= mSize);
-
- int length = mData.length;
- mActiveStart = start;
- mActiveEnd = end;
-
- // If no data is visible, keep the cache content
- if (start == end) return;
-
- int contentStart = Utils.clamp((start + end) / 2 - length / 2,
- 0, Math.max(0, mSize - length));
- int contentEnd = Math.min(contentStart + length, mSize);
- if (mContentStart > start || mContentEnd < end
- || Math.abs(contentStart - mContentStart) > MIN_LOAD_COUNT) {
- setContentWindow(contentStart, contentEnd);
- }
- }
-
- private class MySourceListener implements MediaSet.MediaSetListener {
- public void onContentDirty() {
- reloadData(LOAD_SOURCE, mContentStart, mContentEnd, RELOAD_DELAY);
- }
- }
-
- public void setListener(AlbumSetView.ModelListener listener) {
- mListener = listener;
- }
-
- // TODO: using only one task to update the content
- private class ReloadTask {
- private int mStart;
- private int mEnd;
- private final int mLoadBits;
-
- private MediaItem[] mLoadData = null;
- private int mUpdateSize = -1;
-
- public ReloadTask(int loadBits, int start, int end) {
- mStart = start;
- mEnd = end;
- mLoadBits = loadBits;
- }
-
- public void execute(long delay) {
- mDataHandler.sendMessageDelayed(
- mDataHandler.obtainMessage(MSG_LOAD_CONTENT, this), delay);
- }
-
- public void loadFromDatabase() {
- int loadBits = mLoadBits;
- mLoadData = null;
-
- if ((loadBits & LOAD_SOURCE) != 0) {
- if (!mSource.reload()) loadBits &= ~LOAD_SOURCE;
- }
-
- if ((loadBits & (LOAD_SOURCE | LOAD_SIZE)) != 0) {
- mUpdateSize = mSource.getSubMediaSetCount();
- }
-
- if ((loadBits & LOAD_RANGE) != 0) {
- int size = mSource.getSubMediaSetCount();
- MediaSet subset = mSource.getSubMediaSet(mStart);
- if (subset != null) {
- ArrayList<MediaItem> items =
- subset.getMediaItem(0, MAX_COVER_COUNT);
- mLoadData = items.toArray(new MediaItem[items.size()]);
- }
- }
- if (loadBits != 0) {
- mMainHandler.sendMessage(
- mMainHandler.obtainMessage(MSG_UPDATE_CONTENT, this));
- }
- }
-
- public void updateContent() {
- if (mUpdateSize >= 0 && mUpdateSize != mSize) {
- mSize = mUpdateSize;
- if (mListener != null) mListener.onSizeChanged(mSize);
- }
- int index = mStart;
- if (mLoadData != null
- && index >= mContentStart && index < mContentEnd) {
- MediaItem[] update = mLoadData;
- MediaItem[] original = mData[index];
- // TODO: Fix it. Find a way to judge if we need to update content
- if (!update.equals(original)) {
- mData[index] = update;
- if (mListener != null
- && index >= mActiveStart && index < mActiveEnd) {
- mListener.onWindowContentChanged(index, original, update);
- }
- }
- }
- mStart = index + 1;
- mStart = Math.max(mContentStart, mStart);
- mEnd = Math.min(mContentEnd, mEnd);
- if (mStart < mEnd) {
- mDataHandler.sendMessage(
- mDataHandler.obtainMessage(MSG_LOAD_CONTENT, this));
- }
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/AlbumSetPage.java b/new3d/src/com/android/gallery3d/app/AlbumSetPage.java
deleted file mode 100644
index a1ce4ef..0000000
--- a/new3d/src/com/android/gallery3d/app/AlbumSetPage.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.Bundle;
-import android.os.Message;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.data.MediaSet;
-import com.android.gallery3d.ui.AdaptiveBackground;
-import com.android.gallery3d.ui.AlbumSetView;
-import com.android.gallery3d.ui.GLView;
-import com.android.gallery3d.ui.HudMenu;
-import com.android.gallery3d.ui.HeadUpDisplay;
-import com.android.gallery3d.ui.SelectionManager;
-import com.android.gallery3d.ui.SlotView;
-import com.android.gallery3d.ui.SynchronizedHandler;
-
-public class AlbumSetPage extends ActivityState implements SlotView.SlotTapListener {
- private static final int CHANGE_BACKGROUND = 1;
-
- private static final int MARGIN_HUD_SLOTVIEW = 5;
- private static final int DATA_CACHE_SIZE = 256;
-
- private AdaptiveBackground mBackground;
- private AlbumSetView mAlbumSetView;
- private HudMenu mHudMenu;
- private HeadUpDisplay mHud;
- private SynchronizedHandler mHandler;
-
- private Bitmap mBgImages[];
- private int mBgIndex = 0;
-
- protected SelectionManager mSelectionManager;
- private AlbumSetDataAdapter mAlbumSetDataAdapter;
-
- private GLView mRootPane = new GLView() {
- @Override
- protected void onLayout(
- boolean changed, int left, int top, int right, int bottom) {
- mBackground.layout(0, 0, right - left, bottom - top);
- mHud.layout(0, 0, right - left, bottom - top);
-
- int slotViewTop = mHud.getTopBarBottomPosition() + MARGIN_HUD_SLOTVIEW;
- int slotViewBottom = mHud.getBottomBarTopPosition()
- - MARGIN_HUD_SLOTVIEW;
-
- mAlbumSetView.layout(0, slotViewTop, right - left, slotViewBottom);
- }
- };
-
- @Override
- public void onBackPressed() {
- if (mSelectionManager.inSelectionMode()) {
- mSelectionManager.leaveSelectionMode();
- } else {
- super.onBackPressed();
- }
- }
-
- public void onSingleTapUp(int slotIndex) {
- if (!mSelectionManager.inSelectionMode()) {
- Bundle data = new Bundle();
- data.putInt(AlbumPage.KEY_BUCKET_INDEX, slotIndex);
- // uncomment the following line to test slideshow mode
- // mContext.getStateManager().startState(SlideshowPage.class, data);
- mContext.getStateManager().startState(AlbumPage.class, data);
- } else {
- long id = mAlbumSetDataAdapter.getMediaSet(slotIndex).getUniqueId();
- mSelectionManager.toggle(id);
- mAlbumSetView.invalidate();
- }
- }
-
- public void onLongTap(int slotIndex) {
- long id = mAlbumSetDataAdapter.getMediaSet(slotIndex).getUniqueId();
- mSelectionManager.toggle(id);
- mAlbumSetView.invalidate();
- }
-
- public AlbumSetPage() {}
-
- @Override
- public void onCreate(Bundle data, Bundle restoreState) {
- initializeViews();
- intializeData();
- mHandler = new SynchronizedHandler(mContext.getGLRoot()) {
- @Override
- public void handleMessage(Message message) {
- switch (message.what) {
- case CHANGE_BACKGROUND:
- changeBackground();
- mHandler.sendEmptyMessageDelayed(
- CHANGE_BACKGROUND, 3000);
- break;
- }
- }
- };
- }
-
- @Override
- public void onPause() {
- mHandler.removeMessages(CHANGE_BACKGROUND);
- mHudMenu.onPause();
- }
-
- @Override
- public void onResume() {
- setContentPane(mRootPane);
- mHandler.sendEmptyMessage(CHANGE_BACKGROUND);
- }
-
- private void intializeData() {
- MediaSet mediaSet = mContext.getDataManager().getRootSet();
- mSelectionManager.setSourceMediaSet(mediaSet);
- mAlbumSetDataAdapter = new AlbumSetDataAdapter(mContext, mediaSet, DATA_CACHE_SIZE);
- mAlbumSetView.setModel(mAlbumSetDataAdapter);
- }
-
- private void initializeViews() {
- mSelectionManager = new SelectionManager(mContext, true);
-
- mBackground = new AdaptiveBackground();
- mRootPane.addComponent(mBackground);
- mAlbumSetView = new AlbumSetView(mContext, mSelectionManager);
- mAlbumSetView.setSlotTapListener(this);
-
- mRootPane.addComponent(mAlbumSetView);
- mHud = new HeadUpDisplay(mContext.getAndroidContext());
- mHudMenu = new HudMenu(mContext, mSelectionManager);
- mHud.setMenu(mHudMenu);
- mRootPane.addComponent(mHud);
- loadBackgroundBitmap(R.drawable.square,
- R.drawable.potrait, R.drawable.landscape);
- mBackground.setImage(mBgImages[mBgIndex]);
- }
-
- public void changeBackground() {
- mBackground.setImage(mBgImages[mBgIndex]);
- if (++mBgIndex == mBgImages.length) mBgIndex = 0;
- }
-
- private void loadBackgroundBitmap(int ... ids) {
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.RGB_565;
- mBgImages = new Bitmap[ids.length];
- Resources res = mContext.getResources();
- for (int i = 0, n = ids.length; i < n; ++i) {
- Bitmap bitmap = BitmapFactory.decodeResource(res, ids[i], options);
- mBgImages[i] = mBackground.getAdaptiveBitmap(bitmap);
- bitmap.recycle();
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/Gallery.java b/new3d/src/com/android/gallery3d/app/Gallery.java
deleted file mode 100644
index 4ba3f49..0000000
--- a/new3d/src/com/android/gallery3d/app/Gallery.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.util.Log;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.data.DataManager;
-import com.android.gallery3d.data.DecodeService;
-import com.android.gallery3d.data.DownloadService;
-import com.android.gallery3d.data.ImageService;
-import com.android.gallery3d.ui.GLRoot;
-import com.android.gallery3d.ui.GLRootView;
-import com.android.gallery3d.ui.PositionRepository;
-
-public final class Gallery extends Activity implements GalleryContext {
- public static final String REVIEW_ACTION = "com.android.gallery3d.app.REVIEW";
-
- private static final String TAG = "Gallery";
- private GLRootView mGLRootView;
-
- private StateManager mStateManager;
- private ImageService mImageService;
- private DataManager mDataManager;
- private PositionRepository mPositionRepository = new PositionRepository();
- private DownloadService mDownloadService;
- private DecodeService mDecodeService;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Log.e(TAG, "Picasa Cache Path: " + this.getExternalCacheDir());
- setContentView(R.layout.main);
- mGLRootView = (GLRootView) findViewById(R.id.gl_root_view);
-
- if (savedInstanceState != null) {
- getStateManager().restoreFromState(savedInstanceState);
- } else {
- getStateManager().startState(AlbumSetPage.class, new Bundle());
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
- mGLRootView.onResume();
- getStateManager().resume();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mGLRootView.onPause();
- getStateManager().pause();
- }
-
- @Override
- public void onStop() {
- super.onStop();
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- Log.i(TAG, "onDestroy");
- }
-
- @Override
- public void onBackPressed() {
- // send the back event to the top sub-state
- getStateManager().getTopState().onBackPressed();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- getStateManager().saveState(outState);
- }
-
- public Context getAndroidContext() {
- return this;
- }
-
- public synchronized ImageService getImageService() {
- if (mImageService == null) {
- mImageService = new ImageService(getContentResolver());
- }
- return mImageService;
- }
-
- public synchronized DataManager getDataManager() {
- if (mDataManager == null) {
- mDataManager = new DataManager(this);
- }
- return mDataManager;
- }
-
- public synchronized StateManager getStateManager() {
- if (mStateManager == null) {
- mStateManager = new StateManager(this);
- }
- return mStateManager;
- }
-
- public GLRoot getGLRoot() {
- return mGLRootView;
- }
-
- public PositionRepository getPositionRepository() {
- return mPositionRepository;
- }
-
- public synchronized DownloadService getDownloadService() {
- if (mDownloadService == null) {
- mDownloadService = new DownloadService();
- }
- return mDownloadService;
- }
-
- public synchronized DecodeService getDecodeService() {
- if (mDecodeService == null) {
- mDecodeService = new DecodeService();
- }
- return mDecodeService;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/GalleryContext.java b/new3d/src/com/android/gallery3d/app/GalleryContext.java
deleted file mode 100644
index 69695ed..0000000
--- a/new3d/src/com/android/gallery3d/app/GalleryContext.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-
-package com.android.gallery3d.app;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.res.Resources;
-import android.os.Looper;
-
-import com.android.gallery3d.data.DataManager;
-import com.android.gallery3d.data.DecodeService;
-import com.android.gallery3d.data.DownloadService;
-import com.android.gallery3d.data.ImageService;
-import com.android.gallery3d.ui.GLRoot;
-import com.android.gallery3d.ui.PositionRepository;
-
-public interface GalleryContext {
- public ImageService getImageService();
- public StateManager getStateManager();
- public DataManager getDataManager();
- public DownloadService getDownloadService();
- public DecodeService getDecodeService();
-
- public GLRoot getGLRoot();
- public PositionRepository getPositionRepository();
-
- public Context getAndroidContext();
-
- public Looper getMainLooper();
- public Resources getResources();
- public ContentResolver getContentResolver();
-
-}
diff --git a/new3d/src/com/android/gallery3d/app/MovieView.java b/new3d/src/com/android/gallery3d/app/MovieView.java
deleted file mode 100644
index dbbd02c..0000000
--- a/new3d/src/com/android/gallery3d/app/MovieView.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.os.Bundle;
-import android.provider.MediaStore;
-import android.view.View;
-import android.view.Window;
-import android.view.WindowManager;
-
-import com.android.gallery3d.R;
-
-
-/**
- * This activity plays a video from a specified URI.
- */
-public class MovieView extends Activity {
- @SuppressWarnings("unused")
- private static final String TAG = "MovieView";
-
- private MovieViewControl mControl;
- private boolean mFinishOnCompletion;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.movie_view);
- View rootView = findViewById(R.id.root);
- Intent intent = getIntent();
- mControl = new MovieViewControl(rootView, this, intent.getData()) {
- @Override
- public void onCompletion() {
- if (mFinishOnCompletion) {
- finish();
- }
- }
- };
- if (intent.hasExtra(MediaStore.EXTRA_SCREEN_ORIENTATION)) {
- int orientation = intent.getIntExtra(
- MediaStore.EXTRA_SCREEN_ORIENTATION,
- ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
- if (orientation != getRequestedOrientation()) {
- setRequestedOrientation(orientation);
- }
- }
- mFinishOnCompletion = intent.getBooleanExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION, true);
- Window win = getWindow();
- WindowManager.LayoutParams winParams = win.getAttributes();
- winParams.buttonBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
- win.setAttributes(winParams);
- }
-
- @Override
- public void onPause() {
- mControl.onPause();
- super.onPause();
- }
-
- @Override
- public void onResume() {
- mControl.onResume();
- super.onResume();
- }
-
- @Override
- public void onDestroy() {
- mControl.onDestroy();
- super.onDestroy();
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/MovieViewControl.java b/new3d/src/com/android/gallery3d/app/MovieViewControl.java
deleted file mode 100644
index 199f8eb..0000000
--- a/new3d/src/com/android/gallery3d/app/MovieViewControl.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.app.AlertDialog;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.DialogInterface.OnCancelListener;
-import android.content.DialogInterface.OnClickListener;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteException;
-import android.media.MediaPlayer;
-import android.net.Uri;
-import android.os.Handler;
-import android.provider.MediaStore;
-import android.provider.MediaStore.Video;
-import android.util.Log;
-import android.view.View;
-import android.widget.MediaController;
-import android.widget.VideoView;
-
-import com.android.gallery3d.R;
-
-public class MovieViewControl implements
- MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener {
-
- @SuppressWarnings("unused")
- private static final String TAG = "MovieViewControl";
-
- private static final int HALF_MINUTE = 30 * 1000;
- private static final int TWO_MINUTES = 4 * HALF_MINUTE;
-
- // Copied from MediaPlaybackService in the Music Player app.
- private static final String SERVICECMD = "com.android.music.musicservicecommand";
- private static final String CMDNAME = "command";
- private static final String CMDPAUSE = "pause";
-
- private final VideoView mVideoView;
- private final View mProgressView;
- private final Uri mUri;
- private final ContentResolver mContentResolver;
-
- Handler mHandler = new Handler();
-
- Runnable mPlayingChecker = new Runnable() {
- public void run() {
- if (mVideoView.isPlaying()) {
- mProgressView.setVisibility(View.GONE);
- } else {
- mHandler.postDelayed(mPlayingChecker, 250);
- }
- }
- };
-
- public static String formatDuration(final Context context, int durationMs) {
- int duration = durationMs / 1000;
- int h = duration / 3600;
- int m = (duration - h * 3600) / 60;
- int s = duration - (h * 3600 + m * 60);
- String durationValue;
- if (h == 0) {
- durationValue = String.format(context.getString(R.string.details_ms), m, s);
- } else {
- durationValue = String.format(context.getString(R.string.details_hms), h, m, s);
- }
- return durationValue;
- }
-
- public MovieViewControl(View rootView, Context context, Uri videoUri) {
- mContentResolver = context.getContentResolver();
- mVideoView = (VideoView) rootView.findViewById(R.id.surface_view);
- mProgressView = rootView.findViewById(R.id.progress_indicator);
-
- mUri = videoUri;
-
- // For streams that we expect to be slow to start up, show a
- // progress spinner until playback starts.
- String scheme = mUri.getScheme();
- if ("http".equalsIgnoreCase(scheme) || "rtsp".equalsIgnoreCase(scheme)) {
- mHandler.postDelayed(mPlayingChecker, 250);
- } else {
- mProgressView.setVisibility(View.GONE);
- }
-
- mVideoView.setOnErrorListener(this);
- mVideoView.setOnCompletionListener(this);
- mVideoView.setVideoURI(mUri);
- mVideoView.setMediaController(new MediaController(context));
-
- // make the video view handle keys for seeking and pausing
- mVideoView.requestFocus();
-
- Intent i = new Intent(SERVICECMD);
- i.putExtra(CMDNAME, CMDPAUSE);
- context.sendBroadcast(i);
-
- final Integer bookmark = getBookmark();
- if (bookmark != null) {
- AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(R.string.resume_playing_title);
- builder.setMessage(String.format(
- context.getString(R.string.resume_playing_message),
- formatDuration(context, bookmark)));
- builder.setOnCancelListener(new OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- onCompletion();
- }
- });
- builder.setPositiveButton(
- R.string.resume_playing_resume, new OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- mVideoView.seekTo(bookmark);
- mVideoView.start();
- }
- });
- builder.setNegativeButton(
- R.string.resume_playing_restart, new OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- mVideoView.start();
- }
- });
- builder.show();
- } else {
- mVideoView.start();
- }
- }
-
- private static boolean uriSupportsBookmarks(Uri uri) {
- String scheme = uri.getScheme();
- String authority = uri.getAuthority();
- return ("content".equalsIgnoreCase(scheme)
- && MediaStore.AUTHORITY.equalsIgnoreCase(authority));
- }
-
- private Integer getBookmark() {
- if (!uriSupportsBookmarks(mUri)) {
- return null;
- }
-
- String[] projection = new String[] {
- Video.VideoColumns.DURATION, Video.VideoColumns.BOOKMARK};
-
- try {
- Cursor cursor = mContentResolver.query(mUri, projection, null, null, null);
- if (cursor != null) {
- try {
- if (cursor.moveToFirst()) {
- int duration = getCursorInteger(cursor, 0);
- int bookmark = getCursorInteger(cursor, 1);
- if ((bookmark < HALF_MINUTE) || (duration < TWO_MINUTES)
- || (bookmark > (duration - HALF_MINUTE))) {
- return null;
- }
- return Integer.valueOf(bookmark);
- }
- } finally {
- cursor.close();
- }
- }
- } catch (SQLiteException e) {
- // ignore
- }
-
- return null;
- }
-
- private static int getCursorInteger(Cursor cursor, int index) {
- try {
- return cursor.getInt(index);
- } catch (SQLiteException e) {
- return 0;
- } catch (NumberFormatException e) {
- return 0;
- }
-
- }
-
- private void setBookmark(int bookmark, int duration) {
- if (!uriSupportsBookmarks(mUri)) {
- return;
- }
-
- ContentValues values = new ContentValues();
- values.put(Video.VideoColumns.BOOKMARK, Integer.toString(bookmark));
- values.put(Video.VideoColumns.DURATION, Integer.toString(duration));
- try {
- mContentResolver.update(mUri, values, null, null);
- } catch (SecurityException e) {
- Log.w(TAG, "set bookmark fail", e);
- // Ignore, can happen if we try to set the bookmark on a read-only
- // resource such as a video attached to GMail.
- } catch (SQLiteException e) {
- Log.w(TAG, "set bookmark fail", e);
- // ignore. can happen if the content doesn't support a bookmark
- // column.
- } catch (UnsupportedOperationException e) {
- Log.w(TAG, "set bookmark fail", e);
- // ignore. can happen if the external volume is already detached.
- }
- }
-
- public void onPause() {
- mHandler.removeCallbacksAndMessages(null);
- setBookmark(mVideoView.getCurrentPosition(), mVideoView.getDuration());
-
- mVideoView.suspend();
- }
-
- public void onResume() {
- mVideoView.resume();
- }
-
- public void onDestroy() {
- mVideoView.stopPlayback();
- }
-
- public boolean onError(MediaPlayer player, int arg1, int arg2) {
- mHandler.removeCallbacksAndMessages(null);
- mProgressView.setVisibility(View.GONE);
- return false;
- }
-
- public void onCompletion(MediaPlayer mp) {
- onCompletion();
- }
-
- public void onCompletion() {
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/PhotoPage.java b/new3d/src/com/android/gallery3d/app/PhotoPage.java
deleted file mode 100644
index d2bc96d..0000000
--- a/new3d/src/com/android/gallery3d/app/PhotoPage.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.LargeBitmap;
-import android.graphics.Bitmap.Config;
-import android.os.Bundle;
-import android.os.Message;
-import android.util.Log;
-
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.data.MediaSet;
-import com.android.gallery3d.ui.GLCanvas;
-import com.android.gallery3d.ui.GLRoot;
-import com.android.gallery3d.ui.GLView;
-import com.android.gallery3d.ui.ImageViewer;
-import com.android.gallery3d.ui.SynchronizedHandler;
-import com.android.gallery3d.ui.ImageViewer.ImageData;
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.FutureListener;
-
-import java.util.ArrayList;
-
-public class PhotoPage extends ActivityState {
- private static final String TAG = PhotoPage.class.getSimpleName();
-
- public static final String KEY_SET_INDEX = "keySetIndex";
- public static final String KEY_PHOTO_INDEX = "keyPhotoIndex";
-
- private static final int MSG_UPDATE_SCREENNAIL = 1;
- private static final int MSG_UPDATE_FULLIMAGE = 2;
-
- private static final int TARGET_LENGTH = 1600;
-
- private SynchronizedHandler mHandler;
-
- private ImageViewer mImageViewer;
- private final MyImageViewerModel mModel = new MyImageViewerModel();
- private int mSetIndex;
- private int mPhotoIndex;
-
- private MediaSet mMediaSet;
-
- private GLView mRootPane = new GLView() {
-
- @Override
- protected void renderBackground(GLCanvas view) {
- view.clearBuffer();
- }
-
- @Override
- protected void onLayout(
- boolean changed, int left, int top, int right, int bottom) {
- if (mImageViewer != null) {
- mImageViewer.layout(0, 0, right - left, bottom - top);
- }
- }
- };
-
- @Override
- public void onCreate(Bundle data, Bundle restoreState) {
- mHandler = new SynchronizedHandler(mContext.getGLRoot()) {
- @Override
- public void handleMessage(Message message) {
- switch (message.what) {
- case MSG_UPDATE_SCREENNAIL: {
- mModel.updateScreenNail(message.arg1, (Bitmap) message.obj);
- break;
- }
- case MSG_UPDATE_FULLIMAGE: {
- mModel.updateLargeImage(message.arg1, (LargeBitmap) message.obj);
- break;
- }
- default: throw new AssertionError();
- }
- }
- };
-
- mSetIndex = data.getInt(KEY_SET_INDEX);
- mPhotoIndex = data.getInt(KEY_PHOTO_INDEX);
-
- mMediaSet = mContext.getDataManager()
- .getRootSet().getSubMediaSet(mSetIndex);
-
- mImageViewer = new ImageViewer(mContext);
- mImageViewer.setModel(mModel);
- mRootPane.addComponent(mImageViewer);
- mModel.requestNextImage();
- }
-
- @Override
- public void onPause() {
- GLRoot root = mContext.getGLRoot();
- root.lockRenderThread();
- try {
- mImageViewer.freeTextures();
- } finally {
- root.unlockRenderThread();
- }
- }
-
- @Override
- protected void onResume() {
- setContentPane(mRootPane);
- mImageViewer.prepareTextures();
- }
-
- private class MyImageViewerModel implements ImageViewer.Model {
-
- private LargeBitmap mLargeBitmap;
-
- private Bitmap mScreenNails[] = new Bitmap[3]; // prev, curr, next
-
- public LargeBitmap getLargeBitmap() {
- return mLargeBitmap;
- }
-
- public ImageData getImageData(int which) {
- Bitmap screennail = mScreenNails[which];
- if (screennail == null) return null;
-
- int width = 0;
- int height = 0;
-
- if (which == INDEX_CURRENT && mLargeBitmap != null) {
- width = mLargeBitmap.getWidth();
- height = mLargeBitmap.getHeight();
- } else {
- // We cannot get the size of image before getting the
- // full-size image. In the future, we should add the data to
- // database or get it from the header in runtime. Now, we
- // just use the thumb-nail image to estimate the size
- float scale = (float) TARGET_LENGTH / Math.max(
- screennail.getWidth(), screennail.getHeight());
- width = Math.round(screennail.getWidth() * scale);
- height = Math.round(screennail.getHeight() * scale);
- }
- return new ImageData(width, height, screennail);
- }
-
- public void next() {
- ++mPhotoIndex;
- Bitmap[] screenNails = mScreenNails;
-
- if (screenNails[INDEX_PREVIOUS] != null) {
- screenNails[INDEX_PREVIOUS].recycle();
- }
- screenNails[INDEX_PREVIOUS] = screenNails[INDEX_CURRENT];
- screenNails[INDEX_CURRENT] = screenNails[INDEX_NEXT];
- screenNails[INDEX_NEXT] = null;
-
- if (mLargeBitmap != null) {
- mLargeBitmap.recycle();
- mLargeBitmap = null;
- }
-
- requestNextImage();
- }
-
- public void previous() {
- --mPhotoIndex;
- Bitmap[] screenNails = mScreenNails;
-
- if (screenNails[INDEX_NEXT] != null) {
- screenNails[INDEX_NEXT].recycle();
- }
- screenNails[INDEX_NEXT] = screenNails[INDEX_CURRENT];
- screenNails[INDEX_CURRENT] = screenNails[INDEX_PREVIOUS];
- screenNails[INDEX_PREVIOUS] = null;
-
- if (mLargeBitmap != null) {
- mLargeBitmap.recycle();
- mLargeBitmap = null;
- }
-
- requestNextImage();
- }
-
- public void updateScreenNail(int index, Bitmap screenNail) {
- int offset = (index - mPhotoIndex) + 1;
- if (offset < 0 || offset > 2) {
- screenNail.recycle();
- return;
- }
-
- if (screenNail != null) {
- mScreenNails[offset] = screenNail;
- mImageViewer.notifyScreenNailInvalidated(offset);
- }
- requestNextImage();
- }
-
- public void updateLargeImage(int index, LargeBitmap largeBitmap) {
- int offset = (index - mPhotoIndex) + 1;
- if (offset != INDEX_CURRENT) {
- largeBitmap.recycle();
- return;
- }
-
- if (largeBitmap != null) {
- mLargeBitmap = largeBitmap;
- mImageViewer.notifyLargeBitmapInvalidated();
- // We need to update the estimated width and height
- mImageViewer.notifyScreenNailInvalidated(INDEX_CURRENT);
- }
- requestNextImage();
- }
-
- private MediaItem getMediaItem(
- ArrayList<MediaItem> items, int start, int index) {
- index = index - start;
- if (index < 0 || index >= items.size()) return null;
- return items.get(index);
- }
-
- public void requestNextImage() {
-
- int start = Math.max(0, mPhotoIndex - 1);
-
- ArrayList<MediaItem> items = mMediaSet.getMediaItem(start, 3);
- if (items.size() == 0) return;
-
- // First request the current screen nail
- if (mScreenNails[INDEX_CURRENT] == null) {
- MediaItem current = getMediaItem(items, start, mPhotoIndex);
- if (current != null) {
- current.requestImage(MediaItem.TYPE_THUMBNAIL,
- new ScreenNailListener(mPhotoIndex));
- return;
- }
- }
-
- // Next, the next screen nail
- if (mScreenNails[INDEX_NEXT] == null) {
- MediaItem next = getMediaItem(items, start, mPhotoIndex + 1);
- if (next != null) {
- next.requestImage(MediaItem.TYPE_THUMBNAIL,
- new ScreenNailListener(mPhotoIndex + 1));
- return;
- }
- }
-
- // Next, the previous screen nail
- if (mScreenNails[INDEX_PREVIOUS] == null) {
- MediaItem previous = getMediaItem(items, start, mPhotoIndex - 1);
- if (previous != null) {
- previous.requestImage(MediaItem.TYPE_THUMBNAIL,
- new ScreenNailListener(mPhotoIndex - 1));
- return;
- }
- }
-
- // Next, the full size image
- if (mLargeBitmap == null) {
- MediaItem current = getMediaItem(items, start, mPhotoIndex);
- if (current != null) {
- current.requestLargeImage(MediaItem.TYPE_FULL_IMAGE,
- new LargeImageListener(mPhotoIndex));
- return;
- }
- }
- }
- }
-
- private static Bitmap[] getScaledBitmaps(Bitmap bitmap, int minLength) {
- Config config = bitmap.hasAlpha()
- ? Config.ARGB_8888 : Config.RGB_565;
-
- int width = bitmap.getWidth() / 2;
- int height = bitmap.getHeight() / 2;
-
- ArrayList<Bitmap> list = new ArrayList<Bitmap>();
- list.add(bitmap);
- while (width > minLength || height > minLength) {
- Bitmap half = Bitmap.createBitmap(width, height, config);
- Canvas canvas = new Canvas(half);
- canvas.scale(0.5f, 0.5f);
- canvas.drawBitmap(bitmap, 0, 0, null);
- width /= 2;
- height /= 2;
- bitmap = half;
- list.add(bitmap);
- }
- return list.toArray(new Bitmap[list.size()]);
- }
-
- private class ScreenNailListener implements FutureListener<Bitmap> {
-
- private final int mIndex;
-
- public ScreenNailListener(int index) {
- mIndex = index;
- }
-
- public void onFutureDone(Future<? extends Bitmap> future) {
- Bitmap bitmap = null;
- try {
- bitmap = future.get();
- } catch (Exception e) {
- Log.v(TAG, "fail to get image", e);
- }
- mHandler.sendMessage(mHandler.obtainMessage(
- MSG_UPDATE_SCREENNAIL, mIndex, 0, bitmap));
- }
- }
-
- private class LargeImageListener implements FutureListener<LargeBitmap> {
-
- private final int mIndex;
-
- public LargeImageListener(int index) {
- mIndex = index;
- }
-
- public void onFutureDone(Future<? extends LargeBitmap> future) {
- LargeBitmap largeBitmap = null;
- try {
- largeBitmap = future.get();
- } catch (Exception e) {
- Log.v(TAG, "fail to get image", e);
- }
- mHandler.sendMessage(mHandler.obtainMessage(
- MSG_UPDATE_FULLIMAGE, mIndex, 0, largeBitmap));
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/SlideshowDataAdapter.java b/new3d/src/com/android/gallery3d/app/SlideshowDataAdapter.java
deleted file mode 100644
index 04b7695..0000000
--- a/new3d/src/com/android/gallery3d/app/SlideshowDataAdapter.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.graphics.Bitmap;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-
-import com.android.gallery3d.app.SlideshowPage.ModelListener;
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.data.MediaSet;
-import com.android.gallery3d.data.MediaSet.MediaSetListener;
-import com.android.gallery3d.ui.SynchronizedHandler;
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.FutureListener;
-import com.android.gallery3d.util.Utils;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-
-public class SlideshowDataAdapter implements SlideshowPage.Model {
- private static final String TAG = "SlideshowDataAdapter";
-
- private static final int IMAGE_QUEUE_CAPACITY = 3;
-
- private static final int MSG_LOAD_MEDIA_ITEM = 0;
- private static final int MSG_FILL_BITMAP = 1;
-
- private static final int MSG_LOAD_DATA = 2;
- private static final int MSG_UPDATE_DATA = 3;
-
- private final MediaSet mSource;
-
- private int mIndex = 0;
- private int mSize = 0;
-
- private LinkedList<Bitmap> mImageQueue = new LinkedList<Bitmap>();
- private int mImageRequestCount = IMAGE_QUEUE_CAPACITY;
-
- private Handler mMainHandler;
- private Handler mDataHandler;
-
- private SlideshowPage.ModelListener mListener;
-
- public SlideshowDataAdapter(GalleryContext context, MediaSet source) {
- mSource = source;
- mSource.setContentListener(new SourceListener());
-
- mMainHandler = new SynchronizedHandler(context.getGLRoot()) {
- @Override
- public void handleMessage(Message message) {
- switch (message.what) {
- case MSG_UPDATE_DATA:
- ((ReloadTask) message.obj).updateContent();
- break;
- case MSG_FILL_BITMAP:
- ((LoadNextImageTask) message.obj).fillBitmap();
- break;
- default: throw new AssertionError(message.what);
- }
- }
- };
-
- mDataHandler = new Handler(context.getDataManager().getDataLooper()) {
- @Override
- public void handleMessage(Message message) {
- switch (message.what) {
- case MSG_LOAD_DATA:
- ((ReloadTask) message.obj).reloadData();
- break;
- case MSG_LOAD_MEDIA_ITEM:
- ((LoadNextImageTask) message.obj).loadMediaItem();
- break;
- default:
- throw new AssertionError(message.what);
- }
- }
- };
-
- new ReloadTask().execute();
- }
-
- public boolean hasNext() {
- return !mImageQueue.isEmpty();
- }
-
- public Bitmap nextSlideBitmap() {
- new LoadNextImageTask(mIndex++).execute();
- return mImageQueue.removeFirst();
- }
-
- private class ReloadTask {
- private int mUpdateSize = -1;
-
- public void execute() {
- mDataHandler.sendMessage(
- mDataHandler.obtainMessage(MSG_LOAD_DATA, this));
- }
-
- public void reloadData() {
- mSource.reload();
- mUpdateSize = mSource.getMediaItemCount();
- mMainHandler.sendMessage(
- mMainHandler.obtainMessage(MSG_UPDATE_DATA, this));
- }
-
- public void updateContent() {
- int size = mSize;
- mSize = mUpdateSize;
- if (size == mIndex && size < mUpdateSize && mImageRequestCount > 0) {
- --mImageRequestCount;
- new LoadNextImageTask(mIndex++).execute();
- }
- }
- }
-
- private class LoadNextImageTask implements FutureListener<Bitmap>{
- private int mItemIndex;
- private MediaItem mItem;
- private Bitmap mBitmap;
-
- public LoadNextImageTask(int index) {
- mItemIndex = index;
- }
-
- public void execute() {
- mDataHandler.sendMessage(
- mDataHandler.obtainMessage(MSG_LOAD_MEDIA_ITEM, this));
- }
-
- public void loadMediaItem() {
- ArrayList<MediaItem> list = mSource.getMediaItem(mItemIndex, 1);
- // If list is empty, assume it is the end of the list
- if (!list.isEmpty()) {
- mItem = list.get(0);
- mItem.requestImage(MediaItem.TYPE_FULL_IMAGE, this);
- }
- }
-
- public void onFutureDone(Future<? extends Bitmap> future) {
- try {
- mBitmap = future.get();
- if (mBitmap != null) {
- mBitmap = Utils.resizeBitmap(mBitmap, 640);
- }
- } catch (Throwable e) {
- Log.w(TAG, "fail to get bitmap", e);
- }
- mMainHandler.sendMessage(
- mMainHandler.obtainMessage(MSG_FILL_BITMAP, this));
- }
-
- public void fillBitmap() {
- if (mBitmap != null) {
- mImageQueue.addLast(mBitmap);
- if (mImageQueue.size() == 1 && mListener != null) {
- mListener.onContentChanged();
- }
- }
- if (mImageRequestCount > 0 && mIndex < mSize) {
- --mImageRequestCount;
- new LoadNextImageTask(mIndex++).execute();
- }
- }
- }
-
- private class SourceListener implements MediaSetListener {
- public void onContentDirty() {
- new ReloadTask().execute();
- }
- }
-
- public void setListener(ModelListener listener) {
- mListener = listener;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/SlideshowPage.java b/new3d/src/com/android/gallery3d/app/SlideshowPage.java
deleted file mode 100644
index 7e7053f..0000000
--- a/new3d/src/com/android/gallery3d/app/SlideshowPage.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.graphics.Bitmap;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-
-import com.android.gallery3d.data.MediaSet;
-import com.android.gallery3d.ui.GLCanvas;
-import com.android.gallery3d.ui.GLView;
-import com.android.gallery3d.ui.SlideshowView;
-import com.android.gallery3d.ui.SynchronizedHandler;
-import com.android.gallery3d.util.Utils;
-
-public class SlideshowPage extends ActivityState {
- private static final String TAG = "SlideshowPage";
-
- public static final String KEY_BUCKET_INDEX = "keyBucketIndex";
-
- private static final long SLIDESHOW_DELAY = 3000; // 2 seconds
- private static final int MSG_SHOW_NEXT_SLIDE = 1;
-
- public static interface Model {
- public boolean hasNext();
- public Bitmap nextSlideBitmap();
- public void setListener(ModelListener listener);
- }
-
- public static interface ModelListener {
- public void onContentChanged();
- }
-
- private Handler mHandler;
- private Model mModel;
- private SlideshowView mSlideshowView;
- private boolean mSlideshowActive = false;
-
- private GLView mRootPane = new GLView() {
- @Override
- protected void onLayout(
- boolean changed, int left, int top, int right, int bottom) {
- mSlideshowView.layout(0, 0, right - left, bottom - top);
- }
-
- @Override
- protected void renderBackground(GLCanvas canvas) {
- canvas.clearBuffer();
- }
- };
-
- @Override
- public void onCreate(Bundle data, Bundle restoreState) {
- mHandler = new SynchronizedHandler(mContext.getGLRoot()) {
- @Override
- public void handleMessage(Message message) {
- Utils.Assert(message.what == MSG_SHOW_NEXT_SLIDE);
- showNextSlide();
- }
- };
- initializeViews();
- intializeData(data);
- }
-
- private void showNextSlide() {
- if (!mModel.hasNext()) {
- mSlideshowActive = false;
- return;
- }
- mSlideshowActive = true;
- mSlideshowView.next(mModel.nextSlideBitmap());
- mHandler.sendEmptyMessageDelayed(MSG_SHOW_NEXT_SLIDE, SLIDESHOW_DELAY);
- }
-
- @Override
- public void onPause() {
- mHandler.removeMessages(MSG_SHOW_NEXT_SLIDE);
- }
-
- @Override
- public void onResume() {
- mHandler.sendEmptyMessage(MSG_SHOW_NEXT_SLIDE);
- }
-
- private void initializeViews() {
- mSlideshowView = new SlideshowView();
- mRootPane.addComponent(mSlideshowView);
- setContentPane(mRootPane);
- }
-
- private void intializeData(Bundle data) {
- int bucketIndex = data.getInt(KEY_BUCKET_INDEX);
- MediaSet mediaSet = mContext.getDataManager()
- .getRootSet().getSubMediaSet(bucketIndex);
- SlideshowDataAdapter adapter =
- new SlideshowDataAdapter(mContext, mediaSet);
- setModel(adapter);
- }
-
- public void setModel(Model source) {
- mHandler.removeMessages(MSG_SHOW_NEXT_SLIDE);
- mModel = source;
- mModel.setListener(new MyModelListener());
- showNextSlide();
- }
-
- private class MyModelListener implements ModelListener {
- public void onContentChanged() {
- if (!mSlideshowActive) showNextSlide();
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/StateManager.java b/new3d/src/com/android/gallery3d/app/StateManager.java
deleted file mode 100644
index 18f216f..0000000
--- a/new3d/src/com/android/gallery3d/app/StateManager.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.os.Bundle;
-import android.os.Parcelable;
-
-import com.android.gallery3d.util.Utils;
-
-import java.util.Stack;
-
-public class StateManager {
- private static final String TAG = "StateManager";
- private boolean mIsResumed = false;
-
- private static final String MAIN_KEY = "activity-state";
- private static final String DATA_KEY = "data";
- private static final String STATE_KEY = "bundle";
- private static final String CLASS_KEY = "class";
-
- private GalleryContext mContext;
- private Stack<StateEntry> mStack = new Stack<StateEntry>();
-
- public StateManager(GalleryContext context) {
- mContext = context;
- }
-
- public void startState(Class<? extends ActivityState> stateClass,
- Bundle data) {
- ActivityState stateView = null;
- try {
- stateView = stateClass.newInstance();
- } catch (Exception e) {
- throw new AssertionError(e);
- }
- stateView.setContext(mContext);
-
- if (!mStack.isEmpty()) {
- mStack.peek().activityState.onPause();
- }
-
- mStack.push(new StateEntry(data, stateView));
- stateView.onCreate(data, null);
- if (mIsResumed) stateView.onResume();
- }
-
- public void resume() {
- if (mIsResumed) return;
- mIsResumed = true;
- if (!mStack.isEmpty()) getTopState().onResume();
- }
-
- public void pause() {
- if (!mIsResumed) return;
- mIsResumed = false;
- if (!mStack.isEmpty()) getTopState().onPause();
- }
-
- void finishState(ActivityState stateView) {
- if (stateView != mStack.peek().activityState) {
- throw new IllegalArgumentException("The stateview to be finished"
- + " is not at the top of the stack!");
- }
- // Remove the top stateview.
- mStack.pop();
- stateView.onPause();
- stateView.onDestroy();
-
- if (mStack.isEmpty()) {
- ((Gallery) mContext).finish();
- } else {
- // Restore the immediately previous stateview
- mStack.peek().activityState.onResume();
- }
- }
-
- @SuppressWarnings("unchecked")
- public void restoreFromState(Bundle inState) {
- Parcelable list[] = inState.getParcelableArray(MAIN_KEY);
-
- for (Parcelable parcelable : list) {
- Bundle bundle = (Bundle) parcelable;
- Class<? extends ActivityState> klass =
- (Class<? extends ActivityState>) bundle.getSerializable(CLASS_KEY);
-
- Bundle data = bundle.getBundle(DATA_KEY);
- Bundle state = bundle.getBundle(STATE_KEY);
-
- ActivityState activityState;
- try {
- activityState = klass.newInstance();
- } catch (Exception e) {
- throw new AssertionError(e);
- }
- activityState.setContext(mContext);
- activityState.onCreate(data, state);
- mStack.push(new StateEntry(data, activityState));
- }
- }
-
- public void saveState(Bundle outState) {
- Parcelable list[] = new Parcelable[mStack.size()];
-
- int i = 0;
- for (StateEntry entry : mStack) {
- Bundle bundle = new Bundle();
- bundle.putSerializable(CLASS_KEY, entry.activityState.getClass());
- bundle.putBundle(DATA_KEY, entry.data);
- Bundle state = new Bundle();
- entry.activityState.onSaveState(state);
- bundle.putBundle(STATE_KEY, state);
- list[i++] = bundle;
- }
- outState.putParcelableArray(MAIN_KEY, list);
- }
-
- public ActivityState getTopState() {
- Utils.Assert(!mStack.isEmpty());
- return mStack.peek().activityState;
- }
-
- private static class StateEntry {
- public Bundle data;
- public ActivityState activityState;
-
- public StateEntry(Bundle data, ActivityState state) {
- this.data = data;
- this.activityState = state;
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/app/Wallpaper.java b/new3d/src/com/android/gallery3d/app/Wallpaper.java
deleted file mode 100644
index 6fe12ec..0000000
--- a/new3d/src/com/android/gallery3d/app/Wallpaper.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.app.Activity;
-import android.app.ProgressDialog;
-import android.app.WallpaperManager;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.provider.MediaStore;
-import android.util.Log;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.util.Utils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Wallpaper picker for the gallery application. This just redirects to the
- * standard pick action.
- */
-public class Wallpaper extends Activity {
- private static final String TAG = "SetWallpaper";
-
- // TODO: move this action to CropImage activity
- private static final String CROP_ACTION = "com.android.camera.action.CROP";
-
- static final int PHOTO_PICKED = 1;
- static final int CROP_DONE = 2;
-
- static final int MSG_SHOW_PROGRESS = 0;
- static final int MSG_FINISH = 1;
-
- static final String DO_LAUNCH_ICICLE = "do_launch";
- static final String TEMP_FILE_PATH_ICICLE = "temp_file_path";
-
- private ProgressDialog mProgressDialog = null;
- private boolean mDoLaunch = true;
- private File mTempFile;
-
- private final Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_SHOW_PROGRESS: {
- CharSequence c = getText(R.string.wallpaper);
- mProgressDialog = ProgressDialog.show(
- Wallpaper.this, "", c, true, false);
- break;
- }
- case MSG_FINISH: {
- closeProgressDialog();
- setResult(RESULT_OK);
- finish();
- break;
- }
- }
- }
- };
-
- static class SetWallpaperThread extends Thread {
- private final Bitmap mBitmap;
- private final Handler mHandler;
- private final Context mContext;
- private final File mFile;
-
- public SetWallpaperThread(Bitmap bitmap,
- Handler handler, Context context, File file) {
- mBitmap = bitmap;
- mHandler = handler;
- mContext = context;
- mFile = file;
- }
-
- @Override
- public void run() {
- try {
- WallpaperManager.getInstance(mContext).setBitmap(mBitmap);
- } catch (IOException e) {
- Log.e(TAG, "Failed to set wallpaper.", e);
- } finally {
- mHandler.sendEmptyMessage(MSG_FINISH);
- mFile.delete();
- }
- }
- }
-
- private void closeProgressDialog() {
- if (mProgressDialog != null) {
- mProgressDialog.dismiss();
- mProgressDialog = null;
- }
- }
-
- @Override
- protected void onCreate(Bundle bundle) {
- super.onCreate(bundle);
- if (bundle != null) {
- mDoLaunch = bundle.getBoolean(DO_LAUNCH_ICICLE);
- mTempFile = new File(bundle.getString(TEMP_FILE_PATH_ICICLE));
- }
- }
-
- @Override
- protected void onSaveInstanceState(Bundle saveState) {
- saveState.putBoolean(DO_LAUNCH_ICICLE, mDoLaunch);
- saveState.putString(TEMP_FILE_PATH_ICICLE, mTempFile.getAbsolutePath());
- }
-
- @Override
- protected void onPause() {
- closeProgressDialog();
- super.onPause();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- if (!mDoLaunch) return;
- Uri imageToUse = getIntent().getData();
- if (imageToUse != null) {
- Intent intent = new Intent();
- intent.setAction(CROP_ACTION);
- intent.setData(imageToUse);
- formatIntent(intent);
- startActivityForResult(intent, CROP_DONE);
- } else {
- Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
- intent.setType("image/*");
- intent.putExtra("crop", "true");
- formatIntent(intent);
- startActivityForResult(intent, PHOTO_PICKED);
- }
- }
-
- protected void formatIntent(Intent intent) {
- // TODO: A temporary file is NOT necessary
- // The CropImage intent should be able to set the wallpaper directly
- // without writing to a file, which we then need to read here to write
- // it again as the final wallpaper, this is silly
- mTempFile = getFileStreamPath("temp-wallpaper");
- mTempFile.getParentFile().mkdirs();
-
- int width = getWallpaperDesiredMinimumWidth();
- int height = getWallpaperDesiredMinimumHeight();
- intent.putExtra("outputX", width);
- intent.putExtra("outputY", height);
- intent.putExtra("aspectX", width);
- intent.putExtra("aspectY", height);
- intent.putExtra("scale", true);
- intent.putExtra("noFaceDetection", true);
- intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mTempFile));
- intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.name());
- // TODO: we should have an extra called "setWallpaper" to ask CropImage
- // to set the cropped image as a wallpaper directly. This means the
- // SetWallpaperThread should be moved out of this class to CropImage
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if ((requestCode == PHOTO_PICKED || requestCode == CROP_DONE)
- && (resultCode == RESULT_OK) && (data != null)) {
- try {
- InputStream s = new FileInputStream(mTempFile);
- try {
- Bitmap bitmap = BitmapFactory.decodeStream(s);
- if (bitmap == null) {
- Log.e(TAG, "Failed to set wallpaper. "
- + "Couldn't get bitmap for path " + mTempFile);
- } else {
- mHandler.sendEmptyMessage(MSG_SHOW_PROGRESS);
- new SetWallpaperThread(bitmap, mHandler, this, mTempFile).start();
- }
- mDoLaunch = false;
- } finally {
- Utils.closeSilently(s);
- }
- } catch (FileNotFoundException ex) {
- Log.e(TAG, "file not found: " + mTempFile, ex);
- }
- } else {
- setResult(RESULT_CANCELED);
- finish();
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/BlobCache.java b/new3d/src/com/android/gallery3d/data/BlobCache.java
deleted file mode 100644
index 7f900f4..0000000
--- a/new3d/src/com/android/gallery3d/data/BlobCache.java
+++ /dev/null
@@ -1,615 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// This is an on-disk cache which maps a 64-bits key to a byte array.
-//
-// It consists of three files: one index file and two data files. One of the
-// data files is "active", and the other is "inactive". New entries are
-// appended into the active region until it reaches the size limit. At that
-// point the active file and the inactive file are swapped, and the new active
-// file is truncated to empty (and the index for that file is also cleared).
-// The index is a hash table with linear probing. When the load factor reaches
-// 0.5, it does the same thing like when the size limit is reached.
-//
-// The index file format: (all numbers are stored in little-endian)
-// [0] Magic number: 0xB3273030
-// [4] MaxEntries: Max number of hash entries per region.
-// [8] MaxBytes: Max number of data bytes per region (including header).
-// [12] ActiveRegion: The active growing region: 0 or 1.
-// [16] ActiveEntries: The number of hash entries used in the active region.
-// [20] ActiveBytes: The number of data bytes used in the active region.
-// [24] Reserved (should be 0).
-// [28] Checksum of [0..28).
-// [32] Hash entries for region 0. The size is X = (12 * MaxEntries bytes).
-// [32 + X] Hash entries for region 1. The size is also X.
-//
-// Each hash entry is 12 bytes: 8 bytes key and 4 bytes offset into the data
-// file. The offset is 0 when the slot is free. Note that 0 is a valid value
-// for key. The keys are used directly as index into a hash table, so they
-// should be suitably distributed.
-//
-// Each data file stores data for one region. The data file is concatenated
-// blobs followed by the magic number 0xBD248510.
-//
-// The blob format:
-// [0] Key of this blob
-// [8] Checksum of this blob
-// [12] Offset of this blob
-// [16] Length of this blob (not including header)
-// [20] Blob
-//
-// Below are the interface for BlobCache. The instance of this class does not
-// support concurrent use by multiple threads.
-//
-// public BlobCache(String path, int maxEntries, int maxBytes, boolean reset) throws IOException;
-// public void insert(long key, byte[] data) throws IOException;
-// public byte[] lookup(long key) throws IOException;
-// public void lookup(LookupRequest req) throws IOException;
-// public void close();
-// public void syncIndex();
-// public void syncAll();
-//
-package com.android.gallery3d.data;
-
-import android.util.Log;
-
-import java.io.Closeable;
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.ByteOrder;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-import java.util.zip.Adler32;
-
-public class BlobCache {
- private static final String TAG = "BlobCache";
-
- private static final int MAGIC_INDEX_FILE = 0xB3273030;
- private static final int MAGIC_DATA_FILE = 0xBD248510;
-
- // index header offset
- private static final int IH_MAGIC = 0;
- private static final int IH_MAX_ENTRIES = 4;
- private static final int IH_MAX_BYTES = 8;
- private static final int IH_ACTIVE_REGION = 12;
- private static final int IH_ACTIVE_ENTRIES = 16;
- private static final int IH_ACTIVE_BYTES = 20;
- private static final int IH_CHECKSUM = 28;
- private static final int INDEX_HEADER_SIZE = 32;
-
- private static final int DATA_HEADER_SIZE = 4;
-
- // blob header offset
- private static final int BH_KEY = 0;
- private static final int BH_CHECKSUM = 8;
- private static final int BH_OFFSET = 12;
- private static final int BH_LENGTH = 16;
- private static final int BLOB_HEADER_SIZE = 20;
-
- private RandomAccessFile mIndexFile;
- private RandomAccessFile mDataFile0;
- private RandomAccessFile mDataFile1;
- private FileChannel mIndexChannel;
- private MappedByteBuffer mIndexBuffer;
-
- private int mMaxEntries;
- private int mMaxBytes;
- private int mActiveRegion;
- private int mActiveEntries;
- private int mActiveBytes;
-
- private RandomAccessFile mActiveDataFile;
- private RandomAccessFile mInactiveDataFile;
- private int mActiveHashStart;
- private int mInactiveHashStart;
- private byte[] mIndexHeader = new byte[INDEX_HEADER_SIZE];
- private byte[] mBlobHeader = new byte[BLOB_HEADER_SIZE];
- private Adler32 mAdler32 = new Adler32();
-
- // Creates the cache. Three files will be created:
- // path + ".idx", path + ".0", and path + ".1"
- // The ".0" file and the ".1" file each stores data for a region. Each of
- // them can grow to the size specified by maxBytes. The maxEntries parameter
- // specifies the maximum number of entries each region can have. If the
- // "reset" parameter is true, the cache will be cleared before use.
- public BlobCache(String path, int maxEntries, int maxBytes, boolean reset)
- throws IOException {
- mIndexFile = new RandomAccessFile(path + ".idx", "rw");
- mDataFile0 = new RandomAccessFile(path + ".0", "rw");
- mDataFile1 = new RandomAccessFile(path + ".1", "rw");
-
- if (!reset && loadIndex()) {
- return;
- }
-
- resetCache(maxEntries, maxBytes);
-
- if (!loadIndex()) {
- closeAll();
- throw new IOException("unable to load index");
- }
- }
-
- // Close the cache. All resources are released. No other method should be
- // called after this is called.
- public void close() {
- syncAll();
- closeAll();
- }
-
- private void closeAll() {
- closeSilently(mIndexChannel);
- closeSilently(mIndexFile);
- closeSilently(mDataFile0);
- closeSilently(mDataFile1);
- }
-
- // Returns true if loading index is successful. After this method is called,
- // mIndexHeader and index header in file should be kept sync.
- private boolean loadIndex() {
- try {
- mIndexFile.seek(0);
- mDataFile0.seek(0);
- mDataFile1.seek(0);
-
- byte[] buf = mIndexHeader;
- if (mIndexFile.read(buf) != INDEX_HEADER_SIZE) {
- Log.w(TAG, "cannot read header");
- return false;
- }
-
- if (readInt(buf, IH_MAGIC) != MAGIC_INDEX_FILE) {
- Log.w(TAG, "cannot read header magic");
- return false;
- }
-
- mMaxEntries = readInt(buf, IH_MAX_ENTRIES);
- mMaxBytes = readInt(buf, IH_MAX_BYTES);
- mActiveRegion = readInt(buf, IH_ACTIVE_REGION);
- mActiveEntries = readInt(buf, IH_ACTIVE_ENTRIES);
- mActiveBytes = readInt(buf, IH_ACTIVE_BYTES);
-
- int sum = readInt(buf, IH_CHECKSUM);
- if (checkSum(buf, 0, IH_CHECKSUM) != sum) {
- Log.w(TAG, "header checksum does not match");
- return false;
- }
-
- // Sanity check
- if (mMaxEntries <= 0) {
- Log.w(TAG, "invalid max entries");
- return false;
- }
- if (mMaxBytes <= 0) {
- Log.w(TAG, "invalid max bytes");
- return false;
- }
- if (mActiveRegion != 0 && mActiveRegion != 1) {
- Log.w(TAG, "invalid active region");
- return false;
- }
- if (mActiveEntries < 0 || mActiveEntries > mMaxEntries) {
- Log.w(TAG, "invalid active entries");
- return false;
- }
- if (mActiveBytes < DATA_HEADER_SIZE || mActiveBytes > mMaxBytes) {
- Log.w(TAG, "invalid active bytes");
- return false;
- }
-
- // Make sure data file has magic
- byte[] magic = new byte[4];
- if (mDataFile0.read(magic) != 4) {
- Log.w(TAG, "cannot read data file magic");
- return false;
- }
- if (readInt(magic, 0) != MAGIC_DATA_FILE) {
- Log.w(TAG, "invalid data file magic");
- return false;
- }
- if (mDataFile1.read(magic) != 4) {
- Log.w(TAG, "cannot read data file magic");
- return false;
- }
- if (readInt(magic, 0) != MAGIC_DATA_FILE) {
- Log.w(TAG, "invalid data file magic");
- return false;
- }
-
- // Map index file to memory
- mIndexChannel = mIndexFile.getChannel();
- mIndexBuffer = mIndexChannel.map(FileChannel.MapMode.READ_WRITE,
- 0, mIndexFile.length());
- mIndexBuffer.order(ByteOrder.LITTLE_ENDIAN);
-
- setActiveVariables();
- return true;
- } catch (IOException ex) {
- Log.e(TAG, "loadIndex failed.", ex);
- return false;
- }
- }
-
- private void setActiveVariables() throws IOException {
- mActiveDataFile = (mActiveRegion == 0) ? mDataFile0 : mDataFile1;
- mInactiveDataFile = (mActiveRegion == 1) ? mDataFile0 : mDataFile1;
- mActiveDataFile.setLength(mActiveBytes);
- mActiveDataFile.seek(mActiveBytes);
-
- mActiveHashStart = INDEX_HEADER_SIZE;
- mInactiveHashStart = INDEX_HEADER_SIZE;
-
- if (mActiveRegion == 0) {
- mInactiveHashStart += mMaxEntries * 12;
- } else {
- mActiveHashStart += mMaxEntries * 12;
- }
- }
-
- private void resetCache(int maxEntries, int maxBytes) throws IOException {
- mIndexFile.setLength(0); // truncate to zero the index
- mIndexFile.setLength(INDEX_HEADER_SIZE + maxEntries * 12 * 2);
- mIndexFile.seek(0);
- byte[] buf = mIndexHeader;
- writeInt(buf, IH_MAGIC, MAGIC_INDEX_FILE);
- writeInt(buf, IH_MAX_ENTRIES, maxEntries);
- writeInt(buf, IH_MAX_BYTES, maxBytes);
- writeInt(buf, IH_ACTIVE_REGION, 0);
- writeInt(buf, IH_ACTIVE_ENTRIES, 0);
- writeInt(buf, IH_ACTIVE_BYTES, DATA_HEADER_SIZE);
- writeInt(buf, IH_CHECKSUM, checkSum(buf, 0, IH_CHECKSUM));
- mIndexFile.write(buf);
-
- mDataFile0.setLength(0);
- mDataFile1.setLength(0);
- mDataFile0.seek(0);
- mDataFile1.seek(0);
- writeInt(buf, 0, MAGIC_DATA_FILE);
- mDataFile0.write(buf, 0, 4);
- mDataFile1.write(buf, 0, 4);
- }
-
- // Flip the active region and the inactive region.
- private void flipRegion() throws IOException {
- mActiveRegion = 1 - mActiveRegion;
- mActiveEntries = 0;
- mActiveBytes = DATA_HEADER_SIZE;
-
- writeInt(mIndexHeader, IH_ACTIVE_REGION, mActiveRegion);
- writeInt(mIndexHeader, IH_ACTIVE_ENTRIES, mActiveEntries);
- writeInt(mIndexHeader, IH_ACTIVE_BYTES, mActiveBytes);
- updateIndexHeader();
-
- setActiveVariables();
- clearHash(mActiveHashStart);
- syncIndex();
- }
-
- // Sync mIndexHeader to the index file.
- private void updateIndexHeader() {
- writeInt(mIndexHeader, IH_CHECKSUM,
- checkSum(mIndexHeader, 0, IH_CHECKSUM));
- mIndexBuffer.position(0);
- mIndexBuffer.put(mIndexHeader);
- }
-
- // Clear the hash table starting from the specified offset.
- private void clearHash(int hashStart) {
- byte[] zero = new byte[1024];
- mIndexBuffer.position(hashStart);
- for (int count = mMaxEntries * 12; count > 0;) {
- int todo = Math.min(count, 1024);
- mIndexBuffer.put(zero, 0, todo);
- count -= todo;
- }
- }
-
- // Inserts a (key, data) pair into the cache.
- public void insert(long key, byte[] data) throws IOException {
- if (DATA_HEADER_SIZE + BLOB_HEADER_SIZE + data.length > mMaxBytes) {
- throw new RuntimeException("blob is too large!");
- }
-
- if (mActiveBytes + BLOB_HEADER_SIZE + data.length > mMaxBytes
- || mActiveEntries * 2 >= mMaxEntries) {
- flipRegion();
- }
-
- if (!lookupInternal(key, mActiveHashStart)) {
- // If we don't have an existing entry with the same key, increase
- // the entry count.
- mActiveEntries++;
- writeInt(mIndexHeader, IH_ACTIVE_ENTRIES, mActiveEntries);
- }
-
- insertInternal(key, data, data.length);
- updateIndexHeader();
- }
-
- // Appends the data to the active file. It also updates the hash entry.
- // The proper hash entry (suitable for insertion or replacement) must be
- // pointed by mSlotOffset.
- private void insertInternal(long key, byte[] data, int length)
- throws IOException {
- byte[] header = mBlobHeader;
- int sum = checkSum(data);
- writeLong(header, BH_KEY, key);
- writeInt(header, BH_CHECKSUM, sum);
- writeInt(header, BH_OFFSET, mActiveBytes);
- writeInt(header, BH_LENGTH, length);
- mActiveDataFile.write(header);
- mActiveDataFile.write(data, 0, length);
-
- mIndexBuffer.putLong(mSlotOffset, key);
- mIndexBuffer.putInt(mSlotOffset + 8, mActiveBytes);
- mActiveBytes += BLOB_HEADER_SIZE + length;
- writeInt(mIndexHeader, IH_ACTIVE_BYTES, mActiveBytes);
- }
-
- public static class LookupRequest {
- public long key; // input: the key to find
- public byte[] buffer; // input/output: the buffer to store the blob
- public int length; // output: the length of the blob
- }
-
- // This method is for one-off lookup. For repeated lookup, use the version
- // accepting LookupRequest to avoid repeated memory allocation.
- private LookupRequest mLookupRequest = new LookupRequest();
- public byte[] lookup(long key) throws IOException {
- mLookupRequest.key = key;
- mLookupRequest.buffer = null;
- if (lookup(mLookupRequest)) {
- return mLookupRequest.buffer;
- } else {
- return null;
- }
- }
-
- // Returns true if the associated blob for the given key is available.
- // The blob is stored in the buffer pointed by req.buffer, and the length
- // is in stored in the req.length variable.
- //
- // The user can input a non-null value in req.buffer, and this method will
- // try to use that buffer. If that buffer is not large enough, this method
- // will allocate a new buffer and assign it to req.buffer.
- //
- // This method tries not to throw IOException even if the data file is
- // corrupted, but it can still throw IOException if things get strange.
- public boolean lookup(LookupRequest req) throws IOException {
- // Look up in the active region first.
- if (lookupInternal(req.key, mActiveHashStart)) {
- if (getBlob(mActiveDataFile, mFileOffset, req)) {
- return true;
- }
- }
-
- // We want to copy the data from the inactive file to the active file
- // if it's available. So we keep the offset of the hash entry so we can
- // avoid looking it up again.
- int insertOffset = mSlotOffset;
-
- // Look up in the inactive region.
- if (lookupInternal(req.key, mInactiveHashStart)) {
- if (getBlob(mInactiveDataFile, mFileOffset, req)) {
- // If we don't have enough space to insert this blob into
- // the active file, just return it.
- if (mActiveBytes + BLOB_HEADER_SIZE + req.length > mMaxBytes
- || mActiveEntries * 2 >= mMaxEntries) {
- return true;
- }
- // Otherwise copy it over.
- mSlotOffset = insertOffset;
- try {
- insertInternal(req.key, req.buffer, req.length);
- mActiveEntries++;
- writeInt(mIndexHeader, IH_ACTIVE_ENTRIES, mActiveEntries);
- updateIndexHeader();
- } catch (Throwable t) {
- Log.e(TAG, "cannot copy over");
- }
- return true;
- }
- }
-
- return false;
- }
-
-
- // Copies the blob for the specified offset in the specified file to
- // req.buffer. If req.buffer is null or too small, allocate a buffer and
- // assign it to req.buffer.
- // Returns false if the blob is not available (either the index file is
- // not sync with the data file, or one of them is corrupted). The length
- // of the blob is stored in the req.length variable.
- private boolean getBlob(RandomAccessFile file, int offset,
- LookupRequest req) throws IOException {
- byte[] header = mBlobHeader;
- long oldPosition = file.getFilePointer();
- try {
- file.seek(offset);
- if (file.read(header) != BLOB_HEADER_SIZE) {
- Log.w(TAG, "cannot read blob header");
- return false;
- }
- long blobKey = readLong(header, BH_KEY);
- if (blobKey != req.key) {
- Log.w(TAG, "blob key does not match: " + blobKey);
- return false;
- }
- int sum = readInt(header, BH_CHECKSUM);
- int blobOffset = readInt(header, BH_OFFSET);
- if (blobOffset != offset) {
- Log.w(TAG, "blob offset does not match: " + blobOffset);
- return false;
- }
- int length = readInt(header, BH_LENGTH);
- if (length < 0 || length > mMaxBytes - offset - BLOB_HEADER_SIZE) {
- Log.w(TAG, "invalid blob length: " + length);
- return false;
- }
- if (req.buffer == null || req.buffer.length < length) {
- req.buffer = new byte[length];
- }
-
- byte[] blob = req.buffer;
- req.length = length;
-
- if (file.read(blob, 0, length) != length) {
- Log.w(TAG, "cannot read blob data");
- return false;
- }
- if (checkSum(blob, 0, length) != sum) {
- Log.w(TAG, "blob checksum does not match: " + sum);
- return false;
- }
- return true;
- } catch (Throwable t) {
- Log.e(TAG, "getBlob failed.", t);
- return false;
- } finally {
- file.seek(oldPosition);
- }
- }
-
- // Tries to look up a key in the specified hash region.
- // Returns true if the lookup is successful.
- // The slot offset in the index file is saved in mSlotOffset. If the lookup
- // is successful, it's the slot found. Otherwise it's the slot suitable for
- // insertion.
- // If the lookup is successful, the file offset is also saved in
- // mFileOffset.
- private int mSlotOffset;
- private int mFileOffset;
- private boolean lookupInternal(long key, int hashStart) throws IOException {
- int slot = (int) (key % mMaxEntries);
- if (slot < 0) slot += mMaxEntries;
- int slotBegin = slot;
- while (true) {
- int offset = hashStart + slot * 12;
- long candidateKey = mIndexBuffer.getLong(offset);
- int candidateOffset = mIndexBuffer.getInt(offset + 8);
- if (candidateOffset == 0) {
- mSlotOffset = offset;
- return false;
- } else if (candidateKey == key) {
- mSlotOffset = offset;
- mFileOffset = candidateOffset;
- return true;
- } else {
- if (++slot >= mMaxEntries) {
- slot = 0;
- }
- if (slot == slotBegin) {
- Log.w(TAG, "corrupted index: clear the slot.");
- mIndexBuffer.putInt(hashStart + slot * 12 + 8, 0);
- }
- }
- }
- }
-
- public void syncIndex() {
- try {
- mIndexBuffer.force();
- } catch (Throwable t) {
- Log.w(TAG, "sync index failed", t);
- }
- }
-
- public void syncAll() {
- syncIndex();
- try {
- mDataFile0.getFD().sync();
- } catch (Throwable t) {
- Log.w(TAG, "sync data file 0 failed", t);
- }
- try {
- mDataFile1.getFD().sync();
- } catch (Throwable t) {
- Log.w(TAG, "sync data file 1 failed", t);
- }
- }
-
- // This is for testing only.
- //
- // Returns the active count (mActiveEntries). This also verifies that
- // the active count matches matches what's inside the hash region.
- int getActiveCount() {
- int count = 0;
- for (int i = 0; i < mMaxEntries; i++) {
- int offset = mActiveHashStart + i * 12;
- long candidateKey = mIndexBuffer.getLong(offset);
- int candidateOffset = mIndexBuffer.getInt(offset + 8);
- if (candidateOffset != 0) ++count;
- }
- if (count == mActiveEntries) {
- return count;
- } else {
- Log.e(TAG, "wrong active count: " + mActiveEntries + " vs " + count);
- return -1; // signal failure.
- }
- }
-
- int checkSum(byte[] data) {
- mAdler32.reset();
- mAdler32.update(data);
- return (int) mAdler32.getValue();
- }
-
- int checkSum(byte[] data, int offset, int nbytes) {
- mAdler32.reset();
- mAdler32.update(data, offset, nbytes);
- return (int) mAdler32.getValue();
- }
-
- static void closeSilently(Closeable c) {
- if (c == null) return;
- try {
- c.close();
- } catch (Throwable t) {
- // do nothing
- }
- }
-
- static int readInt(byte[] buf, int offset) {
- return (buf[offset] & 0xff)
- | ((buf[offset + 1] & 0xff) << 8)
- | ((buf[offset + 2] & 0xff) << 16)
- | ((buf[offset + 3] & 0xff) << 24);
- }
-
- static long readLong(byte[] buf, int offset) {
- long result = buf[offset + 7] & 0xff;
- for (int i = 6; i >= 0; i--) {
- result = (result << 8) | (buf[offset + i] & 0xff);
- }
- return result;
- }
-
- static void writeInt(byte[] buf, int offset, int value) {
- for (int i = 0; i < 4; i++) {
- buf[offset + i] = (byte) (value & 0xff);
- value >>= 8;
- }
- }
-
- static void writeLong(byte[] buf, int offset, long value) {
- for (int i = 0; i < 8; i++) {
- buf[offset + i] = (byte) (value & 0xff);
- value >>= 8;
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/ComboAlbumSet.java b/new3d/src/com/android/gallery3d/data/ComboAlbumSet.java
deleted file mode 100644
index ec255ac..0000000
--- a/new3d/src/com/android/gallery3d/data/ComboAlbumSet.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-// ComboAlbumSet combines multiple media sets into one. It lists all sub
-// media sets from the input album sets.
-// This only handles SubMediaSets, not MediaItems. (That's all we need now)
-public class ComboAlbumSet extends MediaSet implements MediaSet.MediaSetListener {
- private static final String TAG = "ComboAlbumSet";
- private final MediaSet[] mSets;
- private long mUniqueId;
-
- public ComboAlbumSet(DataManager dataManager, int parentId, int childKey,
- MediaSet ... mediaSets) {
- mUniqueId = dataManager.obtainSetId(parentId, childKey, this);
- mSets = mediaSets;
- for (MediaSet set : mSets) {
- set.setContentListener(this);
- }
- }
-
- @Override
- public long getUniqueId() {
- return mUniqueId;
- }
-
- @Override
- public MediaSet getSubMediaSet(int index) {
- for (MediaSet set : mSets) {
- int size = set.getSubMediaSetCount();
- if (index < size) {
- return set.getSubMediaSet(index);
- }
- index -= size;
- }
- throw new IndexOutOfBoundsException();
- }
-
- @Override
- public int getSubMediaSetCount() {
- int count = 0;
- for (MediaSet set : mSets) {
- count += set.getSubMediaSetCount();
- }
- return count;
- }
-
- @Override
- public String getName() {
- return TAG;
- }
-
- @Override
- public int getTotalMediaItemCount() {
- int count = 0;
- for (MediaSet set : mSets) {
- count += set.getTotalMediaItemCount();
- }
- return count;
- }
-
- @Override
- public boolean reload() {
- boolean changed = false;
- for (MediaSet set : mSets) {
- changed |= set.reload();
- }
- return changed;
- }
-
- public void onContentDirty() {
- if (mListener != null) {
- mListener.onContentDirty();
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/DataManager.java b/new3d/src/com/android/gallery3d/data/DataManager.java
deleted file mode 100644
index 95f01e7..0000000
--- a/new3d/src/com/android/gallery3d/data/DataManager.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.net.Uri;
-import android.os.HandlerThread;
-import android.os.Looper;
-import android.os.Process;
-import android.util.Log;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.util.IdentityCache;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-// DataManager manages all media sets and media items in the system.
-//
-// Current organization:
-// ComboMediaSet
-// -- MergeAlbumSet
-// -- LocalAlbumSet(isImage=true) .. LocalAlbum(isImage=true) .. LocalImage
-// -- LocalAlbumSet(isImage=false) .. LocalAlbum(isImage=false) .. LocalVideo
-// -- PicasaAlbumSet .. PicasaAlbum .. PicasaImage
-//
-// Each MediaSet and MediaItem has a unique 64 bits id. The most significant
-// 32 bits represents its parent, and the least significant 32 bits represents
-// the self id. For MediaSet the self id is is globally unique, but for
-// MediaItem it's unique only relative to its parent.
-//
-// To make sure the id is the same when the MediaSet is re-created, a key
-// is provided to obtainSetId() to make sure the same self id will be used as
-// when the parent and key are the same.
-
-public class DataManager {
- private static final String TAG = "DataManager";
- private static int PICASA_CACHE_MAX_ENTRIES = 5000;
- private static int PICASA_CACHE_MAX_BYTES = 200 * 1024 * 1024;
- private static String PICASA_CACHE_FILE = "/picasaweb";
-
- // This is a predefined parent id for sets created directly by DataManager.
- public static final int ID_ROOT = 0;
-
- // This is predefined child key for sets.
- public static final int KEY_COMBO = 0;
- public static final int KEY_MERGE = 1;
- public static final int KEY_LOCAL_IMAGE = 2;
- public static final int KEY_LOCAL_VIDEO = 3;
- public static final int KEY_PICASA = 4;
-
- private GalleryContext mContext;
- private MediaSet mRootSet;
- private HandlerThread mDataThread;
- private IdentityCache<Integer, MediaSet> mMediaSetCache;
- private HashMap<Long, Integer> mKeyToSelfId;
- private BlobCache mPicasaCache = null;
-
- public DataManager(GalleryContext context) {
- mContext = context;
- mMediaSetCache = new IdentityCache<Integer, MediaSet>();
- mKeyToSelfId = new HashMap<Long, Integer>();
- }
-
- public static long makeId(int parent, int self) {
- long result = parent;
- return (result << 32) | (self & 0xffffffffL);
- }
-
- public static int extractSelfId(long id) {
- return (int) id;
- }
-
- public static int extractParentId(long id) {
- return (int) (id >> 32);
- }
-
- private int mNextSelfId = 1;
- public long obtainSetId(int parentId, int childKey, MediaSet self) {
- long key = parentId;
- key = (key << 32) | (childKey & 0xffffffffL);
-
- int selfId;
- Integer value = mKeyToSelfId.get(key);
-
- if (value != null) {
- selfId = value;
- } else {
- while (mMediaSetCache.get(mNextSelfId) != null
- || mNextSelfId == ID_ROOT) {
- ++mNextSelfId;
- }
- selfId = mNextSelfId++;
- mKeyToSelfId.put(key, selfId);
- }
-
- mMediaSetCache.put(selfId, self);
- return makeId(parentId, selfId);
- }
-
- // Return null when we cannot instantiate a BlobCache, e.g.:
- // there is no SD card found.
- public BlobCache getPicasaCache() {
- if (mPicasaCache == null) {
- String path = getPicasaCachePath();
- if (path == null) {
- return null;
- } else {
- try {
- mPicasaCache = new BlobCache(path, PICASA_CACHE_MAX_ENTRIES,
- PICASA_CACHE_MAX_BYTES, false);
- } catch (IOException e) {
- Log.e(TAG, "Cannot instantiate Picasaweb Cache!", e);
- }
- }
- }
- return mPicasaCache;
- }
-
- private String getPicasaCachePath() {
- File cacheDir = mContext.getAndroidContext().getExternalCacheDir();
- return cacheDir == null
- ? null
- : cacheDir.getAbsolutePath() + PICASA_CACHE_FILE;
- }
-
- public MediaSet getRootSet() {
- if (mRootSet == null) {
- PicasaAlbumSet picasaSet = new PicasaAlbumSet(
- ID_ROOT, KEY_PICASA, mContext);
- LocalAlbumSet localImageSet = new LocalAlbumSet(
- ID_ROOT, KEY_LOCAL_IMAGE, mContext, true);
- LocalAlbumSet localVideoSet = new LocalAlbumSet(
- ID_ROOT, KEY_LOCAL_VIDEO, mContext, false);
-
- MediaSet localSet = new MergeAlbumSet(
- this, ID_ROOT, KEY_MERGE,
- LocalAlbum.sDateTakenComparator,
- localImageSet, localVideoSet);
-
- mRootSet = new ComboAlbumSet(
- this, ID_ROOT, KEY_COMBO,
- localSet, picasaSet);
- mRootSet.reload();
- }
- return mRootSet;
- }
-
- public synchronized Looper getDataLooper() {
- if (mDataThread == null ) {
- mDataThread = new HandlerThread(
- "DataThread", Process.THREAD_PRIORITY_BACKGROUND);
- mDataThread.start();
- }
- return mDataThread.getLooper();
- }
-
- public MediaSet getMediaSet(int id) {
- return mMediaSetCache.get(id);
- }
-
- public MediaSet getMediaSet(int parentId, int childKey) {
- long key = parentId;
- key = (key << 32) | (childKey & 0xffffffffL);
-
- Integer selfId = mKeyToSelfId.get(key);
- if (selfId == null) return null;
-
- return getMediaSet(selfId);
- }
-
- public int getSupportedOperations(long uniqueId) {
- int parentId = DataManager.extractParentId(uniqueId);
- MediaSet parent = getMediaSet(parentId);
- return parent.getSupportedOperations(uniqueId);
- }
-
- public void delete(long uniqueId) {
- int parentId = DataManager.extractParentId(uniqueId);
- MediaSet parent = getMediaSet(parentId);
- parent.delete(uniqueId);
- }
-
- public void rotate(long uniqueId, int degrees) {
- int parentId = DataManager.extractParentId(uniqueId);
- MediaSet parent = getMediaSet(parentId);
- parent.rotate(uniqueId, degrees);
- }
-
- public Uri getMediaItemUri(long uniqueId) {
- int parentId = DataManager.extractParentId(uniqueId);
- MediaSet parent = getMediaSet(parentId);
- return parent.getMediaItemUri(uniqueId);
- }
-
- public int getMediaType(long uniqueId) {
- int parentId = DataManager.extractParentId(uniqueId);
- MediaSet parent = getMediaSet(parentId);
- return parent.getMediaType(uniqueId);
- }
-
- public Map<Integer, String> getDetails(long uniqueId) {
- // TODO: implement get details
- return null;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/DecodeService.java b/new3d/src/com/android/gallery3d/data/DecodeService.java
deleted file mode 100644
index 7213698..0000000
--- a/new3d/src/com/android/gallery3d/data/DecodeService.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.LargeBitmap;
-import android.graphics.BitmapFactory.Options;
-import android.util.Log;
-
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.FutureListener;
-import com.android.gallery3d.util.FutureTask;
-import com.android.gallery3d.util.Utils;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.concurrent.Callable;
-import java.util.concurrent.Executor;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-public class DecodeService {
- private static final String TAG = "DecodeService";
-
- private static final int CORE_POOL_SIZE = 1;
- private static final int MAX_POOL_SIZE = 1;
- private static final int KEEP_ALIVE_TIME = 10000; // 10 seconds
- private static final int JPEG_MARK_POSITION = 60 * 1024;
-
- private final Executor mExecutor = new ThreadPoolExecutor(
- CORE_POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME,
- TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
-
- public Future<Bitmap> requestDecode(
- File file, Options options, FutureListener<? super Bitmap> listener) {
- if (options == null) options = new Options();
- FutureTask<Bitmap> task = new DecodeFutureTask(
- new DecodeFile(file, options), options, listener);
- mExecutor.execute(task);
- return task;
- }
-
- public FutureTask<Bitmap> requestDecode(
- byte[] bytes, Options options, FutureListener<? super Bitmap> listener) {
- return requestDecode(bytes, 0, bytes.length, options, listener);
- }
-
- public FutureTask<Bitmap> requestDecode(
- byte[] bytes, int offset, int length,
- Options options, FutureListener<? super Bitmap> listener) {
- if (options == null) options = new Options();
- if (offset < 0 || length <= 0 || offset + length > bytes.length) {
- throw new IllegalArgumentException(String.format(
- "offset = %s, length = %s, bytes = %s",
- offset, length, bytes.length));
- }
- FutureTask<Bitmap> task = new DecodeFutureTask(
- new DecodeByteArray(bytes, offset, length, options),
- options, listener);
- mExecutor.execute(task);
- return task;
- }
-
- public FutureTask<Bitmap> requestDecode(
- File file, Options options, int targetLength, int maxPixelCount,
- FutureListener<? super Bitmap> listener) {
- if (options == null) options = new Options();
- FutureTask<Bitmap> task = new DecodeFutureTask(
- new DecodeAndSampleFile(file, options, targetLength, maxPixelCount),
- options, listener);
- mExecutor.execute(task);
- return task;
- }
-
- public FutureTask<LargeBitmap> requestCreateLargeBitmap(
- byte[] bytes, int offset, int length,
- FutureListener<? super LargeBitmap> listener) {
- if (offset < 0 || length <= 0 || offset + length > bytes.length) {
- throw new IllegalArgumentException(String.format(
- "offset = %s, length = %s, bytes = %s",
- offset, length, bytes.length));
- }
- FutureTask<LargeBitmap> task = new FutureTask<LargeBitmap>(
- new CreateLargeBitampFromByteArray(
- bytes, offset, length, false), listener);
- mExecutor.execute(task);
- return task;
- }
-
- public FutureTask<LargeBitmap> requestCreateLargeBitmap(
- String filePath, FutureListener<? super LargeBitmap> listener) {
- FutureTask<LargeBitmap> task = new FutureTask<LargeBitmap>(
- new CreateLargeBitampFromFilePath(filePath, false), listener);
- mExecutor.execute(task);
- return task;
- }
-
- private static class DecodeFutureTask extends FutureTask<Bitmap> {
-
- private final Options mOptions;
-
- public DecodeFutureTask(Callable<Bitmap> callable,
- Options options, FutureListener<? super Bitmap> listener) {
- super(callable, listener);
- mOptions = options;
- }
-
- @Override
- public void cancelTask() {
- mOptions.requestCancelDecode();
- }
- }
-
- private static class DecodeFile implements Callable<Bitmap> {
-
- private final File mFile;
- private final Options mOptions;
-
- public DecodeFile(File file, Options options) {
- mFile = file;
- mOptions = options;
- }
-
- public Bitmap call() throws Exception {
- return BitmapFactory.decodeFile(mFile.getAbsolutePath(), mOptions);
- }
- }
-
- private static class DecodeByteArray implements Callable<Bitmap> {
- private final byte[] mBytes;
- private final Options mOptions;
- private final int mOffset;
- private final int mLength;
-
- public DecodeByteArray(
- byte bytes[], int offset, int length, Options options) {
- mBytes = bytes;
- mOffset = offset;
- mLength = length;
- mOptions = options;
- }
-
- public Bitmap call() throws Exception {
- return BitmapFactory.decodeByteArray(mBytes, mOffset, mLength, mOptions);
- }
- }
-
- private static class CreateLargeBitampFromByteArray implements
- Callable<LargeBitmap> {
- private final byte[] mBytes;
- private final int mOffset;
- private final int mLength;
- private final boolean mIsShareable;
-
- public CreateLargeBitampFromByteArray(
- byte bytes[], int offset, int length, boolean isShareable) {
- mBytes = bytes;
- mOffset = offset;
- mLength = length;
- mIsShareable = isShareable;
- }
-
- public LargeBitmap call() throws Exception {
- return BitmapFactory.createLargeBitmap(mBytes, mOffset, mLength,
- mIsShareable);
- }
- }
-
- private static class CreateLargeBitampFromFilePath implements
- Callable<LargeBitmap> {
- private final String mFilePath;
- private final boolean mIsShareable;
-
- public CreateLargeBitampFromFilePath(
- String filePath, boolean isShareable) {
- mFilePath = filePath;
- mIsShareable = isShareable;
- }
-
- public LargeBitmap call() throws Exception {
- return BitmapFactory.createLargeBitmap(mFilePath, mIsShareable);
- }
- }
-
- private static class DecodeAndSampleFile implements Callable<Bitmap> {
-
- private final int mTargetLength;
- private final int mMaxPixelCount;
- private final File mFile;
- private final Options mOptions;
-
- public DecodeAndSampleFile(
- File file, Options options, int targetLength, int maxPixelCount) {
- mFile = file;
- mOptions = options;
- mTargetLength = targetLength;
- mMaxPixelCount = maxPixelCount;
- }
-
- public Bitmap call() throws IOException {
- BufferedInputStream bis = new BufferedInputStream(
- new FileInputStream(mFile), JPEG_MARK_POSITION);
- try {
- // Decode bufferedInput for calculating a sample size.
- final BitmapFactory.Options options = mOptions;
- options.inJustDecodeBounds = true;
- bis.mark(JPEG_MARK_POSITION);
- BitmapFactory.decodeStream(bis, null, options);
- if (options.mCancel) return null;
-
- try {
- bis.reset();
- } catch (IOException e) {
- Log.w(TAG, "failed in resetting the buffer after reading the jpeg header", e);
- bis.close();
- bis = new BufferedInputStream(new FileInputStream(mFile));
- }
-
- options.inSampleSize = Utils.computeSampleSize(
- options, mTargetLength, mMaxPixelCount);
- options.inJustDecodeBounds = false;
- return BitmapFactory.decodeStream(bis, null, options);
- } finally {
- bis.close();
- }
- }
-
- }
-
-}
diff --git a/new3d/src/com/android/gallery3d/data/DownloadService.java b/new3d/src/com/android/gallery3d/data/DownloadService.java
deleted file mode 100644
index 47246e5..0000000
--- a/new3d/src/com/android/gallery3d/data/DownloadService.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import com.android.gallery3d.util.FutureListener;
-import com.android.gallery3d.util.FutureTask;
-
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.concurrent.Callable;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-public class DownloadService {
- private static final int CORE_POOL_SIZE = 2;
- private static final int MAX_POOL_SIZE = 4;
- private static final int KEEP_ALIVE_TIME = 10000;
-
- private final ThreadPoolExecutor mExecutor = new ThreadPoolExecutor(
- CORE_POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME,
- TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
-
- public FutureTask<Void> requestDownload(
- URL url, File file, FutureListener<Void> listener) {
- FutureTask<Void> task = new FutureTask<Void>(
- new DownloadToFile(url, file), listener);
- mExecutor.execute(task);
- return task;
- }
-
- public FutureTask<byte[]> requestDownload(
- URL url, FutureListener<? super byte[]> listener) {
- FutureTask<byte[]> task = new FutureTask<byte[]>(
- new DownloadToByteArray(url), listener);
- mExecutor.execute(task);
- return task;
- }
-
- private static void download(URL url, OutputStream output) throws IOException {
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- try {
- if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
- throw new RuntimeException(String.format("connection error: %s - %s",
- conn.getResponseCode(), conn.getResponseMessage()));
- }
- InputStream input = conn.getInputStream();
- byte buffer[] = new byte[4096];
- int rc = input.read(buffer, 0, buffer.length);
- while (rc > 0) {
- output.write(buffer, 0, rc);
- rc = input.read(buffer, 0, buffer.length);
- }
- } finally {
- conn.disconnect();
- }
- }
-
- private static class DownloadToFile implements Callable<Void> {
-
- private final URL mUrl;
- private final File mFile;
-
- public DownloadToFile(URL url, File file) {
- mUrl = url;
- mFile = file;
- }
-
- public Void call() throws Exception {
- BufferedOutputStream bos =
- new BufferedOutputStream(new FileOutputStream(mFile));
- try {
- download(mUrl, bos);
- return null;
- } finally {
- bos.close();
- }
- }
- }
-
- private static class DownloadToByteArray implements Callable<byte[]> {
- private final URL mUrl;
-
- public DownloadToByteArray(URL url) {
- mUrl = url;
- }
-
- public byte[] call() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- download(mUrl, baos);
- return baos.toByteArray();
- } finally {
- baos.close();
- }
- }
- }
-
-}
diff --git a/new3d/src/com/android/gallery3d/data/ImageService.java b/new3d/src/com/android/gallery3d/data/ImageService.java
deleted file mode 100644
index 485db0d..0000000
--- a/new3d/src/com/android/gallery3d/data/ImageService.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.content.ContentResolver;
-import android.graphics.Bitmap;
-import android.os.Process;
-import android.provider.MediaStore.Images;
-import android.provider.MediaStore.Video;
-
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.FutureHelper;
-import com.android.gallery3d.util.FutureListener;
-import com.android.gallery3d.util.Utils;
-
-import java.util.concurrent.Executor;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class ImageService {
- private static final String TAG = "ImageService";
-
- private static final int MICRO_TARGET_PIXELS = 128 * 128;
- private static final int CORE_POOL_SIZE = 1;
- private static final int MAX_POOL_SIZE = 1;
- private static final int KEEP_ALIVE_TIME = 10000; // 10 seconds
-
- private final Executor mExecutor = new ThreadPoolExecutor(
- CORE_POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME,
- TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(),
- new MyThreadFactory());
-
- private final ContentResolver mContentResolver;
-
- public ImageService(ContentResolver contentResolver) {
- mContentResolver = contentResolver;
- }
-
- public Future<Bitmap> requestImageThumbnail(
- int id, int type, FutureListener<? super Bitmap> listener) {
- if (type != MediaItem.TYPE_MICROTHUMBNAIL
- && type != MediaItem.TYPE_THUMBNAIL) {
- throw new IllegalArgumentException(String.format("type = %s", type));
- }
- GetImageThumbnail task =
- new GetImageThumbnail(id, type, mContentResolver, listener);
- mExecutor.execute(task);
- return task;
- }
-
- public Future<Bitmap> requestVideoThumbnail(
- int id, int type, FutureListener<? super Bitmap> listener) {
- if (type != MediaItem.TYPE_MICROTHUMBNAIL
- && type != MediaItem.TYPE_THUMBNAIL
- && type != MediaItem.TYPE_FULL_IMAGE) {
- throw new IllegalArgumentException(String.format("type = %s", type));
- }
- GetVideoThumbnail task =
- new GetVideoThumbnail(id, type, mContentResolver, listener);
- mExecutor.execute(task);
- return task;
- }
-
- private static class GetImageThumbnail extends FutureHelper<Bitmap> implements Runnable {
- private final int STATE_READY = 0;
- private final int STATE_RUNNING = 1;
- private final int STATE_CANCELED = 2;
- private final int STATE_RAN = 4;
-
- // mState tries to guard that onCancel() is called only when
- // getThumbnail() is being executed.
- private AtomicInteger mState = new AtomicInteger(STATE_READY);
- private final int mId;
- private final int mType;
- private final ContentResolver mResolver;
-
- public GetImageThumbnail(int id, int type, ContentResolver resolver,
- FutureListener<? super Bitmap> listener) {
- super(listener);
- mId = id;
- mType = type;
- mResolver= resolver;
- }
-
- public void run() {
- Bitmap bitmap = null;
- try {
- bitmap = getThumbnail();
- } catch (Throwable throwable) {
- setException(throwable);
- return;
- }
- if (!isCancelled()) {
- if (bitmap == null && isCancelling()) {
- cancelled();
- } else {
- setResult(bitmap);
- }
- }
- }
-
- @Override
- protected void onCancel() {
- if (mState.compareAndSet(STATE_READY, STATE_CANCELED)) {
- cancelled();
- } else if (mState.compareAndSet(STATE_RUNNING, STATE_CANCELED)) {
- switch (mType) {
- case MediaItem.TYPE_THUMBNAIL:
- case MediaItem.TYPE_MICROTHUMBNAIL:
- // TODO: MediaProvider doesn't provide a way to specify
- // which kind of thumbnail to be canceled. We should
- // try to fix the issue in MediaProvider or here.
- Images.Thumbnails.cancelThumbnailRequest(mResolver, mId);
- break;
- default:
- throw new IllegalArgumentException();
- }
- }
- }
-
- private Bitmap getThumbnail() {
- Bitmap result = null;
- int kind;
-
- switch (mType) {
- case MediaItem.TYPE_THUMBNAIL:
- kind = Images.Thumbnails.MINI_KIND;
- break;
- case MediaItem.TYPE_MICROTHUMBNAIL:
- kind = Images.Thumbnails.MICRO_KIND;
- break;
- default:
- throw new IllegalArgumentException();
- }
-
- if (mState.compareAndSet(STATE_READY, STATE_RUNNING)) {
- result = Images.Thumbnails.getThumbnail(
- mResolver, mId, kind, null);
- mState.compareAndSet(STATE_RUNNING, STATE_RAN);
- }
-
- return result;
- }
- }
-
- private static class GetVideoThumbnail extends FutureHelper<Bitmap> implements Runnable {
- private final int STATE_READY = 0;
- private final int STATE_RUNNING = 1;
- private final int STATE_CANCELED = 2;
- private final int STATE_RAN = 4;
-
- private AtomicInteger mState = new AtomicInteger(STATE_READY);
- private final int mId;
- private final int mType;
- private final ContentResolver mResolver;
-
- public GetVideoThumbnail(int id, int type, ContentResolver resolver,
- FutureListener<? super Bitmap> listener) {
- super(listener);
- mId = id;
- mType = type;
- mResolver= resolver;
- }
-
- public void run() {
- Bitmap bitmap = null;
- try {
- bitmap = getThumbnail();
- } catch (Throwable throwable) {
- setException(throwable);
- return;
- }
- if (!isCancelled()) {
- if (bitmap == null && isCancelling()) {
- cancelled();
- } else {
- setResult(bitmap);
- }
- }
- }
-
- @Override
- protected void onCancel() {
- if (mState.compareAndSet(STATE_READY, STATE_CANCELED)) {
- cancelled();
- } else if (mState.compareAndSet(STATE_RUNNING, STATE_CANCELED)) {
- // TODO: fix the issue that we cannot cancel only one request
- Video.Thumbnails.cancelThumbnailRequest(mResolver, mId);
- }
- }
-
- private Bitmap getThumbnail() {
- Bitmap result = null;
- int kind;
-
- switch (mType) {
- case MediaItem.TYPE_FULL_IMAGE:
- case MediaItem.TYPE_THUMBNAIL:
- kind = Video.Thumbnails.MINI_KIND;
- break;
- case MediaItem.TYPE_MICROTHUMBNAIL:
- kind = Video.Thumbnails.MICRO_KIND;
- break;
- default:
- throw new IllegalArgumentException();
- }
-
- if (mState.compareAndSet(STATE_READY, STATE_RUNNING)) {
- result = Video.Thumbnails.getThumbnail(
- mResolver, mId, kind, null);
- mState.compareAndSet(STATE_RUNNING, STATE_RAN);
- }
-
- return result;
- }
- }
-
- class MyThreadFactory implements ThreadFactory {
- public Thread newThread(final Runnable r) {
- return new Thread() {
- public void run() {
- Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
- r.run();
- }
- };
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/LocalAlbum.java b/new3d/src/com/android/gallery3d/data/LocalAlbum.java
deleted file mode 100644
index 9572255..0000000
--- a/new3d/src/com/android/gallery3d/data/LocalAlbum.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.content.ContentResolver;
-import android.database.ContentObserver;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Handler;
-import android.provider.MediaStore.Images;
-import android.provider.MediaStore.Video;
-import android.provider.MediaStore.Images.ImageColumns;
-import android.provider.MediaStore.Video.VideoColumns;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.util.Utils;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-// LocalAlbumSet lists all media items in one bucket on local storage.
-// The media items need to be all images or all videos, but not both.
-public class LocalAlbum extends MediaSet {
- private static final String TAG = "LocalAlbum";
- private static final String[] COUNT_PROJECTION = { "count(*)" };
- private static final String DELETE_ITEM_WHERE_CLAUSE = "_id=?";
- private final String mWhereClause;
- private final String mOrderClause;
- private final Uri mBaseUri;
- private final String[] mProjection;
- public static final Comparator<LocalAlbum> sBucketNameComparator =
- new BucketNameComparator();
- public static final Comparator<MediaItem> sDateTakenComparator =
- new DateTakenComparator();
-
- private final GalleryContext mContext;
- private final ContentResolver mResolver;
- private final int mBucketId;
- private final String mBucketName;
- private boolean mIsImage;
- private long mUniqueId;
- private AtomicBoolean mContentDirty = new AtomicBoolean(true);
-
- public LocalAlbum(int parentId, GalleryContext context, int bucketId,
- String name, boolean isImage) {
- mContext = context;
- mResolver = context.getContentResolver();
- mBucketId = bucketId;
- mBucketName = name;
- mIsImage = isImage;
-
- if (isImage) {
- mWhereClause = ImageColumns.BUCKET_ID + "=?";
- mOrderClause = ImageColumns.DATE_TAKEN + " DESC, "
- + ImageColumns._ID + " ASC";
- mBaseUri = Images.Media.EXTERNAL_CONTENT_URI;
- mProjection = LocalImage.PROJECTION;
- } else {
- mWhereClause = VideoColumns.BUCKET_ID + "=?";
- mOrderClause = VideoColumns.DATE_TAKEN + " DESC, "
- + VideoColumns._ID + " ASC";
- mBaseUri = Video.Media.EXTERNAL_CONTENT_URI;
- mProjection = LocalVideo.PROJECTION;
- }
-
- mUniqueId = context.getDataManager().obtainSetId(parentId, bucketId, this);
- mResolver.registerContentObserver(mBaseUri, true, new MyContentObserver());
- }
-
- @Override
- public long getUniqueId() {
- return mUniqueId;
- }
-
- @Override
- public ArrayList<MediaItem> getMediaItem(int start, int count) {
- ImageService imageService = mContext.getImageService();
- DataManager dataManager = mContext.getDataManager();
- Uri uri = mBaseUri.buildUpon()
- .appendQueryParameter("limit", start + "," + count).build();
- ArrayList<MediaItem> list = new ArrayList<MediaItem>();
- Utils.assertNotInRenderThread();
- Cursor cursor = mResolver.query(
- uri, mProjection, mWhereClause,
- new String[]{String.valueOf(mBucketId)},
- mOrderClause);
-
- try {
- while (cursor.moveToNext()) {
- int myId = getMyId();
- if (mIsImage) {
- list.add(LocalImage.load(myId, mContext, cursor, dataManager));
- } else {
- list.add(LocalVideo.load(myId, imageService, cursor, dataManager));
- }
- }
- } finally {
- cursor.close();
- }
- return list;
- }
-
- @Override
- public int getMediaItemCount() {
- Utils.assertNotInRenderThread();
- Cursor cursor = mResolver.query(
- mBaseUri, COUNT_PROJECTION, mWhereClause,
- new String[]{String.valueOf(mBucketId)}, null);
- try {
- Utils.Assert(cursor.moveToNext());
- return cursor.getInt(0);
- } finally {
- cursor.close();
- }
- }
-
- @Override
- public String getName() {
- return mBucketName;
- }
-
- @Override
- public int getTotalMediaItemCount() {
- return getMediaItemCount();
- }
-
- private static class BucketNameComparator implements Comparator<LocalAlbum> {
- public int compare(LocalAlbum s1, LocalAlbum s2) {
- int result = s1.mBucketName.compareTo(s2.mBucketName);
- if (result != 0) return result;
- return Utils.compare(s1.mBucketId, s2.mBucketId);
- }
- }
-
- private static class DateTakenComparator implements Comparator<MediaItem> {
- public int compare(MediaItem item1, MediaItem item2) {
- LocalMediaItem s1 = (LocalMediaItem) item1;
- LocalMediaItem s2 = (LocalMediaItem) item2;
- return -Utils.compare(s1.mDateTakenInMs, s2.mDateTakenInMs);
- }
- }
-
- @Override
- public boolean reload() {
- return mContentDirty.compareAndSet(true, false);
- }
-
- private class MyContentObserver extends ContentObserver {
- public MyContentObserver() {
- super(new Handler(mContext.getMainLooper()));
- }
-
- @Override
- public void onChange(boolean selfChange) {
- if (mContentDirty.compareAndSet(false, true)) {
- if (mListener != null) mListener.onContentDirty();
- }
- }
- }
-
- @Override
- public int getMergeId() {
- return mBucketId;
- }
-
- @Override
- public int getSupportedOperations(long uniqueId) {
- return SUPPORT_DELETE | SUPPORT_ROTATE;
- }
-
- @Override
- public void delete(long uniqueId) {
- Utils.Assert(DataManager.extractParentId(uniqueId) == getMyId());
- int itemId = DataManager.extractSelfId(uniqueId);
- Utils.assertNotInRenderThread();
- mResolver.delete(mBaseUri, DELETE_ITEM_WHERE_CLAUSE,
- new String[] {String.valueOf(itemId)});
- }
-
- @Override
- public void rotate(long uniqueId, int degrees) {
- // TODO
- }
-
- public Uri getMediaItemUri(long uniqueId) {
- Utils.Assert(DataManager.extractParentId(uniqueId) == getMyId());
- int itemId = DataManager.extractSelfId(uniqueId);
- return mBaseUri.buildUpon().appendPath(String.valueOf(itemId)).build();
- }
-
- public void deleteSelf() {
- Utils.assertNotInRenderThread();
- mResolver.delete(mBaseUri, mWhereClause,
- new String[]{String.valueOf(mBucketId)});
- }
-
- public int getMediaType(long uniqueId) {
- return mIsImage ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_VIDEO;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/LocalAlbumSet.java b/new3d/src/com/android/gallery3d/data/LocalAlbumSet.java
deleted file mode 100644
index 2007a15..0000000
--- a/new3d/src/com/android/gallery3d/data/LocalAlbumSet.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.database.ContentObserver;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Handler;
-import android.provider.MediaStore.Images;
-import android.provider.MediaStore.Video;
-import android.provider.MediaStore.Images.ImageColumns;
-import android.provider.MediaStore.Video.VideoColumns;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.util.Utils;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-// LocalAlbumSet lists all image or video albums in the local storage.
-public class LocalAlbumSet extends MediaSet {
- private static final String TAG = "LocalAlbumSet";
-
- // The indices should match the following projections.
- private static final int BUCKET_ID_INDEX = 0;
- private static final int BUCKET_NAME_INDEX = 1;
-
- private static final String[] PROJECTION_IMAGE_BUCKETS = {
- ImageColumns.BUCKET_ID,
- ImageColumns.BUCKET_DISPLAY_NAME };
-
- private static final String[] PROJECTION_VIDEO_BUCKETS = {
- VideoColumns.BUCKET_ID,
- VideoColumns.BUCKET_DISPLAY_NAME };
-
- private final String[] mProjection;
- private final Uri mBaseUri;
-
- private GalleryContext mContext;
- private boolean mIsImage;
- private long mUniqueId;
- private ArrayList<LocalAlbum> mAlbums = new ArrayList<LocalAlbum>();
- private AtomicBoolean mContentDirty = new AtomicBoolean(true);
- private final MyContentObserver mContentObserver;
-
- public LocalAlbumSet(int parentId, int childKey, GalleryContext context,
- boolean isImage) {
- mContext = context;
- mIsImage = isImage;
- if (isImage) {
- mProjection = PROJECTION_IMAGE_BUCKETS;
- mBaseUri = Images.Media.EXTERNAL_CONTENT_URI;
- } else {
- mProjection = PROJECTION_VIDEO_BUCKETS;
- mBaseUri = Video.Media.EXTERNAL_CONTENT_URI;
- }
-
- mUniqueId = context.getDataManager().obtainSetId(parentId, childKey, this);
- mContentObserver = new MyContentObserver();
- context.getContentResolver().registerContentObserver(
- mBaseUri, true, mContentObserver);
- }
-
- @Override
- public long getUniqueId() {
- return mUniqueId;
- }
-
- @Override
- public MediaSet getSubMediaSet(int index) {
- return mAlbums.get(index);
- }
-
- @Override
- public int getSubMediaSetCount() {
- return mAlbums.size();
- }
-
- @Override
- public String getName() {
- return TAG;
- }
-
- @Override
- public int getTotalMediaItemCount() {
- int total = 0;
- for (MediaSet album : mAlbums) {
- total += album.getTotalMediaItemCount();
- }
- return total;
- }
-
- protected ArrayList<LocalAlbum> loadSubMediaSets() {
- Uri uri = mBaseUri.buildUpon().
- appendQueryParameter("distinct", "true").build();
- Utils.assertNotInRenderThread();
- Cursor cursor = mContext.getContentResolver().query(
- uri, mProjection, null, null, null);
- if (cursor == null) throw new NullPointerException();
- HashMap<Integer, String> buffer = new HashMap<Integer, String>();
- try {
- while (cursor.moveToNext()) {
- buffer.put(cursor.getInt(BUCKET_ID_INDEX),
- cursor.getString(BUCKET_NAME_INDEX));
- }
- } finally {
- cursor.close();
- }
-
- ArrayList<LocalAlbum> albums = new ArrayList<LocalAlbum>();
- DataManager dataManager = mContext.getDataManager();
- int parentId = getMyId();
- for (Map.Entry<Integer, String> entry : buffer.entrySet()) {
- int childKey = entry.getKey();
- LocalAlbum album = (LocalAlbum) dataManager.getMediaSet(parentId, childKey);
- if (album == null) {
- album = new LocalAlbum(parentId, mContext,
- childKey, entry.getValue(), mIsImage);
- }
- albums.add(album);
- }
- for (int i = 0, n = albums.size(); i < n; ++i) {
- albums.get(i).reload();
- }
- Collections.sort(albums, LocalAlbum.sBucketNameComparator);
- return albums;
- }
-
- private class MyContentObserver extends ContentObserver {
- public MyContentObserver() {
- super(new Handler(mContext.getMainLooper()));
- }
-
- @Override
- public void onChange(boolean selfChange) {
- if (mContentDirty.compareAndSet(false, true)) {
- if (mListener != null) mListener.onContentDirty();
- }
- }
- }
-
- @Override
- public int getSupportedOperations(long uniqueId) {
- return SUPPORT_DELETE;
- }
-
- @Override
- public void delete(long uniqueId) {
- Utils.Assert(DataManager.extractParentId(uniqueId) == getMyId());
-
- int childId = DataManager.extractSelfId(uniqueId);
- LocalAlbum child = (LocalAlbum) mContext.getDataManager().getMediaSet(childId);
- child.deleteSelf();
- }
-
- @Override
- public boolean reload() {
- if (!mContentDirty.compareAndSet(true, false)) return false;
- ArrayList<LocalAlbum> album = loadSubMediaSets();
- if (album.equals(mAlbums)) return false;
- mAlbums = album;
- return true;
- }
-
- // For debug only. Fake there is a ContentObserver.onChange() event.
- void fakeChange() {
- mContentObserver.dispatchChange(true);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/LocalImage.java b/new3d/src/com/android/gallery3d/data/LocalImage.java
deleted file mode 100644
index 1570661..0000000
--- a/new3d/src/com/android/gallery3d/data/LocalImage.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.FutureListener;
-
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.LargeBitmap;
-import android.provider.MediaStore.Images.ImageColumns;
-import android.util.Log;
-
-import com.android.gallery3d.app.GalleryContext;
-
-import java.io.File;
-
-// LocalImage represents an image in the local storage.
-public class LocalImage extends LocalMediaItem {
-
- private static final int MICRO_TARGET_PIXELS = 128 * 128;
-
- private static final int FULLIMAGE_TARGET_SIZE = 2048;
- private static final int FULLIMAGE_MAX_NUM_PIXELS = 3 * 1024 * 1024;
- private static final String TAG = "LocalImage";
-
- // Must preserve order between these indices and the order of the terms in
- // the following PROJECTION array.
- private static final int INDEX_ID = 0;
- private static final int INDEX_CAPTION = 1;
- private static final int INDEX_MIME_TYPE = 2;
- private static final int INDEX_LATITUDE = 3;
- private static final int INDEX_LONGITUDE = 4;
- private static final int INDEX_DATE_TAKEN = 5;
- private static final int INDEX_DATE_ADDED = 6;
- private static final int INDEX_DATE_MODIFIED = 7;
- private static final int INDEX_DATA = 8;
- private static final int INDEX_ORIENTATION = 9;
-
- static final String[] PROJECTION = {
- ImageColumns._ID, // 0
- ImageColumns.TITLE, // 1
- ImageColumns.MIME_TYPE, // 2
- ImageColumns.LATITUDE, // 3
- ImageColumns.LONGITUDE, // 4
- ImageColumns.DATE_TAKEN, // 5
- ImageColumns.DATE_ADDED, // 6
- ImageColumns.DATE_MODIFIED, // 7
- ImageColumns.DATA, // 8
- ImageColumns.ORIENTATION}; // 9
-
- private final BitmapFactory.Options mOptions = new BitmapFactory.Options();
-
- private long mUniqueId;
- private int mRotation;
- private final GalleryContext mContext;
-
- protected LocalImage(GalleryContext context) {
- mContext = context;
- }
-
- @Override
- public long getUniqueId() {
- return mUniqueId;
- }
-
- @Override
- public synchronized Future<Bitmap>
- requestImage(int type, FutureListener<? super Bitmap> listener) {
- if (type == TYPE_FULL_IMAGE) {
- return mContext.getDecodeService().requestDecode(
- new File(mFilePath), null, FULLIMAGE_TARGET_SIZE,
- FULLIMAGE_MAX_NUM_PIXELS, listener);
- } else {
- return mContext.getImageService()
- .requestImageThumbnail(mId, type, listener);
- }
- }
-
- public static LocalImage load(int parentId, GalleryContext context,
- Cursor cursor, DataManager dataManager) {
- int itemId = cursor.getInt(INDEX_ID);
- LocalImage item = new LocalImage(context);
- item.mId = itemId;
- item.mCaption = cursor.getString(INDEX_CAPTION);
- item.mMimeType = cursor.getString(INDEX_MIME_TYPE);
- item.mLatitude = cursor.getDouble(INDEX_LATITUDE);
- item.mLongitude = cursor.getDouble(INDEX_LONGITUDE);
- item.mDateTakenInMs = cursor.getLong(INDEX_DATE_TAKEN);
- item.mDateAddedInSec = cursor.getLong(INDEX_DATE_ADDED);
- item.mDateModifiedInSec = cursor.getLong(INDEX_DATE_MODIFIED);
- item.mFilePath = cursor.getString(INDEX_DATA);
- item.mRotation = cursor.getInt(INDEX_ORIENTATION);
- item.mUniqueId = DataManager.makeId(parentId, itemId);
-
- return item;
- }
-
- public Future<LargeBitmap> requestLargeImage(int type,
- FutureListener<LargeBitmap> listener) {
- DecodeService service = mContext.getDecodeService();
- return service.requestCreateLargeBitmap(mFilePath, listener);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/LocalMediaItem.java b/new3d/src/com/android/gallery3d/data/LocalMediaItem.java
deleted file mode 100644
index a3b8bd0..0000000
--- a/new3d/src/com/android/gallery3d/data/LocalMediaItem.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-//
-// LocalMediaItem is an abstract class captures those common fields
-// in LocalImage and LocalVideo.
-//
-public abstract class LocalMediaItem extends MediaItem {
-
- private static final String TAG = "LocalMediaItem";
-
- // database fields
- protected int mId;
- protected String mCaption;
- protected String mMimeType;
- protected double mLatitude;
- protected double mLongitude;
- protected long mDateTakenInMs;
- protected long mDateAddedInSec;
- protected long mDateModifiedInSec;
- protected String mFilePath;
-}
diff --git a/new3d/src/com/android/gallery3d/data/LocalVideo.java b/new3d/src/com/android/gallery3d/data/LocalVideo.java
deleted file mode 100644
index f7a1a6a..0000000
--- a/new3d/src/com/android/gallery3d/data/LocalVideo.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.LargeBitmap;
-import android.provider.MediaStore.Video.VideoColumns;
-
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.FutureListener;
-
-// LocalVideo represents a video in the local storage.
-public class LocalVideo extends LocalMediaItem {
-
- private static final int MICRO_TARGET_PIXELS = 128 * 128;
-
- // Must preserve order between these indices and the order of the terms in
- // the following PROJECTION array.
- private static final int INDEX_ID = 0;
- private static final int INDEX_CAPTION = 1;
- private static final int INDEX_MIME_TYPE = 2;
- private static final int INDEX_LATITUDE = 3;
- private static final int INDEX_LONGITUDE = 4;
- private static final int INDEX_DATE_TAKEN = 5;
- private static final int INDEX_DATE_ADDED = 6;
- private static final int INDEX_DATE_MODIFIED = 7;
- private static final int INDEX_DATA = 8;
- private static final int INDEX_DURATION = 9;
-
- static final String[] PROJECTION = new String[] {
- VideoColumns._ID,
- VideoColumns.TITLE,
- VideoColumns.MIME_TYPE,
- VideoColumns.LATITUDE,
- VideoColumns.LONGITUDE,
- VideoColumns.DATE_TAKEN,
- VideoColumns.DATE_ADDED,
- VideoColumns.DATE_MODIFIED,
- VideoColumns.DATA,
- VideoColumns.DURATION};
-
- private long mUniqueId;
- public int mDurationInSec;
- private final ImageService mImageService;
-
- protected LocalVideo(ImageService imageService) {
- mImageService = imageService;
- }
-
- @Override
- public long getUniqueId() {
- return mUniqueId;
- }
-
- @Override
- public synchronized Future<Bitmap>
- requestImage(int type, FutureListener<? super Bitmap> listener) {
- return mImageService.requestVideoThumbnail(mId, type, listener);
- }
-
- public static LocalVideo load(int parentId, ImageService imageService,
- Cursor cursor, DataManager dataManager) {
- int itemId = cursor.getInt(INDEX_ID);
- LocalVideo item = new LocalVideo(imageService);
- item.mId = itemId;
- item.mCaption = cursor.getString(INDEX_CAPTION);
- item.mMimeType = cursor.getString(INDEX_MIME_TYPE);
- item.mLatitude = cursor.getDouble(INDEX_LATITUDE);
- item.mLongitude = cursor.getDouble(INDEX_LONGITUDE);
- item.mDateTakenInMs = cursor.getLong(INDEX_DATE_TAKEN);
- item.mDateAddedInSec = cursor.getLong(INDEX_DATE_ADDED);
- item.mDateModifiedInSec = cursor.getLong(INDEX_DATE_MODIFIED);
- item.mFilePath = cursor.getString(INDEX_DATA);
- item.mDurationInSec = cursor.getInt(INDEX_DURATION);
- item.mUniqueId = DataManager.makeId(parentId, itemId);
-
- return item;
- }
-
- public Future<LargeBitmap> requestLargeImage(
- int type, FutureListener<LargeBitmap> listener) {
- throw new UnsupportedOperationException("Cannot regquest a large image"
- + " to a local video!");
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/MediaItem.java b/new3d/src/com/android/gallery3d/data/MediaItem.java
deleted file mode 100644
index 2d4ea44..0000000
--- a/new3d/src/com/android/gallery3d/data/MediaItem.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.graphics.Bitmap;
-import android.graphics.LargeBitmap;
-
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.FutureListener;
-
-// MediaItem represents an image or a video item.
-public abstract class MediaItem {
- public static final int TYPE_COUNT = 3;
- public static final int TYPE_FULL_IMAGE = 0;
- public static final int TYPE_THUMBNAIL = 1;
- public static final int TYPE_MICROTHUMBNAIL = 2;
-
- public static final int IMAGE_READY = 0;
- public static final int IMAGE_WAIT = 1;
- public static final int IMAGE_ERROR = -1;
-
- public abstract long getUniqueId();
- public abstract Future<Bitmap>
- requestImage(int type, FutureListener<? super Bitmap> listener);
-
- public abstract Future<LargeBitmap> requestLargeImage(int type,
- FutureListener<LargeBitmap> listener);
-}
diff --git a/new3d/src/com/android/gallery3d/data/MediaSet.java b/new3d/src/com/android/gallery3d/data/MediaSet.java
deleted file mode 100644
index 75167eb..0000000
--- a/new3d/src/com/android/gallery3d/data/MediaSet.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.net.Uri;
-
-import java.util.ArrayList;
-
-// MediaSet is a directory-like data structure.
-// It contains MediaItems and sub-MediaSets.
-//
-// The primary interface are:
-// getMediaItemCount(), getMediaItem() and
-// getSubMediaSetCount(), getSubMediaSet().
-//
-// getTotalMediaItemCount() returns the number of all MediaItems, including
-// those in sub-MediaSets.
-public abstract class MediaSet {
-
- // Below are the bits returned from getSupportedOperations():
- public static final int SUPPORT_DELETE = 1;
- public static final int SUPPORT_ROTATE = 2;
- public static final int SUPPORT_SHARE = 4;
-
- public static final int MEDIA_TYPE_UNKNOWN = 1;
- public static final int MEDIA_TYPE_IMAGE = 2;
- public static final int MEDIA_TYPE_VIDEO = 4;
- public static final int MEDIA_TYPE_ALL = MEDIA_TYPE_IMAGE | MEDIA_TYPE_VIDEO;
-
- public interface MediaSetListener {
- public void onContentDirty();
- }
-
- public int getMediaItemCount() {
- return 0;
- }
-
- // Returns the media items in the range [start, start + count).
- //
- // The number of media items returned may be less than the specified count
- // if there are not enough media items available. The number of
- // media items available may not be consistent with the return value of
- // getMediaItemCount() because the contents of database may have already
- // changed.
- public ArrayList<MediaItem> getMediaItem(int start, int count) {
- throw new IndexOutOfBoundsException();
- }
-
- public int getSubMediaSetCount() {
- return 0;
- }
-
- public MediaSet getSubMediaSet(int index) {
- throw new IndexOutOfBoundsException();
- }
-
- public abstract int getTotalMediaItemCount();
-
- public abstract long getUniqueId();
- public abstract String getName();
-
- protected MediaSetListener mListener;
-
- public void setContentListener(MediaSetListener listener) {
- mListener = listener;
- }
-
- // Reload the content. Return true if the content is changed; false otherwise.
- // reload should be called in the same thread as getMediaItem(int, int) and
- // getSubMediaSet(int).
- public abstract boolean reload();
-
- public int getSupportedOperations(long uniqueId) {
- return 0;
- }
-
- public void delete(long uniqueId) {
- throw new UnsupportedOperationException();
- }
-
- public void rotate(long uniqueId, int degrees) {
- throw new UnsupportedOperationException();
- }
-
- public Uri getMediaItemUri(long uniqueId) {
- throw new UnsupportedOperationException();
- }
-
- public int getMediaType(long uniqueId) {
- return MEDIA_TYPE_UNKNOWN;
- }
-
- public int getMergeId() {
- return 0;
- }
-
- int getMyId() {
- return DataManager.extractSelfId(getUniqueId());
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/MergeAlbum.java b/new3d/src/com/android/gallery3d/data/MergeAlbum.java
deleted file mode 100644
index 7ca8433..0000000
--- a/new3d/src/com/android/gallery3d/data/MergeAlbum.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-// MergeAlbum merges items from two or more MediaSets. It uses a Comparator to
-// determine the order of items. The items are assumed to be sorted in the input
-// media sets (with the same order that the Comparator uses).
-//
-// This only handles MediaItems, not SubMediaSets.
-public class MergeAlbum extends MediaSet implements MediaSet.MediaSetListener {
- private static final String TAG = "MergeAlbum";
- private final DataManager mDataManager;
- private final long mUniqueId;
- private final int mPageSize;
- private final Comparator<MediaItem> mComparator;
- private final MediaSet[] mSources;
- private final int mMergeId;
-
- private ArrayList<MediaSet> mSets;
- private int mSize; // caches mSets.size()
- private FetchCache[] mFetcher;
-
- // mIndex maps global position to the position of each underlying media sets.
- private TreeMap<Integer, int[]> mIndex;
-
- public MergeAlbum(DataManager dataManager, int parentId, int pageSize,
- Comparator<MediaItem> comparator, MediaSet[] sources, int mergeId) {
- mUniqueId = dataManager.obtainSetId(parentId, mergeId, this);
- mDataManager = dataManager;
- mPageSize = pageSize;
- mComparator = comparator;
- mSources = sources;
- mMergeId = mergeId;
- updateData();
- }
-
- public void updateData() {
- ArrayList<MediaSet> matches = new ArrayList<MediaSet>();
-
- // Find sources that have a sub media set with specified merge id.
- for (MediaSet set : mSources) {
- for (int i = 0, n = set.getSubMediaSetCount(); i < n; i++) {
- MediaSet subset = set.getSubMediaSet(i);
- int mergeId = subset.getMergeId();
- if (mergeId == mMergeId) {
- matches.add(subset);
- }
- }
- }
-
- // If the matches doesn't change, we don't need to update.
- if (mSets != null) {
- int n = matches.size();
- if (n == mSize) {
- int i;
- for (i = 0; i < n; i++) {
- if (matches.get(i) != mSets.get(i)) break;
- }
- if (i == n) return;
- }
- }
-
- mSets = matches;
- mSize = matches.size();
- mFetcher = new FetchCache[mSize];
- for (int i = 0; i < mSize; i++) {
- MediaSet s = mSets.get(i);
- s.setContentListener(this);
- mFetcher[i] = new FetchCache(s, mPageSize);
- }
- mIndex = new TreeMap<Integer, int[]>();
- mIndex.put(0, new int[mSize]);
- }
-
- private void invalidateCache() {
- for (int i = 0; i < mSize; i++) {
- mFetcher[i].invalidate();
- }
- mIndex.clear();
- mIndex.put(0, new int[mSize]);
- }
-
- @Override
- public long getUniqueId() {
- return mUniqueId;
- }
-
- @Override
- public String getName() {
- return TAG;
- }
-
- @Override
- public int getMediaItemCount() {
- return getTotalMediaItemCount();
- }
-
- @Override
- public ArrayList<MediaItem> getMediaItem(int start, int count) {
-
- // First find the nearest mark position <= start.
- SortedMap<Integer, int[]> head = mIndex.headMap(start + 1);
- int markPos = head.lastKey();
- int[] subPos = head.get(markPos).clone();
- MediaItem[] slot = new MediaItem[mSize];
-
- // fill all slots
- for (int i = 0; i < mSize; i++) {
- slot[i] = mFetcher[i].getItem(subPos[i]);
- }
-
- ArrayList<MediaItem> result = new ArrayList<MediaItem>();
-
- for (int i = markPos; i < start + count; i++) {
- int k = -1; // k points to the best slot up to now.
- for (int j = 0; j < mSize; j++) {
- if (slot[j] != null) {
- if (k == -1 || mComparator.compare(slot[j], slot[k]) < 0) {
- k = j;
- }
- }
- }
-
- // If we don't have anything, all streams are exhausted.
- if (k == -1) break;
-
- // Pick the best slot and refill it.
- subPos[k]++;
- if (i >= start) {
- result.add(slot[k]);
- }
- slot[k] = mFetcher[k].getItem(subPos[k]);
-
- // Periodically leave a mark in the index, so we can come back later.
- if ((i + 1) % mPageSize == 0) {
- mIndex.put(i + 1, subPos.clone());
- }
- }
-
- return result;
- }
-
- @Override
- public int getTotalMediaItemCount() {
- int count = 0;
- for (MediaSet set : mSets) {
- count += set.getTotalMediaItemCount();
- }
- return count;
- }
-
- @Override
- public boolean reload() {
- boolean changed = false;
- for (MediaSet set : mSets) {
- changed |= set.reload();
- }
- if (changed) {
- invalidateCache();
- updateData();
- }
- return changed;
- }
-
- public void onContentDirty() {
- if (mListener != null) mListener.onContentDirty();
- }
-
- public void deleteSelf() {
- for (MediaSet set : mSets) {
- mDataManager.delete(set.getUniqueId());
- }
- }
-}
-
-class FetchCache {
- private static final String TAG = "FetchCache";
- private MediaSet mBaseSet;
- private int mPageSize;
- private ArrayList<MediaItem> mCache;
- private int mStartPos;
-
- FetchCache(MediaSet baseSet, int pageSize) {
- mBaseSet = baseSet;
- mPageSize = pageSize;
- }
-
- void invalidate() {
- mCache = null;
- }
-
- MediaItem getItem(int index) {
- boolean needLoading = false;
- if (mCache == null) {
- needLoading = true;
- } else if (index < mStartPos || index >= mStartPos + mPageSize) {
- needLoading = true;
- }
-
- if (needLoading) {
- mCache = mBaseSet.getMediaItem(index, mPageSize);
- mStartPos = index;
- }
-
- if (index < mStartPos || index >= mStartPos + mCache.size()) {
- return null;
- }
-
- return mCache.get(index - mStartPos);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/MergeAlbumSet.java b/new3d/src/com/android/gallery3d/data/MergeAlbumSet.java
deleted file mode 100644
index 0593140..0000000
--- a/new3d/src/com/android/gallery3d/data/MergeAlbumSet.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import com.android.gallery3d.util.Utils;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.TreeSet;
-
-// MergeAlbumSet merges two or more media sets into one.
-// If the the input media sets have sub media sets with the item id,
-// they are merged into one media set.
-public class MergeAlbumSet extends MediaSet implements MediaSet.MediaSetListener {
- private static final String TAG = "MergeAlbumSet";
- private static final int PAGE_SIZE = 100;
- private final long mUniqueId;
- private final DataManager mDataManager;
- private Comparator<MediaItem> mComparator;
- private final MediaSet[] mSets;
- private ArrayList<MergeAlbum> mAlbums = new ArrayList<MergeAlbum>();
- private TreeSet<Integer> mIds = new TreeSet<Integer>();
-
- public MergeAlbumSet(DataManager dataManager, int parentId, int childKey,
- Comparator<MediaItem> comparator, MediaSet ... mediaSets) {
- mUniqueId = dataManager.obtainSetId(parentId, childKey, this);
- mDataManager = dataManager;
- mComparator = comparator;
- mSets = mediaSets;
- updateIds();
- for (MediaSet set : mediaSets) {
- set.setContentListener(this);
- }
- }
-
- @Override
- public long getUniqueId() {
- return mUniqueId;
- }
-
- private void updateIds() {
-
- // allIds keeps all item id of the (sub) media sets in the album sets
- // we want to merge.
- TreeSet<Integer> allIds = new TreeSet<Integer>();
- for (MediaSet set : mSets) {
- for (int i = 0, n = set.getSubMediaSetCount(); i < n; i++) {
- MediaSet subset = set.getSubMediaSet(i);
- int subId = subset.getMergeId();
- allIds.add(subId);
- }
- }
- // Update all existing albums.
- for (MergeAlbum album : mAlbums) {
- album.updateData();
- }
-
- // If there are new ids, create new albums for them.
- for (int subId : allIds) {
- if (mIds.contains(subId)) continue;
- mIds.add(subId);
- mAlbums.add(new MergeAlbum(mDataManager,
- getMyId(), PAGE_SIZE, mComparator, mSets, subId));
- }
- }
-
- @Override
- public MediaSet getSubMediaSet(int index) {
- return mAlbums.get(index);
- }
-
- @Override
- public int getSubMediaSetCount() {
- return mAlbums.size();
- }
-
- @Override
- public String getName() {
- return TAG;
- }
-
- @Override
- public int getTotalMediaItemCount() {
- int count = 0;
- for (MediaSet set : mSets) {
- count += set.getTotalMediaItemCount();
- }
- return count;
- }
-
- @Override
- public boolean reload() {
- boolean changed = false;
- for (MediaSet set : mSets) {
- changed |= set.reload();
- }
- if (changed) updateIds();
- return changed;
- }
-
- public void onContentDirty() {
- if (mListener != null) mListener.onContentDirty();
- }
-
- @Override
- public int getSupportedOperations(long uniqueId) {
- return SUPPORT_DELETE;
- }
-
- @Override
- public void delete(long uniqueId) {
- Utils.Assert(DataManager.extractParentId(uniqueId) == getMyId());
-
- int childId = DataManager.extractSelfId(uniqueId);
- MergeAlbum child = (MergeAlbum) mDataManager.getMediaSet(childId);
- child.deleteSelf();
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/PicasaAlbum.java b/new3d/src/com/android/gallery3d/data/PicasaAlbum.java
deleted file mode 100644
index ab16499..0000000
--- a/new3d/src/com/android/gallery3d/data/PicasaAlbum.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.content.ContentResolver;
-import android.database.ContentObserver;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Handler;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.picasa.AlbumEntry;
-import com.android.gallery3d.picasa.EntrySchema;
-import com.android.gallery3d.picasa.PhotoEntry;
-import com.android.gallery3d.picasa.PicasaContentProvider;
-import com.android.gallery3d.util.Utils;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-// PicasaAlbum lists all images in a Picasa album.
-public class PicasaAlbum extends MediaSet {
- public static final Comparator<PicasaAlbum>
- sEditDateComparator = new EditDateComparator();
-
- private static final String TAG = "PicasaAlbum";
- private static final EntrySchema SCHEMA = PhotoEntry.SCHEMA;
- private static final String[] COUNT_PROJECTION = { "count(*)" };
- private static final String WHERE_CLAUSE = PhotoEntry.Columns.ALBUM_ID + " = ?";
-
- private final AlbumEntry mData;
- private final ContentResolver mResolver;
- private long mUniqueId;
- private GalleryContext mContext;
- private AtomicBoolean mContentDirty = new AtomicBoolean(true);
-
- public PicasaAlbum(int parentId, GalleryContext context, AlbumEntry entry) {
- mContext = context;
- mResolver = context.getContentResolver();
- mData = entry;
- mUniqueId = context.getDataManager().obtainSetId(parentId, (int) mData.id, this);
- mResolver.registerContentObserver(
- PicasaContentProvider.PHOTOS_URI, true, new MyContentObserver());
- }
-
- @Override
- public long getUniqueId() {
- return mUniqueId;
- }
-
- @Override
- public ArrayList<MediaItem> getMediaItem(int start, int count) {
- Uri uri = PicasaContentProvider.PHOTOS_URI.buildUpon()
- .appendQueryParameter("limit", start + "," + count).build();
-
- ArrayList<MediaItem> list = new ArrayList<MediaItem>();
- Utils.assertNotInRenderThread();
- Cursor cursor = mResolver.query(uri,
- SCHEMA.getProjection(), WHERE_CLAUSE,
- new String[]{String.valueOf(mData.id)},
- PhotoEntry.Columns.DISPLAY_INDEX);
-
- try {
- while (cursor.moveToNext()) {
- PhotoEntry entry = SCHEMA.cursorToObject(cursor, new PhotoEntry());
- DataManager dataManager = mContext.getDataManager();
- long uniqueId = DataManager.makeId(getMyId(), (int) entry.id);
- PicasaImage item = new PicasaImage(uniqueId, mContext, entry);
- list.add(item);
- }
- } finally {
- cursor.close();
- }
- return list;
- }
-
- @Override
- public int getMediaItemCount() {
- Utils.assertNotInRenderThread();
- Cursor cursor = mResolver.query(
- PicasaContentProvider.PHOTOS_URI,
- COUNT_PROJECTION, WHERE_CLAUSE,
- new String[]{String.valueOf(mData.id)}, null);
- try {
- Utils.Assert(cursor.moveToNext());
- return cursor.getInt(0);
- } finally {
- cursor.close();
- }
- }
-
- @Override
- public String getName() {
- return mData.title;
- }
-
- @Override
- public int getTotalMediaItemCount() {
- return getMediaItemCount();
- }
-
- @Override
- public boolean reload() {
- return mContentDirty.compareAndSet(true, false);
- }
-
- private class MyContentObserver extends ContentObserver {
- public MyContentObserver() {
- super(new Handler(mContext.getMainLooper()));
- }
-
- @Override
- public void onChange(boolean selfChange) {
- if (mContentDirty.compareAndSet(false, true)) {
- if (mListener != null) mListener.onContentDirty();
- }
- }
- }
-
- private static class EditDateComparator implements Comparator<PicasaAlbum> {
- public int compare(PicasaAlbum a, PicasaAlbum b) {
- int result = -Utils.compare(a.mData.dateEdited, b.mData.dateEdited);
- if (result != 0) return result;
- return Utils.compare(a.mData.id, b.mData.id);
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/PicasaAlbumSet.java b/new3d/src/com/android/gallery3d/data/PicasaAlbumSet.java
deleted file mode 100644
index 3ba71d6..0000000
--- a/new3d/src/com/android/gallery3d/data/PicasaAlbumSet.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.database.ContentObserver;
-import android.database.Cursor;
-import android.os.Handler;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.picasa.AlbumEntry;
-import com.android.gallery3d.picasa.EntrySchema;
-import com.android.gallery3d.picasa.PicasaContentProvider;
-import com.android.gallery3d.util.Utils;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-// PicasaAlbumSet lists all albums in a Picasa account.
-public class PicasaAlbumSet extends MediaSet {
- private static final String TAG = "PicasaAlbumSet";
- private final EntrySchema SCHEMA = AlbumEntry.SCHEMA;
-
- private ArrayList<PicasaAlbum> mAlbums = new ArrayList<PicasaAlbum>();
- private final ArrayList<AlbumEntry> mLoadBuffer = new ArrayList<AlbumEntry>();
- private final long mUniqueId;
- private GalleryContext mContext;
- private AtomicBoolean mContentDirty = new AtomicBoolean(true);
-
- public PicasaAlbumSet(int parentId, int childKey, GalleryContext context) {
- mContext = context;
- mUniqueId = context.getDataManager().obtainSetId(parentId, childKey, this);
- context.getContentResolver().registerContentObserver(
- PicasaContentProvider.ALBUMS_URI, true, new MyContentObserver());
- }
-
- @Override
- public MediaSet getSubMediaSet(int index) {
- return mAlbums.get(index);
- }
-
- @Override
- public int getSubMediaSetCount() {
- return mAlbums.size();
- }
-
- @Override
- public String getName() {
- return TAG;
- }
-
- @Override
- public long getUniqueId() {
- return mUniqueId;
- }
-
- @Override
- public int getTotalMediaItemCount() {
- int totalCount = 0;
- for (PicasaAlbum album : mAlbums) {
- totalCount += album.getTotalMediaItemCount();
- }
- return totalCount;
- }
-
- private ArrayList<PicasaAlbum> loadSubMediaSets() {
- Utils.assertNotInRenderThread();
- Cursor cursor = mContext.getContentResolver().query(
- PicasaContentProvider.ALBUMS_URI,
- SCHEMA.getProjection(), null, null, null);
- try {
- while (cursor.moveToNext()) {
- AlbumEntry entry = SCHEMA.cursorToObject(cursor, new AlbumEntry());
- mLoadBuffer.add(entry);
- }
- } finally {
- cursor.close();
- }
-
- ArrayList<PicasaAlbum> newAlbums = new ArrayList<PicasaAlbum>();
- DataManager dataManager = mContext.getDataManager();
-
- int parentId = getMyId();
- for (int i = 0, n = mLoadBuffer.size(); i < n; i++) {
- AlbumEntry entry = mLoadBuffer.get(i);
- int childKey = (int) entry.id;
- PicasaAlbum album = (PicasaAlbum) dataManager.getMediaSet(parentId, childKey);
- if (album == null) {
- album = new PicasaAlbum(parentId, mContext, entry);
- }
- newAlbums.add(album);
- }
-
- for (int i = 0, n = mAlbums.size(); i < n; ++i) {
- mAlbums.get(i).reload();
- }
- Collections.sort(newAlbums, PicasaAlbum.sEditDateComparator);
- return newAlbums;
- }
-
- private class MyContentObserver extends ContentObserver {
- public MyContentObserver() {
- super(new Handler(mContext.getMainLooper()));
- }
-
- @Override
- public void onChange(boolean selfChange) {
- if (mContentDirty.compareAndSet(false, true)) {
- if (mListener != null) mListener.onContentDirty();
- }
- }
- }
-
- @Override
- public boolean reload() {
- if (!mContentDirty.compareAndSet(true, false)) return false;
- ArrayList<PicasaAlbum> album = loadSubMediaSets();
- if (album.equals(mAlbums)) return false;
- mAlbums = album;
- return true;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/data/PicasaImage.java b/new3d/src/com/android/gallery3d/data/PicasaImage.java
deleted file mode 100644
index 37edcb1..0000000
--- a/new3d/src/com/android/gallery3d/data/PicasaImage.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.graphics.Bitmap;
-import android.graphics.LargeBitmap;
-import android.util.Log;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.data.BlobCache.LookupRequest;
-import com.android.gallery3d.picasa.PhotoEntry;
-import com.android.gallery3d.util.ComboFuture;
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.FutureListener;
-import com.android.gallery3d.util.Utils;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.ByteBuffer;
-
-// PicasaImage is an image in the Picasa account.
-public class PicasaImage extends MediaItem {
- private static final String TAG = "PicasaImage";
-
- private final GalleryContext mContext;
- private final PhotoEntry mData;
- private final BlobCache mPicasaCache;
- private final long mUniqueId;
-
- public PicasaImage(long uniqueId, GalleryContext context, PhotoEntry entry) {
- mContext = context;
- mData = entry;
- mPicasaCache = mContext.getDataManager().getPicasaCache();
- mUniqueId = uniqueId;
- }
-
- @Override
- public long getUniqueId() {
- return mUniqueId;
- }
-
- @Override
- public synchronized Future<Bitmap>
- requestImage(int type, FutureListener<? super Bitmap> listener) {
- URL photoUrl = getPhotoUrl(type);
- if (mPicasaCache != null) {
-
- // Try to get the image from cache.
- LookupRequest request = new LookupRequest();
- request.key = Utils.crc64Long(photoUrl.toString());
- boolean isCached = false;
- try {
- isCached = mPicasaCache.lookup(request);
- } catch (IOException e) {
- Log.w(TAG, "IOException in getting an image from " +
- "PicasaCache", e);
- }
-
- if (isCached) {
- byte[] uri = Utils.getBytesInUtf8(photoUrl.toString());
- if (isSameUri(uri, request.buffer)) {
- DecodeService service = mContext.getDecodeService();
- return service.requestDecode(request.buffer, uri.length,
- request.length - uri.length, null, listener);
- } else {
- Log.w(TAG, "The cached image has different URI?");
- }
- }
-
- Log.d(TAG, "Get uncached picasa image (type, url): " + type +
- " " + photoUrl.toString());
- }
-
- // Get the image from Picasaweb instead.
- return new PicasaBitmapTask(type, photoUrl, listener);
- }
-
- private boolean isSameUri(byte[] uri, byte[] buffer) {
- int uriLength = uri.length;
- if (uriLength > buffer.length) {
- return false;
- }
- for (int i = 0; i < uriLength; ++i) {
- if (uri[i] != buffer[i]) {
- return false;
- }
- }
- return true;
- }
-
- private URL getPhotoUrl(int type) {
- URL url = null;
- try {
- switch (type) {
- case MediaItem.TYPE_MICROTHUMBNAIL:
- url = new URL(mData.thumbnailUrl);
- break;
- case MediaItem.TYPE_THUMBNAIL:
- url = new URL(mData.screennailUrl);
- break;
- case MediaItem.TYPE_FULL_IMAGE:
- url = new URL(mData.contentUrl);
- break;
- default:
- throw new AssertionError();
- }
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- return url;
- }
-
- private class PicasaBitmapTask extends ComboFuture<Bitmap> {
- private final URL mUrl;
- private final int mType;
-
- public PicasaBitmapTask(
- int type, URL url, FutureListener<? super Bitmap> listener) {
- super(listener);
- mType = type;
- mUrl = url;
- execute();
- }
-
- @Override
- protected Future<?> executeNextTask(int step, Future<?> current)
- throws Exception {
- switch (step) {
- case 0: {
- DownloadService service = mContext.getDownloadService();
- return service.requestDownload(mUrl, this);
- }
- case 1: {
- byte[] downloadedImage = (byte[]) current.get();
-
- if ((mPicasaCache != null)
- && (mType != MediaItem.TYPE_FULL_IMAGE)) {
- // Insert the downloaded image to the cache if we have a
- // cache and the image is not a full size one.
- long cacheKey = Utils.crc64Long(mUrl.toString());
- byte[] uri = Utils.getBytesInUtf8(mUrl.toString());
- ByteBuffer buffer = ByteBuffer.allocate(
- downloadedImage.length + uri.length);
- buffer.put(uri);
- buffer.put(downloadedImage);
- mPicasaCache.insert(cacheKey, buffer.array());
- }
-
- // Decode the downloaded image.
- DecodeService service = mContext.getDecodeService();
- return service.requestDecode(downloadedImage, null, this);
- }
- }
- return null;
- }
- }
-
- private class PicasaLargeBitmapTask extends ComboFuture<LargeBitmap> {
- private final URL mUrl;
- private final int mType;
-
- public PicasaLargeBitmapTask(
- int type, URL url, FutureListener<? super LargeBitmap> listener) {
- super(listener);
- mType = type;
- mUrl = url;
- execute();
- }
-
- @Override
- protected Future<?> executeNextTask(int step, Future<?> current)
- throws Exception {
- switch (step) {
- case 0: {
- DownloadService service = mContext.getDownloadService();
- return service.requestDownload(mUrl, this);
- }
- case 1: {
- byte[] downloadedImage = (byte[]) current.get();
-
- // Create the large bitmap.
- DecodeService service = mContext.getDecodeService();
- return service.requestCreateLargeBitmap(downloadedImage, 0,
- downloadedImage.length, this);
- }
- }
- return null;
- }
- }
-
- public Future<LargeBitmap> requestLargeImage(int type,
- FutureListener<LargeBitmap> listener) {
- URL photoUrl = getPhotoUrl(type);
- return new PicasaLargeBitmapTask(type, photoUrl, listener);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/gadget/PhotoAppWidgetConfigure.java b/new3d/src/com/android/gallery3d/gadget/PhotoAppWidgetConfigure.java
deleted file mode 100644
index c075079..0000000
--- a/new3d/src/com/android/gallery3d/gadget/PhotoAppWidgetConfigure.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.gadget;
-
-import android.app.Activity;
-import android.appwidget.AppWidgetManager;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.os.Bundle;
-import android.widget.RemoteViews;
-
-public class PhotoAppWidgetConfigure extends Activity {
-
- @SuppressWarnings("unused")
- private static final String TAG = "PhotoAppWidgetConfigure";
- static final int REQUEST_GET_PHOTO = 2;
-
- private int mAppWidgetId = -1;
-
- @Override
- protected void onCreate(Bundle bundle) {
- super.onCreate(bundle);
-
- // Someone is requesting that we configure the given mAppWidgetId, which
- // means we prompt the user to pick and crop a photo.
- mAppWidgetId = getIntent().getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
-
- if (mAppWidgetId == -1) {
- setResult(Activity.RESULT_CANCELED);
- finish();
- return;
- }
-
- // TODO: get these values from constants somewhere
- // TODO: Adjust the PhotoFrame's image size to avoid on the fly scaling
- // TODO: we should handle it in two steps: Send a GET_CONTENT
- // intent and then a CROP intent.
- Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
- intent.setType("image/*");
- intent.putExtra("crop", "true");
- intent.putExtra("aspectX", 1);
- intent.putExtra("aspectY", 1);
- intent.putExtra("outputX", 192);
- intent.putExtra("outputY", 192);
- intent.putExtra("noFaceDetection", true);
- intent.putExtra("return-data", true);
-
- startActivityForResult(intent, REQUEST_GET_PHOTO);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode == RESULT_OK && mAppWidgetId != -1) {
- // Store the cropped photo in our database
- Bitmap bitmap = (Bitmap) data.getParcelableExtra("data");
-
- PhotoDatabaseHelper helper = new PhotoDatabaseHelper(this);
- if (helper.setPhoto(mAppWidgetId, bitmap)) {
- resultCode = Activity.RESULT_OK;
-
- // Push newly updated widget to surface
- RemoteViews views = PhotoAppWidgetProvider.buildUpdate(this, mAppWidgetId, helper);
- AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
- appWidgetManager.updateAppWidget(new int[] { mAppWidgetId }, views);
- }
- helper.close();
- } else {
- resultCode = Activity.RESULT_CANCELED;
- }
-
- // Make sure we pass back the original mAppWidgetId
- Intent resultValue = new Intent();
- resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
- setResult(resultCode, resultValue);
- finish();
- }
-}
diff --git a/new3d/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java b/new3d/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java
deleted file mode 100644
index b4d330e..0000000
--- a/new3d/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.gadget;
-
-import android.appwidget.AppWidgetManager;
-import android.appwidget.AppWidgetProvider;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.util.Log;
-import android.widget.RemoteViews;
-
-import com.android.gallery3d.R;
-
-/**
- * Simple widget to show a user-selected picture.
- */
-public class PhotoAppWidgetProvider extends AppWidgetProvider {
- static final String TAG = "PhotoAppWidgetProvider";
- static final boolean LOGD = true;
-
- @Override
- public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
- // Update each requested appWidgetId with its unique photo
- PhotoDatabaseHelper helper = new PhotoDatabaseHelper(context);
- for (int appWidgetId : appWidgetIds) {
- int[] specificAppWidget = new int[] {appWidgetId};
- RemoteViews views = buildUpdate(context, appWidgetId, helper);
- if (LOGD) {
- Log.d(TAG, "sending out views=" + views + " for id=" + appWidgetId);
- }
- appWidgetManager.updateAppWidget(specificAppWidget, views);
- }
- helper.close();
- }
-
- @Override
- public void onDeleted(Context context, int[] appWidgetIds) {
- // Clean deleted photos out of our database
- PhotoDatabaseHelper helper = new PhotoDatabaseHelper(context);
- for (int appWidgetId : appWidgetIds) {
- helper.deletePhoto(appWidgetId);
- }
- helper.close();
- }
-
- /**
- * Load photo for given widget and build {@link RemoteViews} for it.
- */
- static RemoteViews buildUpdate(Context context, int appWidgetId, PhotoDatabaseHelper helper) {
- RemoteViews views = null;
- Bitmap bitmap = helper.getPhoto(appWidgetId);
- if (bitmap != null) {
- views = new RemoteViews(context.getPackageName(), R.layout.photo_frame);
- views.setImageViewBitmap(R.id.photo, bitmap);
- }
- return views;
- }
-
-}
diff --git a/new3d/src/com/android/gallery3d/gadget/PhotoDatabaseHelper.java b/new3d/src/com/android/gallery3d/gadget/PhotoDatabaseHelper.java
deleted file mode 100644
index 17591f4..0000000
--- a/new3d/src/com/android/gallery3d/gadget/PhotoDatabaseHelper.java
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-
-package com.android.gallery3d.gadget;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteException;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.util.Log;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-class PhotoDatabaseHelper extends SQLiteOpenHelper {
- private static final String DATABASE_NAME = "launcher.db";
-
- private static final int DATABASE_VERSION = 2;
-
- static final String TABLE_PHOTOS = "photos";
- static final String FIELD_APPWIDGET_ID = "appWidgetId";
- static final String FIELD_PHOTO_BLOB = "photoBlob";
-
- PhotoDatabaseHelper(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL("CREATE TABLE " + TABLE_PHOTOS + " ("
- + FIELD_APPWIDGET_ID + " INTEGER PRIMARY KEY,"
- + FIELD_PHOTO_BLOB + " BLOB" + ");");
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- int version = oldVersion;
-
- if (version != DATABASE_VERSION) {
- Log.w(PhotoAppWidgetProvider.TAG, "Destroying all old data.");
- db.execSQL("DROP TABLE IF EXISTS " + TABLE_PHOTOS);
- onCreate(db);
- }
- }
-
- /**
- * Store the given bitmap in this database for the given appWidgetId.
- */
- public boolean setPhoto(int appWidgetId, Bitmap bitmap) {
- boolean success = false;
- try {
- // Try go guesstimate how much space the icon will take when
- // serialized to avoid unnecessary allocations/copies during
- // the write.
- int size = bitmap.getWidth() * bitmap.getHeight() * 4;
- ByteArrayOutputStream out = new ByteArrayOutputStream(size);
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
- out.flush();
- out.close();
-
- ContentValues values = new ContentValues();
- values.put(PhotoDatabaseHelper.FIELD_APPWIDGET_ID, appWidgetId);
- values.put(PhotoDatabaseHelper.FIELD_PHOTO_BLOB, out.toByteArray());
-
- SQLiteDatabase db = getWritableDatabase();
- db.insertOrThrow(PhotoDatabaseHelper.TABLE_PHOTOS, null, values);
-
- success = true;
- } catch (SQLiteException e) {
- Log.e(PhotoAppWidgetProvider.TAG, "Could not open database", e);
- } catch (IOException e) {
- Log.e(PhotoAppWidgetProvider.TAG, "Could not serialize photo", e);
- }
- if (PhotoAppWidgetProvider.LOGD) {
- Log.d(PhotoAppWidgetProvider.TAG, "setPhoto success=" + success);
- }
- return success;
- }
-
- private static final String[] PHOTOS_PROJECTION = {FIELD_PHOTO_BLOB};
- private static final int INDEX_PHOTO_BLOB = 0;
- private static final String WHERE_CLAUSE = FIELD_APPWIDGET_ID + " = ?";
-
- /**
- * Inflate and return a bitmap for the given appWidgetId.
- */
- public Bitmap getPhoto(int appWidgetId) {
- Cursor c = null;
- Bitmap bitmap = null;
- try {
- SQLiteDatabase db = getReadableDatabase();
- String selection = String.format("%s=%d", FIELD_APPWIDGET_ID, appWidgetId);
- c = db.query(TABLE_PHOTOS, PHOTOS_PROJECTION,
- WHERE_CLAUSE, new String[]{String.valueOf(appWidgetId)},
- null, null, null, null);
-
- if (c != null && PhotoAppWidgetProvider.LOGD) {
- Log.d(PhotoAppWidgetProvider.TAG, "getPhoto query count=" + c.getCount());
- }
-
- if (c != null && c.moveToFirst()) {
- byte[] data = c.getBlob(INDEX_PHOTO_BLOB);
- if (data != null) {
- bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
- }
- }
- } catch (SQLiteException e) {
- Log.e(PhotoAppWidgetProvider.TAG, "Could not load photo from database", e);
- } finally {
- if (c != null) c.close();
- }
- return bitmap;
- }
-
- /**
- * Remove any bitmap associated with the given appWidgetId.
- */
- public void deletePhoto(int appWidgetId) {
- try {
- SQLiteDatabase db = getWritableDatabase();
- String whereClause = String.format("%s=%d", FIELD_APPWIDGET_ID, appWidgetId);
- db.delete(TABLE_PHOTOS, whereClause, null);
- } catch (SQLiteException e) {
- Log.e(PhotoAppWidgetProvider.TAG, "Could not delete photo from database", e);
- }
- }
-}
\ No newline at end of file
diff --git a/new3d/src/com/android/gallery3d/picasa/AlbumEntry.java b/new3d/src/com/android/gallery3d/picasa/AlbumEntry.java
deleted file mode 100644
index 24d6a40..0000000
--- a/new3d/src/com/android/gallery3d/picasa/AlbumEntry.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import org.xml.sax.Attributes;
-
-/**
- * This class models the album entry kind in the Picasa GData API.
- */
-@Entry.Table("albums")
-public final class AlbumEntry extends Entry {
- public static final EntrySchema SCHEMA = new EntrySchema(AlbumEntry.class);
-
- /**
- * The user account that is the sync source for this entry. Must be set
- * before insert/update.
- */
- @Column(Columns.SYNC_ACCOUNT)
- public String syncAccount;
-
- /**
- * The ETag for the album/photos GData feed.
- */
- @Column(Columns.PHOTOS_ETAG)
- public String photosEtag = null;
-
- /**
- * True if the contents of the album need to be synchronized. Must be set
- * before insert/update.
- */
- @Column(Columns.PHOTOS_DIRTY)
- public boolean photosDirty;
-
- /**
- * The "edit" URI of the album.
- */
- @Column(Columns.EDIT_URI)
- public String editUri;
-
- /**
- * The album owner.
- */
- @Column(Columns.USER)
- public String user;
-
- /**
- * The title of the album.
- */
- @Column(value = Columns.TITLE)
- public String title;
-
- /**
- * A short summary of the contents of the album.
- */
- @Column(value = Columns.SUMMARY)
- public String summary;
-
- /**
- * The date the album was created.
- */
- @Column(Columns.DATE_PUBLISHED)
- public long datePublished;
-
- /**
- * The date the album was last updated.
- */
- @Column(Columns.DATE_UPDATED)
- public long dateUpdated;
-
- /**
- * The date the album entry was last edited. May be more recent than
- * dateUpdated.
- */
- @Column(Columns.DATE_EDITED)
- public long dateEdited;
-
- /**
- * The number of photos in the album.
- */
- @Column(Columns.NUM_PHOTOS)
- public int numPhotos;
-
- /**
- * The number of bytes of storage that this album uses.
- */
- @Column(Columns.BYTES_USED)
- public long bytesUsed;
-
- /**
- * The user-specified location associated with the album.
- */
- @Column(Columns.LOCATION_STRING)
- public String locationString;
-
- /**
- * The thumbnail URL associated with the album.
- */
- @Column(Columns.THUMBNAIL_URL)
- public String thumbnailUrl;
-
- /**
- * A link to the HTML page associated with the album.
- */
- @Column(Columns.HTML_PAGE_URL)
- public String htmlPageUrl;
-
- /**
- * Column names specific to album entries.
- */
- public static final class Columns extends PicasaApi.Columns {
- public static final String PHOTOS_ETAG = "photos_etag";
- public static final String USER = "user";
- public static final String BYTES_USED = "bytes_used";
- public static final String NUM_PHOTOS = "num_photos";
- public static final String LOCATION_STRING = "location_string";
- public static final String PHOTOS_DIRTY = "photos_dirty";
- }
-
- /**
- * Resets values to defaults for object reuse.
- */
- @Override
- public void clear() {
- super.clear();
- syncAccount = null;
- photosDirty = false;
- editUri = null;
- user = null;
- title = null;
- summary = null;
- datePublished = 0;
- dateUpdated = 0;
- dateEdited = 0;
- numPhotos = 0;
- bytesUsed = 0;
- locationString = null;
- thumbnailUrl = null;
- htmlPageUrl = null;
- }
-
- /**
- * Sets the property value corresponding to the given XML element, if
- * applicable.
- */
- @Override
- public void setPropertyFromXml(String uri, String localName, Attributes attrs, String content) {
- char localNameChar = localName.charAt(0);
- if (uri.equals(GDataParser.GPHOTO_NAMESPACE)) {
- switch (localNameChar) {
- case 'i':
- if (localName.equals("id")) {
- id = Long.parseLong(content);
- }
- break;
- case 'u':
- if (localName.equals("user")) {
- user = content;
- }
- break;
- case 'n':
- if (localName.equals("numphotos")) {
- numPhotos = Integer.parseInt(content);
- }
- break;
- case 'b':
- if (localName.equals("bytesUsed")) {
- bytesUsed = Long.parseLong(content);
- }
- break;
- }
- } else if (uri.equals(GDataParser.ATOM_NAMESPACE)) {
- switch (localNameChar) {
- case 't':
- if (localName.equals("title")) {
- title = content;
- }
- break;
- case 's':
- if (localName.equals("summary")) {
- summary = content;
- }
- break;
- case 'p':
- if (localName.equals("published")) {
- datePublished = GDataParser.parseAtomTimestamp(content);
- }
- break;
- case 'u':
- if (localName.equals("updated")) {
- dateUpdated = GDataParser.parseAtomTimestamp(content);
- }
- break;
- case 'l':
- if (localName.equals("link")) {
- String rel = attrs.getValue("", "rel");
- String href = attrs.getValue("", "href");
- if (rel.equals("alternate") && attrs.getValue("", "type").equals("text/html")) {
- htmlPageUrl = href;
- } else if (rel.equals("edit")) {
- editUri = href;
- }
- }
- break;
- }
- } else if (uri.equals(GDataParser.APP_NAMESPACE)) {
- if (localName.equals("edited")) {
- dateEdited = GDataParser.parseAtomTimestamp(content);
- }
- } else if (uri.equals(GDataParser.MEDIA_RSS_NAMESPACE)) {
- if (localName == "thumbnail") {
- thumbnailUrl = attrs.getValue("", "url");
- }
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/Entry.java b/new3d/src/com/android/gallery3d/picasa/Entry.java
deleted file mode 100644
index a20bad0..0000000
--- a/new3d/src/com/android/gallery3d/picasa/Entry.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import org.xml.sax.Attributes;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-public abstract class Entry {
- public static final String[] ID_PROJECTION = { "_id" };
-
- // The primary key of the entry.
- @Column("_id")
- public long id = 0;
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- public @interface Table {
- String value();
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.FIELD)
- public @interface Column {
- String value();
-
- boolean indexed() default false;
-
- boolean fullText() default false;
- }
-
- public void clear() {
- id = 0;
- }
-
- abstract public void setPropertyFromXml(
- String uri, String localName, Attributes attrs, String content);
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/EntrySchema.java b/new3d/src/com/android/gallery3d/picasa/EntrySchema.java
deleted file mode 100644
index 147e6f3..0000000
--- a/new3d/src/com/android/gallery3d/picasa/EntrySchema.java
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.util.Log;
-
-import com.android.gallery3d.util.Utils;
-
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-
-public final class EntrySchema {
- public static final int TYPE_STRING = 0;
- public static final int TYPE_BOOLEAN = 1;
- public static final int TYPE_SHORT = 2;
- public static final int TYPE_INT = 3;
- public static final int TYPE_LONG = 4;
- public static final int TYPE_FLOAT = 5;
- public static final int TYPE_DOUBLE = 6;
- public static final int TYPE_BLOB = 7;
- public static final String SQLITE_TYPES[] = {
- "TEXT", "INTEGER", "INTEGER", "INTEGER", "INTEGER", "REAL", "REAL", "NONE" };
-
- private static final String TAG = "SchemaInfo";
- private static final String FULL_TEXT_INDEX_SUFFIX = "_fulltext";
-
- private final String mTableName;
- private final ColumnInfo[] mColumnInfo;
- private final String[] mProjection;
- private final boolean mHasFullTextIndex;
-
- public EntrySchema(Class<? extends Entry> clazz) {
- // Get table and column metadata from reflection.
- ColumnInfo[] columns = parseColumnInfo(clazz);
- mTableName = parseTableName(clazz);
- mColumnInfo = columns;
-
- // Cache the list of projection columns and check for full-text columns.
- String[] projection = {};
- boolean hasFullTextIndex = false;
- if (columns != null) {
- projection = new String[columns.length];
- for (int i = 0; i != columns.length; ++i) {
- ColumnInfo column = columns[i];
- projection[i] = column.name;
- if (column.fullText) {
- hasFullTextIndex = true;
- }
- }
- }
- mProjection = projection;
- mHasFullTextIndex = hasFullTextIndex;
- }
-
- public String getTableName() {
- return mTableName;
- }
-
- public ColumnInfo[] getColumnInfo() {
- return mColumnInfo;
- }
-
- public String[] getProjection() {
- return mProjection;
- }
-
- private void logExecSql(SQLiteDatabase db, String sql) {
- // Log.i(TAG, sql);
- db.execSQL(sql);
- }
-
- public <T extends Entry> T cursorToObject(Cursor cursor, T object) {
- try {
- for (ColumnInfo column : mColumnInfo) {
- int columnIndex = column.projectionIndex;
- Field field = column.field;
- switch (column.type) {
- case TYPE_STRING:
- field.set(object, cursor.getString(columnIndex));
- break;
- case TYPE_BOOLEAN:
- field.setBoolean(object, cursor.getShort(columnIndex) == 1);
- break;
- case TYPE_SHORT:
- field.setShort(object, cursor.getShort(columnIndex));
- break;
- case TYPE_INT:
- field.setInt(object, cursor.getInt(columnIndex));
- break;
- case TYPE_LONG:
- field.setLong(object, cursor.getLong(columnIndex));
- break;
- case TYPE_FLOAT:
- field.setFloat(object, cursor.getFloat(columnIndex));
- break;
- case TYPE_DOUBLE:
- field.setDouble(object, cursor.getDouble(columnIndex));
- break;
- case TYPE_BLOB:
- field.set(object, cursor.getBlob(columnIndex));
- break;
- }
- }
- return object;
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-
- public void objectToValues(Entry object, ContentValues values) {
- try {
- for (ColumnInfo column : mColumnInfo) {
- String columnName = column.name;
- Field field = column.field;
- switch (column.type) {
- case TYPE_STRING:
- values.put(columnName, (String) field.get(object));
- break;
- case TYPE_BOOLEAN:
- values.put(columnName, field.getBoolean(object));
- break;
- case TYPE_SHORT:
- values.put(columnName, field.getShort(object));
- break;
- case TYPE_INT:
- values.put(columnName, field.getInt(object));
- break;
- case TYPE_LONG:
- values.put(columnName, field.getLong(object));
- break;
- case TYPE_FLOAT:
- values.put(columnName, field.getFloat(object));
- break;
- case TYPE_DOUBLE:
- values.put(columnName, field.getDouble(object));
- break;
- case TYPE_BLOB:
- values.put(columnName, (byte[]) field.get(object));
- break;
- }
- }
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-
- public Cursor queryAll(SQLiteDatabase db) {
- return db.query(mTableName, mProjection, null, null, null, null, null);
- }
-
- public boolean queryWithId(SQLiteDatabase db, long id, Entry entry) {
- Cursor cursor = db.query(mTableName, mProjection, "_id=?",
- new String[] {Long.toString(id)}, null, null, null);
- boolean success = false;
- if (cursor.moveToFirst()) {
- cursorToObject(cursor, entry);
- success = true;
- }
- cursor.close();
- return success;
- }
-
- public long insertOrReplace(SQLiteDatabase db, Entry entry) {
- ContentValues values = new ContentValues();
- objectToValues(entry, values);
- if (entry.id == 0) {
- Log.i(TAG, "removing id before insert");
- values.remove("_id");
- }
- long id = db.replace(mTableName, "_id", values);
- entry.id = id;
- return id;
- }
-
- public boolean deleteWithId(SQLiteDatabase db, long id) {
- return db.delete(mTableName, "_id=?", new String[] { Long.toString(id) }) == 1;
- }
-
- public void createTables(SQLiteDatabase db) {
- // Wrapped class must have a @Table.Definition.
- String tableName = mTableName;
- Utils.Assert(tableName != null);
-
- // Add the CREATE TABLE statement for the main table.
- StringBuilder sql = new StringBuilder("CREATE TABLE ");
- sql.append(tableName);
- sql.append(" (_id INTEGER PRIMARY KEY");
- for (ColumnInfo column : mColumnInfo) {
- if (!column.isId()) {
- sql.append(',');
- sql.append(column.name);
- sql.append(' ');
- sql.append(SQLITE_TYPES[column.type]);
- if (column.extraSql != null) {
- sql.append(' ');
- sql.append(column.extraSql);
- }
- }
- }
- sql.append(");");
- logExecSql(db, sql.toString());
- sql.setLength(0);
-
- // Create indexes for all indexed columns.
- for (ColumnInfo column : mColumnInfo) {
- // Create an index on the indexed columns.
- if (column.indexed) {
- sql.append("CREATE INDEX ");
- sql.append(tableName);
- sql.append("_index_");
- sql.append(column.name);
- sql.append(" ON ");
- sql.append(tableName);
- sql.append(" (");
- sql.append(column.name);
- sql.append(");");
- logExecSql(db, sql.toString());
- sql.setLength(0);
- }
- }
-
- if (mHasFullTextIndex) {
- // Add an FTS virtual table if using full-text search.
- String ftsTableName = tableName + FULL_TEXT_INDEX_SUFFIX;
- sql.append("CREATE VIRTUAL TABLE ");
- sql.append(ftsTableName);
- sql.append(" USING FTS3 (_id INTEGER PRIMARY KEY");
- for (ColumnInfo column : mColumnInfo) {
- if (column.fullText) {
- // Add the column to the FTS table.
- String columnName = column.name;
- sql.append(',');
- sql.append(columnName);
- sql.append(" TEXT");
- }
- }
- sql.append(");");
- logExecSql(db, sql.toString());
- sql.setLength(0);
-
- // Build an insert statement that will automatically keep the FTS
- // table in sync.
- StringBuilder insertSql = new StringBuilder("INSERT OR REPLACE INTO ");
- insertSql.append(ftsTableName);
- insertSql.append(" (_id");
- for (ColumnInfo column : mColumnInfo) {
- if (column.fullText) {
- insertSql.append(',');
- insertSql.append(column.name);
- }
- }
- insertSql.append(") VALUES (new._id");
- for (ColumnInfo column : mColumnInfo) {
- if (column.fullText) {
- insertSql.append(",new.");
- insertSql.append(column.name);
- }
- }
- insertSql.append(");");
- String insertSqlString = insertSql.toString();
-
- // Add an insert trigger.
- sql.append("CREATE TRIGGER ");
- sql.append(tableName);
- sql.append("_insert_trigger AFTER INSERT ON ");
- sql.append(tableName);
- sql.append(" FOR EACH ROW BEGIN ");
- sql.append(insertSqlString);
- sql.append("END;");
- logExecSql(db, sql.toString());
- sql.setLength(0);
-
- // Add an update trigger.
- sql.append("CREATE TRIGGER ");
- sql.append(tableName);
- sql.append("_update_trigger AFTER UPDATE ON ");
- sql.append(tableName);
- sql.append(" FOR EACH ROW BEGIN ");
- sql.append(insertSqlString);
- sql.append("END;");
- logExecSql(db, sql.toString());
- sql.setLength(0);
-
- // Add a delete trigger.
- sql.append("CREATE TRIGGER ");
- sql.append(tableName);
- sql.append("_delete_trigger AFTER DELETE ON ");
- sql.append(tableName);
- sql.append(" FOR EACH ROW BEGIN DELETE FROM ");
- sql.append(ftsTableName);
- sql.append(" WHERE _id = old._id; END;");
- logExecSql(db, sql.toString());
- sql.setLength(0);
- }
- }
-
- public void dropTables(SQLiteDatabase db) {
- String tableName = mTableName;
- StringBuilder sql = new StringBuilder("DROP TABLE IF EXISTS ");
- sql.append(tableName);
- sql.append(';');
- logExecSql(db, sql.toString());
- sql.setLength(0);
-
- if (mHasFullTextIndex) {
- sql.append("DROP TABLE IF EXISTS ");
- sql.append(tableName);
- sql.append(FULL_TEXT_INDEX_SUFFIX);
- sql.append(';');
- logExecSql(db, sql.toString());
- }
-
- }
-
- public void deleteAll(SQLiteDatabase db) {
- StringBuilder sql = new StringBuilder("DELETE FROM ");
- sql.append(mTableName);
- sql.append(";");
- logExecSql(db, sql.toString());
- }
-
- private String parseTableName(Class<? extends Object> clazz) {
- // Check for a table annotation.
- Entry.Table table = clazz.getAnnotation(Entry.Table.class);
- if (table == null) {
- return null;
- }
-
- // Return the table name.
- return table.value();
- }
-
- private ColumnInfo[] parseColumnInfo(Class<? extends Object> clazz) {
- // Gather metadata from each annotated field.
- ArrayList<ColumnInfo> columns = new ArrayList<ColumnInfo>();
- Field[] fields = clazz.getFields();
- for (int i = 0; i != fields.length; ++i) {
- // Get column metadata from the annotation.
- Field field = fields[i];
- Entry.Column info = ((AnnotatedElement) field).getAnnotation(Entry.Column.class);
- if (info == null) {
- continue;
- }
-
- // Determine the field type.
- int type;
- Class<?> fieldType = field.getType();
- if (fieldType == String.class) {
- type = TYPE_STRING;
- } else if (fieldType == boolean.class) {
- type = TYPE_BOOLEAN;
- } else if (fieldType == short.class) {
- type = TYPE_SHORT;
- } else if (fieldType == int.class) {
- type = TYPE_INT;
- } else if (fieldType == long.class) {
- type = TYPE_LONG;
- } else if (fieldType == float.class) {
- type = TYPE_FLOAT;
- } else if (fieldType == double.class) {
- type = TYPE_DOUBLE;
- } else if (fieldType == byte[].class) {
- type = TYPE_BLOB;
- } else {
- throw new IllegalArgumentException(
- "Unsupported field type for column: " + fieldType.getName());
- }
-
- // Add the column to the array.
- int index = columns.size();
- columns.add(new ColumnInfo(info.value(),
- type, info.indexed(), info.fullText(), field, index));
- }
-
- // Return a list.
- ColumnInfo[] columnList = new ColumnInfo[columns.size()];
- columns.toArray(columnList);
- return columnList;
- }
-
- public static final class ColumnInfo {
- private static final String ID_KEY = "_id";
-
- public final String name;
- public final int type;
- public final boolean indexed;
- public final boolean fullText;
- public final String extraSql = "";
- public final Field field;
- public final int projectionIndex;
-
- public ColumnInfo(String name, int type, boolean indexed,
- boolean fullText, Field field, int projectionIndex) {
- this.name = name.toLowerCase();
- this.type = type;
- this.indexed = indexed;
- this.fullText = fullText;
- this.field = field;
- this.projectionIndex = projectionIndex;
- }
-
- public boolean isId() {
- return ID_KEY.equals(name);
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/GDataClient.java b/new3d/src/com/android/gallery3d/picasa/GDataClient.java
deleted file mode 100644
index 9e8a47a..0000000
--- a/new3d/src/com/android/gallery3d/picasa/GDataClient.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import android.text.TextUtils;
-import android.util.Log;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.params.HttpClientParams;
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
-public final class GDataClient {
- private static final String TAG = "GDataClient";
- private static final String USER_AGENT = "GData/1.0; gzip";
- private static final String X_HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override";
- private static final String IF_MATCH = "If-Match";
- private static final int CONNECTION_TIMEOUT = 20000; // ms.
- private static final int MIN_GZIP_SIZE = 512;
- public static final HttpParams HTTP_PARAMS;
- public static final ThreadSafeClientConnManager HTTP_CONNECTION_MANAGER;
-
- private final DefaultHttpClient mHttpClient =
- new DefaultHttpClient(HTTP_CONNECTION_MANAGER, HTTP_PARAMS);
- private String mAuthToken;
-
- static {
- // Prepare HTTP parameters.
- HttpParams params = new BasicHttpParams();
- HttpConnectionParams.setStaleCheckingEnabled(params, false);
- HttpConnectionParams.setConnectionTimeout(params, CONNECTION_TIMEOUT);
- HttpConnectionParams.setSoTimeout(params, CONNECTION_TIMEOUT);
- HttpClientParams.setRedirecting(params, true);
- HttpProtocolParams.setUserAgent(params, USER_AGENT);
- HTTP_PARAMS = params;
-
- // Register HTTP protocol.
- SchemeRegistry schemeRegistry = new SchemeRegistry();
- schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
-
- // Create the connection manager.
- HTTP_CONNECTION_MANAGER = new ThreadSafeClientConnManager(params, schemeRegistry);
- }
-
- public static final class Operation {
- public String inOutEtag;
- public int outStatus;
- public InputStream outBody;
- }
-
- public void setAuthToken(String authToken) {
- mAuthToken = authToken;
- }
-
- public void get(String feedUrl, Operation operation) throws IOException {
- callMethod(new HttpGet(feedUrl), operation);
- }
-
- public void post(String feedUrl, byte[] data, String contentType, Operation operation)
- throws IOException {
- ByteArrayEntity entity = getCompressedEntity(data);
- entity.setContentType(contentType);
- HttpPost post = new HttpPost(feedUrl);
- post.setEntity(entity);
- callMethod(post, operation);
- }
-
- public void put(String feedUrl, byte[] data, String contentType, Operation operation)
- throws IOException {
- ByteArrayEntity entity = getCompressedEntity(data);
- entity.setContentType(contentType);
- HttpPost post = new HttpPost(feedUrl);
- post.setHeader(X_HTTP_METHOD_OVERRIDE, "PUT");
- post.setEntity(entity);
- callMethod(post, operation);
- }
-
- public void putStream(String feedUrl, InputStream stream, String contentType,
- Operation operation) throws IOException {
- InputStreamEntity entity = new InputStreamEntity(stream, -1);
- entity.setContentType(contentType);
- HttpPost post = new HttpPost(feedUrl);
- post.setHeader(X_HTTP_METHOD_OVERRIDE, "PUT");
- post.setEntity(entity);
- callMethod(post, operation);
- }
-
- public void delete(String feedUrl, Operation operation) throws IOException {
- HttpPost post = new HttpPost(feedUrl);
- String etag = operation.inOutEtag;
- post.setHeader(X_HTTP_METHOD_OVERRIDE, "DELETE");
- post.setHeader(IF_MATCH, etag != null ? etag : "*");
- callMethod(post, operation);
- }
-
- private void callMethod(HttpUriRequest request, Operation operation) throws IOException {
- // Specify GData protocol version 2.0.
- request.addHeader("GData-Version", "2");
-
- // Indicate support for gzip-compressed responses.
- request.addHeader("Accept-Encoding", "gzip");
-
- // Specify authorization token if provided.
- String authToken = mAuthToken;
- if (!TextUtils.isEmpty(authToken)) {
- request.addHeader("Authorization", "GoogleLogin auth=" + authToken);
- }
-
- // Specify the ETag of a prior response, if available.
- String etag = operation.inOutEtag;
- if (etag != null) {
- request.addHeader("If-None-Match", etag);
- }
-
- // Execute the HTTP request.
- HttpResponse httpResponse = null;
- try {
- httpResponse = mHttpClient.execute(request);
- } catch (IOException e) {
- Log.w(TAG, "Request failed: " + request.getURI());
- throw e;
- }
-
- // Get the status code and response body.
- int status = httpResponse.getStatusLine().getStatusCode();
- InputStream stream = null;
- HttpEntity entity = httpResponse.getEntity();
- if (entity != null) {
- // Wrap the entity input stream in a GZIP decoder if necessary.
- stream = entity.getContent();
- if (stream != null) {
- Header header = entity.getContentEncoding();
- if (header != null) {
- if (header.getValue().contains("gzip")) {
- stream = new GZIPInputStream(stream);
- }
- }
- }
- }
-
- // Return the stream if successful.
- Header etagHeader = httpResponse.getFirstHeader("ETag");
- operation.outStatus = status;
- operation.inOutEtag = etagHeader != null ? etagHeader.getValue() : null;
- operation.outBody = stream;
- }
-
- private ByteArrayEntity getCompressedEntity(byte[] data) throws IOException {
- ByteArrayEntity entity;
- if (data.length >= MIN_GZIP_SIZE) {
- ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(data.length / 2);
- GZIPOutputStream gzipOutput = new GZIPOutputStream(byteOutput);
- gzipOutput.write(data);
- gzipOutput.close();
- entity = new ByteArrayEntity(byteOutput.toByteArray());
- } else {
- entity = new ByteArrayEntity(data);
- }
- return entity;
- }
-
- public static String inputStreamToString(InputStream stream) throws IOException {
- InputStreamReader reader = new InputStreamReader(stream);
- StringBuilder builder = new StringBuilder();
- char buffer[] = new char[4096];
- int charsRead = reader.read(buffer);
- while (charsRead > 0) {
- builder.append(buffer, 0, charsRead);
- }
- return builder.toString();
- }
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/GDataParser.java b/new3d/src/com/android/gallery3d/picasa/GDataParser.java
deleted file mode 100644
index 175789c..0000000
--- a/new3d/src/com/android/gallery3d/picasa/GDataParser.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import android.text.format.Time;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public final class GDataParser implements ContentHandler {
- public static final String APP_NAMESPACE = "http://www.w3.org/2007/app";
- public static final String ATOM_NAMESPACE = "http://www.w3.org/2005/Atom";
- public static final String GD_NAMESPACE = "http://schemas.google.com/g/2005";
- public static final String GPHOTO_NAMESPACE = "http://schemas.google.com/photos/2007";
- public static final String MEDIA_RSS_NAMESPACE = "http://search.yahoo.com/mrss/";
- public static final String GML_NAMESPACE = "http://www.opengis.net/gml";
- private static final String FEED_ELEMENT = "feed";
- private static final String ENTRY_ELEMENT = "entry";
-
- private static final int STATE_DOCUMENT = 0;
- private static final int STATE_FEED = 1;
- private static final int STATE_ENTRY = 2;
-
- private static final int NUM_LEVELS = 5;
-
- private Entry mEntry = null;
- private EntryHandler mHandler = null;
- private int mState = STATE_DOCUMENT;
- private int mLevel = 0;
- private final String[] mUri = new String[NUM_LEVELS];
- private final String[] mName = new String[NUM_LEVELS];
- private final AttributesImpl[] mAttributes = new AttributesImpl[NUM_LEVELS];
- private final StringBuilder mValue = new StringBuilder(128);
-
- public interface EntryHandler {
- void handleEntry(Entry entry);
- }
-
- public GDataParser() {
- AttributesImpl[] attributes = mAttributes;
- for (int i = 0; i != NUM_LEVELS; ++i) {
- attributes[i] = new AttributesImpl();
- }
- }
-
- public void setEntry(Entry entry) {
- mEntry = entry;
- }
-
- public void setHandler(EntryHandler handler) {
- mHandler = handler;
- }
-
- public static long parseAtomTimestamp(String timestamp) {
- Time time = new Time();
- time.parse3339(timestamp);
- return time.toMillis(true);
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attrs)
- throws SAXException {
- switch (mState) {
- case STATE_DOCUMENT:
- // Expect an atom:feed element.
- if (uri.equals(ATOM_NAMESPACE) && localName.equals(FEED_ELEMENT)) {
- mState = STATE_FEED;
- } else {
- throw new SAXException();
- }
- break;
- case STATE_FEED:
- // Expect a feed property element or an atom:entry element.
- if (uri.equals(ATOM_NAMESPACE) && localName.equals(ENTRY_ELEMENT)) {
- mState = STATE_ENTRY;
- mEntry.clear();
- } else {
- startProperty(uri, localName, attrs);
- }
- break;
- case STATE_ENTRY:
- startProperty(uri, localName, attrs);
- break;
- }
- }
-
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (mLevel > 0) {
- // Handle property exit.
- endProperty();
- } else {
- // Handle state exit.
- switch (mState) {
- case STATE_DOCUMENT:
- throw new SAXException();
- case STATE_FEED:
- mState = STATE_DOCUMENT;
- break;
- case STATE_ENTRY:
- mState = STATE_FEED;
- mHandler.handleEntry(mEntry);
- break;
- }
- }
- }
-
- private void startProperty(String uri, String localName, Attributes attrs) {
- // Push element information onto the property stack.
- int level = ++mLevel;
- mValue.setLength(0);
- mUri[level] = uri;
- mName[level] = localName;
- mAttributes[level].setAttributes(attrs);
- }
-
- private void endProperty() {
- // Apply property to the entry, then pop the stack.
- int level = mLevel;
- mEntry.setPropertyFromXml(mUri[level], mName[level], mAttributes[level], mValue.toString());
- mLevel = level - 1;
- }
-
- public void characters(char[] ch, int start, int length) throws SAXException {
- mValue.append(ch, start, length);
- }
-
- public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
- // Ignored.
- }
-
- public void processingInstruction(String target, String data) throws SAXException {
- // Ignored.
- }
-
- public void setDocumentLocator(Locator locator) {
- // Ignored.
- }
-
- public void skippedEntity(String name) throws SAXException {
- // Ignored.
- }
-
- public void startDocument() throws SAXException {
- // Ignored.
- }
-
- public void endDocument() throws SAXException {
- // Ignored.
- }
-
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- // Ignored.
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- // Ignored.
- }
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/PhotoEntry.java b/new3d/src/com/android/gallery3d/picasa/PhotoEntry.java
deleted file mode 100644
index 0f13baa..0000000
--- a/new3d/src/com/android/gallery3d/picasa/PhotoEntry.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import org.xml.sax.Attributes;
-
-/**
- * This class models the photo entry kind in the Picasa GData API.
- */
-@Entry.Table("photos")
-public final class PhotoEntry extends Entry {
- public static final EntrySchema SCHEMA = new EntrySchema(PhotoEntry.class);
-
- public static class Columns {
- public static final String SYNC_ACCOUNT = "sync_account";
- public static final String EDIT_URI = "edit_uri";
- public static final String ALBUM_ID = "album_id";
- public static final String DISPLAY_INDEX = "display_index";
- public static final String TITLE = "title";
- public static final String SUMMARY = "summary";
- public static final String DATE_PUBLISHED = "date_published";
- public static final String DATE_UPDATED = "date_updated";
- public static final String DATE_EDITED = "date_edited";
- public static final String DATE_TAKEN = "date_taken";
- public static final String COMMENT_COUNT = "comment_count";
- public static final String WIDTH = "width";
- public static final String HEIGHT = "height";
- public static final String ROTATION = "rotation";
- public static final String SIZE = "size";
- public static final String LATITUDE = "latitude";
- public static final String LONGITUDE = "longitude";
- public static final String THUMBNAIL_URL = "thumbnail_url";
- public static final String SCREENNAIL_URL = "screennail_url";
- public static final String CONTENT_URL = "content_url";
- public static final String CONTENT_TYPE = "content_type";
- public static final String HTML_PAGE_URL = "html_page_url";
- }
-
- /**
- * The user account that is the sync source for this entry. Must be set
- * before insert/update.
- */
- @Column(Columns.SYNC_ACCOUNT)
- public String syncAccount;
-
- /**
- * The "edit" URI of the photo.
- */
- @Column(Columns.EDIT_URI)
- public String editUri;
-
- /**
- * The containing album ID.
- */
- @Column(value = Columns.ALBUM_ID, indexed = true)
- public long albumId;
-
- /**
- * The display index of the photo within the album. Must be set before
- * insert/update.
- */
- @Column(value = Columns.DISPLAY_INDEX, indexed = true)
- public int displayIndex;
-
- /**
- * The title of the photo.
- */
- @Column(Columns.TITLE)
- public String title;
-
- /**
- * A short summary of the photo.
- */
- @Column(Columns.SUMMARY)
- public String summary;
-
- /**
- * The date the photo was added.
- */
- @Column(Columns.DATE_PUBLISHED)
- public long datePublished;
-
- /**
- * The date the photo was last updated.
- */
- @Column(Columns.DATE_UPDATED)
- public long dateUpdated;
-
- /**
- * The date the photo entry was last edited. May be more recent than
- * dateUpdated.
- */
- @Column(Columns.DATE_EDITED)
- public long dateEdited;
-
- /**
- * The date the photo was captured as specified in the EXIF data.
- */
- @Column(Columns.DATE_TAKEN)
- public long dateTaken;
-
- /**
- * The number of comments associated with the photo.
- */
- @Column(Columns.COMMENT_COUNT)
- public int commentCount;
-
- /**
- * The width of the photo in pixels.
- */
- @Column(Columns.WIDTH)
- public int width;
-
- /**
- * The height of the photo in pixels.
- */
- @Column(Columns.HEIGHT)
- public int height;
-
- /**
- * The rotation of the photo in degrees, if rotation has not already been
- * applied.
- */
- @Column(Columns.ROTATION)
- public int rotation;
-
- /**
- * The size of the photo is bytes.
- */
- @Column(Columns.SIZE)
- public int size;
-
- /**
- * The latitude associated with the photo.
- */
- @Column(Columns.LATITUDE)
- public double latitude;
-
- /**
- * The longitude associated with the photo.
- */
- @Column(Columns.LONGITUDE)
- public double longitude;
-
- /**
- * The "mini-thumbnail" URL for the photo (currently 144px-cropped).
- */
- @Column(Columns.THUMBNAIL_URL)
- public String thumbnailUrl;
-
- /**
- * The "screennail" URL for the photo (currently 800px).
- */
- @Column(Columns.SCREENNAIL_URL)
- public String screennailUrl;
-
- /**
- * The "content" URL for the photo (currently 1280px, or a video). The
- * original image URL is not fetched since "imgmax" accepts one size, used
- * to get this resource.
- */
- @Column(Columns.CONTENT_URL)
- public String contentUrl;
-
- /**
- * The MIME type of the content URL.
- */
- @Column(Columns.CONTENT_TYPE)
- public String contentType;
-
- /**
- * A link to the HTML page associated with the album.
- */
- @Column(Columns.HTML_PAGE_URL)
- public String htmlPageUrl;
-
- /**
- * Resets values to defaults for object reuse.
- */
- @Override
- public void clear() {
- super.clear();
- syncAccount = null;
- editUri = null;
- albumId = 0;
- displayIndex = 0;
- title = null;
- summary = null;
- datePublished = 0;
- dateUpdated = 0;
- dateEdited = 0;
- dateTaken = 0;
- commentCount = 0;
- width = 0;
- height = 0;
- rotation = 0;
- size = 0;
- latitude = 0;
- longitude = 0;
- thumbnailUrl = null;
- screennailUrl = null;
- contentUrl = null;
- contentType = null;
- htmlPageUrl = null;
- }
-
- /**
- * Sets the property value corresponding to the given XML element, if
- * applicable.
- */
- @Override
- public void setPropertyFromXml(String uri, String localName, Attributes attrs, String content) {
- try {
- char localNameChar = localName.charAt(0);
- if (uri.equals(GDataParser.GPHOTO_NAMESPACE)) {
- switch (localNameChar) {
- case 'i':
- if (localName.equals("id")) {
- id = Long.parseLong(content);
- }
- break;
- case 'a':
- if (localName.equals("albumid")) {
- albumId = Long.parseLong(content);
- }
- break;
- case 't':
- if (localName.equals("timestamp")) {
- dateTaken = Long.parseLong(content);
- }
- break;
- case 'c':
- if (localName.equals("commentCount")) {
- commentCount = Integer.parseInt(content);
- }
- break;
- case 'w':
- if (localName.equals("width")) {
- width = Integer.parseInt(content);
- }
- break;
- case 'h':
- if (localName.equals("height")) {
- height = Integer.parseInt(content);
- }
- break;
- case 'r':
- if (localName.equals("rotation")) {
- rotation = Integer.parseInt(content);
- }
- break;
- case 's':
- if (localName.equals("size")) {
- size = Integer.parseInt(content);
- }
- break;
- case 'l':
- if (localName.equals("latitude")) {
- latitude = Double.parseDouble(content);
- } else if (localName.equals("longitude")) {
- longitude = Double.parseDouble(content);
- }
- break;
- }
- } else if (uri.equals(GDataParser.ATOM_NAMESPACE)) {
- switch (localNameChar) {
- case 't':
- if (localName.equals("title")) {
- title = content;
- }
- break;
- case 's':
- if (localName.equals("summary")) {
- summary = content;
- }
- break;
- case 'p':
- if (localName.equals("published")) {
- datePublished = GDataParser.parseAtomTimestamp(content);
- }
- break;
- case 'u':
- if (localName.equals("updated")) {
- dateUpdated = GDataParser.parseAtomTimestamp(content);
- }
- break;
- case 'l':
- if (localName.equals("link")) {
- String rel = attrs.getValue("", "rel");
- String href = attrs.getValue("", "href");
- if (rel.equals("alternate")
- && attrs.getValue("", "type").equals("text/html")) {
- htmlPageUrl = href;
- } else if (rel.equals("edit")) {
- editUri = href;
- }
- }
- break;
- }
- } else if (uri.equals(GDataParser.APP_NAMESPACE)) {
- if (localName.equals("edited")) {
- dateEdited = GDataParser.parseAtomTimestamp(content);
- }
- } else if (uri.equals(GDataParser.MEDIA_RSS_NAMESPACE)) {
- if (localName.equals("thumbnail")) {
- int width = Integer.parseInt(attrs.getValue("", "width"));
- int height = Integer.parseInt(attrs.getValue("", "height"));
- int dimension = Math.max(width, height);
- String url = attrs.getValue("", "url");
- if (dimension <= PicasaApi.THUMBNAIL_SIZE_THRESHOLD) {
- thumbnailUrl = url;
- } else {
- screennailUrl = url;
- }
- } else if (localName.equals("content")) {
- // Only replace an existing URL if the MIME type is video.
- String type = attrs.getValue("", "type");
- if (contentUrl == null || type.startsWith("video/")) {
- contentUrl = attrs.getValue("", "url");
- contentType = type;
- }
- }
- } else if (uri.equals(GDataParser.GML_NAMESPACE)) {
- if (localName.equals("pos")) {
- int spaceIndex = content.indexOf(' ');
- if (spaceIndex != -1) {
- latitude = Double.parseDouble(content.substring(0, spaceIndex));
- longitude = Double.parseDouble(content.substring(spaceIndex + 1));
- }
- }
- }
- } catch (Exception e) {
- return;
- }
- }
-
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/PicasaApi.java b/new3d/src/com/android/gallery3d/picasa/PicasaApi.java
deleted file mode 100644
index b45d421..0000000
--- a/new3d/src/com/android/gallery3d/picasa/PicasaApi.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.app.Activity;
-import android.content.Context;
-import android.content.SyncResult;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.util.Xml;
-
-import org.apache.http.HttpStatus;
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.net.SocketException;
-import java.util.ArrayList;
-
-public final class PicasaApi {
- public static final int RESULT_OK = 0;
- public static final int RESULT_NOT_MODIFIED = 1;
- public static final int RESULT_ERROR = 2;
-
- private static final String TAG = "PicasaAPI";
- private static final String BASE_URL = "http://picasaweb.google.com/data/feed/api/";
- private static final String BASE_QUERY_STRING;
-
- // The specs of query parameters are documented here:
- // http://code.google.com/apis/picasaweb/docs/2.0/reference.html
- public static final int THUMBNAIL_SIZE_THRESHOLD = 144;
- private static final String THUMBNAIL_SIZE = "144c";
- private static final String SCREENNAIL_SIZE = "512u";
- private static final String FULL_SIZE = "d"; // Use the original size
-
-
- static {
- // Build the base query string using screen dimensions.
- final StringBuilder query = new StringBuilder("?max-results=1000");
- query.append("&imgmax=").append(FULL_SIZE);
- query.append("&thumbsize=").append(THUMBNAIL_SIZE).append(",")
- .append(SCREENNAIL_SIZE);
- query.append("&visibility=visible");
- BASE_QUERY_STRING = query.toString();
- }
-
- private final GDataClient mClient;
- private final GDataClient.Operation mOperation = new GDataClient.Operation();
- private final GDataParser mParser = new GDataParser();
- private final AlbumEntry mAlbumInstance = new AlbumEntry();
- private final PhotoEntry mPhotoInstance = new PhotoEntry();
- private AuthAccount mAuth;
-
- public static final class AuthAccount {
- public final String user;
- public final String authToken;
- public final Account account;
-
- public AuthAccount(String user, String authToken, Account account) {
- this.user = user;
- this.authToken = authToken;
- this.account = account;
- }
- }
-
- public static Account[] getAccounts(Context context) {
- // Return the list of accounts supporting the Picasa GData service.
- AccountManager accountManager = AccountManager.get(context);
- Account[] accounts = {};
- try {
- accounts = accountManager.getAccountsByTypeAndFeatures(PicasaService.ACCOUNT_TYPE,
- new String[] { PicasaService.FEATURE_SERVICE_NAME }, null, null).getResult();
- } catch (Exception e) {
- Log.e(TAG, "cannot get accounts", e);
- }
- return accounts;
- }
-
- public static AuthAccount[] getAuthenticatedAccounts(Context context) {
- AccountManager accountManager = AccountManager.get(context);
- Account[] accounts = getAccounts(context);
- if (accounts == null) return new AuthAccount[0];
-
- int numAccounts = accounts.length;
- ArrayList<AuthAccount> authAccounts = new ArrayList<AuthAccount>(numAccounts);
- for (int i = 0; i != numAccounts; ++i) {
- Account account = accounts[i];
- String authToken;
- try {
- // Get the token without user interaction.
- authToken = accountManager
- .blockingGetAuthToken(account, PicasaService.SERVICE_NAME, true);
-
- // TODO: Remove this once the build is signed by Google, since
- // we will always have permission.
- // This code requests permission from the user explicitly.
- if (context instanceof Activity) {
- Bundle bundle = accountManager.getAuthToken(
- account, PicasaService.SERVICE_NAME, null, (Activity) context,
- null, null).getResult();
- authToken = bundle.getString("authtoken");
- PicasaService.requestSync(context, PicasaService.TYPE_USERS_ALBUMS, -1);
- }
-
- // Add the account information to the list of accounts.
- if (authToken != null) {
- String username = canonicalizeUsername(account.name);
- authAccounts.add(new AuthAccount(username, authToken, account));
- }
- } catch (Exception e) {
- Log.e(TAG, "fail to get authenticated accounts", e);
- }
- }
- return authAccounts.toArray(new AuthAccount[authAccounts.size()]);
- }
-
- /**
- * Returns a canonical username for a Gmail account. Lowercases the username and
- * strips off a "gmail.com" or "googlemail.com" domain, but leaves other domains alone.
- *
- * e.g., Passing in "User@gmail.com: will return "user".
- *
- * @param username The username to be canonicalized.
- * @return The username, lowercased and possibly stripped of its domain if a "gmail.com" or
- * "googlemail.com" domain.
- */
- public static String canonicalizeUsername(String username) {
- username = username.toLowerCase();
- if (username.contains("@gmail.") || username.contains("@googlemail.")) {
- // Strip the domain from GMail accounts for
- // canonicalization. TODO: is there an official way?
- username = username.substring(0, username.indexOf('@'));
- }
- return username;
- }
-
- public PicasaApi() {
- mClient = new GDataClient();
- }
-
- public void setAuth(AuthAccount auth) {
- mAuth = auth;
- synchronized (mClient) {
- mClient.setAuthToken(auth.authToken);
- }
- }
-
- @SuppressWarnings("fallthrough")
- public int getAlbums(AccountManager accountManager,
- SyncResult syncResult, UserEntry user, GDataParser.EntryHandler handler) {
- // Construct the query URL for user albums.
- StringBuilder builder = new StringBuilder(BASE_URL);
- builder.append("user/");
- builder.append(Uri.encode(mAuth.user));
- builder.append(BASE_QUERY_STRING);
- builder.append("&kind=album");
- try {
- // Send the request.
- synchronized (mOperation) {
- GDataClient.Operation operation = mOperation;
- operation.inOutEtag = user.albumsEtag;
- boolean retry = false;
- int numRetries = 1;
- do {
- retry = false;
- synchronized (mClient) {
- mClient.get(builder.toString(), operation);
- }
- switch (operation.outStatus) {
- case HttpStatus.SC_OK:
- break;
- case HttpStatus.SC_NOT_MODIFIED:
- return RESULT_NOT_MODIFIED;
- case HttpStatus.SC_FORBIDDEN:
- case HttpStatus.SC_UNAUTHORIZED:
- if (!retry) {
- accountManager.invalidateAuthToken(
- PicasaService.ACCOUNT_TYPE, mAuth.authToken);
- retry = true;
- }
- if (numRetries == 0) {
- ++syncResult.stats.numAuthExceptions;
- }
- // fall-through
- default:
- Log.i(TAG, "getAlbums uri " + builder.toString());
- Log.e(TAG, "getAlbums: unexpected status code "
- + operation.outStatus + " data: " + operation.outBody.toString());
- ++syncResult.stats.numIoExceptions;
- return RESULT_ERROR;
- }
- --numRetries;
- } while (retry && numRetries >= 0);
-
- // Store the new ETag for the user/albums feed.
- user.albumsEtag = operation.inOutEtag;
-
- // Parse the response.
- synchronized (mParser) {
- GDataParser parser = mParser;
- parser.setEntry(mAlbumInstance);
- parser.setHandler(handler);
- try {
- Xml.parse(operation.outBody, Xml.Encoding.UTF_8, parser);
- } catch (SocketException e) {
- Log.e(TAG, "getAlbumPhotos: " + e);
- ++syncResult.stats.numIoExceptions;
- e.printStackTrace();
- return RESULT_ERROR;
- }
- }
- }
- return RESULT_OK;
- } catch (IOException e) {
- Log.e(TAG, "getAlbums: " + e);
- ++syncResult.stats.numIoExceptions;
- } catch (SAXException e) {
- Log.e(TAG, "getAlbums: " + e);
- ++syncResult.stats.numParseExceptions;
- }
- return RESULT_ERROR;
- }
-
- public int getAlbumPhotos(AccountManager accountManager, SyncResult syncResult,
- AlbumEntry album, GDataParser.EntryHandler handler) {
- // Construct the query URL for user albums.
- StringBuilder builder = new StringBuilder(BASE_URL);
- builder.append("user/");
- builder.append(Uri.encode(mAuth.user));
- builder.append("/albumid/");
- builder.append(album.id);
- builder.append(BASE_QUERY_STRING);
- builder.append("&kind=photo");
- try {
- // Send the request.
- synchronized (mOperation) {
- GDataClient.Operation operation = mOperation;
- operation.inOutEtag = album.photosEtag;
- boolean retry = false;
- int numRetries = 1;
- do {
- retry = false;
- synchronized (mClient) {
- mClient.get(builder.toString(), operation);
- }
- switch (operation.outStatus) {
- case HttpStatus.SC_OK:
- break;
- case HttpStatus.SC_NOT_MODIFIED:
- return RESULT_NOT_MODIFIED;
- case HttpStatus.SC_FORBIDDEN:
- case HttpStatus.SC_UNAUTHORIZED:
- // We need to reset the authtoken and retry only once.
- if (!retry) {
- retry = true;
- accountManager.invalidateAuthToken(PicasaService.SERVICE_NAME, mAuth.authToken);
- }
- if (numRetries == 0) {
- ++syncResult.stats.numAuthExceptions;
- }
- break;
- default:
- Log.e(TAG, "getAlbumPhotos: " + builder.toString()
- + ", unexpected status code " + operation.outStatus);
- ++syncResult.stats.numIoExceptions;
- return RESULT_ERROR;
- }
- --numRetries;
- } while (retry && numRetries >= 0);
-
- // Store the new ETag for the album/photos feed.
- album.photosEtag = operation.inOutEtag;
-
- // Parse the response.
- synchronized (mParser) {
- GDataParser parser = mParser;
- parser.setEntry(mPhotoInstance);
- parser.setHandler(handler);
- try {
- Xml.parse(operation.outBody, Xml.Encoding.UTF_8, parser);
- } catch (SocketException e) {
- Log.e(TAG, "getAlbumPhotos: " + e);
- ++syncResult.stats.numIoExceptions;
- e.printStackTrace();
- return RESULT_ERROR;
- }
- }
- }
- return RESULT_OK;
- } catch (IOException e) {
- Log.e(TAG, "getAlbumPhotos", e);
- ++syncResult.stats.numIoExceptions;
- } catch (SAXException e) {
- Log.e(TAG, "getAlbumPhotos", e);
- ++syncResult.stats.numParseExceptions;
- }
- return RESULT_ERROR;
- }
-
- public int deleteEntry(String editUri) {
- try {
- synchronized (mOperation) {
- GDataClient.Operation operation = mOperation;
- operation.inOutEtag = null;
- synchronized (mClient) {
- mClient.delete(editUri, operation);
- }
- if (operation.outStatus == 200) {
- return RESULT_OK;
- } else {
- Log.e(TAG, "deleteEntry: failed with status code " + operation.outStatus);
- }
- }
- } catch (IOException e) {
- Log.e(TAG, "deleteEntry", e);
- }
- return RESULT_ERROR;
- }
-
- /**
- * Column names shared by multiple entry kinds.
- */
- public static class Columns {
- public static final String _ID = "_id";
- public static final String SYNC_ACCOUNT = "sync_account";
- public static final String EDIT_URI = "edit_uri";
- public static final String TITLE = "title";
- public static final String SUMMARY = "summary";
- public static final String DATE_PUBLISHED = "date_published";
- public static final String DATE_UPDATED = "date_updated";
- public static final String DATE_EDITED = "date_edited";
- public static final String THUMBNAIL_URL = "thumbnail_url";
- public static final String HTML_PAGE_URL = "html_page_url";
- }
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/PicasaContentProvider.java b/new3d/src/com/android/gallery3d/picasa/PicasaContentProvider.java
deleted file mode 100644
index 57b8295..0000000
--- a/new3d/src/com/android/gallery3d/picasa/PicasaContentProvider.java
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.SyncResult;
-import android.content.pm.ProviderInfo;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.net.Uri;
-import android.util.Log;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public final class PicasaContentProvider extends TableContentProvider {
- public static final String AUTHORITY = "com.android.gallery3d.picasa.contentprovider";
- public static final Uri BASE_URI = Uri.parse("content://" + AUTHORITY);
- public static final Uri PHOTOS_URI = Uri.withAppendedPath(BASE_URI, "photos");
- public static final Uri ALBUMS_URI = Uri.withAppendedPath(BASE_URI, "albums");
-
- private static final String TAG = "PicasaContentProvider";
- private static final String[] ID_EDITED_PROJECTION = {"_id", "date_edited"};
- private static final String[] ID_EDITED_INDEX_PROJECTION =
- {"_id", "date_edited", "display_index"};
- private static final String WHERE_ACCOUNT = "sync_account=?";
- private static final String WHERE_ALBUM_ID = "album_id=?";
-
- private final PhotoEntry mPhotoInstance = new PhotoEntry();
- private final AlbumEntry mAlbumInstance = new AlbumEntry();
- private SyncContext mSyncContext = null;
- private Account mActiveAccount;
-
- @Override
- public void attachInfo(Context context, ProviderInfo info) {
- // Initialize the provider and set the database.
- super.attachInfo(context, info);
- setDatabase(new Database(context, Database.DATABASE_NAME));
-
- // Add mappings for each of the exposed tables.
- addMapping(AUTHORITY, "photos", "vnd.android.gallery3d.picasa.photo", PhotoEntry.SCHEMA);
- addMapping(AUTHORITY, "albums", "vnd.android.gallery3d.picasa.album", AlbumEntry.SCHEMA);
-
- // Create the sync context.
- try {
- mSyncContext = new SyncContext();
- } catch (Exception e) {
- Log.e(TAG, "cannot get sync context", e);
- // The database wasn't created successfully, we create a memory backed database.
- setDatabase(new Database(context, null));
- }
- }
-
- public static final class Database extends SQLiteOpenHelper {
- public static final String DATABASE_NAME = "picasa.db";
- public static final int DATABASE_VERSION = 83;
-
- public Database(Context context, String name) {
- super(context, name, null, DATABASE_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- PhotoEntry.SCHEMA.createTables(db);
- AlbumEntry.SCHEMA.createTables(db);
- UserEntry.SCHEMA.createTables(db);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- // No new versions yet, if we are asked to upgrade we just reset
- // everything.
- PhotoEntry.SCHEMA.dropTables(db);
- AlbumEntry.SCHEMA.dropTables(db);
- UserEntry.SCHEMA.dropTables(db);
- onCreate(db);
- }
- }
-
- @Override
- public int delete(Uri uri, String selection, String[] selectionArgs) {
- // Ensure that the URI is well-formed. We currently do not allow WHERE
- // clauses.
- List<String> path = uri.getPathSegments();
- if (path.size() != 2 || !uri.getAuthority().equals(AUTHORITY) || selection != null) {
- return 0;
- }
-
- // Get the sync context.
- SyncContext context = mSyncContext;
-
- // Determine if the URI refers to an album or photo.
- String type = path.get(0);
- long id = Long.parseLong(path.get(1));
- SQLiteDatabase db = context.db;
- if (type.equals("photos")) {
- // Retrieve the photo from the database to get the edit URI.
- PhotoEntry photo = mPhotoInstance;
- if (PhotoEntry.SCHEMA.queryWithId(db, id, photo)) {
- // Send a DELETE request to the API.
- if (context.login(photo.syncAccount)) {
- if (context.api.deleteEntry(photo.editUri) == PicasaApi.RESULT_OK) {
- deletePhoto(db, id);
- context.photosChanged = true;
- return 1;
- }
- }
- }
- } else if (type.equals("albums")) {
- // Retrieve the album from the database to get the edit URI.
- AlbumEntry album = mAlbumInstance;
- if (AlbumEntry.SCHEMA.queryWithId(db, id, album)) {
- // Send a DELETE request to the API.
- if (context.login(album.syncAccount)) {
- if (context.api.deleteEntry(album.editUri) == PicasaApi.RESULT_OK) {
- deleteAlbum(db, id);
- context.albumsChanged = true;
- return 1;
- }
- }
- }
- }
- context.finish();
- return 0;
- }
-
- public void reloadAccounts() {
- mSyncContext.reloadAccounts();
- }
-
- public void setActiveSyncAccount(Account account) {
- mActiveAccount = account;
- }
-
- public void syncUsers(SyncResult syncResult) {
- syncUsers(mSyncContext, syncResult);
- }
-
- public void syncUsersAndAlbums(final boolean syncAlbumPhotos, SyncResult syncResult) {
- SyncContext context = mSyncContext;
-
- // Synchronize users authenticated on the device.
- UserEntry[] users = syncUsers(context, syncResult);
-
- // Synchronize albums for each user.
- String activeUsername = null;
- if (mActiveAccount != null) {
- activeUsername = PicasaApi.canonicalizeUsername(mActiveAccount.name);
- }
- boolean didSyncActiveUserName = false;
- for (int i = 0, numUsers = users.length; i != numUsers; ++i) {
- if (activeUsername != null && !context.accounts[i].user.equals(activeUsername))
- continue;
- if (!ContentResolver.getSyncAutomatically(context.accounts[i].account, AUTHORITY))
- continue;
- didSyncActiveUserName = true;
- context.api.setAuth(context.accounts[i]);
- syncUserAlbums(context, users[i], syncResult);
- if (syncAlbumPhotos) {
- syncUserPhotos(context, users[i].account, syncResult);
- } else {
- // // Always sync added albums.
- // for (Long albumId : context.albumsAdded) {
- // syncAlbumPhotos(albumId, false);
- // }
- }
- }
- if (!didSyncActiveUserName) {
- ++syncResult.stats.numAuthExceptions;
- }
- context.finish();
- }
-
- public void syncAlbumPhotos(
- final long albumId, final boolean forceRefresh, SyncResult syncResult) {
- SyncContext context = mSyncContext;
- AlbumEntry album = new AlbumEntry();
- if (AlbumEntry.SCHEMA.queryWithId(context.db, albumId, album)) {
- if ((album.photosDirty || forceRefresh) && context.login(album.syncAccount)) {
- if (isSyncEnabled(album.syncAccount, context)) {
- syncAlbumPhotos(context, album.syncAccount, album, syncResult);
- }
- }
- }
- context.finish();
- }
-
- public static boolean isSyncEnabled(String accountName, SyncContext context) {
- if (context.accounts == null) {
- context.reloadAccounts();
- }
- PicasaApi.AuthAccount[] accounts = context.accounts;
- int numAccounts = accounts.length;
- for (int i = 0; i < numAccounts; ++i) {
- PicasaApi.AuthAccount account = accounts[i];
- if (account.user.equals(accountName)) {
- return ContentResolver.getSyncAutomatically(account.account, AUTHORITY);
- }
- }
- return true;
- }
-
- private UserEntry[] syncUsers(SyncContext context, SyncResult syncResult) {
- // Get authorized accounts.
- context.reloadAccounts();
- PicasaApi.AuthAccount[] accounts = context.accounts;
- int numUsers = accounts.length;
- UserEntry[] users = new UserEntry[numUsers];
-
- // Scan existing accounts.
- EntrySchema schema = UserEntry.SCHEMA;
- SQLiteDatabase db = context.db;
- Cursor cursor = schema.queryAll(db);
- if (cursor.moveToFirst()) {
- do {
- // Read the current account.
- UserEntry entry = new UserEntry();
- schema.cursorToObject(cursor, entry);
-
- // Find the corresponding account, or delete the row if it does
- // not exist.
- int i;
- for (i = 0; i != numUsers; ++i) {
- if (accounts[i].user.equals(entry.account)) {
- users[i] = entry;
- break;
- }
- }
- if (i == numUsers) {
- Log.e(TAG, "Deleting user " + entry.account);
- entry.albumsEtag = null;
- deleteUser(db, entry.account);
- }
- } while (cursor.moveToNext());
- } else {
- // Log.i(TAG, "No users in database yet");
- }
- cursor.close();
-
- // Add new accounts and synchronize user albums if recursive.
- for (int i = 0; i != numUsers; ++i) {
- UserEntry entry = users[i];
- PicasaApi.AuthAccount account = accounts[i];
- if (entry == null) {
- entry = new UserEntry();
- entry.account = account.user;
- users[i] = entry;
- Log.e(TAG, "Inserting user " + entry.account);
- }
- }
- return users;
- }
-
- private void syncUserAlbums(
- final SyncContext context, final UserEntry user, final SyncResult syncResult) {
- // Query existing album entry (id, dateEdited) sorted by ID.
- final SQLiteDatabase db = context.db;
- Cursor cursor = db.query(AlbumEntry.SCHEMA.getTableName(),
- ID_EDITED_PROJECTION, WHERE_ACCOUNT, new String[] { user.account },
- null, null, AlbumEntry.Columns.DATE_EDITED);
- int localCount = cursor.getCount();
-
- // Build a sorted index with existing entry timestamps.
- final EntryMetadata local[] = new EntryMetadata[localCount];
- for (int i = 0; i != localCount; ++i) {
- cursor.moveToPosition(i); // TODO: throw exception here if returns
- // false?
- local[i] = new EntryMetadata(cursor.getLong(0), cursor.getLong(1), 0);
- }
- cursor.close();
- Arrays.sort(local);
-
- // Merge the truth from the API into the local database.
- final EntrySchema albumSchema = AlbumEntry.SCHEMA;
- final EntryMetadata key = new EntryMetadata();
- final AccountManager accountManager = AccountManager.get(getContext());
- int result = context.api.getAlbums(
- accountManager, syncResult, user, new GDataParser.EntryHandler() {
- public void handleEntry(Entry entry) {
- AlbumEntry album = (AlbumEntry) entry;
- long albumId = album.id;
- key.id = albumId;
- int index = Arrays.binarySearch(local, key);
- EntryMetadata metadata = index >= 0 ? local[index] : null;
- if (metadata == null || metadata.dateEdited < album.dateEdited) {
- // Insert / update.
- Log.i(TAG, "insert / update album " + album.title);
- album.syncAccount = user.account;
- album.photosDirty = true;
- albumSchema.insertOrReplace(db, album);
- if (metadata == null) {
- context.albumsAdded.add(albumId);
- }
- ++syncResult.stats.numUpdates;
- } else {
- // Up-to-date.
- // Log.i(TAG, "up-to-date album " + album.title);
- }
-
- // Mark item as surviving so it is not deleted.
- if (metadata != null) {
- metadata.survived = true;
- }
- }
- });
-
- // Return if not modified or on error.
- switch (result) {
- case PicasaApi.RESULT_ERROR:
- ++syncResult.stats.numParseExceptions;
- case PicasaApi.RESULT_NOT_MODIFIED:
- return;
- }
-
- // Update the user entry with the new ETag.
- UserEntry.SCHEMA.insertOrReplace(db, user);
-
- // Delete all entries not present in the API response.
- for (int i = 0; i != localCount; ++i) {
- EntryMetadata metadata = local[i];
- if (!metadata.survived) {
- deleteAlbum(db, metadata.id);
- ++syncResult.stats.numDeletes;
- Log.i(TAG, "delete album " + metadata.id);
- }
- }
-
- // Note that albums changed.
- context.albumsChanged = true;
- }
-
- private void syncUserPhotos(SyncContext context, String account, SyncResult syncResult) {
- // Synchronize albums with out-of-date photos.
- SQLiteDatabase db = context.db;
- Cursor cursor = db.query(AlbumEntry.SCHEMA.getTableName(),
- Entry.ID_PROJECTION, "sync_account=? AND photos_dirty=1",
- new String[] { account }, null, null, null);
- AlbumEntry album = new AlbumEntry();
- for (int i = 0, count = cursor.getCount(); i != count; ++i) {
- cursor.moveToPosition(i);
- if (AlbumEntry.SCHEMA.queryWithId(db, cursor.getLong(0), album)) {
- syncAlbumPhotos(context, account, album, syncResult);
- }
-
- // Abort if interrupted.
- if (Thread.interrupted()) {
- ++syncResult.stats.numIoExceptions;
- Log.e(TAG, "syncUserPhotos interrupted");
- }
- }
- cursor.close();
- }
-
- private void syncAlbumPhotos(SyncContext context, final String account,
- AlbumEntry album, final SyncResult syncResult) {
- Log.i(TAG, "Syncing Picasa album: " + album.title);
- // Query existing album entry (id, dateEdited) sorted by ID.
- final SQLiteDatabase db = context.db;
- long albumId = album.id;
- String[] albumIdArgs = { Long.toString(albumId) };
- Cursor cursor = db.query(PhotoEntry.SCHEMA.getTableName(), ID_EDITED_INDEX_PROJECTION, WHERE_ALBUM_ID, albumIdArgs, null,
- null, "date_edited");
- int localCount = cursor.getCount();
-
- // Build a sorted index with existing entry timestamps and display
- // indexes.
- final EntryMetadata local[] = new EntryMetadata[localCount];
- final EntryMetadata key = new EntryMetadata();
- for (int i = 0; i != localCount; ++i) {
- cursor.moveToPosition(i); // TODO: throw exception here if returns
- // false?
- local[i] = new EntryMetadata(cursor.getLong(0), cursor.getLong(1), cursor.getInt(2));
- }
- cursor.close();
- Arrays.sort(local);
-
- // Merge the truth from the API into the local database.
- final EntrySchema photoSchema = PhotoEntry.SCHEMA;
- final int[] displayIndex = { 0 };
- final AccountManager accountManager = AccountManager.get(getContext());
- int result = context.api.getAlbumPhotos(
- accountManager, syncResult, album, new GDataParser.EntryHandler() {
- public void handleEntry(Entry entry) {
- PhotoEntry photo = (PhotoEntry) entry;
- long photoId = photo.id;
- int newDisplayIndex = displayIndex[0];
- key.id = photoId;
- int index = Arrays.binarySearch(local, key);
- EntryMetadata metadata = index >= 0 ? local[index] : null;
- if (metadata == null || metadata.dateEdited < photo.dateEdited
- || metadata.displayIndex != newDisplayIndex) {
-
- // Insert / update.
- // Log.i(TAG, "insert / update photo " + photo.title);
- photo.syncAccount = account;
- photo.displayIndex = newDisplayIndex;
- photoSchema.insertOrReplace(db, photo);
- ++syncResult.stats.numUpdates;
- } else {
- // Up-to-date.
- // Log.i(TAG, "up-to-date photo " + photo.title);
- }
-
- // Mark item as surviving so it is not deleted.
- if (metadata != null) {
- metadata.survived = true;
- }
-
- // Increment the display index.
- displayIndex[0] = newDisplayIndex + 1;
- }
- });
-
- // Return if not modified or on error.
- switch (result) {
- case PicasaApi.RESULT_ERROR:
- ++syncResult.stats.numParseExceptions;
- Log.e(TAG, "syncAlbumPhotos error");
- case PicasaApi.RESULT_NOT_MODIFIED:
- // Log.e(TAG, "result not modified");
- return;
- }
-
- // Delete all entries not present in the API response.
- for (int i = 0; i != localCount; ++i) {
- EntryMetadata metadata = local[i];
- if (!metadata.survived) {
- deletePhoto(db, metadata.id);
- ++syncResult.stats.numDeletes;
- // Log.i(TAG, "delete photo " + metadata.id);
- }
- }
-
- // Mark album as no longer dirty and store the new ETag.
- album.photosDirty = false;
- AlbumEntry.SCHEMA.insertOrReplace(db, album);
- // Log.i(TAG, "Clearing dirty bit on album " + albumId);
-
- // Mark that photos changed.
- // context.photosChanged = true;
- getContext().getContentResolver().notifyChange(ALBUMS_URI, null, false);
- getContext().getContentResolver().notifyChange(PHOTOS_URI, null, false);
- }
-
- private void deleteUser(SQLiteDatabase db, String account) {
- Log.w(TAG, "deleteUser(" + account + ")");
-
- // Select albums owned by the user.
- String albumTableName = AlbumEntry.SCHEMA.getTableName();
- String[] whereArgs = { account };
- Cursor cursor = db.query(AlbumEntry.SCHEMA.getTableName(),
- Entry.ID_PROJECTION, WHERE_ACCOUNT, whereArgs, null, null, null);
-
- // Delete contained photos for each album.
- if (cursor.moveToFirst()) {
- do {
- deleteAlbumPhotos(db, cursor.getLong(0));
- } while (cursor.moveToNext());
- }
- cursor.close();
-
- // Delete all albums.
- db.delete(albumTableName, WHERE_ACCOUNT, whereArgs);
-
- // Delete the user entry.
- db.delete(UserEntry.SCHEMA.getTableName(), "account=?", whereArgs);
- }
-
- private void deleteAlbum(SQLiteDatabase db, long albumId) {
- // Delete contained photos.
- deleteAlbumPhotos(db, albumId);
-
- // Delete the album.
- AlbumEntry.SCHEMA.deleteWithId(db, albumId);
- }
-
- private void deleteAlbumPhotos(SQLiteDatabase db, long albumId) {
- Log.v(TAG, "deleteAlbumPhotos(" + albumId + ")");
- String photoTableName = PhotoEntry.SCHEMA.getTableName();
- String[] whereArgs = { Long.toString(albumId) };
- Cursor cursor = db.query(photoTableName,
- Entry.ID_PROJECTION, WHERE_ALBUM_ID, whereArgs, null, null, null);
-
- // Delete cache entry for each photo.
- if (cursor.moveToFirst()) {
- do {
- deletePhotoCache(cursor.getLong(0));
- } while (cursor.moveToNext());
- }
- cursor.close();
-
- // Delete all photos.
- db.delete(photoTableName, WHERE_ALBUM_ID, whereArgs);
- }
-
- private void deletePhoto(SQLiteDatabase db, long photoId) {
- PhotoEntry.SCHEMA.deleteWithId(db, photoId);
- deletePhotoCache(photoId);
- }
-
- private void deletePhotoCache(long photoId) {
- // TODO: implement it.
- }
-
- private final class SyncContext {
- // List of all authenticated user accounts.
- public PicasaApi.AuthAccount[] accounts;
-
- // A connection to the Picasa API for a specific user account. Initially
- // null.
- public PicasaApi api = new PicasaApi();
-
- // A handle to the Picasa databse.
- public SQLiteDatabase db;
-
- // List of album IDs that were added during the sync.
- public final ArrayList<Long> albumsAdded = new ArrayList<Long>();
-
- // Set to true if albums were changed.
- public boolean albumsChanged = false;
-
- // Set to true if photos were changed.
- public boolean photosChanged = false;
-
- public SyncContext() {
- db = mDatabase.getWritableDatabase();
- }
-
- public void reloadAccounts() {
- accounts = PicasaApi.getAuthenticatedAccounts(getContext());
- }
-
- public void finish() {
- // Send notifications if needed and reset state.
- ContentResolver cr = getContext().getContentResolver();
- if (albumsChanged) {
- cr.notifyChange(ALBUMS_URI, null, false);
- }
- if (photosChanged) {
- cr.notifyChange(PHOTOS_URI, null, false);
- }
- albumsChanged = false;
- photosChanged = false;
- }
-
- public boolean login(String user) {
- if (accounts == null) {
- reloadAccounts();
- }
- final PicasaApi.AuthAccount[] authAccounts = accounts;
- for (PicasaApi.AuthAccount auth : authAccounts) {
- if (auth.user.equals(user)) {
- api.setAuth(auth);
- return true;
- }
- }
- return false;
- }
- }
-
- /**
- * Minimal metadata gathered during sync.
- */
- private static final class EntryMetadata implements Comparable<EntryMetadata> {
- public long id;
- public long dateEdited;
- public int displayIndex;
- public boolean survived = false;
-
- public EntryMetadata() {
- }
-
- public EntryMetadata(long id, long dateEdited, int displayIndex) {
- this.id = id;
- this.dateEdited = dateEdited;
- this.displayIndex = displayIndex;
- }
-
- public int compareTo(EntryMetadata other) {
- return Long.signum(id - other.id);
- }
-
- }
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/PicasaReceiver.java b/new3d/src/com/android/gallery3d/picasa/PicasaReceiver.java
deleted file mode 100644
index 3e28820..0000000
--- a/new3d/src/com/android/gallery3d/picasa/PicasaReceiver.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
-
-public class PicasaReceiver extends BroadcastReceiver {
-
- private static final String TAG = "PicasaRecevier";
-
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.v(TAG, "Accounts changed: " + intent);
- }
-
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/PicasaService.java b/new3d/src/com/android/gallery3d/picasa/PicasaService.java
deleted file mode 100644
index bc2adc7..0000000
--- a/new3d/src/com/android/gallery3d/picasa/PicasaService.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.accounts.AuthenticatorException;
-import android.accounts.OperationCanceledException;
-import android.app.Service;
-import android.content.ContentProviderClient;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SyncResult;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.IBinder;
-import android.os.Process;
-
-import java.io.IOException;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-public final class PicasaService extends Service {
- public static final String ACTION_SYNC = "com.android.gallery3d.picasa.action.SYNC";
- public static final String ACTION_PERIODIC_SYNC =
- "com.android.gallery3d.picasa.action.PERIODIC_SYNC";
- public static final String ACCOUNT_TYPE = "com.google";
- public static final String SERVICE_NAME = "lh2";
- public static final String FEATURE_SERVICE_NAME = "service_" + SERVICE_NAME;
- public static final String KEY_TYPE = "com.android.gallery3d.SYNC_TYPE";
- public static final String KEY_ID = "com.android.gallery3d.SYNC_ID";
- public static final int TYPE_USERS = 0;
- public static final int TYPE_USERS_ALBUMS = 1;
- public static final int TYPE_ALBUM_PHOTOS = 2;
-
- private final HandlerThread mSyncThread = new HandlerThread("PicasaSyncThread");
- private final Handler mSyncHandler;
- private static final AtomicBoolean sSyncPending = new AtomicBoolean(false);
-
- public static void requestSync(Context context, int type, long id) {
- Bundle extras = new Bundle();
- extras.putInt(KEY_TYPE, type);
- extras.putLong(KEY_ID, id);
-
- Account[] accounts = PicasaApi.getAccounts(context);
- for (Account account : accounts) {
- ContentResolver.requestSync(account, PicasaContentProvider.AUTHORITY, extras);
- }
-
- // context.startService(new Intent(context,
- // PicasaService.class).putExtras(extras));
- }
-
- public PicasaService() {
- mSyncThread.start();
- mSyncHandler = new Handler(mSyncThread.getLooper());
- mSyncHandler.post(new Runnable() {
- public void run() {
- Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
- }
- });
- }
-
- private static PicasaContentProvider getContentProvider(Context context) {
- ContentResolver cr = context.getContentResolver();
- ContentProviderClient client =
- cr.acquireContentProviderClient(PicasaContentProvider.AUTHORITY);
- return (PicasaContentProvider) client.getLocalContentProvider();
- }
-
- @Override
- public int onStartCommand(final Intent intent, int flags, final int startId) {
- mSyncHandler.post(new Runnable() {
- public void run() {
- performSync(PicasaService.this, null, intent.getExtras(), new SyncResult());
- stopSelf(startId);
- }
- });
- return START_NOT_STICKY;
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- return new PicasaSyncAdapter(getApplicationContext()).getSyncAdapterBinder();
- }
-
- @Override
- public void onDestroy() {
- mSyncThread.quit();
- }
-
- public static boolean performSync(
- Context context, Account account, Bundle extras, SyncResult syncResult) {
- // Skip if another sync is pending.
- if (!sSyncPending.compareAndSet(false, true)) {
- return false;
- }
-
- // Perform the sync.
- performSyncImpl(context, account, extras, syncResult);
-
- // Mark sync as complete and notify all waiters.
- sSyncPending.set(false);
- synchronized (sSyncPending) {
- sSyncPending.notifyAll();
- }
- return true;
- }
-
- public static void waitForPerformSync() {
- synchronized (sSyncPending) {
- while (sSyncPending.get()) {
- try {
- // Wait for the sync to complete.
- sSyncPending.wait();
- } catch (InterruptedException e) {
- // Stop waiting if interrupted.
- break;
- }
- }
- }
- }
-
- private static void performSyncImpl(
- Context context, Account account, Bundle extras, SyncResult syncResult) {
- // Initialize newly added accounts to sync by default.
- String authority = PicasaContentProvider.AUTHORITY;
- if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, false)) {
- if (account != null && ContentResolver.getIsSyncable(account, authority) < 0) {
- try {
- ContentResolver.setIsSyncable(
- account, authority, getIsSyncable(context, account) ? 1 : 0);
- } catch (OperationCanceledException e) {
- } catch (IOException e) {
- }
- }
- return;
- }
-
- // Do nothing if sync is disabled for this account. TODO: is this
- // blocked in PicasaContentProvider too?
- if (account != null && ContentResolver.getIsSyncable(account, authority) < 0) {
- ++syncResult.stats.numSkippedEntries;
- return;
- }
-
- // Get the type of sync operation and the entity ID, if applicable.
- // Default to synchronize all.
- int type = extras.getInt(PicasaService.KEY_TYPE, PicasaService.TYPE_USERS_ALBUMS);
- long id = extras.getLong(PicasaService.KEY_ID, -1);
-
- // Get the content provider instance and reload the list of user
- // accounts.
- PicasaContentProvider provider = getContentProvider(context);
- provider.reloadAccounts();
-
- // Restrict sync to either a specific account or all accounts.
- provider.setActiveSyncAccount(account);
-
- // Perform the desired sync operation.
- switch (type) {
- case PicasaService.TYPE_USERS:
- provider.syncUsers(syncResult);
- break;
- case PicasaService.TYPE_USERS_ALBUMS:
- provider.syncUsersAndAlbums(true, syncResult);
- break;
- case PicasaService.TYPE_ALBUM_PHOTOS:
- provider.syncAlbumPhotos(id, true, syncResult);
- break;
- default:
- throw new IllegalArgumentException();
- }
- }
-
- private static boolean getIsSyncable(Context context, Account account)
- throws IOException, OperationCanceledException {
- try {
- Account[] picasaAccounts = AccountManager.get(context).getAccountsByTypeAndFeatures(
- ACCOUNT_TYPE, new String[] { FEATURE_SERVICE_NAME },
- null /* callback */, null /* handler */).getResult();
- for (Account picasaAccount : picasaAccounts) {
- if (account.equals(picasaAccount)) {
- return true;
- }
- }
- return false;
- } catch (AuthenticatorException e) {
- throw new IOException(e.getMessage());
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/PicasaSyncAdapter.java b/new3d/src/com/android/gallery3d/picasa/PicasaSyncAdapter.java
deleted file mode 100644
index 5d5ae60..0000000
--- a/new3d/src/com/android/gallery3d/picasa/PicasaSyncAdapter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.content.AbstractThreadedSyncAdapter;
-import android.content.BroadcastReceiver;
-import android.content.ContentProviderClient;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SyncResult;
-import android.os.Bundle;
-import android.util.Log;
-
-public class PicasaSyncAdapter extends AbstractThreadedSyncAdapter {
- private final Context mContext;
- public final static String TAG = "PicasaSyncAdapter";
-
- public PicasaSyncAdapter(Context applicationContext) {
- super(applicationContext, false);
- mContext = applicationContext;
- }
-
- @Override
- public void onPerformSync(Account account, Bundle extras, String authority,
- ContentProviderClient providerClient, SyncResult syncResult) {
- if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, false)) {
- try {
- Account[] picasaAccounts = AccountManager.get(getContext())
- .getAccountsByTypeAndFeatures(
- PicasaService.ACCOUNT_TYPE,
- new String[] { PicasaService.FEATURE_SERVICE_NAME },
- null /* callback */, null /* handler */).getResult();
- boolean isPicasaAccount = false;
- for (Account picasaAccount : picasaAccounts) {
- if (account.equals(picasaAccount)) {
- isPicasaAccount = true;
- break;
- }
- }
- if (isPicasaAccount) {
- ContentResolver.setIsSyncable(account, authority, 1);
- ContentResolver.setSyncAutomatically(account, authority, true);
- }
- } catch (Exception e) {
- Log.e(TAG, "cannot do sync", e);
- }
- return;
- }
- try {
- PicasaService.performSync(mContext, account, extras, syncResult);
- } catch (Exception e) {
- // Report an error
- ++syncResult.stats.numIoExceptions;
- }
- }
-
- public static final class AccountChangeReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- // TODO: Need to get account list change broadcast.
- }
-
- }
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/TableContentProvider.java b/new3d/src/com/android/gallery3d/picasa/TableContentProvider.java
deleted file mode 100644
index ed2e297..0000000
--- a/new3d/src/com/android/gallery3d/picasa/TableContentProvider.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import android.content.ContentProvider;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.UriMatcher;
-import android.database.Cursor;
-import android.database.SQLException;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.net.Uri;
-import android.text.TextUtils;
-
-import java.util.ArrayList;
-
-public class TableContentProvider extends ContentProvider {
- private static final String NULL_COLUMN_HACK = "_id";
- protected SQLiteOpenHelper mDatabase = null;
- private final UriMatcher mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
- private final ArrayList<Mapping> mMappings = new ArrayList<Mapping>();
-
- public void setDatabase(SQLiteOpenHelper database) {
- mDatabase = database;
- }
-
- public void addMapping(String authority, String path, String mimeSubtype, EntrySchema table) {
- // Add the table URI mapping.
- ArrayList<Mapping> mappings = mMappings;
- UriMatcher matcher = mUriMatcher;
- matcher.addURI(authority, path, mappings.size());
- mappings.add(new Mapping(table, mimeSubtype, false));
-
- // Add the row URI mapping.
- matcher.addURI(authority, path + "/#", mappings.size());
- mappings.add(new Mapping(table, mimeSubtype, true));
- }
-
- @Override
- public boolean onCreate() {
- // The database may not be loaded yet since attachInfo() has not been
- // called, so we cannot
- // check that the database opened successfully. Returns true
- // optimistically.
- return true;
- }
-
- @Override
- public String getType(Uri uri) {
- // Resolve the URI.
- int match = mUriMatcher.match(uri);
- if (match == UriMatcher.NO_MATCH) {
- throw new IllegalArgumentException("Invalid URI: " + uri);
- }
-
- // Combine the standard type with the user-provided subtype.
- Mapping mapping = mMappings.get(match);
- String prefix = mapping.hasId
- ? ContentResolver.CURSOR_ITEM_BASE_TYPE
- : ContentResolver.CURSOR_DIR_BASE_TYPE;
- return prefix + "/" + mapping.mimeSubtype;
- }
-
- @Override
- public Cursor query(Uri uri, String[] projection,
- String selection, String[] selectionArgs, String sortOrder) {
- // Resolve the URI.
- int match = mUriMatcher.match(uri);
- if (match == UriMatcher.NO_MATCH) {
- throw new IllegalArgumentException("Invalid URI: " + uri);
- }
-
- // Add the ID predicate if needed.
- Mapping mapping = mMappings.get(match);
- if (mapping.hasId) {
- selection = whereWithId(uri, selection);
- }
-
- // System.out.println("QUERY " + uri + " WHERE (" + selection + ")");
-
- // Run the query.
- String tableName = mapping.table.getTableName();
- String limit = uri.getQueryParameter("limit");
- Cursor cursor = mDatabase.getReadableDatabase().query(
- tableName, projection, selection, selectionArgs, null, null,
- sortOrder, limit);
- cursor.setNotificationUri(getContext().getContentResolver(), uri);
- return cursor;
- }
-
- @Override
- public Uri insert(Uri uri, ContentValues values) {
- // Resolve the URI.
- int match = mUriMatcher.match(uri);
- Mapping mapping = match != UriMatcher.NO_MATCH ? mMappings.get(match) : null;
- if (mapping == null || mapping.hasId) {
- throw new IllegalArgumentException("Invalid URI: " + uri);
- }
-
- // Insert into the database, notify observers, and return the qualified
- // URI.
- String tableName = mapping.table.getTableName();
- long rowId = mDatabase.getWritableDatabase().insert(tableName, NULL_COLUMN_HACK, values);
- if (rowId > 0) {
- notifyChange(uri);
- return Uri.withAppendedPath(uri, Long.toString(rowId));
- } else {
- throw new SQLException("Failed to insert row at: " + uri);
- }
- }
-
- @Override
- public int bulkInsert(Uri uri, ContentValues[] values) {
- // Resolve the URI.
- int match = mUriMatcher.match(uri);
- Mapping mapping = match != UriMatcher.NO_MATCH ? mMappings.get(match) : null;
- if (mapping == null || mapping.hasId) {
- throw new IllegalArgumentException("Invalid URI: " + uri);
- }
-
- // Insert all rows into the database and notify observers.
- String tableName = mapping.table.getTableName();
- SQLiteDatabase database = mDatabase.getWritableDatabase();
- int numInserted = 0;
- try {
- int length = values.length;
- database.beginTransaction();
- for (int i = 0; i != length; ++i) {
- database.insert(tableName, NULL_COLUMN_HACK, values[i]);
- }
- database.setTransactionSuccessful();
- numInserted = length;
- } finally {
- database.endTransaction();
- }
- notifyChange(uri);
- return numInserted;
- }
-
- @Override
- public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- // Resolve the URI.
- int match = mUriMatcher.match(uri);
- if (match == UriMatcher.NO_MATCH) {
- throw new IllegalArgumentException("Invalid URI: " + uri);
- }
-
- // Add the ID predicate if needed.
- Mapping mapping = mMappings.get(match);
- if (mapping.hasId) {
- selection = whereWithId(uri, selection);
- }
-
- // Update the item(s) and broadcast a change notification.
- SQLiteDatabase db = mDatabase.getWritableDatabase();
- String tableName = mapping.table.getTableName();
- int count = db.update(tableName, values, selection, selectionArgs);
- notifyChange(uri);
- return count;
- }
-
- @Override
- public int delete(Uri uri, String selection, String[] selectionArgs) {
- // Resolve the URI.
- int match = mUriMatcher.match(uri);
- if (match == UriMatcher.NO_MATCH) {
- throw new IllegalArgumentException("Invalid URI: " + uri);
- }
-
- // Add the ID predicate if needed.
- Mapping mapping = mMappings.get(match);
- if (mapping.hasId) {
- selection = whereWithId(uri, selection);
- }
-
- // Delete the item(s) and broadcast a change notification.
- SQLiteDatabase db = mDatabase.getWritableDatabase();
- String tableName = mapping.table.getTableName();
- int count = db.delete(tableName, selection, selectionArgs);
- notifyChange(uri);
- return count;
- }
-
- private final String whereWithId(Uri uri, String selection) {
- String id = uri.getPathSegments().get(1);
- StringBuilder where = new StringBuilder("_id=");
- where.append(id);
- if (!TextUtils.isEmpty(selection)) {
- where.append(" AND (");
- where.append(selection);
- where.append(')');
- }
- return where.toString();
- }
-
- private final void notifyChange(Uri uri) {
- getContext().getContentResolver().notifyChange(uri, null);
- }
-
- private static final class Mapping {
- public EntrySchema table;
- public String mimeSubtype;
- public boolean hasId;
-
- public Mapping(EntrySchema table, String mimeSubtype, boolean hasId) {
- this.table = table;
- this.mimeSubtype = mimeSubtype;
- this.hasId = hasId;
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/picasa/UserEntry.java b/new3d/src/com/android/gallery3d/picasa/UserEntry.java
deleted file mode 100644
index a0c86d1..0000000
--- a/new3d/src/com/android/gallery3d/picasa/UserEntry.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.picasa;
-
-import org.xml.sax.Attributes;
-
-@Entry.Table("users")
-public final class UserEntry extends Entry {
- public static final EntrySchema SCHEMA = new EntrySchema(UserEntry.class);
-
- @Column("account")
- public String account;
-
- @Column("albums_etag")
- public String albumsEtag;
-
- @Override
- public void setPropertyFromXml(String uri, String localName, Attributes attrs, String content) {
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/AbstractDisplayItem.java b/new3d/src/com/android/gallery3d/ui/AbstractDisplayItem.java
deleted file mode 100644
index 61eed85..0000000
--- a/new3d/src/com/android/gallery3d/ui/AbstractDisplayItem.java
+++ /dev/null
@@ -1,118 +0,0 @@
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-import android.util.Log;
-
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.FutureListener;
-
-public abstract class AbstractDisplayItem
- extends DisplayItem implements FutureListener<Bitmap> {
-
- private static final String TAG = "AbstractDisplayItem";
-
- private static final int STATE_INVALID = 0x01;
- private static final int STATE_VALID = 0x02;
- private static final int STATE_UPDATING = 0x04;
- private static final int STATE_CANCELING = 0x08;
- private static final int STATE_ERROR = 0x10;
-
- private int mState = STATE_INVALID;
- private Future<Bitmap> mFuture;
- private boolean mImageRequested = false;
- private boolean mRecycling = false;
- private Bitmap mBitmap;
-
- protected final MediaItem mMediaItem;
-
- public AbstractDisplayItem(MediaItem item) {
- mMediaItem = item;
- if (item == null) mState = STATE_ERROR;
- }
-
- public void updateImage() {
- Future<Bitmap> future = mFuture;
- mFuture = null;
-
- if (future.isCancelled()) {
- mState = STATE_INVALID;
- if (mRecycling) {
- onRecycled();
- } else if (mImageRequested) {
- Log.v(TAG, String.format("request image again %s", toString()));
- requestImage();
- }
- return;
- }
-
- Bitmap bitmap = null;
- try {
- bitmap = future.get();
- } catch (Throwable t) {
- Log.e(TAG, "cannot get bitmap", t);
- }
-
- if (mRecycling) {
- if (bitmap != null) bitmap.recycle();
- onRecycled();
- return;
- }
-
- mBitmap = bitmap;
- mState = bitmap == null ? STATE_ERROR : STATE_VALID ;
- onBitmapAvailable(mBitmap);
- }
-
- @Override
- public long getIdentity() {
- return mMediaItem != null
- ? mMediaItem.getUniqueId()
- : System.identityHashCode(this);
- }
-
- public void requestImage() {
- if (mState == STATE_INVALID) {
- mState = STATE_UPDATING;
- mFuture = mMediaItem.requestImage(MediaItem.TYPE_MICROTHUMBNAIL, this);
- }
- mImageRequested = true;
- }
-
- public void cancelImageRequest() {
- if (mState == STATE_UPDATING) {
- mState = STATE_CANCELING;
- mFuture.requestCancel();
- }
- mImageRequested = false;
- }
-
- private boolean inState(int states) {
- return (mState & states) != 0;
- }
-
- public void recycle() {
- if (!inState(STATE_UPDATING | STATE_CANCELING)) {
- if (mBitmap != null) {
- mBitmap.recycle();
- mBitmap = null;
- }
- onRecycled();
- } else {
- mRecycling = true;
- cancelImageRequest();
- }
- }
-
- public boolean isRequestInProgress() {
- return mImageRequested && inState(STATE_UPDATING | STATE_CANCELING);
- }
-
- protected void onRecycled() {
- }
-
- abstract protected void onBitmapAvailable(Bitmap bitmap);
-
- abstract public void onFutureDone(Future<? extends Bitmap> future);
-}
diff --git a/new3d/src/com/android/gallery3d/ui/AdaptiveBackground.java b/new3d/src/com/android/gallery3d/ui/AdaptiveBackground.java
deleted file mode 100644
index 42cb2cc..0000000
--- a/new3d/src/com/android/gallery3d/ui/AdaptiveBackground.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.LightingColorFilter;
-import android.graphics.Paint;
-
-import com.android.gallery3d.anim.FloatAnimation;
-
-public class AdaptiveBackground extends GLView {
-
- private static final int BACKGROUND_WIDTH = 128;
- private static final int BACKGROUND_HEIGHT = 64;
- private static final int FILTERED_COLOR = 0xffaaaaaa;
- private static final int ANIMATION_DURATION = 500;
-
- private BasicTexture mOldBackground;
- private BasicTexture mBackground;
-
- private final Paint mPaint;
- private Bitmap mPendingBitmap;
- private final FloatAnimation mAnimation =
- new FloatAnimation(0, 1, ANIMATION_DURATION);
-
- public AdaptiveBackground() {
- Paint paint = new Paint();
- paint.setFilterBitmap(true);
- paint.setColorFilter(new LightingColorFilter(FILTERED_COLOR, 0));
- mPaint = paint;
- }
-
- public Bitmap getAdaptiveBitmap(Bitmap bitmap) {
- Bitmap target = Bitmap.createBitmap(
- BACKGROUND_WIDTH, BACKGROUND_HEIGHT, Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(target);
- int width = bitmap.getWidth();
- int height = bitmap.getHeight();
- int left = 0;
- int top = 0;
- if (width * BACKGROUND_HEIGHT > height * BACKGROUND_WIDTH) {
- float scale = (float) BACKGROUND_HEIGHT / height;
- canvas.scale(scale, scale);
- left = (BACKGROUND_WIDTH - (int) (width * scale + 0.5)) / 2;
- } else {
- float scale = (float) BACKGROUND_WIDTH / width;
- canvas.scale(scale, scale);
- top = (BACKGROUND_HEIGHT - (int) (height * scale + 0.5)) / 2;
- }
- canvas.drawBitmap(bitmap, left, top, mPaint);
- BoxBlurFilter.apply(target,
- BoxBlurFilter.MODE_REPEAT, BoxBlurFilter.MODE_CLAMP);
- return target;
- }
-
- private void startTransition(Bitmap bitmap) {
- BitmapTexture texture = new BitmapTexture(bitmap);
- if (mBackground == null) {
- mBackground = texture;
- } else {
- if (mOldBackground != null) mOldBackground.recycle();
- mOldBackground = mBackground;
- mBackground = texture;
- mAnimation.start();
- }
- invalidate();
- }
-
- public void setImage(Bitmap bitmap) {
- if (mAnimation.isActive()) {
- mPendingBitmap = bitmap;
- } else {
- startTransition(bitmap);
- }
- }
-
- public void setScrollPosition(int position) {
- if (mScrollX == position) return;
- mScrollX = position;
- invalidate();
- }
-
- @Override
- protected void render(GLCanvas canvas) {
- if (mBackground == null) return;
-
- int height = getHeight();
- float scale = (float) height / BACKGROUND_HEIGHT;
- int width = (int) (BACKGROUND_WIDTH * scale + 0.5f);
- int scroll = mScrollX;
- int start = (scroll / width) * width;
-
- if (mOldBackground == null) {
- for (int i = start, n = scroll + getWidth(); i < n; i += width) {
- mBackground.draw(canvas, i - scroll, 0, width, height);
- }
- } else {
- boolean moreAnimation =
- mAnimation.calculate(canvas.currentAnimationTimeMillis());
- float ratio = mAnimation.get();
- for (int i = start, n = scroll + getWidth(); i < n; i += width) {
- canvas.drawMixed(mOldBackground,
- mBackground, ratio, i - scroll, 0, width, height);
- }
- if (moreAnimation) {
- invalidate();
- } else if (mPendingBitmap != null) {
- startTransition(mPendingBitmap);
- mPendingBitmap = null;
- }
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/new3d/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
deleted file mode 100644
index 6aa19ec..0000000
--- a/new3d/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-import android.graphics.Color;
-import android.os.Message;
-import android.util.Log;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.app.AlbumSetDataAdapter;
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.ui.AlbumSetView.AlbumSetItem;
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.Utils;
-
-public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener {
- private static final String TAG = "GallerySlidingWindow";
- private static final int MSG_UPDATE_IMAGE = 0;
-
- public static interface Listener {
- public void onSizeChanged(int size);
- public void onContentInvalidated();
- public void onWindowContentChanged(
- int slot, AlbumSetItem old, AlbumSetItem update);
- }
-
- private final AlbumSetView.Model mSource;
- private int mSize;
-
- private int mContentStart = 0;
- private int mContentEnd = 0;
-
- private int mActiveStart = 0;
- private int mActiveEnd = 0;
-
- private Listener mListener;
-
- private final AlbumSetItem mData[];
- private final SelectionManager mSelectionManager;
- private final ColorTexture mWaitLoadingTexture;
-
- private SynchronizedHandler mHandler;
-
- private int mActiveRequestCount = 0;
-
- public AlbumSetSlidingWindow(GalleryContext context,
- SelectionManager manager, AlbumSetView.Model source, int cacheSize) {
- source.setListener(this);
- mSource = source;
- mSelectionManager = manager;
- mData = new AlbumSetItem[cacheSize];
- mSize = source.size();
-
- mWaitLoadingTexture = new ColorTexture(Color.GRAY);
- mWaitLoadingTexture.setSize(1, 1);
-
- mHandler = new SynchronizedHandler(context.getGLRoot()) {
- @Override
- public void handleMessage(Message message) {
- Utils.Assert(message.what == MSG_UPDATE_IMAGE);
- ((GalleryDisplayItem) message.obj).updateImage();
- }
- };
-
- }
-
- public void setListener(Listener listener) {
- mListener = listener;
- }
-
- public AlbumSetItem get(int slotIndex) {
- if (!isActiveSlot(slotIndex)) {
- throw new IllegalArgumentException(
- String.format("invalid slot: %s outsides (%s, %s)",
- slotIndex, mActiveStart, mActiveEnd));
- }
- return mData[slotIndex % mData.length];
- }
-
- public int size() {
- return mSize;
- }
-
- public boolean isActiveSlot(int slotIndex) {
- return slotIndex >= mActiveStart && slotIndex < mActiveEnd;
- }
-
- private void setContentWindow(int contentStart, int contentEnd) {
- if (contentStart == mContentStart && contentEnd == mContentEnd) return;
-
- if (contentStart >= mContentEnd || mContentStart >= contentEnd) {
- for (int i = mContentStart, n = mContentEnd; i < n; ++i) {
- freeSlotContent(i);
- }
- mSource.setActiveWindow(contentStart, contentEnd);
- for (int i = contentStart; i < contentEnd; ++i) {
- prepareSlotContent(i);
- }
- } else {
- for (int i = mContentStart; i < contentStart; ++i) {
- freeSlotContent(i);
- }
- for (int i = contentEnd, n = mContentEnd; i < n; ++i) {
- freeSlotContent(i);
- }
- mSource.setActiveWindow(contentStart, contentEnd);
- for (int i = contentStart, n = mContentStart; i < n; ++i) {
- prepareSlotContent(i);
- }
- for (int i = mContentEnd; i < contentEnd; ++i) {
- prepareSlotContent(i);
- }
- }
-
- mContentStart = contentStart;
- mContentEnd = contentEnd;
- }
-
- public void setActiveWindow(int start, int end) {
- Utils.Assert(start <= end
- && end - start <= mData.length && end <= mSize);
- AlbumSetItem data[] = mData;
-
- mActiveStart = start;
- mActiveEnd = end;
-
- // If no data is visible, keep the cache content
- if (start == end) return;
-
- int contentStart = Utils.clamp((start + end) / 2 - data.length / 2,
- 0, Math.max(0, mSize - data.length));
- int contentEnd = Math.min(contentStart + data.length, mSize);
- setContentWindow(contentStart, contentEnd);
- updateAllImageRequests();
- }
-
- // We would like to request non active slots in the following order:
- // Order: 8 6 4 2 1 3 5 7
- // |---------|---------------|---------|
- // |<- active ->|
- // |<-------- cached range ----------->|
- private void requestNonactiveImages() {
- int range = Math.max(
- mContentEnd - mActiveEnd, mActiveStart - mContentStart);
- for (int i = 0 ;i < range; ++i) {
- requestImagesInSlot(mActiveEnd + i);
- requestImagesInSlot(mActiveStart - 1 - i);
- }
- }
-
- private void cancelNonactiveImages() {
- int range = Math.max(
- mContentEnd - mActiveEnd, mActiveStart - mContentStart);
- for (int i = 0 ;i < range; ++i) {
- cancelImagesInSlot(mActiveEnd + i);
- cancelImagesInSlot(mActiveStart - 1 - i);
- }
- }
-
- private void requestImagesInSlot(int slotIndex) {
- if (slotIndex < mContentStart || slotIndex >= mContentEnd) return;
- AlbumSetItem items = mData[slotIndex % mData.length];
- for (DisplayItem item : items.covers) {
- ((GalleryDisplayItem) item).requestImage();
- }
- }
-
- private void cancelImagesInSlot(int slotIndex) {
- if (slotIndex < mContentStart || slotIndex >= mContentEnd) return;
- AlbumSetItem items = mData[slotIndex % mData.length];
- for (DisplayItem item : items.covers) {
- ((GalleryDisplayItem) item).cancelImageRequest();
- }
- }
-
- private void freeSlotContent(int slotIndex) {
- AlbumSetItem data[] = mData;
- int index = slotIndex % data.length;
- AlbumSetItem original = data[index];
- if (original != null) {
- data[index] = null;
- for (DisplayItem item : original.covers) {
- ((GalleryDisplayItem) item).recycle();
- }
- }
- }
-
- private void prepareSlotContent(final int slotIndex) {
- AlbumSetItem item = new AlbumSetItem();
- MediaItem[] coverItems = mSource.getMediaItems(slotIndex);
- item.covers = new GalleryDisplayItem[coverItems.length];
- for (int i = 0; i < coverItems.length; ++i) {
- item.covers[i] = new GalleryDisplayItem(slotIndex, i, coverItems[i]);
- }
- mData[slotIndex % mData.length] = item;
- }
-
- private void updateSlotContent(final int slotIndex) {
- AlbumSetItem data[] = mData;
-
- int index = slotIndex % data.length;
- AlbumSetItem original = data[index];
- AlbumSetItem update = new AlbumSetItem();
- data[index] = update;
-
- MediaItem[] coverItems = mSource.getMediaItems(slotIndex);
- update.covers = new GalleryDisplayItem[coverItems.length];
- for (int i = 0; i < coverItems.length; ++i) {
- GalleryDisplayItem cover =
- new GalleryDisplayItem(slotIndex, i, coverItems[i]);
- update.covers[i] = cover;
- }
- if (mListener != null && isActiveSlot(slotIndex)) {
- mListener.onWindowContentChanged(slotIndex, original, update);
- }
- if (original != null) {
- for (DisplayItem item : original.covers) {
- ((GalleryDisplayItem) item).recycle();
- }
- }
- }
-
- private void notifySlotChanged(int slotIndex) {
- // If the updated content is not cached, ignore it
- if (slotIndex < mContentStart || slotIndex >= mContentEnd) {
- Log.w(TAG, String.format(
- "invalid update: %s is outside (%s, %s)",
- slotIndex, mContentStart, mContentEnd) );
- return;
- }
- updateSlotContent(slotIndex);
- boolean isActive = isActiveSlot(slotIndex);
- if (mActiveRequestCount == 0 || isActive) {
- for (DisplayItem item : mData[slotIndex % mData.length].covers) {
- GalleryDisplayItem galleryItem = (GalleryDisplayItem) item;
- galleryItem.requestImage();
- if (isActive && galleryItem.isRequestInProgress()) {
- ++mActiveRequestCount;
- }
- }
- }
- }
-
- private void updateAllImageRequests() {
- mActiveRequestCount = 0;
- for (int i = mActiveStart, n = mActiveEnd; i < n; ++i) {
- for (DisplayItem item : mData[i % mData.length].covers) {
- GalleryDisplayItem coverItem = (GalleryDisplayItem) item;
- coverItem.requestImage();
- if (coverItem.isRequestInProgress()) ++mActiveRequestCount;
- }
- }
- if (mActiveRequestCount == 0) {
- requestNonactiveImages();
- } else {
- cancelNonactiveImages();
- }
- }
-
- private class GalleryDisplayItem extends AbstractDisplayItem {
-
- private final int mSlotIndex;
- private final int mCoverIndex;
- private Texture mContent;
-
- public GalleryDisplayItem(int slotIndex, int coverIndex, MediaItem item) {
- super(item);
- mSlotIndex = slotIndex;
- mCoverIndex = coverIndex;
- updateContent(mWaitLoadingTexture);
- }
-
- @Override
- protected void onBitmapAvailable(Bitmap bitmap) {
- if (isActiveSlot(mSlotIndex)) {
- --mActiveRequestCount;
- if (mActiveRequestCount == 0) requestNonactiveImages();
- }
- if (bitmap != null) {
- BitmapTexture texture = new BitmapTexture(bitmap);
- texture.setThrottled(true);
- updateContent(texture);
- if (mListener != null) mListener.onContentInvalidated();
- }
- }
-
- private void updateContent(Texture content) {
- mContent = content;
-
- int width = mContent.getWidth();
- int height = mContent.getHeight();
-
- float scalex = AlbumSetView.SLOT_WIDTH / (float) width;
- float scaley = AlbumSetView.SLOT_HEIGHT / (float) height;
- float scale = Math.min(scalex, scaley);
-
- width = (int) Math.floor(width * scale);
- height = (int) Math.floor(height * scale);
-
- setSize(width, height);
- }
-
- @Override
- public void render(GLCanvas canvas) {
- SelectionManager manager = mSelectionManager;
- boolean topItem = mCoverIndex == 0;
- boolean checked = false;
- if (topItem) {
- // TODO: add support for batch mode to improve performance
- long id = mSource.getMediaSet(mSlotIndex).getUniqueId();
- checked = manager.isItemSelected(id);
- }
-
- manager.getSelectionDrawer().draw(
- canvas, mContent, mWidth, mHeight, checked, topItem);
- }
-
- @Override
- public long getIdentity() {
- // TODO: should use item's id
- return System.identityHashCode(this);
- }
-
- @Override
- public void onFutureDone(Future<? extends Bitmap> future) {
- mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_IMAGE, this));
- }
-
- @Override
- public String toString() {
- return String.format("GalleryDisplayItem(%s, %s)", mSlotIndex, mCoverIndex);
- }
- }
-
- public void onSizeChanged(int size) {
- if (mSize != size) {
- mSize = size;
- if (mListener != null) mListener.onSizeChanged(mSize);
- }
- }
-
- public void onWindowContentChanged(int index, MediaItem[] old, MediaItem[] update) {
- notifySlotChanged(index);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/AlbumSetView.java b/new3d/src/com/android/gallery3d/ui/AlbumSetView.java
deleted file mode 100644
index 4a7fc9b..0000000
--- a/new3d/src/com/android/gallery3d/ui/AlbumSetView.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Rect;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.data.MediaSet;
-import com.android.gallery3d.ui.PositionRepository.Position;
-import com.android.gallery3d.util.Utils;
-
-import java.util.Random;
-
-public class AlbumSetView extends SlotView {
- private static final String TAG = "AlbumSetView";
- private static final int CACHE_SIZE = 32;
-
- static final int SLOT_WIDTH = 144;
- static final int SLOT_HEIGHT = 144;
- private static final int HORIZONTAL_GAP = 42;
- private static final int VERTICAL_GAP = 42;
-
- private int mVisibleStart;
- private int mVisibleEnd;
-
- private Random mRandom = new Random();
- private long mSeed = mRandom.nextLong();
-
- private AlbumSetSlidingWindow mDataWindow;
- private final GalleryContext mContext;
- private final SelectionManager mSelectionManager;
-
- public static interface Model {
- public MediaItem[] getMediaItems(int index);
- public MediaSet getMediaSet(int index);
- public int size();
- public void setActiveWindow(int start, int end);
- public void setListener(ModelListener listener);
- }
-
- public static interface ModelListener {
- public void onWindowContentChanged(
- int index, MediaItem old[], MediaItem update[]);
- public void onSizeChanged(int size);
- }
-
- public static class AlbumSetItem {
- public DisplayItem[] covers;
- }
-
- public AlbumSetView(GalleryContext context, SelectionManager selectionManager) {
- super(context.getAndroidContext(), context.getPositionRepository());
- mContext = context;
- mSelectionManager = selectionManager;
- setSlotSize(SLOT_WIDTH, SLOT_HEIGHT);
- setSlotGaps(HORIZONTAL_GAP, VERTICAL_GAP, false);
- }
-
- public void setModel(AlbumSetView.Model model) {
-
- if (mDataWindow != null) {
- mDataWindow.setListener(null);
- setSlotCount(0);
- mDataWindow = null;
- }
- if (model != null) {
- mDataWindow = new AlbumSetSlidingWindow(
- mContext, mSelectionManager, model, CACHE_SIZE);
- mDataWindow.setListener(new MyCacheListener());
- setSlotCount(mDataWindow.size());
- updateVisibleRange(getVisibleStart(), getVisibleEnd());
- }
- }
-
- private void putSlotContent(int slotIndex, AlbumSetItem entry) {
- // Get displayItems from mItemsetMap or create them from MediaSet.
- Utils.Assert(entry != null);
- Rect rect = getSlotRect(slotIndex);
-
- DisplayItem[] items = entry.covers;
- mRandom.setSeed(slotIndex ^ mSeed);
-
- int x = (rect.left + rect.right) / 2;
- int y = (rect.top + rect.bottom) / 2;
-
- // Put the cover items in reverse order, so that the first item is on
- // top of the rest.
- for (int i = items.length -1; i > 0; --i) {
- DisplayItem item = items[i];
- int dx = 0;
- int dy = 0;
- int theta = 0;
- if (i != 0) {
- int seed = i;
- int sign = (seed % 2 == 0) ? 1 : -1;
- theta = (int) (30.0f * (0.5f - (float) Math.random()));
- dx = (int) (sign * 12.0f * seed + (0.5f - mRandom.nextFloat()) * 4 * seed);
- dy = (int) (sign * 4 + ((sign == 1) ? -8.0f : sign * (mRandom.nextFloat()) * 16.0f));
- }
- Position position = new Position();
- position.set(rect.left + item.getWidth() / 2 + dx, y + dy, 0, theta, 1f);
- putDisplayItem(position, item);
- }
- if (items.length > 0) {
- Position position = new Position();
- position.set(x, y, 0, 0, 1f);
- putDisplayItem(position, items[0]);
- }
- }
-
- private void freeSlotContent(int index, AlbumSetItem entry) {
- if (entry == null) return;
- for (DisplayItem item : entry.covers) {
- removeDisplayItem(item);
- }
- }
-
- public int size() {
- return mDataWindow.size();
- }
-
- @Override
- public void onLayoutChanged(int width, int height) {
- updateVisibleRange(0, 0);
- updateVisibleRange(getVisibleStart(), getVisibleEnd());
- }
-
- @Override
- public void onScrollPositionChanged(int position) {
- updateVisibleRange(getVisibleStart(), getVisibleEnd());
- }
-
- private void updateVisibleRange(int start, int end) {
- if (start == mVisibleStart && end == mVisibleEnd) return;
- if (start >= mVisibleEnd || mVisibleStart >= end) {
- for (int i = mVisibleStart, n = mVisibleEnd; i < n; ++i) {
- freeSlotContent(i, mDataWindow.get(i));
- }
- mDataWindow.setActiveWindow(start, end);
- for (int i = start; i < end; ++i) {
- putSlotContent(i, mDataWindow.get(i));
- }
- } else {
- for (int i = mVisibleStart; i < start; ++i) {
- freeSlotContent(i, mDataWindow.get(i));
- }
- for (int i = end, n = mVisibleEnd; i < n; ++i) {
- freeSlotContent(i, mDataWindow.get(i));
- }
- mDataWindow.setActiveWindow(start, end);
- for (int i = start, n = mVisibleStart; i < n; ++i) {
- putSlotContent(i, mDataWindow.get(i));
- }
- for (int i = mVisibleEnd; i < end; ++i) {
- putSlotContent(i, mDataWindow.get(i));
- }
- }
- mVisibleStart = start;
- mVisibleEnd = end;
-
- invalidate();
- }
-
- private class MyCacheListener implements AlbumSetSlidingWindow.Listener {
-
- public void onSizeChanged(int size) {
- setSlotCount(size);
- updateVisibleRange(getVisibleStart(), getVisibleEnd());
- }
-
- public void onWindowContentChanged(int slot, AlbumSetItem old, AlbumSetItem update) {
- freeSlotContent(slot, old);
- putSlotContent(slot, update);
- invalidate();
- }
-
- public void onContentInvalidated() {
- invalidate();
- }
- }
-}
\ No newline at end of file
diff --git a/new3d/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/new3d/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
deleted file mode 100644
index a95bd3a..0000000
--- a/new3d/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
+++ /dev/null
@@ -1,324 +0,0 @@
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-import android.graphics.Color;
-import android.os.Message;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.Utils;
-
-public class AlbumSlidingWindow implements AlbumView.ModelListener {
- private static final String TAG = "AlbumSlidingWindow";
-
- private static final int MSG_UPDATE_IMAGE = 0;
- private static final int MSG_UPDATE_SLOT = 1;
-
- public static interface Listener {
- public void onSizeChanged(int size);
- public void onContentInvalidated();
- public void onWindowContentChanged(
- int slot, DisplayItem old, DisplayItem update);
- }
-
- private final AlbumView.Model mSource;
- private int mSize;
-
- private int mContentStart = 0;
- private int mContentEnd = 0;
-
- private int mActiveStart = 0;
- private int mActiveEnd = 0;
-
- private Listener mListener;
-
- private final AlbumDisplayItem mData[];
- private final SelectionManager mSelectionManager;
- private final ColorTexture mWaitLoadingTexture;
-
- private SynchronizedHandler mHandler;
-
- private int mActiveRequestCount = 0;
-
- public AlbumSlidingWindow(GalleryContext context,
- SelectionManager manager, AlbumView.Model source, int cacheSize) {
- source.setListener(this);
- mSource = source;
- mSelectionManager = manager;
- mData = new AlbumDisplayItem[cacheSize];
- mSize = source.size();
-
- mWaitLoadingTexture = new ColorTexture(Color.GRAY);
- mWaitLoadingTexture.setSize(1, 1);
-
- mHandler = new SynchronizedHandler(context.getGLRoot()) {
- @Override
- public void handleMessage(Message message) {
- switch (message.what) {
- case MSG_UPDATE_IMAGE: {
- ((AlbumDisplayItem) message.obj).updateImage();
- break;
- }
- case MSG_UPDATE_SLOT: {
- updateSlotContent(message.arg1);
- break;
- }
-
- }
- }
- };
- }
-
- public void setListener(Listener listener) {
- mListener = listener;
- }
-
- public DisplayItem get(int slotIndex) {
- if (!isActiveSlot(slotIndex)) {
- throw new IllegalArgumentException(
- String.format("invalid slot: %s outsides (%s, %s)",
- slotIndex, mActiveStart, mActiveEnd));
- }
- Utils.Assert(isActiveSlot(slotIndex));
- return mData[slotIndex % mData.length];
- }
-
- public int size() {
- return mSize;
- }
-
- public boolean isActiveSlot(int slotIndex) {
- return slotIndex >= mActiveStart && slotIndex < mActiveEnd;
- }
-
- private void setContentWindow(int contentStart, int contentEnd) {
- if (contentStart == mContentStart && contentEnd == mContentEnd) return;
-
- if (contentStart >= mContentEnd || mContentStart >= contentEnd) {
- for (int i = mContentStart, n = mContentEnd; i < n; ++i) {
- freeSlotContent(i);
- }
- mSource.setActiveWindow(contentStart, contentEnd);
- for (int i = contentStart; i < contentEnd; ++i) {
- prepareSlotContent(i);
- }
- } else {
- for (int i = mContentStart; i < contentStart; ++i) {
- freeSlotContent(i);
- }
- for (int i = contentEnd, n = mContentEnd; i < n; ++i) {
- freeSlotContent(i);
- }
- mSource.setActiveWindow(contentStart, contentEnd);
- for (int i = contentStart, n = mContentStart; i < n; ++i) {
- prepareSlotContent(i);
- }
- for (int i = mContentEnd; i < contentEnd; ++i) {
- prepareSlotContent(i);
- }
- }
-
- mContentStart = contentStart;
- mContentEnd = contentEnd;
- }
-
- public void setActiveWindow(int start, int end) {
-
- Utils.Assert(start <= end
- && end - start <= mData.length && end <= mSize,
- String.format("%s, %s, %s", start, end, mData.length));
- DisplayItem data[] = mData;
-
- mActiveStart = start;
- mActiveEnd = end;
-
- // If no data is visible, keep the cache content
- if (start == end) return;
-
- int contentStart = Utils.clamp((start + end) / 2 - data.length / 2,
- 0, Math.max(0, mSize - data.length));
- int contentEnd = Math.min(contentStart + data.length, mSize);
- setContentWindow(contentStart, contentEnd);
- updateAllImageRequests();
- }
-
- // We would like to request non active slots in the following order:
- // Order: 8 6 4 2 1 3 5 7
- // |---------|---------------|---------|
- // |<- active ->|
- // |<-------- cached range ----------->|
- private void requestNonactiveImages() {
- int range = Math.max(
- (mContentEnd - mActiveEnd), (mActiveStart - mContentStart));
- for (int i = 0 ;i < range; ++i) {
- requestSlotImage(mActiveEnd + i, false);
- requestSlotImage(mActiveStart - 1 - i, false);
- }
- }
-
- private void requestSlotImage(int slotIndex, boolean isActive) {
- if (slotIndex < mContentStart || slotIndex >= mContentEnd) return;
- AlbumDisplayItem item = mData[slotIndex % mData.length];
- item.requestImage();
- }
-
- private void cancelNonactiveImages() {
- int range = Math.max(
- (mContentEnd - mActiveEnd), (mActiveStart - mContentStart));
- for (int i = 0 ;i < range; ++i) {
- cancelSlotImage(mActiveEnd + i, false);
- cancelSlotImage(mActiveStart - 1 - i, false);
- }
- }
-
- private void cancelSlotImage(int slotIndex, boolean isActive) {
- if (slotIndex < mContentStart || slotIndex >= mContentEnd) return;
- AlbumDisplayItem item = mData[slotIndex % mData.length];
- item.cancelImageRequest();
- }
-
- private void freeSlotContent(int slotIndex) {
- AlbumDisplayItem data[] = mData;
- int index = slotIndex % data.length;
- AlbumDisplayItem original = data[index];
- if (original != null) {
- original.recycle();
- data[index] = null;
- }
- }
-
- private void prepareSlotContent(final int slotIndex) {
- mData[slotIndex % mData.length] = new AlbumDisplayItem(
- slotIndex, mSource.get(slotIndex));
- }
-
- private void updateSlotContent(final int slotIndex) {
- MediaItem item = mSource.get(slotIndex);
- AlbumDisplayItem data[] = mData;
- int index = slotIndex % data.length;
- AlbumDisplayItem original = data[index];
- AlbumDisplayItem update = new AlbumDisplayItem(slotIndex, item);
- data[index] = update;
- boolean isActive = isActiveSlot(slotIndex);
- if (mListener != null && isActive) {
- mListener.onWindowContentChanged(slotIndex, original, update);
- }
- if (original != null) {
- if (isActive && original.isRequestInProgress()) {
- --mActiveRequestCount;
- }
- original.recycle();
- }
- if (isActive) {
- if (mActiveRequestCount == 0) cancelNonactiveImages();
- ++mActiveRequestCount;
- update.requestImage();
- } else {
- if (mActiveRequestCount == 0) update.requestImage();
- }
- }
-
- private void updateAllImageRequests() {
- mActiveRequestCount = 0;
- AlbumDisplayItem data[] = mData;
- for (int i = mActiveStart, n = mActiveEnd; i < n; ++i) {
- AlbumDisplayItem item = data[i % data.length];
- item.requestImage();
- if (item.isRequestInProgress()) ++mActiveRequestCount;
- }
- if (mActiveRequestCount == 0) {
- requestNonactiveImages();
- } else {
- cancelNonactiveImages();
- }
- }
-
- private class AlbumDisplayItem extends AbstractDisplayItem {
-
- private final int mSlotIndex;
- private Texture mContent;
-
- public AlbumDisplayItem(int slotIndex, MediaItem item) {
- super(item);
- mSlotIndex = slotIndex;
- updateContent(mWaitLoadingTexture);
- }
-
- @Override
- public void onBitmapAvailable(Bitmap bitmap) {
- boolean isActiveSlot = isActiveSlot(mSlotIndex);
- if (isActiveSlot) {
- --mActiveRequestCount;
- if (mActiveRequestCount == 0) requestNonactiveImages();
- }
- if (bitmap != null) {
- BitmapTexture texture = new BitmapTexture(bitmap);
- texture.setThrottled(true);
- updateContent(texture);
- if (mListener != null && isActiveSlot) {
- mListener.onContentInvalidated();
- }
- }
- }
-
- private void updateContent(Texture content) {
- mContent = content;
-
- int width = mContent.getWidth();
- int height = mContent.getHeight();
-
- float scalex = AlbumView.SLOT_WIDTH / (float) width;
- float scaley = AlbumView.SLOT_HEIGHT / (float) height;
- float scale = Math.min(scalex, scaley);
-
- width = (int) Math.floor(width * scale);
- height = (int) Math.floor(height * scale);
-
- setSize(width, height);
- }
-
- @Override
- public void render(GLCanvas canvas) {
- SelectionManager manager = mSelectionManager;
- boolean checked = false;
- if (mMediaItem != null) {
- long id = mMediaItem.getUniqueId();
- checked = manager.isItemSelected(id);
- }
-
- manager.getSelectionDrawer().draw(
- canvas, mContent, mWidth, mHeight, checked);
- }
-
- @Override
- public long getIdentity() {
- // TODO: should use item's id
- return System.identityHashCode(this);
- }
-
- @Override
- public void onFutureDone(Future<? extends Bitmap> future) {
- mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_IMAGE, this));
- }
-
- @Override
- public String toString() {
- return String.format("AlbumDisplayItem[%s]", mSlotIndex);
- }
- }
-
- public void onSizeChanged(int size) {
- if (mSize != size) {
- mSize = size;
- if (mListener != null) mListener.onSizeChanged(mSize);
- }
- }
-
- public void onWindowContentChanged(int index, MediaItem old, MediaItem update) {
- if (index >= mContentStart && index < mContentEnd) {
- updateSlotContent(index);
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/AlbumView.java b/new3d/src/com/android/gallery3d/ui/AlbumView.java
deleted file mode 100644
index bafb1ae..0000000
--- a/new3d/src/com/android/gallery3d/ui/AlbumView.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Rect;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.ui.PositionRepository.Position;
-
-public class AlbumView extends SlotView {
- private static final String TAG = "AlbumView";
- private static final int CACHE_SIZE = 64;
-
- static final int SLOT_WIDTH = 144;
- static final int SLOT_HEIGHT = 144;
- private static final int HORIZONTAL_GAP = 0;
- private static final int VERTICAL_GAP = 0;
-
- private int mVisibleStart = 0;
- private int mVisibleEnd = 0;
-
- private AlbumSlidingWindow mDataWindow;
- private final GalleryContext mContext;
- private final SelectionManager mSelectionManager;
-
- public static interface Model {
- public int size();
- public MediaItem get(int index);
- public void setActiveWindow(int start, int end);
- public void setListener(ModelListener listener);
- }
-
- public static interface ModelListener {
- public void onWindowContentChanged(
- int index, MediaItem old, MediaItem update);
- public void onSizeChanged(int size);
- }
-
- public AlbumView(GalleryContext context, SelectionManager selectionManager) {
- super(context.getAndroidContext(), context.getPositionRepository());
- setSlotSize(SLOT_WIDTH, SLOT_HEIGHT);
- setSlotGaps(HORIZONTAL_GAP, VERTICAL_GAP, true);
- mContext = context;
- mSelectionManager = selectionManager;
- }
-
- public void setModel(Model model) {
- if (mDataWindow != null) {
- mDataWindow.setListener(null);
- setSlotCount(0);
- mDataWindow = null;
- }
- if (model != null) {
- mDataWindow = new AlbumSlidingWindow(
- mContext, mSelectionManager, model, CACHE_SIZE);
- mDataWindow.setListener(new MyDataModelListener());
- setSlotCount(model.size());
- updateVisibleRange(getVisibleStart(), getVisibleEnd());
- }
- }
-
- private void putSlotContent(int slotIndex, DisplayItem item) {
- Rect rect = getSlotRect(slotIndex);
- Position position = new Position(
- (rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 0);
- putDisplayItem(position, item);
- }
-
- private void updateVisibleRange(int start, int end) {
- if (start == mVisibleStart && end == mVisibleEnd) return;
-
- if (start >= mVisibleEnd || mVisibleStart >= end) {
- for (int i = mVisibleStart, n = mVisibleEnd; i < n; ++i) {
- removeDisplayItem(mDataWindow.get(i));
- }
- mDataWindow.setActiveWindow(start, end);
- for (int i = start; i < end; ++i) {
- putSlotContent(i, mDataWindow.get(i));
- }
- } else {
- for (int i = mVisibleStart; i < start; ++i) {
- removeDisplayItem(mDataWindow.get(i));
- }
- for (int i = end, n = mVisibleEnd; i < n; ++i) {
- removeDisplayItem(mDataWindow.get(i));
- }
- mDataWindow.setActiveWindow(start, end);
- for (int i = start, n = mVisibleStart; i < n; ++i) {
- putSlotContent(i, mDataWindow.get(i));
- }
- for (int i = mVisibleEnd; i < end; ++i) {
- putSlotContent(i, mDataWindow.get(i));
- }
- }
-
- mVisibleStart = start;
- mVisibleEnd = end;
- }
-
- @Override
- protected void onLayoutChanged(int width, int height) {
- // Reput all the items
- updateVisibleRange(0, 0);
- updateVisibleRange(getVisibleStart(), getVisibleEnd());
- }
-
- @Override
- protected void onScrollPositionChanged(int position) {
- updateVisibleRange(getVisibleStart(), getVisibleEnd());
- }
-
- private class MyDataModelListener implements AlbumSlidingWindow.Listener {
-
- public void onContentInvalidated() {
- invalidate();
- }
-
- public void onSizeChanged(int size) {
- setSlotCount(size);
- updateVisibleRange(getVisibleStart(), getVisibleEnd());
- }
-
- public void onWindowContentChanged(
- int slotIndex, DisplayItem old, DisplayItem update) {
- removeDisplayItem(old);
- putSlotContent(slotIndex, update);
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/BasicTexture.java b/new3d/src/com/android/gallery3d/ui/BasicTexture.java
deleted file mode 100644
index 35b633a..0000000
--- a/new3d/src/com/android/gallery3d/ui/BasicTexture.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import com.android.gallery3d.util.Utils;
-
-import java.lang.ref.WeakReference;
-import java.util.WeakHashMap;
-
-// BasicTexture is a Texture corresponds to a real GL texture.
-// The state of a BasicTexture indicates whether its data is loaded to GL memory.
-// If a BasicTexture is loaded into GL memory, it has a GL texture id.
-abstract class BasicTexture implements Texture {
-
- private static final String TAG = "BasicTexture";
- protected static final int UNSPECIFIED = -1;
-
- protected static final int STATE_UNLOADED = 0;
- protected static final int STATE_LOADED = 1;
- protected static final int STATE_ERROR = -1;
-
- protected int mId;
- protected int mState;
-
- protected int mWidth = UNSPECIFIED;
- protected int mHeight = UNSPECIFIED;
-
- private int mTextureWidth;
- private int mTextureHeight;
-
- protected WeakReference<GLCanvas> mCanvasRef = null;
- private static WeakHashMap<BasicTexture, Object> sAllTextures
- = new WeakHashMap<BasicTexture, Object>();
- private static ThreadLocal sInFinalizer = new ThreadLocal();
-
- protected BasicTexture(GLCanvas canvas, int id, int state) {
- setAssociatedCanvas(canvas);
- mId = id;
- mState = state;
- synchronized (sAllTextures) {
- sAllTextures.put(this, null);
- }
- }
-
- protected BasicTexture() {
- this(null, 0, STATE_UNLOADED);
- }
-
- protected void setAssociatedCanvas(GLCanvas canvas) {
- mCanvasRef = canvas == null
- ? null
- : new WeakReference<GLCanvas>(canvas);
- }
-
- /**
- * Sets the content size of this texture. In OpenGL, the actual texture
- * size must be of power of 2, the size of the content may be smaller.
- */
- protected void setSize(int width, int height) {
- mWidth = width;
- mHeight = height;
- mTextureWidth = Utils.nextPowerOf2(width);
- mTextureHeight = Utils.nextPowerOf2(height);
- }
-
- public int getId() {
- return mId;
- }
-
- public int getWidth() {
- return mWidth;
- }
-
- public int getHeight() {
- return mHeight;
- }
-
- // Returns the width rounded to the next power of 2.
- public int getTextureWidth() {
- return mTextureWidth;
- }
-
- // Returns the height rounded to the next power of 2.
- public int getTextureHeight() {
- return mTextureHeight;
- }
-
- public void draw(GLCanvas canvas, int x, int y) {
- canvas.drawTexture(this, x, y, getWidth(), getHeight());
- }
-
- public void draw(GLCanvas canvas, int x, int y, int w, int h) {
- canvas.drawTexture(this, x, y, w, h);
- }
-
- // onBind is called before GLCanvas binds this texture.
- // It should make sure the data is uploaded to GL memory.
- abstract protected boolean onBind(GLCanvas canvas);
-
- public boolean isLoaded(GLCanvas canvas) {
- return mState == STATE_LOADED && mCanvasRef.get() == canvas;
- }
-
- // recycle() is called when the texture will never be used again,
- // so it can free all resources.
- public void recycle() {
- freeResource();
- }
-
- // yield() is called when the texture will not be used temporarily,
- // so it can free some resources.
- // The default implementation unloads the texture from GL memory, so
- // the subclass should make sure it can reload the texture to GL memory
- // later, or it will have to override this method.
- public void yield() {
- freeResource();
- }
-
- private void freeResource() {
- GLCanvas canvas = mCanvasRef == null ? null : mCanvasRef.get();
- if (canvas != null && isLoaded(canvas)) {
- canvas.unloadTexture(this);
- }
- mState = BasicTexture.STATE_UNLOADED;
- setAssociatedCanvas(null);
- }
-
- @Override
- protected void finalize() {
- sInFinalizer.set(BasicTexture.class);
- recycle();
- sInFinalizer.set(null);
- }
-
- // This is for deciding if we can call Bitmap's recycle().
- // We cannot call Bitmap's recycle() in finalizer because at that point
- // the finalizer of Bitmap may already be called so recycle() will crash.
- public static boolean inFinalizer() {
- return sInFinalizer.get() != null;
- }
-
- public static void yieldAllTextures() {
- synchronized (sAllTextures) {
- for (BasicTexture t : sAllTextures.keySet()) {
- t.yield();
- }
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/BitmapTexture.java b/new3d/src/com/android/gallery3d/ui/BitmapTexture.java
deleted file mode 100644
index 16df82d..0000000
--- a/new3d/src/com/android/gallery3d/ui/BitmapTexture.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-
-import com.android.gallery3d.util.Utils;
-
-// BitmapTexture is a texture whose content is specified by a fixed Bitmap.
-//
-// The texture does not own the Bitmap. The user should make sure the Bitmap
-// is valid during the texture's lifetime. When the texture is recycled, it
-// does not free the Bitmap.
-public class BitmapTexture extends UploadedTexture {
- protected Bitmap mContentBitmap;
-
- public BitmapTexture(Bitmap bitmap) {
- Utils.Assert(bitmap != null && !bitmap.isRecycled());
- mContentBitmap = bitmap;
- }
-
- @Override
- protected void onFreeBitmap(Bitmap bitmap) {
- // Do nothing.
- }
-
- @Override
- protected Bitmap onGetBitmap() {
- return mContentBitmap;
- }
-
- public Bitmap getBitmap() {
- return mContentBitmap;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/BoxBlurFilter.java b/new3d/src/com/android/gallery3d/ui/BoxBlurFilter.java
deleted file mode 100644
index 0497a61..0000000
--- a/new3d/src/com/android/gallery3d/ui/BoxBlurFilter.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-
-
-public class BoxBlurFilter {
- private static final int RED_MASK = 0xff0000;
- private static final int RED_MASK_SHIFT = 16;
- private static final int GREEN_MASK = 0x00ff00;
- private static final int GREEN_MASK_SHIFT = 8;
- private static final int BLUE_MASK = 0x0000ff;
- private static final int RADIUS = 4;
- private static final int KERNEL_SIZE = RADIUS * 2 + 1;
- private static final int NUM_COLORS = 256;
- private static final int[] KERNEL_NORM = new int[KERNEL_SIZE * NUM_COLORS];
-
- public static final int MODE_REPEAT = 1;
- public static final int MODE_CLAMP = 2;
-
- static {
- int index = 0;
- // Build a lookup table from summed to normalized kernel values.
- // The formula: KERNAL_NORM[value] = value / KERNEL_SIZE
- for (int i = 0; i < NUM_COLORS; ++i) {
- for (int j = 0; j < KERNEL_SIZE; ++j) {
- KERNEL_NORM[index++] = i;
- }
- }
- }
-
- private BoxBlurFilter() {
- }
-
- private static int sample(int x, int width, int mode) {
- if (x >= 0 && x < width) return x;
- return mode == MODE_REPEAT
- ? x < 0 ? x + width : x - width
- : x < 0 ? 0 : width - 1;
- }
-
- public static void apply(
- Bitmap bitmap, int horizontalMode, int verticalMode) {
-
- int width = bitmap.getWidth();
- int height = bitmap.getHeight();
- int data[] = new int[width * height];
- bitmap.getPixels(data, 0, width, 0, 0, width, height);
- int temp[] = new int[width * height];
- applyOneDimension(data, temp, width, height, horizontalMode);
- applyOneDimension(temp, data, height, width, verticalMode);
- bitmap.setPixels(data, 0, width, 0, 0, width, height);
- }
-
- private static void applyOneDimension(
- int[] in, int[] out, int width, int height, int mode) {
- for (int y = 0, read = 0; y < height; ++y, read += width) {
- // Evaluate the kernel for the first pixel in the row.
- int red = 0;
- int green = 0;
- int blue = 0;
- for (int i = -RADIUS; i <= RADIUS; ++i) {
- int argb = in[read + sample(i, width, mode)];
- red += (argb & RED_MASK) >> RED_MASK_SHIFT;
- green += (argb & GREEN_MASK) >> GREEN_MASK_SHIFT;
- blue += argb & BLUE_MASK;
- }
- for (int x = 0, write = y; x < width; ++x, write += height) {
- // Output the current pixel.
- out[write] = 0xFF000000
- | (KERNEL_NORM[red] << RED_MASK_SHIFT)
- | (KERNEL_NORM[green] << GREEN_MASK_SHIFT)
- | KERNEL_NORM[blue];
-
- // Slide to the next pixel, adding the new rightmost pixel and
- // subtracting the former leftmost.
- int prev = in[read + sample(x - RADIUS, width, mode)];
- int next = in[read + sample(x + RADIUS + 1, width, mode)];
- red += ((next & RED_MASK) - (prev & RED_MASK)) >> RED_MASK_SHIFT;
- green += ((next & GREEN_MASK) - (prev & GREEN_MASK)) >> GREEN_MASK_SHIFT;
- blue += (next & BLUE_MASK) - (prev & BLUE_MASK);
- }
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/CanvasTexture.java b/new3d/src/com/android/gallery3d/ui/CanvasTexture.java
deleted file mode 100644
index 679a4bc..0000000
--- a/new3d/src/com/android/gallery3d/ui/CanvasTexture.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Bitmap.Config;
-
-// CanvasTexture is a texture whose content is the drawing on a Canvas.
-// The subclasses should override onDraw() to draw on the bitmap.
-// By default CanvasTexture is not opaque.
-abstract class CanvasTexture extends UploadedTexture {
- protected Canvas mCanvas;
- private final Config mConfig;
-
- public CanvasTexture(int width, int height) {
- mConfig = Config.ARGB_8888;
- setSize(width, height);
- setOpaque(false);
- }
-
- @Override
- protected Bitmap onGetBitmap() {
- Bitmap bitmap = Bitmap.createBitmap(mWidth, mHeight, mConfig);
- mCanvas = new Canvas(bitmap);
- onDraw(mCanvas, bitmap);
- return bitmap;
- }
-
- @Override
- protected void onFreeBitmap(Bitmap bitmap) {
- if (!inFinalizer()) {
- bitmap.recycle();
- }
- }
-
- abstract protected void onDraw(Canvas canvas, Bitmap backing);
-}
diff --git a/new3d/src/com/android/gallery3d/ui/ColorTexture.java b/new3d/src/com/android/gallery3d/ui/ColorTexture.java
deleted file mode 100644
index 94aaa2a..0000000
--- a/new3d/src/com/android/gallery3d/ui/ColorTexture.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import com.android.gallery3d.util.Utils;
-
-// ColorTexture is a texture which fills the rectangle with the specified color.
-public class ColorTexture implements Texture {
-
- private final int mColor;
- private int mWidth;
- private int mHeight;
-
- public ColorTexture(int color) {
- mColor = color;
- mWidth = 1;
- mHeight = 1;
- }
-
- public void draw(GLCanvas canvas, int x, int y) {
- draw(canvas, x, y, mWidth, mHeight);
- }
-
- public void draw(GLCanvas canvas, int x, int y, int w, int h) {
- canvas.fillRect(x, y, w, h, mColor);
- }
-
- public boolean isOpaque() {
- return Utils.isOpaque(mColor);
- }
-
- public void setSize(int width, int height) {
- mWidth = width;
- mHeight = height;
- }
-
- public int getWidth() {
- return mWidth;
- }
-
- public int getHeight() {
- return mHeight;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/DisplayItem.java b/new3d/src/com/android/gallery3d/ui/DisplayItem.java
deleted file mode 100644
index 5ff2355..0000000
--- a/new3d/src/com/android/gallery3d/ui/DisplayItem.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-public abstract class DisplayItem {
-
- // The parameters in this section are used only by DisplayItemPanel
- protected int mWidth;
- protected int mHeight;
-
- protected void setSize(int width, int height) {
- mWidth = width;
- mHeight = height;
- }
-
- public abstract void render(GLCanvas canvas);
-
- public abstract long getIdentity();
-
- public int getWidth() {
- return mWidth;
- }
-
- public int getHeight() {
- return mHeight;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/DownUpDetector.java b/new3d/src/com/android/gallery3d/ui/DownUpDetector.java
deleted file mode 100644
index 19db772..0000000
--- a/new3d/src/com/android/gallery3d/ui/DownUpDetector.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.view.MotionEvent;
-
-public class DownUpDetector {
- public interface DownUpListener {
- void onDown(MotionEvent e);
- void onUp(MotionEvent e);
- }
-
- private boolean mStillDown;
- private DownUpListener mListener;
-
- public DownUpDetector(DownUpListener listener) {
- mListener = listener;
- }
-
- private void setState(boolean down, MotionEvent e) {
- if (down == mStillDown) return;
- mStillDown = down;
- if (down) {
- mListener.onDown(e);
- } else {
- mListener.onUp(e);
- }
- }
-
- public void onTouchEvent(MotionEvent ev) {
- switch (ev.getAction() & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_DOWN:
- setState(true, ev);
- break;
-
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_CANCEL:
- case MotionEvent.ACTION_POINTER_DOWN: // Multitouch event - abort.
- setState(false, ev);
- break;
- }
- }
-
- public boolean isDown() {
- return mStillDown;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/DrawableTexture.java b/new3d/src/com/android/gallery3d/ui/DrawableTexture.java
deleted file mode 100644
index 24597cd..0000000
--- a/new3d/src/com/android/gallery3d/ui/DrawableTexture.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.drawable.Drawable;
-
-// DrawableTexture is a texture whose content is from a Drawable.
-// The width and height of a DrawableTexture is its intrinsic width and height.
-public class DrawableTexture extends CanvasTexture {
-
- private final Drawable mDrawable;
-
- public DrawableTexture(Drawable drawable) {
- super(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
- mDrawable = drawable;
- }
-
- @Override
- protected void onDraw(Canvas canvas, Bitmap backing) {
- mDrawable.setBounds(0, 0, mWidth, mHeight);
- mDrawable.draw(canvas);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/GLCanvas.java b/new3d/src/com/android/gallery3d/ui/GLCanvas.java
deleted file mode 100644
index 5f3c542..0000000
--- a/new3d/src/com/android/gallery3d/ui/GLCanvas.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.RectF;
-
-import javax.microedition.khronos.opengles.GL11;
-
-//
-// GLCanvas gives a convenient interface to draw using OpenGL.
-//
-// When a rectangle is specified in this interface, it means the region
-// [x, x+width) * [y, y+height)
-//
-public interface GLCanvas {
- // Tells GLCanvas the size of the underlying GL surface. This should be
- // called before first drawing and when the size of GL surface is changed.
- // This is called by GLRoot and should not be called by the clients
- // who only want to draw on the GLCanvas. Both width and height must be
- // nonnegative.
- public void setSize(int width, int height);
-
- // Clear the drawing buffers. This should only be used by GLRoot.
- public void clearBuffer();
-
- // This is the time value used to calculate the animation in the current
- // frame. The "set" function should only called by GLRoot, and the
- // "time" parameter must be nonnegative.
- public void setCurrentAnimationTimeMillis(long time);
- public long currentAnimationTimeMillis();
-
- // Sets and gets the current alpha, alpha must be in [0, 1].
- public void setAlpha(float alpha);
- public float getAlpha();
-
- // (current alpha) = (current alpha) * alpha
- public void multiplyAlpha(float alpha);
-
- // Change the current transform matrix.
- public void translate(float x, float y, float z);
- public void scale(float sx, float sy, float sz);
- public void rotate(float angle, float x, float y, float z);
-
- // Modifies the current clip with the specified rectangle.
- // (current clip) = (current clip) intersect (specified rectangle).
- // Returns true if the result clip is non-empty.
- public boolean clipRect(int left, int top, int right, int bottom);
-
- // Pushes the configuration state (matrix, alpha, and clip) onto
- // a private stack.
- public int save();
-
- // Same as save(), but only save those specified in saveFlags.
- public int save(int saveFlags);
-
- public static final int SAVE_FLAG_ALL = 0xFFFFFFFF;
- public static final int SAVE_FLAG_CLIP = 0x01;
- public static final int SAVE_FLAG_ALPHA = 0x02;
- public static final int SAVE_FLAG_MATRIX = 0x04;
-
- // Pops from the top of the stack as current configuration state (matrix,
- // alpha, and clip). This call balances a previous call to save(), and is
- // used to remove all modifications to the configuration state since the
- // last save call.
- public void restore();
-
- // Draws a line using the specified color from (x1, y1) to (x2, y2).
- // (Both end points are included).
- public void drawLine(int x1, int y1, int x2, int y2, int color);
-
- // Fills the specified rectange with the specified color.
- public void fillRect(float x, float y, float width, float height, int color);
-
- // Draws a texture to the specified rectangle.
- public void drawTexture(
- BasicTexture texture, int x, int y, int width, int height);
- public void drawMesh(BasicTexture tex, int x, int y, int xyBuffer,
- int uvBuffer, int indexBuffer, int indexCount);
-
- // Draws a texture to the specified rectangle. The "alpha" parameter
- // overrides the current drawing alpha value.
- public void drawTexture(BasicTexture texture,
- int x, int y, int width, int height, float alpha);
-
- // Draws a the source rectangle part of the texture to the target rectangle.
- public void drawTexture(BasicTexture texture, RectF source, RectF target);
-
- // Draw two textures to the specified rectange. The actual texture used is
- // from * (1 - ratio) + to * ratio
- // The two textures must have the same size.
- public void drawMixed(BasicTexture from, BasicTexture to,
- float ratio, int x, int y, int w, int h);
-
- // Return a texture copied from the specified rectangle.
- public BasicTexture copyTexture(int x, int y, int width, int height);
-
- // Gets the underlying GL instance. This is used only when direct access to
- // GL is needed.
- public GL11 getGLInstance();
-
- // Unloads the specified texture from the canvas. The resource allocated
- // to draw the texture will be released. The specified texture will return
- // to the unloaded state. This function should be called only from
- // BasicTexture or its descendant
- public boolean unloadTexture(BasicTexture texture);
-
- // Delete the specified buffer object, similar to unloadTexture.
- public void deleteBuffer(int bufferId);
-
- // Delete the textures and buffers in GL side. This function should only be
- // called in the GL thread.
- public void deleteRecycledResources();
-}
diff --git a/new3d/src/com/android/gallery3d/ui/GLCanvasImp.java b/new3d/src/com/android/gallery3d/ui/GLCanvasImp.java
deleted file mode 100644
index beada90..0000000
--- a/new3d/src/com/android/gallery3d/ui/GLCanvasImp.java
+++ /dev/null
@@ -1,806 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import com.android.gallery3d.util.IntArray;
-import com.android.gallery3d.util.Utils;
-
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.opengl.GLU;
-import android.opengl.Matrix;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.FloatBuffer;
-import java.util.Stack;
-
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL11;
-import javax.microedition.khronos.opengles.GL11Ext;
-
-public class GLCanvasImp implements GLCanvas {
- @SuppressWarnings("unused")
- private static final String TAG = "GLCanvasImp";
-
- private static final float OPAQUE_ALPHA = 0.95f;
-
- // The first four pairs of (x, y) are for drawing a rectangle, and the last
- // two are for drawing a line.
- private static final float[] BOX_COORDINATES = {
- 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1 };
-
- private final GL11 mGL;
-
- private final float mMatrixValues[] = new float[16];
- private final float mTextureMatrixValues[] = new float[16];
-
- // mapPoints needs 10 input and output numbers.
- private final float mMapPointsBuffer[] = new float[10];
-
- private final float mTextureColor[] = new float[4];
-
- private int mBoxCoords;
-
- private final GLState mGLState;
-
- private long mAnimationTime;
-
- private float mAlpha;
- private final Rect mClipRect = new Rect();
- private final Stack<ConfigState> mRestoreStack =
- new Stack<ConfigState>();
- private ConfigState mRecycledRestoreAction;
-
- private final RectF mDrawTextureSourceRect = new RectF();
- private final RectF mDrawTextureTargetRect = new RectF();
- private final float[] mTempMatrix = new float[32];
- private final IntArray mUnboundTextures = new IntArray();
- private final IntArray mDeleteBuffers = new IntArray();
-
- // Drawing statistics
- int mCountDrawLine;
- int mCountFillRect;
- int mCountDrawMesh;
- int mCountTextureRect;
- int mCountTextureOES;
-
- GLCanvasImp(GL11 gl) {
- mGL = gl;
- mGLState = new GLState(gl);
- initialize();
- }
-
- public void setSize(int width, int height) {
- Utils.Assert(width >= 0 && height >= 0);
-
- GL11 gl = mGL;
- gl.glViewport(0, 0, width, height);
- gl.glMatrixMode(GL11.GL_PROJECTION);
- gl.glLoadIdentity();
- GLU.gluOrtho2D(gl, 0, width, 0, height);
-
- gl.glMatrixMode(GL11.GL_MODELVIEW);
- gl.glLoadIdentity();
-
- // The positive direction in Y coordinate in OpenGL is from bottom to
- // top, which is different from the coordinate system in Java. So, we
- // flip it here.
- float matrix[] = mMatrixValues;
- Matrix.setIdentityM(matrix, 0);
- Matrix.translateM(matrix, 0, 0, height, 0);
- Matrix.scaleM(matrix, 0, 1, -1, 1);
-
- mClipRect.set(0, 0, width, height);
- gl.glScissor(0, 0, width, height);
- }
-
- public long currentAnimationTimeMillis() {
- return mAnimationTime;
- }
-
- public void setAlpha(float alpha) {
- Utils.Assert(alpha >= 0 && alpha <= 1);
- mAlpha = alpha;
- }
-
- public void multiplyAlpha(float alpha) {
- Utils.Assert(alpha >= 0 && alpha <= 1);
- mAlpha *= alpha;
- }
-
- public float getAlpha() {
- return mAlpha;
- }
-
- private static ByteBuffer allocateDirectNativeOrderBuffer(int size) {
- return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
- }
-
- private void initialize() {
- GL11 gl = mGL;
-
- // First create an nio buffer, then create a VBO from it.
- int size = BOX_COORDINATES.length * Float.SIZE / Byte.SIZE;
- FloatBuffer xyBuffer = allocateDirectNativeOrderBuffer(size).asFloatBuffer();
- xyBuffer.put(BOX_COORDINATES, 0, BOX_COORDINATES.length).position(0);
-
- int[] name = new int[1];
- gl.glGenBuffers(1, name, 0);
- mBoxCoords = name[0];
-
- gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBoxCoords);
- gl.glBufferData(GL11.GL_ARRAY_BUFFER,
- xyBuffer.capacity() * (Float.SIZE / Byte.SIZE),
- xyBuffer, GL11.GL_STATIC_DRAW);
-
- gl.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
- gl.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);
-
- // Enable the texture coordinate array for Texture 1
- gl.glClientActiveTexture(GL11.GL_TEXTURE1);
- gl.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);
- gl.glClientActiveTexture(GL11.GL_TEXTURE0);
- gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
-
- // mMatrixValues will be initialized in setSize()
- mAlpha = 1.0f;
- }
-
- private static void putRectangle(float x, float y,
- float width, float height, float[] buffer, FloatBuffer pointer) {
- buffer[0] = x;
- buffer[1] = y;
- buffer[2] = x + width;
- buffer[3] = y;
- buffer[4] = x;
- buffer[5] = y + height;
- buffer[6] = x + width;
- buffer[7] = y + height;
- pointer.put(buffer, 0, 8).position(0);
- }
-
- public void drawLine(int x1, int y1, int x2, int y2, int color) {
- mGLState.setColorMode(color, mAlpha);
- GL11 gl = mGL;
-
- saveTransform();
- translate(x1, y1, 0);
- scale(x2 - x1, y2 - y1, 1);
-
- gl.glLoadMatrixf(mMatrixValues, 0);
- gl.glDrawArrays(GL11.GL_LINE_STRIP, 4, 2);
-
- restoreTransform();
- mCountDrawLine++;
- }
-
- public void fillRect(float x, float y, float width, float height, int color) {
- mGLState.setColorMode(color, mAlpha);
- GL11 gl = mGL;
-
- saveTransform();
- translate(x, y, 0);
- scale(width, height, 1);
-
- gl.glLoadMatrixf(mMatrixValues, 0);
- gl.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4);
-
- restoreTransform();
- mCountFillRect++;
- }
-
- public void translate(float x, float y, float z) {
- Matrix.translateM(mMatrixValues, 0, x, y, z);
- }
-
- public void scale(float sx, float sy, float sz) {
- Matrix.scaleM(mMatrixValues, 0, sx, sy, sz);
- }
-
- public void rotate(float angle, float x, float y, float z) {
- float[] temp = mTempMatrix;
- Matrix.setRotateM(temp, 0, angle, x, y, z);
- Matrix.multiplyMM(temp, 16, mMatrixValues, 0, temp, 0);
- System.arraycopy(temp, 16, mMatrixValues, 0, 16);
- }
-
- private void textureRect(float x, float y, float width, float height) {
- GL11 gl = mGL;
-
- saveTransform();
- translate(x, y, 0);
- scale(width, height, 1);
-
- gl.glLoadMatrixf(mMatrixValues, 0);
- gl.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4);
-
- restoreTransform();
- mCountTextureRect++;
- }
-
- public void drawMesh(BasicTexture tex, int x, int y, int xyBuffer,
- int uvBuffer, int indexBuffer, int indexCount) {
- float alpha = mAlpha;
- if (!bindTexture(tex)) return;
-
- mGLState.setBlendEnabled(!tex.isOpaque() || alpha < OPAQUE_ALPHA);
- mGLState.setTextureAlpha(alpha);
-
- // Reset the texture matrix. We will set our own texture coordinates
- // below.
- setTextureCoords(0, 0, 1, 1);
-
- saveTransform();
- translate(x, y, 0);
-
- mGL.glLoadMatrixf(mMatrixValues, 0);
-
- mGL.glBindBuffer(GL11.GL_ARRAY_BUFFER, xyBuffer);
- mGL.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
-
- mGL.glBindBuffer(GL11.GL_ARRAY_BUFFER, uvBuffer);
- mGL.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);
-
- mGL.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
- mGL.glDrawElements(GL11.GL_TRIANGLE_STRIP,
- indexCount, GL11.GL_UNSIGNED_BYTE, 0);
-
- mGL.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBoxCoords);
- mGL.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
- mGL.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);
-
- restoreTransform();
- mCountDrawMesh++;
- }
-
- private float[] mapPoints(float matrix[], int x1, int y1, int x2, int y2) {
- float[] point = mMapPointsBuffer;
- int srcOffset = 6;
- point[srcOffset] = x1;
- point[srcOffset + 1] = y1;
- point[srcOffset + 2] = 0;
- point[srcOffset + 3] = 1;
-
- int resultOffset = 0;
- Matrix.multiplyMV(point, resultOffset, matrix, 0, point, srcOffset);
- point[resultOffset] /= point[resultOffset + 3];
- point[resultOffset + 1] /= point[resultOffset + 3];
-
- // map the second point
- point[srcOffset] = x2;
- point[srcOffset + 1] = y2;
- resultOffset = 2;
- Matrix.multiplyMV(point, resultOffset, matrix, 0, point, srcOffset);
- point[resultOffset] /= point[resultOffset + 3];
- point[resultOffset + 1] /= point[resultOffset + 3];
-
- return point;
- }
-
- public boolean clipRect(int left, int top, int right, int bottom) {
- float point[] = mapPoints(mMatrixValues, left, top, right, bottom);
-
- // mMatrix could be a rotation matrix. In this case, we need to find
- // the boundaries after rotation. (only handle 90 * n degrees)
- if (point[0] > point[2]) {
- left = (int) point[2];
- right = (int) point[0];
- } else {
- left = (int) point[0];
- right = (int) point[2];
- }
- if (point[1] > point[3]) {
- top = (int) point[3];
- bottom = (int) point[1];
- } else {
- top = (int) point[1];
- bottom = (int) point[3];
- }
- Rect clip = mClipRect;
-
- boolean intersect = clip.intersect(left, top, right, bottom);
- if (!intersect) clip.set(0, 0, 0, 0);
- mGL.glScissor(clip.left, clip.top, clip.width(), clip.height());
- return intersect;
- }
-
- private void drawBoundTexture(
- BasicTexture texture, int x, int y, int width, int height) {
- // Test whether it has been rotated or flipped, if so, glDrawTexiOES
- // won't work
- if (isMatrixRotatedOrFlipped(mMatrixValues)) {
- setTextureCoords(0, 0,
- (texture.getWidth() - 0.5f) / texture.getTextureWidth(),
- (texture.getHeight() - 0.5f) / texture.getTextureHeight());
- textureRect(x, y, width, height);
- } else {
- // draw the rect from bottom-left to top-right
- float points[] = mapPoints(
- mMatrixValues, x, y + height, x + width, y);
- x = (int) points[0];
- y = (int) points[1];
- width = (int) points[2] - x;
- height = (int) points[3] - y;
- if (width > 0 && height > 0) {
- ((GL11Ext) mGL).glDrawTexiOES(x, y, 0, width, height);
- mCountTextureOES++;
- }
- }
- }
-
- public void drawTexture(
- BasicTexture texture, int x, int y, int width, int height) {
- drawTexture(texture, x, y, width, height, mAlpha);
- }
-
- public void drawTexture(BasicTexture texture,
- int x, int y, int width, int height, float alpha) {
- if (width <= 0 || height <= 0) return;
-
- mGLState.setBlendEnabled(!texture.isOpaque() || alpha < OPAQUE_ALPHA);
- if (!bindTexture(texture)) return;
- mGLState.setTextureAlpha(alpha);
- drawBoundTexture(texture, x, y, width, height);
- }
-
- public void drawTexture(BasicTexture texture, RectF source, RectF target) {
- if (target.width() <= 0 || target.height() <= 0) return;
-
- // Copy the input to avoid changing it.
- mDrawTextureSourceRect.set(source);
- mDrawTextureTargetRect.set(target);
- source = mDrawTextureSourceRect;
- target = mDrawTextureTargetRect;
-
- mGLState.setBlendEnabled(!texture.isOpaque() || mAlpha < OPAQUE_ALPHA);
- if (!bindTexture(texture)) return;
- convertCoordinate(source, target, texture);
- setTextureCoords(source);
- mGLState.setTextureAlpha(mAlpha);
- textureRect(target.left, target.top, target.width(), target.height());
- }
-
- // This function changes the source coordinate to the texture coordinates.
- // It also clips the source and target coordinates if it is beyond the
- // bound of the texture.
- private void convertCoordinate(RectF source, RectF target,
- BasicTexture texture) {
-
- int width = texture.getWidth();
- int height = texture.getHeight();
- int texWidth = texture.getTextureWidth();
- int texHeight = texture.getTextureHeight();
- // Convert to texture coordinates
- source.left /= texWidth;
- source.right /= texWidth;
- source.top /= texHeight;
- source.bottom /= texHeight;
-
- // Clip if the rendering range is beyond the bound of the texture.
- if (width < texWidth) {
- float xBound = (width - 0.5f) / texWidth;
- if (source.right > xBound) {
- target.right = target.left + target.width() *
- (xBound - source.left) / source.width();
- source.right = xBound;
- }
- }
- if (height < texHeight) {
- float yBound = (height - 0.5f) / texHeight;
- if (source.bottom > yBound) {
- target.bottom = target.top + target.height() *
- (yBound - source.top) / source.height();
- source.bottom = yBound;
- }
- }
- }
-
- public void drawMixed(BasicTexture from, BasicTexture to,
- float ratio, int x, int y, int w, int h) {
- drawMixed(from, to, ratio, x, y, w, h, mAlpha);
- }
-
- private boolean bindTexture(BasicTexture texture) {
- if (!texture.onBind(this)) return false;
- mGLState.setTexture2DEnabled(true);
- mGL.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId());
- return true;
- }
-
- private void setTextureColor(float r, float g, float b, float alpha) {
- float[] color = mTextureColor;
- color[0] = r;
- color[1] = g;
- color[2] = b;
- color[3] = alpha;
- }
-
- private void drawMixed(BasicTexture from, BasicTexture to,
- float ratio, int x, int y, int width, int height, float alpha) {
-
- if (ratio <= 0) {
- drawTexture(from, x, y, width, height, alpha);
- return;
- } else if (ratio >= 1) {
- drawTexture(to, x, y, width, height, alpha);
- return;
- }
-
- // In the current implementation the two textures must have the
- // same size.
- Utils.Assert(from.getWidth() == to.getWidth()
- && from.getHeight() == to.getHeight());
-
- mGLState.setBlendEnabled(!from.isOpaque()
- || !to.isOpaque() || alpha < OPAQUE_ALPHA);
-
- final GL11 gl = mGL;
- if (!bindTexture(from)) return;
-
- //
- // The formula we want:
- // alpha * ((1 - ratio) * from + ratio * to)
- // The formula that GL supports is in the form of:
- // (1 - combo) * (modulate * from) + combo * to
- //
- // So, we have combo = alpha * ratio
- // and modulate = alpha * (1f - ratio) / (1 - combo)
- //
- float comboRatio = alpha * ratio;
-
- // handle the case that (1 - comboRatio) == 0
- if (alpha < OPAQUE_ALPHA) {
- mGLState.setTextureAlpha(alpha * (1f - ratio) / (1f - comboRatio));
- } else {
- mGLState.setTextureAlpha(1f);
- }
-
- gl.glActiveTexture(GL11.GL_TEXTURE1);
- if (!bindTexture(to)) {
- // Disable TEXTURE1.
- gl.glDisable(GL11.GL_TEXTURE_2D);
- // Switch back to the default texture unit.
- gl.glActiveTexture(GL11.GL_TEXTURE0);
- return;
- }
- gl.glEnable(GL11.GL_TEXTURE_2D);
-
- // Interpolate the RGB and alpha values between both textures.
- mGLState.setTexEnvMode(GL11.GL_COMBINE);
- gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_COMBINE_RGB, GL11.GL_INTERPOLATE);
- gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_COMBINE_ALPHA, GL11.GL_INTERPOLATE);
-
- // Specify the interpolation factor via the alpha component of
- // GL_TEXTURE_ENV_COLORs.
- // We don't use the RGB color, so just give them 0s.
- setTextureColor(0, 0, 0, comboRatio);
- gl.glTexEnvfv(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, mTextureColor, 0);
-
- // Wire up the interpolation factor for RGB.
- gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_SRC2_RGB, GL11.GL_CONSTANT);
- gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_OPERAND2_RGB, GL11.GL_SRC_ALPHA);
-
- // Wire up the interpolation factor for alpha.
- gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_SRC2_ALPHA, GL11.GL_CONSTANT);
- gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_OPERAND2_ALPHA, GL11.GL_SRC_ALPHA);
-
- // Draw the combined texture.
- drawBoundTexture(to, x, y, width, height);
-
- // Disable TEXTURE1.
- gl.glDisable(GL11.GL_TEXTURE_2D);
- // Switch back to the default texture unit.
- gl.glActiveTexture(GL11.GL_TEXTURE0);
- }
-
- // TODO: the code only work for 2D should get fixed for 3D or removed
- private static final int MSKEW_X = 4;
- private static final int MSKEW_Y = 1;
- private static final int MSCALE_X = 0;
- private static final int MSCALE_Y = 5;
-
- private static boolean isMatrixRotatedOrFlipped(float matrix[]) {
- final float eps = 1e-5f;
- return Math.abs(matrix[MSKEW_X]) > eps
- || Math.abs(matrix[MSKEW_Y]) > eps
- || matrix[MSCALE_X] < -eps
- || matrix[MSCALE_Y] > eps;
- }
-
- public BasicTexture copyTexture(int x, int y, int width, int height) {
-
- if (isMatrixRotatedOrFlipped(mMatrixValues)) {
- throw new IllegalArgumentException("cannot support rotated matrix");
- }
- float points[] = mapPoints(mMatrixValues, x, y + height, x + width, y);
- x = (int) points[0];
- y = (int) points[1];
- width = (int) points[2] - x;
- height = (int) points[3] - y;
-
- GL11 gl = mGL;
-
- RawTexture texture = RawTexture.newInstance(this);
- gl.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId());
- texture.setSize(width, height);
-
- int[] cropRect = {0, 0, width, height};
- gl.glTexParameteriv(GL11.GL_TEXTURE_2D,
- GL11Ext.GL_TEXTURE_CROP_RECT_OES, cropRect, 0);
- gl.glTexParameteri(GL11.GL_TEXTURE_2D,
- GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP_TO_EDGE);
- gl.glTexParameteri(GL11.GL_TEXTURE_2D,
- GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP_TO_EDGE);
- gl.glTexParameterf(GL11.GL_TEXTURE_2D,
- GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
- gl.glTexParameterf(GL11.GL_TEXTURE_2D,
- GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
- gl.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0,
- GL11.GL_RGB, x, y, texture.getTextureWidth(),
- texture.getTextureHeight(), 0);
-
- return texture;
- }
-
- private static class GLState {
-
- private final GL11 mGL;
-
- private int mTexEnvMode = GL11.GL_REPLACE;
- private float mTextureAlpha = 1.0f;
- private boolean mTexture2DEnabled = true;
- private boolean mBlendEnabled = true;
-
- public GLState(GL11 gl) {
- mGL = gl;
-
- // Disable unused state
- gl.glDisable(GL11.GL_LIGHTING);
-
- // Enable used features
- gl.glEnable(GL11.GL_DITHER);
- gl.glEnable(GL11.GL_SCISSOR_TEST);
-
- gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
- gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
- gl.glEnable(GL11.GL_TEXTURE_2D);
-
- gl.glTexEnvf(GL11.GL_TEXTURE_ENV,
- GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
-
- // Set the background color
- gl.glClearColor(0f, 0f, 0f, 0f);
- gl.glClearStencil(0);
-
- gl.glEnable(GL11.GL_BLEND);
- gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
- // We use 565 or 8888 format, so set the alignment to 2 bytes/pixel.
- gl.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 2);
- }
-
- public void setTexEnvMode(int mode) {
- if (mTexEnvMode == mode) return;
- mTexEnvMode = mode;
- mGL.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, mode);
- }
-
- public void setTextureAlpha(float alpha) {
- if (mTextureAlpha == alpha) return;
- mTextureAlpha = alpha;
- if (alpha >= OPAQUE_ALPHA) {
- // The alpha is need for those texture without alpha channel
- mGL.glColor4f(1, 1, 1, 1);
- setTexEnvMode(GL11.GL_REPLACE);
- } else {
- mGL.glColor4f(alpha, alpha, alpha, alpha);
- setTexEnvMode(GL11.GL_MODULATE);
- }
- }
-
- public void setColorMode(int color, float alpha) {
- setBlendEnabled(!Utils.isOpaque(color) || alpha < OPAQUE_ALPHA);
-
- // Set mTextureAlpha to an invalid value, so that it will reset
- // again in setTextureAlpha(float) later.
- mTextureAlpha = -1.0f;
-
- setTexture2DEnabled(false);
-
- float prealpha = (color >>> 24) * alpha * 65535f / 255f / 255f;
- mGL.glColor4x(
- Math.round(((color >> 16) & 0xFF) * prealpha),
- Math.round(((color >> 8) & 0xFF) * prealpha),
- Math.round((color & 0xFF) * prealpha),
- Math.round(255 * prealpha));
- }
-
- public void setTexture2DEnabled(boolean enabled) {
- if (mTexture2DEnabled == enabled) return;
- mTexture2DEnabled = enabled;
- if (enabled) {
- mGL.glEnable(GL11.GL_TEXTURE_2D);
- } else {
- mGL.glDisable(GL11.GL_TEXTURE_2D);
- }
- }
-
- public void setBlendEnabled(boolean enabled) {
- if (mBlendEnabled == enabled) return;
- mBlendEnabled = enabled;
- if (enabled) {
- mGL.glEnable(GL11.GL_BLEND);
- } else {
- mGL.glDisable(GL11.GL_BLEND);
- }
- }
- }
-
- public GL11 getGLInstance() {
- return mGL;
- }
-
- public void setCurrentAnimationTimeMillis(long time) {
- Utils.Assert(time >= 0);
- mAnimationTime = time;
- }
-
- public void clearBuffer() {
- mGL.glClear(GL10.GL_COLOR_BUFFER_BIT);
- }
-
- private void setTextureCoords(RectF source) {
- setTextureCoords(source.left, source.top, source.right, source.bottom);
- }
-
- private void setTextureCoords(float left, float top,
- float right, float bottom) {
- mGL.glMatrixMode(GL11.GL_TEXTURE);
- mTextureMatrixValues[0] = right - left;
- mTextureMatrixValues[5] = bottom - top;
- mTextureMatrixValues[10] = 1;
- mTextureMatrixValues[12] = left;
- mTextureMatrixValues[13] = top;
- mTextureMatrixValues[15] = 1;
- mGL.glLoadMatrixf(mTextureMatrixValues, 0);
- mGL.glMatrixMode(GL11.GL_MODELVIEW);
- }
-
- // unloadTexture and deleteBuffer can be called from the finalizer thread,
- // so we synchronized on the mUnboundTextures object.
- public boolean unloadTexture(BasicTexture t) {
- synchronized (mUnboundTextures) {
- if (!t.isLoaded(this)) return false;
- mUnboundTextures.add(t.mId);
- return true;
- }
- }
-
- public void deleteBuffer(int bufferId) {
- synchronized (mUnboundTextures) {
- mDeleteBuffers.add(bufferId);
- }
- }
-
- public void deleteRecycledResources() {
- synchronized (mUnboundTextures) {
- IntArray ids = mUnboundTextures;
- if (ids.size() > 0) {
- mGL.glDeleteTextures(ids.size(), ids.getInternalArray(), 0);
- ids.clear();
- }
-
- ids = mDeleteBuffers;
- if (ids.size() > 0) {
- mGL.glDeleteBuffers(ids.size(), ids.getInternalArray(), 0);
- ids.clear();
- }
- }
- }
-
- public int save() {
- return save(SAVE_FLAG_ALL);
- }
-
- public int save(int saveFlags) {
- ConfigState config = obtainRestoreConfig();
-
- if ((saveFlags & SAVE_FLAG_ALPHA) != 0) {
- config.mAlpha = mAlpha;
- } else {
- config.mAlpha = -1;
- }
-
- if ((saveFlags & SAVE_FLAG_CLIP) != 0) {
- config.mRect.set(mClipRect);
- } else {
- config.mRect.left = Integer.MAX_VALUE;
- }
-
- if ((saveFlags & SAVE_FLAG_MATRIX) != 0) {
- System.arraycopy(mMatrixValues, 0, config.mMatrix, 0, 16);
- } else {
- config.mMatrix[0] = Float.NEGATIVE_INFINITY;
- }
-
- mRestoreStack.push(config);
- return mRestoreStack.size() - 1;
- }
-
- public void restore() {
- if (mRestoreStack.isEmpty()) throw new IllegalStateException();
- ConfigState config = mRestoreStack.pop();
- config.restore(this);
- freeRestoreConfig(config);
- }
-
- private void freeRestoreConfig(ConfigState action) {
- action.mNextFree = mRecycledRestoreAction;
- mRecycledRestoreAction = action;
- }
-
- private ConfigState obtainRestoreConfig() {
- if (mRecycledRestoreAction != null) {
- ConfigState result = mRecycledRestoreAction;
- mRecycledRestoreAction = result.mNextFree;
- return result;
- }
- return new ConfigState();
- }
-
- private static class ConfigState {
- float mAlpha;
- Rect mRect = new Rect();
- float mMatrix[] = new float[16];
- ConfigState mNextFree;
-
- public void restore(GLCanvasImp canvas) {
- if (mAlpha >= 0) canvas.setAlpha(mAlpha);
- if (mRect.left != Integer.MAX_VALUE) {
- Rect rect = mRect;
- canvas.mClipRect.set(rect);
- canvas.mGL.glScissor(
- rect.left, rect.top, rect.width(), rect.height());
- }
- if (mMatrix[0] != Float.NEGATIVE_INFINITY) {
- System.arraycopy(mMatrix, 0, canvas.mMatrixValues, 0, 16);
- }
- }
- }
-
- public void dumpStatisticsAndClear() {
- String line = String.format(
- "MESH:%d, TEX_OES:%d, TEX_RECT:%d, FILL_RECT:%d, LINE:%d",
- mCountDrawMesh, mCountTextureRect, mCountTextureOES,
- mCountFillRect, mCountDrawLine);
- mCountDrawMesh = 0;
- mCountTextureRect = 0;
- mCountTextureOES = 0;
- mCountFillRect = 0;
- mCountDrawLine = 0;
- Log.v(TAG, line);
- }
-
- private void saveTransform() {
- System.arraycopy(mMatrixValues, 0, mTempMatrix, 0, 16);
- }
-
- private void restoreTransform() {
- System.arraycopy(mTempMatrix, 0, mMatrixValues, 0, 16);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/GLListView.java b/new3d/src/com/android/gallery3d/ui/GLListView.java
deleted file mode 100644
index 9af1dd7..0000000
--- a/new3d/src/com/android/gallery3d/ui/GLListView.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import static android.view.View.MeasureSpec.makeMeasureSpec;
-import android.content.Context;
-import android.graphics.Rect;
-import android.os.Handler;
-import android.os.Message;
-import android.view.GestureDetector;
-import android.view.MotionEvent;
-import android.view.View.MeasureSpec;
-import android.widget.Scroller;
-
-import com.android.gallery3d.anim.AlphaAnimation;
-import com.android.gallery3d.anim.CanvasAnimation;
-import com.android.gallery3d.util.Utils;
-
-public class GLListView extends GLView {
- @SuppressWarnings("unused")
- private static final String TAG = "GLListView";
- private static final int INDEX_NONE = -1;
- private static final int SCROLL_BAR_TIMEOUT = 2500;
-
- private static final int HIDE_SCROLL_BAR = 1;
-
- private Model mModel;
- private final Handler mHandler;
-
- private int mHighlightIndex = INDEX_NONE;
- private GLView mHighlightView;
-
- private Texture mHighLight;
- private NinePatchTexture mScrollbar;
-
- private int mVisibleStart = 0; // inclusive
- private int mVisibleEnd = 0; // exclusive
-
- private boolean mHasMeasured = false;
-
- private boolean mScrollBarVisible = false;
- private CanvasAnimation mScrollBarAnimation;
- private OnItemSelectedListener mOnItemSelectedListener;
-
- private final GestureDetector mGestureDetector;
- private final Scroller mScroller;
- private boolean mScrollable;
- private boolean mIsPressed = false;
-
- static public interface Model {
- public int size();
- public GLView getView(int index);
- public boolean isSelectable(int index);
- }
-
- static public interface OnItemSelectedListener {
- public void onItemSelected(GLView view, int position);
- }
-
- public GLListView(Context context) {
- mScroller = new Scroller(context);
- mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- lockRendering();
- try {
- handleMessageLocked(msg);
- } finally {
- unlockRendering();
- }
- }
-
- private void handleMessageLocked(Message msg) {
- switch(msg.what) {
- case HIDE_SCROLL_BAR:
- setScrollBarVisible(false);
- break;
- }
- }
- };
- mGestureDetector = new GestureDetector(
- context, new MyGestureListener(), mHandler);
- }
-
- @Override
- protected void onVisibilityChanged(int visibility) {
- super.onVisibilityChanged(visibility);
- if (visibility == GLView.VISIBLE && mScrollHeight > getHeight()) {
- setScrollBarVisible(true);
- mHandler.sendEmptyMessageDelayed(
- HIDE_SCROLL_BAR, SCROLL_BAR_TIMEOUT);
- }
- }
-
- private void setScrollBarVisible(boolean visible) {
- if (mScrollBarVisible == visible || mScrollbar == null) return;
- mScrollBarVisible = visible;
- if (!visible) {
- mScrollBarAnimation = new AlphaAnimation(1, 0);
- mScrollBarAnimation.setDuration(300);
- mScrollBarAnimation.start();
- } else {
- mScrollBarAnimation = null;
- }
- invalidate();
- }
-
- public void setHighLight(Texture highLight) {
- mHighLight = highLight;
- }
-
- public Model getDataModel() {
- return mModel;
- }
-
- public void setDataModel(Model model) {
- if (mModel == model) return;
-
- // remove views from the old model.
- if (mModel != null) {
- removeAllComponents();
- }
-
- // add views from the new model.
- for (int i = 0, n = model.size(); i < n; ++i) {
- addComponent(model.getView(i));
- }
-
- mModel = model;
- mScrollY = 0;
- requestLayout();
- }
-
- public void setOnItemSelectedListener(OnItemSelectedListener l) {
- mOnItemSelectedListener = l;
- }
-
- private boolean drawWithAnimation(GLCanvas canvas,
- Texture texture, int x, int y, int w, int h, CanvasAnimation anim) {
- long now = canvas.currentAnimationTimeMillis();
- canvas.save(anim.getCanvasSaveFlags());
- boolean more = anim.calculate(canvas.currentAnimationTimeMillis());
- anim.apply(canvas);
- texture.draw(canvas, x, y, w, h);
- canvas.restore();
- if (more) invalidate();
- return more;
- }
-
- @Override
- protected void render(GLCanvas canvas) {
- canvas.save(GLCanvas.SAVE_FLAG_CLIP);
- canvas.clipRect(0, 0, getWidth(), getHeight());
- if (mHighlightIndex != INDEX_NONE) {
- GLView view = getComponent(mHighlightIndex);
- Rect bounds = view.bounds();
- if (mHighLight != null) {
- int width = bounds.width();
- int height = bounds.height();
- mHighLight.draw(canvas,
- bounds.left - mScrollX, bounds.top - mScrollY,
- width, height);
- }
- }
-
- // render visible components only
- for (int i = mVisibleStart; i < mVisibleEnd; ++i) {
- renderChild(canvas, getComponent(i));
- }
-
- canvas.restore();
-
- if (mScrollBarAnimation != null || mScrollBarVisible) {
- int width = mScrollbar.getWidth();
- int height = getHeight() * getHeight() / mScrollHeight;
- int yoffset = mScrollY * getHeight() / mScrollHeight;
- if (mScrollBarAnimation != null) {
- if (!drawWithAnimation(
- canvas, mScrollbar, getWidth() - width, yoffset,
- width, height, mScrollBarAnimation)) {
- mScrollBarAnimation = null;
- }
- } else {
- mScrollbar.draw(
- canvas, getWidth() - width, yoffset, width, height);
- }
- }
- if (mScroller.computeScrollOffset()) {
- setScrollPosition(mScroller.getCurrY(), false);
- }
- }
-
- @Override
- protected void onMeasure(int widthSpec, int heightSpec) {
- // first get the total height
- int height = 0;
- int maxWidth = 0;
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- GLView view = getComponent(i);
- view.measure(widthSpec, MeasureSpec.UNSPECIFIED);
- height += view.getMeasuredHeight();
- maxWidth = Math.max(maxWidth, view.getMeasuredWidth());
- }
- mScrollHeight = height;
- mHasMeasured = true;
- MeasureHelper.getInstance(this)
- .setPreferredContentSize(maxWidth, height)
- .measure(widthSpec, heightSpec);
- }
-
- @Override
- public void requestLayout() {
- mHasMeasured = false;
- super.requestLayout();
- }
-
- @Override
- protected void onLayout(
- boolean change, int left, int top, int right, int bottom) {
-
- if (!mHasMeasured || mMeasuredWidth != (right - left)) {
- measure(makeMeasureSpec(right - left, MeasureSpec.EXACTLY),
- makeMeasureSpec(bottom - top, MeasureSpec.EXACTLY));
- }
-
- mScrollable = mScrollHeight > (bottom - top);
- int width = right - left;
- int yoffset = 0;
-
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- GLView item = getComponent(i);
- int nextOffset = yoffset + item.getMeasuredHeight();
- item.layout(0, yoffset, width, nextOffset);
- yoffset = nextOffset;
- }
- setScrollPosition(mScrollY, true);
- }
-
- private void setScrollPosition(int position, boolean force) {
- int height = getHeight();
-
- position = Utils.clamp(position, 0, mScrollHeight - height);
-
- if (!force && position == mScrollY) return;
- mScrollY = position;
-
- int n = mModel.size();
-
- int start = 0;
- int end = 0;
- for (start = 0; start < n; ++start) {
- if (position < getComponent(start).mBounds.bottom) break;
- }
-
- int bottom = position + height;
- for (end = start; end < n; ++ end) {
- if (bottom <= getComponent(end).mBounds.top) break;
- }
- setVisibleRange(start , end);
- invalidate();
- }
-
- private void setVisibleRange(int start, int end) {
- if (start == mVisibleStart && end == mVisibleEnd) return;
- mVisibleStart = start;
- mVisibleEnd = end;
- }
-
- @Override
- protected boolean dispatchTouchEvent(MotionEvent event) {
- return onTouch(event);
- }
-
- @Override @SuppressWarnings("fallthrough")
- protected boolean onTouch(MotionEvent event) {
-
- mGestureDetector.onTouchEvent(event);
-
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- mIsPressed = true;
- mHandler.removeMessages(HIDE_SCROLL_BAR);
- setScrollBarVisible(mScrollHeight > getHeight());
-
- // fallthrough: we need to highlight the item which is pressed
- case MotionEvent.ACTION_MOVE:
- if (!mScrollable) {
- findAndSetHighlightItem((int) event.getY());
- }
- break;
- case MotionEvent.ACTION_UP:
- mIsPressed = false;
- if (mScrollBarVisible) {
- mHandler.removeMessages(HIDE_SCROLL_BAR);
- mHandler.sendEmptyMessageDelayed(
- HIDE_SCROLL_BAR, SCROLL_BAR_TIMEOUT);
- }
- if (!mScrollable && mOnItemSelectedListener != null
- && mHighlightView != null) {
- mOnItemSelectedListener
- .onItemSelected(mHighlightView, mHighlightIndex);
- }
- case MotionEvent.ACTION_CANCEL:
- case MotionEvent.ACTION_OUTSIDE:
- setHighlightItem(null, INDEX_NONE);
- }
- return true;
- }
-
- private void findAndSetHighlightItem(int y) {
- int position = y + mScrollY;
- for (int i = mVisibleStart, n = mVisibleEnd; i < n; ++i) {
- GLView child = getComponent(i);
- if (child.mBounds.bottom > position) {
- if (mModel.isSelectable(i)) {
- setHighlightItem(child, i);
- return;
- }
- break;
- }
- }
- setHighlightItem(null, INDEX_NONE);
- }
-
- private void setHighlightItem(GLView view, int index) {
- if (index == mHighlightIndex) return;
- mHighlightIndex = index;
- mHighlightView = view;
- if (mHighLight != null) invalidate();
- }
-
- public void setScroller(NinePatchTexture scrollbar) {
- this.mScrollbar = scrollbar;
- requestLayout();
- }
-
- private class MyGestureListener
- extends GestureDetector.SimpleOnGestureListener {
-
- @Override
- public boolean onFling(MotionEvent e1,
- MotionEvent e2, float velocityX, float velocityY) {
- if (!mScrollable) return false;
- mScroller.fling(0, mScrollY,
- 0, -(int) velocityY, 0, 0, 0, mScrollHeight - getHeight());
- invalidate();
- return true;
- }
-
- @Override
- public boolean onScroll(MotionEvent e1,
- MotionEvent e2, float distanceX, float distanceY) {
- if (!mScrollable) return false;
- setHighlightItem(null, INDEX_NONE);
- setScrollPosition(mScrollY + (int) distanceY, false);
- return true;
- }
-
- @Override
- public void onShowPress(MotionEvent e) {
- if (!mScrollable || !mIsPressed) return;
- findAndSetHighlightItem((int) e.getY());
- }
-
- @Override
- public boolean onSingleTapUp(MotionEvent e) {
- if (!mScrollable) return false;
- findAndSetHighlightItem((int) e.getY());
- if (mOnItemSelectedListener != null && mHighlightView != null) {
- mOnItemSelectedListener
- .onItemSelected(mHighlightView, mHighlightIndex);
- }
- setHighlightItem(null, INDEX_NONE);
- return true;
- }
- }
-
-}
diff --git a/new3d/src/com/android/gallery3d/ui/GLRoot.java b/new3d/src/com/android/gallery3d/ui/GLRoot.java
deleted file mode 100644
index 24e5794..0000000
--- a/new3d/src/com/android/gallery3d/ui/GLRoot.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import com.android.gallery3d.anim.CanvasAnimation;
-
-public interface GLRoot {
-
- public static interface OnGLIdleListener {
- public boolean onGLIdle(GLRoot root, GLCanvas canvas);
- }
-
- public void addOnGLIdleListener(OnGLIdleListener listener);
- public void registerLaunchedAnimation(CanvasAnimation animation);
- public void requestRender();
- public void requestLayoutContentPane();
- public boolean hasStencil();
-
- public void lockRenderThread();
- public void unlockRenderThread();
-
- public void setContentPane(GLView content);
-}
diff --git a/new3d/src/com/android/gallery3d/ui/GLRootView.java b/new3d/src/com/android/gallery3d/ui/GLRootView.java
deleted file mode 100644
index 8a5e486..0000000
--- a/new3d/src/com/android/gallery3d/ui/GLRootView.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.app.Activity;
-import android.content.Context;
-import android.graphics.Rect;
-import android.opengl.GLSurfaceView;
-import android.os.Process;
-import android.os.SystemClock;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.view.MotionEvent;
-
-import com.android.gallery3d.anim.CanvasAnimation;
-import com.android.gallery3d.util.Utils;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.concurrent.locks.ReentrantLock;
-
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL11;
-
-// The root component of all <code>GLView</code>s. The rendering is done in GL
-// thread while the event handling is done in the main thread. To synchronize
-// the two threads, the entry points of this package need to synchronize on the
-// <code>GLRootView</code> instance unless it can be proved that the rendering
-// thread won't access the same thing as the method. The entry points include:
-// (1) The public methods of HeadUpDisplay
-// (2) The public methods of CameraHeadUpDisplay
-// (3) The overridden methods in GLRootView.
-public class GLRootView extends GLSurfaceView
- implements GLSurfaceView.Renderer, GLRoot {
- private static final String TAG = "GLRootView";
-
- private final boolean DEBUG_FPS = false;
- private int mFrameCount = 0;
- private long mFrameCountingStart = 0;
-
- private final boolean DEBUG_INVALIDATE = false;
- private int mInvalidateColor = 0;
-
- private final boolean DEBUG_DRAWING_STAT = false;
-
- private static final int FLAG_INITIALIZED = 1;
- private static final int FLAG_NEED_LAYOUT = 2;
-
- private GL11 mGL;
- private GLCanvasImp mCanvas;
-
- private GLView mContentView;
- private DisplayMetrics mDisplayMetrics;
-
- private int mFlags = FLAG_NEED_LAYOUT;
- private volatile boolean mRenderRequested = false;
-
- private Rect mClipRect = new Rect();
- private int mClipRetryCount = 0;
-
- private final GalleryEGLConfigChooser mEglConfigChooser =
- new GalleryEGLConfigChooser();
-
- private final ArrayList<CanvasAnimation> mAnimations =
- new ArrayList<CanvasAnimation>();
-
- private final LinkedList<OnGLIdleListener> mIdleListeners =
- new LinkedList<OnGLIdleListener>();
-
- private final IdleRunner mIdleRunner = new IdleRunner();
-
- private ReentrantLock mRenderLock = new ReentrantLock();
-
- private static final int TARGET_FRAME_TIME = 33;
- private long mLastDrawFinishTime;
-
- public GLRootView(Context context) {
- this(context, null);
- }
-
- public GLRootView(Context context, AttributeSet attrs) {
- super(context, attrs);
- mFlags |= FLAG_INITIALIZED;
- setBackgroundDrawable(null);
- setEGLConfigChooser(mEglConfigChooser);
- setRenderer(this);
-
- // Uncomment this to enable gl error check.
- //setDebugFlags(DEBUG_CHECK_GL_ERROR);
- }
-
- public GalleryEGLConfigChooser getEGLConfigChooser() {
- return mEglConfigChooser;
- }
-
- public boolean hasStencil() {
- return getEGLConfigChooser().getStencilBits() > 0;
- }
-
- public void registerLaunchedAnimation(CanvasAnimation animation) {
- // Register the newly launched animation so that we can set the start
- // time more precisely. (Usually, it takes much longer for first
- // rendering, so we set the animation start time as the time we
- // complete rendering)
- mAnimations.add(animation);
- }
-
- public void addOnGLIdleListener(OnGLIdleListener listener) {
- mRenderLock.lock();
- try {
- mIdleListeners.addLast(listener);
- if (!mRenderRequested && !mIdleRunner.mActive) {
- mIdleRunner.mActive = true;
- queueEvent(mIdleRunner);
- }
- } finally {
- mRenderLock.unlock();
- }
- }
-
- public void setContentPane(GLView content) {
- if (mContentView != null) {
- mContentView.detachFromRoot();
- BasicTexture.yieldAllTextures();
- }
- if (content != null) {
- mContentView = content;
- content.attachToRoot(this);
- requestLayoutContentPane();
- }
- }
-
- public GLView getContentPane() {
- return mContentView;
- }
-
- @Override
- public void requestRender() {
- if (DEBUG_INVALIDATE) {
- StackTraceElement e = Thread.currentThread().getStackTrace()[4];
- String caller = e.getFileName() + ":" + e.getLineNumber() + " ";
- Log.v(TAG, "invalidate: " + caller);
- }
- if (mRenderRequested) return;
- mRenderRequested = true;
- super.requestRender();
- }
-
- public void requestLayoutContentPane() {
- mRenderLock.lock();
- try {
- if (mContentView == null || (mFlags & FLAG_NEED_LAYOUT) != 0) return;
-
- // "View" system will invoke onLayout() for initialization(bug ?), we
- // have to ignore it since the GLThread is not ready yet.
- if ((mFlags & FLAG_INITIALIZED) == 0) return;
-
- mFlags |= FLAG_NEED_LAYOUT;
- requestRender();
- } finally {
- mRenderLock.unlock();
- }
- }
-
- private void layoutContentPane() {
- mFlags &= ~FLAG_NEED_LAYOUT;
- int width = getWidth();
- int height = getHeight();
- Log.v(TAG, "layout content pane " + width + "x" + height);
- if (mContentView != null && width != 0 && height != 0) {
- mContentView.layout(0, 0, width, height);
- }
- // Uncomment this to dump the view hierarchy.
- //mContentView.dumpTree("");
- }
-
- @Override
- protected void onLayout(
- boolean changed, int left, int top, int right, int bottom) {
- if (changed) requestLayoutContentPane();
- }
-
- /**
- * Called when the context is created, possibly after automatic destruction.
- */
- // This is a GLSurfaceView.Renderer callback
- public void onSurfaceCreated(GL10 gl1, EGLConfig config) {
- GL11 gl = (GL11) gl1;
- if (mGL != null) {
- // The GL Object has changed
- Log.i(TAG, "GLObject has changed from " + mGL + " to " + gl);
- }
- mGL = gl;
- mCanvas = new GLCanvasImp(gl);
- if (!DEBUG_FPS) {
- setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
- } else {
- setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
- }
- }
-
- /**
- * Called when the OpenGL surface is recreated without destroying the
- * context.
- */
- // This is a GLSurfaceView.Renderer callback
- public void onSurfaceChanged(GL10 gl1, int width, int height) {
- Log.v(TAG, "onSurfaceChanged: " + width + "x" + height
- + ", gl10: " + gl1.toString());
- Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY);
- Utils.setRenderThread();
- GL11 gl = (GL11) gl1;
- Utils.Assert(mGL == gl);
-
- mCanvas.setSize(width, height);
-
- mClipRect.set(0, 0, width, height);
- mClipRetryCount = 2;
- }
-
- private void outputFps() {
- long now = System.nanoTime();
- if (mFrameCountingStart == 0) {
- mFrameCountingStart = now;
- } else if ((now - mFrameCountingStart) > 1000000000) {
- Log.v(TAG, "fps: " + (double) mFrameCount
- * 1000000000 / (now - mFrameCountingStart));
- mFrameCountingStart = now;
- mFrameCount = 0;
- }
- ++mFrameCount;
- }
-
- public void onDrawFrame(GL10 gl) {
- long begin = SystemClock.uptimeMillis();
- mRenderLock.lock();
- try {
- onDrawFrameLocked(gl);
- } finally {
- mRenderLock.unlock();
- }
- long end = SystemClock.uptimeMillis();
-
- if (mLastDrawFinishTime != 0) {
- long wait = mLastDrawFinishTime + TARGET_FRAME_TIME - end;
- if (wait > 0) {
- SystemClock.sleep(wait);
- }
- }
- mLastDrawFinishTime = SystemClock.uptimeMillis();
- }
-
- private void onDrawFrameLocked(GL10 gl) {
- if (DEBUG_FPS) outputFps();
-
- // release the unbound textures and deleted buffers.
- mCanvas.deleteRecycledResources();
-
- // reset texture upload limit
- UploadedTexture.resetUploadLimit();
-
- mRenderRequested = false;
-
- if ((mFlags & FLAG_NEED_LAYOUT) != 0) layoutContentPane();
-
- // OpenGL seems having a bug causing us not being able to reset the
- // scissor box in "onSurfaceChanged()". We have to do it in the second
- // onDrawFrame().
- if (mClipRetryCount > 0) {
- --mClipRetryCount;
- Rect clip = mClipRect;
- gl.glScissor(clip.left, clip.top, clip.width(), clip.height());
- }
-
- mCanvas.setCurrentAnimationTimeMillis(SystemClock.uptimeMillis());
- if (mContentView != null) {
- mContentView.render(mCanvas);
- }
-
- if (!mAnimations.isEmpty()) {
- long now = SystemClock.uptimeMillis();
- for (int i = 0, n = mAnimations.size(); i < n; i++) {
- mAnimations.get(i).setStartTime(now);
- }
- mAnimations.clear();
- }
-
- if (UploadedTexture.uploadLimitReached()) {
- requestRender();
- }
-
- if (!mRenderRequested
- && !mIdleRunner.mActive && !mIdleListeners.isEmpty()) {
- mIdleRunner.mActive = true;
- queueEvent(mIdleRunner);
- }
-
- if (DEBUG_INVALIDATE) {
- mCanvas.fillRect(10, 10, 5, 5, mInvalidateColor);
- mInvalidateColor = ~mInvalidateColor;
- }
-
- if (DEBUG_DRAWING_STAT) {
- mCanvas.dumpStatisticsAndClear();
- }
- }
-
- @Override
- public boolean dispatchTouchEvent(MotionEvent event) {
- mRenderLock.lock();
- try {
- // If this has been detached from root, we don't need to handle event
- return mContentView != null
- ? mContentView.dispatchTouchEvent(event)
- : false;
- } finally {
- mRenderLock.unlock();
- }
- }
-
- public DisplayMetrics getDisplayMetrics() {
- if (mDisplayMetrics == null) {
- mDisplayMetrics = new DisplayMetrics();
- ((Activity) getContext()).getWindowManager()
- .getDefaultDisplay().getMetrics(mDisplayMetrics);
- }
- return mDisplayMetrics;
- }
-
- public GLCanvas getCanvas() {
- return mCanvas;
- }
-
- private class IdleRunner implements Runnable {
- protected boolean mActive = false;
-
- private boolean runInternal() {
- if (mRenderRequested) return false;
- if (mIdleListeners.isEmpty()) return false;
- OnGLIdleListener listener = mIdleListeners.removeFirst();
- if (listener.onGLIdle(GLRootView.this, mCanvas)) {
- mIdleListeners.addLast(listener);
- }
- return mIdleListeners.isEmpty();
- }
-
- public void run() {
- mRenderLock.lock();
- try {
- mActive = runInternal();
- if (mActive) queueEvent(this);
- } finally {
- mRenderLock.unlock();
- }
- }
- }
-
- public void lockRenderThread() {
- mRenderLock.lock();
- }
-
- public void unlockRenderThread() {
- mRenderLock.unlock();
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/GLView.java b/new3d/src/com/android/gallery3d/ui/GLView.java
deleted file mode 100644
index 39daa83..0000000
--- a/new3d/src/com/android/gallery3d/ui/GLView.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Rect;
-import android.os.SystemClock;
-import android.view.MotionEvent;
-
-import com.android.gallery3d.anim.CanvasAnimation;
-import com.android.gallery3d.util.Utils;
-
-import java.util.ArrayList;
-
-// GLView is a UI component. It can render to a GLCanvas and accept touch
-// events. A GLView may have zero or more child GLView and they form a tree
-// structure. The rendering and event handling will pass through the tree
-// structure.
-//
-// A GLView tree should be attached to a GLRoot before event dispatching and
-// rendering happens. GLView asks GLRoot to re-render or re-layout the
-// GLView hierarchy using requestRender() and requestLayoutContentPane().
-//
-// The render() method is called in a separate thread. Before calling
-// dispatchTouchEvent() and layout(), GLRoot acquires a lock to avoid the
-// rendering thread running at the same time. If there are other entry points
-// from main thread (like a Handler) in your GLView, you need to call
-// lockRendering() if the rendering thread should not run at the same time.
-//
-public class GLView {
- private static final String TAG = "GLView";
-
- public static final int VISIBLE = 0;
- public static final int INVISIBLE = 1;
-
- private static final int FLAG_INVISIBLE = 1;
- private static final int FLAG_SET_MEASURED_SIZE = 2;
- private static final int FLAG_LAYOUT_REQUESTED = 4;
-
- protected final Rect mBounds = new Rect();
- protected final Rect mPaddings = new Rect();
-
- private GLRoot mRoot;
- protected GLView mParent;
- private ArrayList<GLView> mComponents;
- private GLView mMotionTarget;
-
- private CanvasAnimation mAnimation;
-
- private int mViewFlags = 0;
-
- protected int mMeasuredWidth = 0;
- protected int mMeasuredHeight = 0;
-
- private int mLastWidthSpec = -1;
- private int mLastHeightSpec = -1;
-
- protected int mScrollY = 0;
- protected int mScrollX = 0;
- protected int mScrollHeight = 0;
- protected int mScrollWidth = 0;
-
- public void startAnimation(CanvasAnimation animation) {
- GLRoot root = getGLRoot();
- if (root == null) throw new IllegalStateException();
-
- mAnimation = animation;
- mAnimation.start();
- root.registerLaunchedAnimation(mAnimation);
- invalidate();
- }
-
- // Sets the visiblity of this GLView (either GLView.VISIBLE or
- // GLView.INVISIBLE).
- public void setVisibility(int visibility) {
- if (visibility == getVisibility()) return;
- if (visibility == VISIBLE) {
- mViewFlags &= ~FLAG_INVISIBLE;
- } else {
- mViewFlags |= FLAG_INVISIBLE;
- }
- onVisibilityChanged(visibility);
- invalidate();
- }
-
- // Returns GLView.VISIBLE or GLView.INVISIBLE
- public int getVisibility() {
- return (mViewFlags & FLAG_INVISIBLE) == 0 ? VISIBLE : INVISIBLE;
- }
-
- // This should only be called on the content pane (the topmost GLView).
- public void attachToRoot(GLRoot root) {
- Utils.Assert(mParent == null && mRoot == null);
- onAttachToRoot(root);
- }
-
- // This should only be called on the content pane (the topmost GLView).
- public void detachFromRoot() {
- Utils.Assert(mParent == null && mRoot != null);
- onDetachFromRoot();
- }
-
- // Returns the number of children of the GLView.
- public int getComponentCount() {
- return mComponents == null ? 0 : mComponents.size();
- }
-
- // Returns the children for the given index.
- public GLView getComponent(int index) {
- if (mComponents == null) {
- throw new ArrayIndexOutOfBoundsException(index);
- }
- return mComponents.get(index);
- }
-
- // Adds a child to this GLView.
- public void addComponent(GLView component) {
- // Make sure the component doesn't have a parent currently.
- if (component.mParent != null) throw new IllegalStateException();
-
- // Build parent-child links
- if (mComponents == null) {
- mComponents = new ArrayList<GLView>();
- }
- mComponents.add(component);
- component.mParent = this;
-
- // If this is added after we have a root, tell the component.
- if (mRoot != null) {
- component.onAttachToRoot(mRoot);
- }
- }
-
- // Removes a child from this GLView.
- public boolean removeComponent(GLView component) {
- if (mComponents == null) return false;
- if (mComponents.remove(component)) {
- removeOneComponent(component);
- return true;
- }
- return false;
- }
-
- // Removes all children of this GLView.
- public void removeAllComponents() {
- for (int i = 0, n = mComponents.size(); i < n; ++i) {
- removeOneComponent(mComponents.get(i));
- }
- mComponents.clear();
- }
-
- private void removeOneComponent(GLView component) {
- if (mMotionTarget == component) {
- long now = SystemClock.uptimeMillis();
- dispatchTouchEvent(MotionEvent.obtain(
- now, now, MotionEvent.ACTION_CANCEL, 0, 0, 0));
- }
- component.onDetachFromRoot();
- component.mParent = null;
- }
-
- public Rect bounds() {
- return mBounds;
- }
-
- public int getWidth() {
- return mBounds.right - mBounds.left;
- }
-
- public int getHeight() {
- return mBounds.bottom - mBounds.top;
- }
-
- public GLRoot getGLRoot() {
- return mRoot;
- }
-
- // Request re-rendering of the view hierarchy.
- // This is used for animation or when the contents changed.
- public void invalidate() {
- GLRoot root = getGLRoot();
- if (root != null) root.requestRender();
- }
-
- // Request re-layout of the view hierarchy.
- public void requestLayout() {
- mViewFlags |= FLAG_LAYOUT_REQUESTED;
- if (mParent != null) {
- mParent.requestLayout();
- } else {
- // Is this a content pane ?
- GLRoot root = getGLRoot();
- if (root != null) root.requestLayoutContentPane();
- }
- }
-
- protected void render(GLCanvas canvas) {
- renderBackground(canvas);
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- renderChild(canvas, getComponent(i));
- }
- }
-
- protected void renderBackground(GLCanvas view) {
- }
-
- protected void renderChild(GLCanvas canvas, GLView component) {
- if (component.getVisibility() != GLView.VISIBLE
- && component.mAnimation == null) return;
-
- int xoffset = component.mBounds.left - mScrollX;
- int yoffset = component.mBounds.top - mScrollY;
-
- canvas.translate(xoffset, yoffset, 0);
-
- CanvasAnimation anim = component.mAnimation;
- if (anim != null) {
- canvas.save(anim.getCanvasSaveFlags());
- if (anim.calculate(canvas.currentAnimationTimeMillis())) {
- invalidate();
- } else {
- component.mAnimation = null;
- }
- anim.apply(canvas);
- }
- component.render(canvas);
- if (anim != null) canvas.restore();
- canvas.translate(-xoffset, -yoffset, 0);
- }
-
- protected boolean onTouch(MotionEvent event) {
- return false;
- }
-
- protected boolean dispatchTouchEvent(MotionEvent event,
- int x, int y, GLView component, boolean checkBounds) {
- Rect rect = component.mBounds;
- int left = rect.left;
- int top = rect.top;
- if (!checkBounds || rect.contains(x, y)) {
- event.offsetLocation(-left, -top);
- if (component.dispatchTouchEvent(event)) {
- event.offsetLocation(left, top);
- return true;
- }
- event.offsetLocation(left, top);
- }
- return false;
- }
-
- protected boolean dispatchTouchEvent(MotionEvent event) {
- int x = (int) event.getX();
- int y = (int) event.getY();
- int action = event.getAction();
- if (mMotionTarget != null) {
- if (action == MotionEvent.ACTION_DOWN) {
- MotionEvent cancel = MotionEvent.obtain(event);
- cancel.setAction(MotionEvent.ACTION_CANCEL);
- dispatchTouchEvent(cancel, x, y, mMotionTarget, false);
- mMotionTarget = null;
- } else {
- dispatchTouchEvent(event, x, y, mMotionTarget, false);
- if (action == MotionEvent.ACTION_CANCEL
- || action == MotionEvent.ACTION_UP) {
- mMotionTarget = null;
- }
- return true;
- }
- }
- if (action == MotionEvent.ACTION_DOWN) {
- // in the reverse rendering order
- for (int i = getComponentCount() - 1; i >= 0; --i) {
- GLView component = getComponent(i);
- if (component.getVisibility() != GLView.VISIBLE) continue;
- if (dispatchTouchEvent(event, x, y, component, true)) {
- mMotionTarget = component;
- return true;
- }
- }
- }
- return onTouch(event);
- }
-
- public Rect getPaddings() {
- return mPaddings;
- }
-
- public void setPaddings(Rect paddings) {
- mPaddings.set(paddings);
- }
-
- public void setPaddings(int left, int top, int right, int bottom) {
- mPaddings.set(left, top, right, bottom);
- }
-
- public void layout(int left, int top, int right, int bottom) {
- boolean sizeChanged = setBounds(left, top, right, bottom);
- if (sizeChanged) {
- mViewFlags &= ~FLAG_LAYOUT_REQUESTED;
- onLayout(true, left, top, right, bottom);
- } else if ((mViewFlags & FLAG_LAYOUT_REQUESTED)!= 0) {
- mViewFlags &= ~FLAG_LAYOUT_REQUESTED;
- onLayout(false, left, top, right, bottom);
- }
- }
-
- private boolean setBounds(int left, int top, int right, int bottom) {
- boolean sizeChanged = (right - left) != (mBounds.right - mBounds.left)
- || (bottom - top) != (mBounds.bottom - mBounds.top);
- mBounds.set(left, top, right, bottom);
- return sizeChanged;
- }
-
- public void measure(int widthSpec, int heightSpec) {
- if (widthSpec == mLastWidthSpec && heightSpec == mLastHeightSpec
- && (mViewFlags & FLAG_LAYOUT_REQUESTED) == 0) {
- return;
- }
-
- mLastWidthSpec = widthSpec;
- mLastHeightSpec = heightSpec;
-
- mViewFlags &= ~FLAG_SET_MEASURED_SIZE;
- onMeasure(widthSpec, heightSpec);
- if ((mViewFlags & FLAG_SET_MEASURED_SIZE) == 0) {
- throw new IllegalStateException(getClass().getName()
- + " should call setMeasuredSize() in onMeasure()");
- }
- }
-
- protected void onMeasure(int widthSpec, int heightSpec) {
- }
-
- protected void setMeasuredSize(int width, int height) {
- mViewFlags |= FLAG_SET_MEASURED_SIZE;
- mMeasuredWidth = width;
- mMeasuredHeight = height;
- }
-
- public int getMeasuredWidth() {
- return mMeasuredWidth;
- }
-
- public int getMeasuredHeight() {
- return mMeasuredHeight;
- }
-
- protected void onLayout(
- boolean changeSize, int left, int top, int right, int bottom) {
- }
-
- /**
- * Gets the bounds of the given descendant that relative to this view.
- */
- public boolean getBoundsOf(GLView descendant, Rect out) {
- int xoffset = 0;
- int yoffset = 0;
- GLView view = descendant;
- while (view != this) {
- if (view == null) return false;
- Rect bounds = view.mBounds;
- xoffset += bounds.left;
- yoffset += bounds.top;
- view = view.mParent;
- }
- out.set(xoffset, yoffset, xoffset + descendant.getWidth(),
- yoffset + descendant.getHeight());
- return true;
- }
-
- protected void onVisibilityChanged(int visibility) {
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- GLView child = getComponent(i);
- if (child.getVisibility() == GLView.VISIBLE) {
- child.onVisibilityChanged(visibility);
- }
- }
- }
-
- protected void onAttachToRoot(GLRoot root) {
- mRoot = root;
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- getComponent(i).onAttachToRoot(root);
- }
- }
-
- protected void onDetachFromRoot() {
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- getComponent(i).onDetachFromRoot();
- }
- mRoot = null;
- }
-
- protected void lockRendering() {
- if (mRoot != null) {
- mRoot.lockRenderThread();
- }
- }
-
- protected void unlockRendering() {
- if (mRoot != null) {
- mRoot.unlockRenderThread();
- }
- }
-
- // This is for debugging only.
- // Dump the view hierarchy into log.
- void dumpTree(String prefix) {
- Log.v(TAG, prefix + getClass().getSimpleName());
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- getComponent(i).dumpTree(prefix + "....");
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java b/new3d/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java
deleted file mode 100644
index cbd5e31..0000000
--- a/new3d/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.gallery3d.ui;
-
-import android.opengl.GLSurfaceView.EGLConfigChooser;
-import android.util.Log;
-
-import javax.microedition.khronos.egl.EGL10;
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.egl.EGLDisplay;
-
-/*
- * The code is copied/adapted from
- * <code>android.opengl.GLSurfaceView.BaseConfigChooser</code>. Here we try to
- * choose a configuration that support RGBA_8888 format and if possible,
- * with stencil buffer, but is not required.
- */
-class GalleryEGLConfigChooser implements EGLConfigChooser {
-
- private static final String TAG = "GalleryEGLConfigChooser";
- private int mStencilBits;
-
- private final int mConfigSpec[] = new int[] {
- EGL10.EGL_RED_SIZE, 5,
- EGL10.EGL_GREEN_SIZE, 6,
- EGL10.EGL_BLUE_SIZE, 5,
- EGL10.EGL_ALPHA_SIZE, 0,
- EGL10.EGL_NONE
- };
-
- public int getStencilBits() {
- return mStencilBits;
- }
-
- public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
- int[] numConfig = new int[1];
- if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, numConfig)) {
- throw new RuntimeException("eglChooseConfig failed");
- }
-
- if (numConfig[0] <= 0) {
- throw new RuntimeException("No configs match configSpec");
- }
-
- EGLConfig[] configs = new EGLConfig[numConfig[0]];
- if (!egl.eglChooseConfig(display,
- mConfigSpec, configs, configs.length, numConfig)) {
- throw new RuntimeException();
- }
-
- return chooseConfig(egl, display, configs);
- }
-
- private EGLConfig chooseConfig(
- EGL10 egl, EGLDisplay display, EGLConfig configs[]) {
-
- EGLConfig result = null;
- int minStencil = Integer.MAX_VALUE;
- int value[] = new int[1];
-
- // Because we need only one bit of stencil, try to choose a config that
- // has stencil support but with smallest number of stencil bits. If
- // none is found, choose any one.
- for (int i = 0, n = configs.length; i < n; ++i) {
- if (egl.eglGetConfigAttrib(
- display, configs[i], EGL10.EGL_RED_SIZE, value)) {
- // Filter out ARGB 8888 configs.
- if (value[0] == 8) continue;
- }
- if (egl.eglGetConfigAttrib(
- display, configs[i], EGL10.EGL_STENCIL_SIZE, value)) {
- if (value[0] == 0) continue;
- if (value[0] < minStencil) {
- minStencil = value[0];
- result = configs[i];
- }
- } else {
- throw new RuntimeException(
- "eglGetConfigAttrib error: " + egl.eglGetError());
- }
- }
- if (result == null) result = configs[0];
- egl.eglGetConfigAttrib(
- display, result, EGL10.EGL_STENCIL_SIZE, value);
- mStencilBits = value[0];
- logConfig(egl, display, result);
- return result;
- }
-
- private static final int[] ATTR_ID = {
- EGL10.EGL_RED_SIZE,
- EGL10.EGL_GREEN_SIZE,
- EGL10.EGL_BLUE_SIZE,
- EGL10.EGL_ALPHA_SIZE,
- EGL10.EGL_DEPTH_SIZE,
- EGL10.EGL_STENCIL_SIZE,
- EGL10.EGL_CONFIG_ID,
- EGL10.EGL_CONFIG_CAVEAT
- };
-
- private static final String[] ATTR_NAME = {
- "R", "G", "B", "A", "D", "S", "ID", "CAVEAT"
- };
-
- private void logConfig(EGL10 egl, EGLDisplay display, EGLConfig config) {
- int value[] = new int[1];
- StringBuilder sb = new StringBuilder();
- for (int j = 0; j < ATTR_ID.length; j++) {
- egl.eglGetConfigAttrib(display, config, ATTR_ID[j], value);
- sb.append(ATTR_NAME[j] + value[0] + " ");
- }
- Log.v(TAG, "Config chosen: " + sb.toString());
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/HeadUpDisplay.java b/new3d/src/com/android/gallery3d/ui/HeadUpDisplay.java
deleted file mode 100644
index fdbc3ab..0000000
--- a/new3d/src/com/android/gallery3d/ui/HeadUpDisplay.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.view.MotionEvent;
-import android.view.View.MeasureSpec;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.util.Utils;
-
-public class HeadUpDisplay extends GLView {
- private static final int POPUP_WINDOW_OVERLAP = 20;
- private static final int POPUP_TRIANGLE_OFFSET = 15;
-
- private static final float MAX_HEIGHT_RATIO = 0.8f;
- private static final float MAX_WIDTH_RATIO = 0.8f;
-
- private static int sPopupWindowOverlap = -1;
- private static int sPopupTriangleOffset;
-
- private MenuItemBar mBottomBar;
- private MenuBar mTopBar;
- private HudMenuInterface mMenu;
-
- private final Context mContext;
-
- private PopupWindow mPopupWindow;
- private GLListView mListView;
-
- private GLView mAnchorView;
-
- private ResourceTexture mPathIcons[];
- private String mPathTitle[];
-
- private static void initializeStaticVariables(Context context) {
- if (sPopupWindowOverlap >= 0) return;
-
- sPopupWindowOverlap = Utils.dpToPixel(context, POPUP_WINDOW_OVERLAP);
- sPopupTriangleOffset = Utils.dpToPixel(context, POPUP_TRIANGLE_OFFSET);
- }
-
- public HeadUpDisplay(Context context) {
- initializeStaticVariables(context);
- mContext = context;
- }
-
- @Override
- protected void onLayout(
- boolean changesize, int left, int top, int right, int bottom) {
- int width = right - left;
- int height = bottom - top;
- int widthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
- int heightSpec = MeasureSpec.UNSPECIFIED;
- mTopBar.measure(widthSpec, heightSpec);
- mBottomBar.measure(widthSpec, heightSpec);
-
- mTopBar.layout(0, 0, width, mTopBar.getMeasuredHeight());
- mBottomBar.layout(
- 0, height - mBottomBar.getMeasuredHeight(), width, height);
- if (mPopupWindow != null
- && mPopupWindow.getVisibility() == GLView.VISIBLE) {
- this.layoutPopupWindow(mAnchorView);
- }
- }
-
- public void setMenu(HudMenuInterface menu) {
- mMenu = menu;
-
- mTopBar = menu.getTopMenuBar();
- mBottomBar = menu.getBottomMenuBar();
- addComponent(mTopBar);
- addComponent(mBottomBar);
-
- mBottomBar.setOnSelectedListener(new BottomBarSelectedListener());
- }
-
- @Override
- protected boolean onTouch(MotionEvent event) {
- if (mPopupWindow != null &&
- mPopupWindow.getVisibility() == GLView.VISIBLE) {
- mBottomBar.setSelectedItem(null);
- return true;
- }
- return false;
- }
-
- @Override
- protected boolean dispatchTouchEvent(MotionEvent event,
- int x, int y, GLView component, boolean checkBounds) {
- if (mPopupWindow != null
- && mPopupWindow.getVisibility() == GLView.VISIBLE
- && component != mPopupWindow && component != mBottomBar) {
- return false;
- }
- return super.dispatchTouchEvent(event, x, y, component, checkBounds);
- }
-
- private void layoutPopupWindow(GLView anchorView) {
- mAnchorView = anchorView;
-
- Rect rect = new Rect();
- getBoundsOf(anchorView, rect);
-
- int width = (int) (getWidth() * MAX_WIDTH_RATIO + .5);
- int height = (int) (getHeight() * MAX_HEIGHT_RATIO + .5);
-
- mPopupWindow.measure(
- MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST),
- MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
-
- width = mPopupWindow.getMeasuredWidth();
- height = mPopupWindow.getMeasuredHeight();
-
- int anchorX = (rect.left + rect.right) / 2;
- int anchorY = rect.top + sPopupWindowOverlap;
-
- int xoffset = Utils.clamp(anchorX - width / 2, 0, getWidth() - width);
- int yoffset = Math.max(0, anchorY - height);
-
- mPopupWindow.setAnchorPosition(anchorX - xoffset);
- mPopupWindow.layout(
- xoffset, yoffset, xoffset + width, yoffset + height);
- }
-
- private void initializePopupWindow() {
- Context context = mContext;
- mListView = new GLListView(context);
- mListView.setOnItemSelectedListener(new PopupMenuItemListener());
- mPopupWindow = new PopupWindow();
-
- mPopupWindow.setBackground(
- new NinePatchTexture(context, R.drawable.popup));
- mPopupWindow.setAnchor(new ResourceTexture(
- context, R.drawable.popup_triangle_bottom),
- (int) (sPopupTriangleOffset + 0.5));
- mListView.setHighLight(new NinePatchTexture(
- context, R.drawable.popup_option_selected));
- mPopupWindow.setContent(mListView);
- mPopupWindow.setVisibility(GLView.INVISIBLE);
- super.addComponent(mPopupWindow);
- }
-
- private class PopupMenuItemListener implements GLListView.OnItemSelectedListener {
- public void onItemSelected(GLView view, int position) {
- if (mMenu != null) mMenu.onMenuItemSelected(mListView.getDataModel(), position);
- mPopupWindow.popoff();
- }
- }
-
- private class BottomBarSelectedListener implements OnSelectedListener {
- public void onSelected(GLView source) {
- if (source == null) {
- mPopupWindow.popoff();
- } else {
- if (mPopupWindow == null) initializePopupWindow();
- mListView.setDataModel(mMenu.getMenuModel(source));
- layoutPopupWindow(source);
- if (mPopupWindow.getVisibility() != GLView.VISIBLE) {
- mPopupWindow.popup();
- }
- }
- }
- }
-
- public int getTopBarBottomPosition() {
- Rect rect = new Rect();
- getBoundsOf(mTopBar, rect);
- return rect.bottom;
- }
-
- public int getBottomBarTopPosition() {
- Rect rect = new Rect();
- getBoundsOf(mBottomBar, rect);
- return rect.top;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/HudMenu.java b/new3d/src/com/android/gallery3d/ui/HudMenu.java
deleted file mode 100644
index 013000d..0000000
--- a/new3d/src/com/android/gallery3d/ui/HudMenu.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.app.ProgressDialog;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.os.Handler;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.data.DataManager;
-import com.android.gallery3d.data.MediaSet;
-import com.android.gallery3d.ui.MenuExecutor.MediaOperation;
-import com.android.gallery3d.ui.MenuExecutor.OnProgressUpdateListener;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class HudMenu implements HudMenuInterface, SelectionManager.SelectionListener {
- private static final String TAG = "HudMenu";
- private static final int DELETE_MODEL = 0;
- private static final int MORE_MODEL = 1;
- private static final int SHARE_IMAGE_MODEL = 2;
- private static final int SHARE_VIDEO_MODEL = 3;
- private static final int SHARE_ALL_MODEL = 4;
- private static final int TOTAL_MODEL_COUNT = 5;
-
- GalleryContext mContext;
- MenuBar mTopBar;
- MenuItemBar mBottomBar;
- NinePatchTexture mHighlight;
- SelectionManager mSelectionManager;
- MenuModel[] mMenuModels;
- MenuExecutor mMenuExecutor;
- MenuItem mShare;
- MenuItem mDelete;
- MenuItem mMore;
- ProgressUpdateDialog mDialog;
-
- private class ProgressUpdateDialog extends ProgressDialog implements OnProgressUpdateListener {
- Handler mUiHandler;
- MediaOperation mOperation;
- boolean mIsDead;
-
- public ProgressUpdateDialog(int title, int total) {
- super(mContext.getAndroidContext());
- setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
- mUiHandler = new Handler();
- setTitle(title);
- setMax(total);
- show();
- }
-
- /**
- * The following two methods are callbacks from data thread.
- */
- public void onProgressUpdate(final int index, Object result) {
- mUiHandler.post(new Runnable() {
- public void run() {
- if (!mIsDead) setProgress(index);
- }
- });
- }
-
- public void onProgressComplete() {
- // SourceMediaSet remains unchanged since SelectionManager is created so race condition
- // between UI and data threads is not a concern here.
- // reload has to be called from data thread.
- mSelectionManager.getSourceMediaSet().reload();
- // dismiss() can be called from any thread.
- dismiss();
- }
-
- // This will be called when back is pressed or dismiss() is called.
- protected void onStop() {
- stop();
- mSelectionManager.leaveSelectionMode();
- }
-
- public void stop() {
- if (!mIsDead) {
- mIsDead = true;
- mOperation.cancel();
- }
- }
-
- public void setOperation(MediaOperation operation) {
- mOperation = operation;
- }
- }
-
- public HudMenu(GalleryContext context, SelectionManager manager) {
- mContext = context;
- mSelectionManager = manager;
- mHighlight = new NinePatchTexture(context.getAndroidContext(), R.drawable.menu_highlight);
- manager.setSelectionListener(this);
- mMenuModels = new MenuModel[TOTAL_MODEL_COUNT];
- mMenuExecutor = new MenuExecutor(context.getDataManager());
- }
-
- public void onPause() {
- if (mDialog != null) {
- mDialog.stop();
- mDialog = null;
- }
- }
-
- public MenuBar getTopMenuBar() {
- if (mTopBar == null) createTopMenuBar();
- return mTopBar;
- }
-
- public MenuItemBar getBottomMenuBar() {
- if (mBottomBar == null) createBottomMenuBar();
- return mBottomBar;
- }
-
- protected void createTopMenuBar() {
- Context context = mContext.getAndroidContext();
- mTopBar = new MenuBar(GLView.INVISIBLE);
- mTopBar.setBackground(new NinePatchTexture(context, R.drawable.top_menu_bar_bg));
-
- // Select all
- MenuButton btn = new MenuButton(context, IconLabel.NULL_ID, R.string.select_all);
- btn.setHighlight(mHighlight);
- btn.setOnClickListener(new MenuButton.OnClickedListener() {
- public void onClicked(GLView source) {
- mSelectionManager.selectAll();
- }
- });
- mTopBar.addComponent(btn);
-
- // Deselect all
- mTopBar.addComponent(new IconLabel(context, IconLabel.NULL_ID, R.string.items));
- btn = new MenuButton(context, IconLabel.NULL_ID, R.string.deselect_all);
- btn.setHighlight(mHighlight);
- btn.setOnClickListener(new MenuButton.OnClickedListener() {
- public void onClicked(GLView source) {
- mSelectionManager.deSelectAll();
- }
- });
- mTopBar.addComponent(btn);
- }
-
- public class MenuModel implements GLListView.Model {
- ArrayList<MenuItem> mItems;
- public MenuModel() {
- mItems = new ArrayList<MenuItem>();
- }
-
- public MenuModel(MenuItem[] items) {
- mItems = new ArrayList<MenuItem>(items.length);
- for (MenuItem item : items) {
- mItems.add(item);
- }
- }
-
- public void addItem(MenuItem item) {
- mItems.add(item);
- }
-
- public GLView getView(int index) {
- return mItems.get(index);
- }
-
- public boolean isSelectable(int index) {
- return true;
- }
-
- public int size() {
- return mItems.size();
- }
-
- /**
- * Handle the menu operation here.
- */
- public void onItemSelected(int position) {
- MenuItem item = (MenuItem) getView(position);
- int title;
- int action = item.getItemId();
- switch (action) {
- case MenuExecutor.ACTION_DELETE:
- title = R.string.delete;
- break;
- case MenuExecutor.ACTION_ROTATE_CW:
- title = R.string.rotate_right;
- break;
- case MenuExecutor.ACTION_ROTATE_CCW:
- title = R.string.rotate_left;
- break;
- case MenuExecutor.ACTION_DETAILS:
- title = R.string.details;
- break;
- default:
- return;
- }
-
- ArrayList<Long> ids = mSelectionManager.getSelected(false);
- if (mDialog != null) mDialog.stop();
- mDialog = new ProgressUpdateDialog(title, ids.size());
- MediaOperation operation = mMenuExecutor.startMediaOperation(action, ids, mDialog);
- mDialog.setOperation(operation);
- }
- }
-
- private class ShareModel extends MenuModel {
- List<ResolveInfo> mInfo;
- Intent mIntent;
-
- public ShareModel(int shareType) {
- Context context = mContext.getAndroidContext();
- mIntent = new Intent(Intent.ACTION_SEND);
- switch (shareType) {
- case SHARE_IMAGE_MODEL:
- mIntent.setType("image/*");
- break;
- case SHARE_VIDEO_MODEL:
- mIntent.setType("video/*");
- break;
- default:
- mIntent.setType("*/*");
- }
- PackageManager packageManager = context.getPackageManager();
- mInfo = packageManager.queryIntentActivities(mIntent, 0);
- for(ResolveInfo info : mInfo) {
- String label = info.loadLabel(packageManager).toString();
- Drawable icon = info.loadIcon(packageManager);
- MenuItem item = createMenuItem(context, icon, label);
- addItem(item);
- }
- }
-
- private MenuItem createMenuItem(Context context, Drawable icon, String title) {
- DrawableTexture iconTexture = null;
- if (icon != null) {
- iconTexture = new DrawableTexture(icon);
- float target = 45;
- int width = icon.getIntrinsicWidth();
- int height = icon.getIntrinsicHeight();
- float scale = target / Math.max(width, height);
- iconTexture.setSize((int) (width * scale + .5f),
- (int) (height * scale + .5f));
- }
- MenuItem item = new MenuItem(context, iconTexture, title);
- item.setHighlight(mHighlight);
- return item;
- }
-
- public void onItemSelected(int position) {
- ResolveInfo info = mInfo.get(position);
- ArrayList<Long> items = mSelectionManager.getSelected(true);
- ArrayList<Uri> uris = new ArrayList<Uri>(items.size());
- DataManager manager = mContext.getDataManager();
- for (Long id : items) {
- if ((manager.getSupportedOperations(id) & MediaSet.SUPPORT_SHARE) != 0) {
- uris.add(manager.getMediaItemUri(id));
- }
- }
-
- if (uris.isEmpty()) {
- // TODO: explain to user that some items can't be shared.
- throw new UnsupportedOperationException();
- } else if (uris.size() == 1) {
- mIntent.setAction(Intent.ACTION_SEND);
- mIntent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
- } else {
- mIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
- mIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
- }
- ActivityInfo ai = info.activityInfo;
- mIntent.setComponent(new ComponentName(ai.packageName, ai.name));
- mContext.getAndroidContext().startActivity(mIntent);
- }
- }
-
- protected void createBottomMenuBar() {
- Context context = mContext.getAndroidContext();
- mBottomBar = new MenuItemBar(GLView.INVISIBLE);
- mBottomBar.setBackground(
- new NinePatchTexture(context, R.drawable.top_menu_bar_bg));
-
- // Share menu
- mShare = new MenuItem(context, R.drawable.icon_share, R.string.share, mHighlight);
- mBottomBar.addComponent(mShare);
-
- // Delete menu & its submenu
- mDelete = new MenuItem(context, R.drawable.icon_delete, R.string.delete
- , mHighlight);
- mMenuModels[DELETE_MODEL] = new MenuModel(new MenuItem[] {
- new MenuItem(context, R.drawable.icon_delete, R.string.confirm_delete,
- mHighlight, MenuExecutor.ACTION_DELETE),
- new MenuItem(context, R.drawable.icon_cancel, R.string.cancel,
- mHighlight)
- });
- mBottomBar.addComponent(mDelete);
-
- // More menu & its submenu
- mMore = new MenuItem(context, R.drawable.icon_more, R.string.more, mHighlight);
- mMenuModels[MORE_MODEL] = new MenuModel(new MenuItem[] {
- new MenuItem(context, R.drawable.icon_details, R.string.details,
- mHighlight, MenuExecutor.ACTION_DETAILS),
- new MenuItem(context, R.drawable.icon_details, R.string.rotate_right,
- mHighlight, MenuExecutor.ACTION_ROTATE_CW),
- new MenuItem(context, R.drawable.icon_details, R.string.rotate_left,
- mHighlight, MenuExecutor.ACTION_ROTATE_CCW),
- });
- mBottomBar.addComponent(mMore);
- }
-
- private int getShareType() {
- ArrayList<Long> items = mSelectionManager.getSelected(false);
- DataManager manager = mContext.getDataManager();
- int type = 0;
-
- for (long id : items) {
- type |= manager.getMediaType(id);
- }
-
- switch (type) {
- case MediaSet.MEDIA_TYPE_IMAGE:
- return SHARE_IMAGE_MODEL;
- case MediaSet.MEDIA_TYPE_VIDEO:
- return SHARE_VIDEO_MODEL;
- default:
- return SHARE_ALL_MODEL;
- }
- }
-
- public GLListView.Model getMenuModel(GLView item) {
- if (item == mDelete) {
- return mMenuModels[DELETE_MODEL];
- } else if (item == mMore) {
- return mMenuModels[MORE_MODEL];
- } else if (item == mShare) {
- int shareType = getShareType();
- if (mMenuModels[shareType] == null) {
- mMenuModels[shareType] = new ShareModel(shareType);
- }
- return mMenuModels[shareType];
- }
-
- return null;
- }
-
- public void onMenuItemSelected(GLListView.Model listViewModel, int position) {
- MenuModel model = (MenuModel) listViewModel;
- model.onItemSelected(position);
- }
-
- public void onSelectionModeChange(boolean inSelectionMode) {
- int visibility = inSelectionMode ? GLView.VISIBLE : GLView.INVISIBLE;
- getTopMenuBar().setVisibility(visibility);
- getBottomMenuBar().setVisibility(visibility);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/HudMenuInterface.java b/new3d/src/com/android/gallery3d/ui/HudMenuInterface.java
deleted file mode 100644
index af48f57..0000000
--- a/new3d/src/com/android/gallery3d/ui/HudMenuInterface.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.android.gallery3d.ui;
-
-public interface HudMenuInterface {
- public MenuBar getTopMenuBar();
- public MenuItemBar getBottomMenuBar();
- public GLListView.Model getMenuModel(GLView item);
- public void onMenuItemSelected(GLListView.Model model, int index);
-}
diff --git a/new3d/src/com/android/gallery3d/ui/IconLabel.java b/new3d/src/com/android/gallery3d/ui/IconLabel.java
deleted file mode 100644
index b338e2d..0000000
--- a/new3d/src/com/android/gallery3d/ui/IconLabel.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.content.Context;
-import android.graphics.Color;
-import android.graphics.Rect;
-
-import com.android.gallery3d.util.Utils;
-
-public class IconLabel extends GLView {
-
- public static final int NULL_ID = 0;
-
- private static final int FONT_COLOR = Color.WHITE;
- private static final float FONT_SIZE = 18;
-
- private static final int MINIMAL_HEIGHT = 32;
-
- private static final int NO_ICON_LEADING_SPACE = 10;
- private static final int TEXT_LEFT_PADDING = 6;
- private static final int TEXT_RIGHT_PADDING = 10;
-
- private static final float ENABLED_ALPHA = 1f;
- private static final float DISABLED_ALPHA = 0.3f;
-
- private static final int HORIZONTAL_PADDINGS = 4;
- private static final int VERTICAL_PADDINGS = 2;
-
- private static int sNoIconLeadingSpace;
- private static int sTextLeftPadding;
- private static int sTextRightPadding;
- private static int sMinimalHeight;
- private static float sFontSize;
- private static int sHorizontalPaddings = -1;
- private static int sVerticalPaddings;
-
- private final BasicTexture mIcon;
- private final StringTexture mText;
- private boolean mEnabled = true;
-
- private static void initializeStaticVariables(Context context) {
- if (sHorizontalPaddings >= 0) return;
-
- sNoIconLeadingSpace = Utils.dpToPixel(context, NO_ICON_LEADING_SPACE);
- sTextLeftPadding = Utils.dpToPixel(context, TEXT_LEFT_PADDING);
- sTextRightPadding = Utils.dpToPixel(context, TEXT_RIGHT_PADDING);
- sMinimalHeight = Utils.dpToPixel(context, MINIMAL_HEIGHT);
- sHorizontalPaddings = Utils.dpToPixel(context, HORIZONTAL_PADDINGS);
- sVerticalPaddings = Utils.dpToPixel(context, VERTICAL_PADDINGS);
-
- sFontSize = Utils.dpToPixel(context, FONT_SIZE);
- }
-
- public IconLabel(Context context, int iconId, int stringId) {
- this(context, iconId == NULL_ID
- ? null : new ResourceTexture(context, iconId),
- context.getString(stringId));
- initializeStaticVariables(context);
- }
-
- public IconLabel(Context context, BasicTexture icon, String label) {
- initializeStaticVariables(context);
- mIcon = icon;
- mText = StringTexture.newInstance(label, sFontSize, FONT_COLOR);
- setPaddings(sHorizontalPaddings,
- sVerticalPaddings, sHorizontalPaddings, sVerticalPaddings);
- }
-
- @Override
- protected void onMeasure(int widthSpec, int heightSpec) {
- int width = mIcon == null ? sNoIconLeadingSpace : mIcon.getWidth();
- width += mText.getWidth();
- width += sTextRightPadding + sTextLeftPadding;
- int height = Math.max(
- mText.getHeight(), mIcon == null ? 0 : mIcon.getHeight());
- height = Math.max(sMinimalHeight, height);
- MeasureHelper.getInstance(this)
- .setPreferredContentSize(width, height)
- .measure(widthSpec, heightSpec);
- }
-
- @Override
- protected void render(GLCanvas canvas) {
- /*
- * The layout: |--padding--|--mIcon--|--sTextLeftPadding--|--mText--|
- * --mTextRightPadding--|--padding--|
- */
- Rect p = mPaddings;
-
- int width = getWidth() - p.left - p.right;
- int height = getHeight() - p.top - p.bottom;
-
- int xoffset = p.left;
-
- float oldAlpha = canvas.getAlpha();
- canvas.multiplyAlpha(mEnabled ? ENABLED_ALPHA : DISABLED_ALPHA);
-
- BasicTexture icon = mIcon;
- if (icon != null) {
- icon.draw(canvas, xoffset,
- p.top + (height - icon.getHeight()) / 2);
- xoffset += icon.getWidth();
- } else {
- xoffset += sNoIconLeadingSpace;
- }
-
- StringTexture title = mText;
- xoffset += sTextLeftPadding;
- int yoffset = p.top + (height - title.getHeight()) / 2;
- //TODO: cut the text if it is too long
- title.draw(canvas, xoffset, yoffset);
-
- canvas.setAlpha(oldAlpha);
- }
-
- public void setEnabled(boolean enabled) {
- if (mEnabled == enabled) return;
- mEnabled = enabled;
- invalidate();
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/ImageViewer.java b/new3d/src/com/android/gallery3d/ui/ImageViewer.java
deleted file mode 100644
index 10a13b5..0000000
--- a/new3d/src/com/android/gallery3d/ui/ImageViewer.java
+++ /dev/null
@@ -1,1118 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.LargeBitmap;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.graphics.Bitmap.Config;
-import android.os.SystemClock;
-import android.util.Log;
-import android.view.GestureDetector;
-import android.view.MotionEvent;
-import android.view.ScaleGestureDetector;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.util.Utils;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public class ImageViewer extends GLView {
- public static final int SIZE_UNKNOWN = -1;
-
- private static final String TAG = "ImageViewer";
-
- // TILE_SIZE must be 2^N - 2. We put one pixel border in each side of the
- // texture to avoid seams between tiles.
- private static final int TILE_SIZE = 254;
- private static final int TILE_BORDER = 1;
- private static final int UPLOAD_LIMIT = 1;
-
- private static final int ENTRY_CURRENT = Model.INDEX_CURRENT;
- private static final int ENTRY_PREVIOUS = Model.INDEX_PREVIOUS;
- private static final int ENTRY_NEXT = Model.INDEX_NEXT;
-
- private static final int IMAGE_GAP = 64;
- private static final int SWITCH_THRESHOLD = 96;
-
- private static final int THRESHOLD_TO_DOWNSCALE = 480;
-
- // the previous/current/next image entries
- private final ScreenNailEntry mScreenNails[] = new ScreenNailEntry[3];
-
- private LargeBitmap mLargeBitmap;
- private int mLevelCount; // cache the value of mScaledBitmaps.length
-
-
- // The mLevel variable indicates which level of bitmap we should use.
- // Level 0 means the original full-sized bitmap, and a larger value means
- // a smaller scaled bitmap (The width and height of each scaled bitmap is
- // half size of the previous one). If the value is in [0, mLevelCount), we
- // use the bitmap in mScaledBitmaps[mLevel] for display, otherwise the value
- // is mLevelCount, and that means we use mBackupTexture for display.
- private int mLevel = 0;
-
- // The offsets of the (left, top) of the upper-left tile to the (left, top)
- // of the view.
- private int mOffsetX;
- private int mOffsetY;
-
- private int mUploadQuota;
- private boolean mRenderComplete;
-
- private final RectF mSourceRect = new RectF();
- private final RectF mTargetRect = new RectF();
-
- private final ScaleGestureDetector mScaleDetector;
- private final GestureDetector mGestureDetector;
- private final DownUpDetector mDownUpDetector;
-
- private final HashMap<Long, Tile> mActiveTiles = new HashMap<Long, Tile>();
- private Iterator<Tile> mUploadIter;
-
- private Tile mRecycledHead = null;
-
- // The width and height of the full-sized bitmap
- private int mImageWidth;
- private int mImageHeight;
-
- private int mCenterX;
- private int mCenterY;
- private float mScale;
-
- // Temp variables to avoid memory allocation
- private final Rect mTileRange = new Rect();
- private final Rect mActiveRange[] = {new Rect(), new Rect()};
-
- private final Uploader mUploader = new Uploader();
- private final AnimationController mAnimationController;
-
- private Model mModel;
- private int mSwitchIndex;
-
- private boolean isTextureFreed = false;
- /*private*/ boolean mInTransition = false;
-
- public ImageViewer(GalleryContext context) {
-
- mGestureDetector = new GestureDetector(context.getAndroidContext(),
- new MyGestureListener(), null, true /* ignoreMultitouch */);
- mScaleDetector = new ScaleGestureDetector(
- context.getAndroidContext(), new MyScaleListener());
- mDownUpDetector = new DownUpDetector(new MyDownUpListener());
-
- mAnimationController = new AnimationController(this);
-
- for (int i = 0, n = mScreenNails.length; i < n; ++i) {
- mScreenNails[i] = new ScreenNailEntry();
- }
- }
-
- public void setModel(Model model) {
- mModel = model;
- notifyScreenNailInvalidated(ENTRY_CURRENT);
- notifyScreenNailInvalidated(ENTRY_PREVIOUS);
- notifyScreenNailInvalidated(ENTRY_NEXT);
- notifyLargeBitmapInvalidated();
-
- resetCurrentImagePosition();
- }
-
- public void notifyLargeBitmapInvalidated() {
- mLargeBitmap = mModel.getLargeBitmap();
- Bitmap screennail = mScreenNails[ENTRY_CURRENT].mBitmap;
- int minLength = THRESHOLD_TO_DOWNSCALE;
- if (screennail != null) {
- minLength = Math.max(screennail.getWidth(), screennail.getHeight());
- }
- if (mLargeBitmap != null) {
- mLevelCount = calcuateLevelCount(mLargeBitmap.getWidth(),
- mLargeBitmap.getHeight(), minLength);
- layoutTiles(mCenterX, mCenterY, mScale);
- invalidate();
- } else {
- mLevelCount = 0;
- }
- }
-
- public int calcuateLevelCount(int width, int height, int minLength) {
- int side = width < height ? width : height;
- return Math.max(0, ceilLog2((float) side / minLength));
- }
-
- public void notifyScreenNailInvalidated(int which) {
- ScreenNailEntry entry = mScreenNails[which];
-
- ImageData data = mModel.getImageData(which);
- if (data == null) {
- entry.set(0, 0, null);
- } else {
- entry.set(data.fullWidth, data.fullHeight, data.screenNail);
- if (which == ENTRY_CURRENT) resetCurrentImagePosition();
- }
- layoutScreenNails(mCenterX, mCenterY, mScale);
- if (entry.mVisible) invalidate();
- }
-
- private void resetCurrentImagePosition() {
- ScreenNailEntry entry = mScreenNails[ENTRY_CURRENT];
- mImageWidth = entry.mWidth;
- mImageHeight = entry.mHeight;
- mAnimationController.onNewImage(mImageWidth, mImageHeight);
- }
-
- @Override
- protected boolean onTouch(MotionEvent event) {
- mGestureDetector.onTouchEvent(event);
- mScaleDetector.onTouchEvent(event);
- mDownUpDetector.onTouchEvent(event);
- return true;
- }
-
- private static int ceilLog2(float value) {
- int i;
- for (i = 0; i < 30; i++) {
- if ((1 << i) >= value) break;
- }
- return i;
- }
-
- @Override
- protected void onLayout(boolean changeSize, int l, int t, int r, int b) {
- if (changeSize) {
- mAnimationController.updateViewSize(getWidth(), getHeight());
- }
- }
-
- private static int gapToSide(int imageWidth, int viewWidth, float scale) {
- return Math.max(0, Math.round(viewWidth - imageWidth * scale) / 2);
- }
-
- /*
- * Here is how we layout the screen nails
- *
- * previous current next
- * ___________ ________________ __________
- * | _______ | | __________ | | ______ |
- * | | | | | | right->| | | | | |
- * | | | |<--->| |<--left | | | | | |
- * | |_______| | | | |__________| | | |______| |
- * |___________| | |________________| |__________|
- * | <--> gapToSide()
- * |
- * IMAGE_GAP
- */
- private void layoutScreenNails(int centerX, int centerY, float scale) {
- int width = getWidth();
- int height = getHeight();
-
- int left = Math.round(width / 2 - centerX * scale);
- int right = Math.round(left + mImageWidth * scale);
-
- int gap = IMAGE_GAP + gapToSide(mImageWidth, width, scale);;
-
- // layout the previous image
- ScreenNailEntry entry = mScreenNails[ENTRY_PREVIOUS];
- entry.mVisible = left > gap && entry.mBitmap != null;
- if (entry.mBitmap != null) {
- float s = Math.min(1, Math.min((float) width / entry.mWidth,
- (float) height / entry.mHeight));
- entry.mDrawWidth = Math.round(entry.mWidth * s);
- entry.mDrawHeight = Math.round(entry.mHeight * s);
- entry.mX = left - gap - gapToSide(
- entry.mWidth, width, s) - entry.mDrawWidth;
- entry.mY = (height - entry.mDrawHeight) / 2;
- entry.mVisible = (entry.mX + entry.mDrawWidth) > 0;
-
- } else {
- entry.mVisible = false;
- }
-
- // layout the next image
- entry = mScreenNails[ENTRY_NEXT];
- if (entry.mBitmap != null) {
- float s = Utils.clamp(Math.min((float) width / entry.mWidth,
- (float) height / entry.mHeight), 0, 2);
- entry.mDrawWidth = Math.round(entry.mWidth * s);
- entry.mDrawHeight = Math.round(entry.mHeight * s);
- entry.mX = right + gap + gapToSide(entry.mWidth, width, s);
- entry.mY = (height - entry.mDrawHeight) / 2;
- entry.mVisible = entry.mX < width;
- } else {
- entry.mVisible = false;
- }
-
- // Layout the current screen nail
- entry = mScreenNails[ENTRY_CURRENT];
- entry.mVisible = mLevel == mLevelCount && entry.mBitmap != null;
- if (entry.mVisible) {
- entry.mX = (int) (width / 2 - centerX * scale);
- entry.mY = (int) (height / 2 - centerY * scale);
- entry.mDrawWidth = Math.round(mImageWidth * scale);
- entry.mDrawHeight = Math.round(mImageHeight * scale);
- }
- }
-
- // Prepare the tiles we want to use for display.
- //
- // 1. Decide the tile level we want to use for display.
- // 2. Decide the tile levels we want to keep as texture (in addition to
- // the one we use for display).
- // 3. Recycle unused tiles.
- // 4. Activate the tiles we want.
- private void layoutTiles(int centerX, int centerY, float scale) {
-
- // The width and height of this view.
- int width = getWidth();
- int height = getHeight();
-
- // The tile levels we want to keep as texture is in the range
- // [fromLevel, endLevel).
- int fromLevel;
- int endLevel;
-
- // We want to use a texture smaller than the display size to avoid
- // displaying artifacts.
- mLevel = Utils.clamp(ceilLog2(1f / scale), 0, mLevelCount);
-
- // We want to keep one more tile level as texture in addition to what
- // we use for display. So it can be faster when the scale moves to the
- // next level. We choose a level closer to the current scale.
- if (mLevel != mLevelCount) {
- Rect range = mTileRange;
- getRange(range, centerX, centerY, mLevel, scale);
- mOffsetX = Math.round(width / 2f + (range.left - centerX) * scale);
- mOffsetY = Math.round(height / 2f + (range.top - centerY) * scale);
- fromLevel = scale * (1 << mLevel) > 1.5f ? mLevel - 1 : mLevel;
- } else {
- // If mLevel == mLevelCount, we will use the backup texture for
- // display, so keep two smallest levels of tiles.
- fromLevel = mLevel - 2;
- }
-
- fromLevel = Math.max(fromLevel, 0);
- endLevel = Math.min(fromLevel + 2, mLevelCount);
- Rect range[] = mActiveRange;
- for (int i = fromLevel; i < endLevel; ++i) {
- getRange(range[i - fromLevel], centerX, centerY, i);
- }
-
- // Recycle unused tiles: if the level of the active tile is outside the
- // range [fromLevel, endLevel) or not in the visible range.
- Iterator<Map.Entry<Long, Tile>>
- iter = mActiveTiles.entrySet().iterator();
- while (iter.hasNext()) {
- Tile tile = iter.next().getValue();
- int level = tile.mTileLevel;
- if (level < fromLevel || level >= endLevel
- || !range[level - fromLevel].contains(tile.mX, tile.mY)) {
- iter.remove();
- recycleTile(tile);
- }
- }
-
- for (int i = fromLevel; i < endLevel; ++i) {
- int size = TILE_SIZE << i;
- Rect r = range[i - fromLevel];
- for (int y = r.top, bottom = r.bottom; y < bottom; y += size) {
- for (int x = r.left, right = r.right; x < right; x += size) {
- activateTile(x, y, i);
- }
- }
- }
- mUploadIter = mActiveTiles.values().iterator();
- }
-
- private void invalidateAllTiles() {
- Iterator<Map.Entry<Long, Tile>> iter = mActiveTiles.entrySet().iterator();
- while (iter.hasNext()) {
- Tile tile = iter.next().getValue();
- recycleTile(tile);
- }
- mActiveTiles.clear();
- }
-
- private void getRange(Rect out, int cX, int cY, int level) {
- getRange(out, cX, cY, level, 1f / (1 << (level + 1)));
- }
-
- // If the bitmap is scaled by the given factor "scale", return the
- // rectangle containing visible range. The left-top coordinate returned is
- // aligned to the tile boundary.
- //
- // (cX, cY) is the point on the original bitmap which will be put in the
- // center of the ImageViewer.
- private void getRange(Rect out, int cX, int cY, int level, float scale) {
- int width = getWidth();
- int height = getHeight();
-
- int left = (int) Math.floor(cX - width / (2f * scale));
- int top = (int) Math.floor(cY - height / (2f * scale));
- int right = (int) Math.ceil(left + width / scale);
- int bottom = (int) Math.ceil(top + height / scale);
-
- // align the rectangle to tile boundary
- int size = TILE_SIZE << level;
- left = Math.max(0, size * (left / size));
- top = Math.max(0, size * (top / size));
- right = Math.min(mImageWidth, right);
- bottom = Math.min(mImageHeight, bottom);
-
- out.set(left, top, right, bottom);
- }
-
- public void setPosition(int centerX, int centerY, float scale) {
- mCenterX = centerX;
- mCenterY = centerY;
- mScale = scale;
-
- layoutTiles(centerX, centerY, scale);
- layoutScreenNails(centerX, centerY, scale);
- invalidate();
- }
-
- private static class AnimationController {
- private long mAnimationStartTime = NO_ANIMATION;
- private static final long NO_ANIMATION = -1;
- private static final long LAST_ANIMATION = -2;
-
- // Animation time in milliseconds.
- private static final float ANIM_TIME_SCROLL = 0;
- private static final float ANIM_TIME_SCALE = 50;
- private static final float ANIM_TIME_SNAPBACK = 600;
- private static final float ANIM_TIME_SWITCHIMAGE = 400;
-
- private int mAnimationKind;
- private final static int ANIM_KIND_SCROLL = 0;
- private final static int ANIM_KIND_SCALE = 1;
- private final static int ANIM_KIND_SNAPBACK = 2;
- private final static int ANIM_KIND_SWITCHIMAGE = 800;
-
- private ImageViewer mViewer;
- private int mImageW, mImageH;
- private int mViewW, mViewH;
-
- // The X, Y are the coordinate on bitmap which shows on the center of
- // the view. We always keep the mCurrent{X,Y,SCALE} sync with the actual
- // values used currently.
- private int mCurrentX, mFromX, mToX;
- private int mCurrentY, mFromY, mToY;
- private float mCurrentScale, mFromScale, mToScale;
-
- // The offsets from the center of the view to the user's focus point,
- // converted to the bitmap domain.
- private float mPrevOffsetX;
- private float mPrevOffsetY;
- private boolean mInScale;
-
- // The limits for position and scale.
- private float mScaleMin, mScaleMax = 4f;
-
- AnimationController(ImageViewer viewer) {
- mViewer = viewer;
- }
-
- public void onNewImage(int width, int height) {
- mImageW = width;
- mImageH = height;
-
- mScaleMin = Math.min(1f, Math.min(
- (float) mViewW / mImageW, (float) mViewH / mImageH));
-
- mCurrentScale = mScaleMin;
- mCurrentX = mImageW / 2;
- mCurrentY = mImageH / 2;
-
- mViewer.setPosition(mCurrentX, mCurrentY, mCurrentScale);
- }
-
- public void updateViewSize(int viewW, int viewH) {
- mViewW = viewW;
- mViewH = viewH;
-
- if (mImageW == 0 || mImageH == 0) return;
-
- mScaleMin = Math.min((float) viewW / mImageW, (float) viewH / mImageH);
- mScaleMin = Math.min(1f, mScaleMin);
-
- mCurrentScale = Utils.clamp(mCurrentScale, mScaleMin, mScaleMax);
- mCurrentX = mImageW / 2;
- mCurrentY = mImageH / 2;
-
- mViewer.setPosition(mCurrentX, mCurrentY, mCurrentScale);
- }
-
- public void scrollBy(float dx, float dy) {
- startAnimation(getTargetX() + Math.round(dx / mCurrentScale),
- getTargetY() + Math.round(dy / mCurrentScale),
- mCurrentScale,
- ANIM_KIND_SCROLL);
- }
-
- public void beginScale(float focusX, float focusY) {
- mInScale = true;
- mPrevOffsetX = (focusX - mViewW / 2f) / mCurrentScale;
- mPrevOffsetY = (focusY - mViewH / 2f) / mCurrentScale;
- }
-
- public void scaleBy(float s, float focusX, float focusY) {
- // The focus point should keep this position on the ImageView.
- // So, mCurrentX + mPrevOffsetX = mCurrentX' + offsetX.
- // mCurrentY + mPrevOffsetY = mCurrentY' + offsetY.
- float offsetX = (focusX - mViewW / 2f) / mCurrentScale;
- float offsetY = (focusY - mViewH / 2f) / mCurrentScale;
- startAnimation(getTargetX() - Math.round(offsetX - mPrevOffsetX),
- getTargetY() - Math.round(offsetY - mPrevOffsetY),
- getTargetScale() * s,
- ANIM_KIND_SCALE);
- mPrevOffsetX = offsetX;
- mPrevOffsetY = offsetY;
- }
-
- public void endScale() {
- mInScale = false;
- startSnapbackIfNeeded();
- }
-
- public void up() {
- startSnapbackIfNeeded();
- }
-
- public void startSwitchTransition(int targetX) {
- startAnimation(targetX,
- mCurrentY, mCurrentScale, ANIM_KIND_SWITCHIMAGE);
- }
-
- private void startAnimation(int centerX, int centerY, float scale, int kind) {
- if (centerX == mCurrentX && centerY == mCurrentY
- && scale == mCurrentScale) {
- return;
- }
-
- mFromX = mCurrentX;
- mFromY = mCurrentY;
- mFromScale = mCurrentScale;
-
- mToX = centerX;
- mToY = centerY;
- mToScale = Utils.clamp(scale, 0.6f * mScaleMin, 1.4f * mScaleMax);
-
- // If the scaled dimension is smaller than the view,
- // force it to be in the center.
- if (Math.floor(mImageH * mToScale) <= mViewH) {
- mToY = mImageH / 2;
- }
-
- mAnimationStartTime = SystemClock.uptimeMillis();
- mAnimationKind = kind;
- advanceAnimation();
- }
-
- // Returns true if redraw is needed.
- public boolean advanceAnimation() {
- if (mAnimationStartTime == NO_ANIMATION) {
- return false;
- } else if (mAnimationStartTime == LAST_ANIMATION) {
- mAnimationStartTime = NO_ANIMATION;
- if (mViewer.mInTransition) {
- mViewer.onTransitionComplete();
- return false;
- } else {
- return startSnapbackIfNeeded();
- }
- }
-
- float animationTime;
- if (mAnimationKind == ANIM_KIND_SCROLL) {
- animationTime = ANIM_TIME_SCROLL;
- } else if (mAnimationKind == ANIM_KIND_SCALE) {
- animationTime = ANIM_TIME_SCALE;
- } else if (mAnimationKind == ANIM_KIND_SWITCHIMAGE) {
- animationTime = ANIM_TIME_SWITCHIMAGE;
- } else /* if (mAnimationKind == ANIM_KIND_SNAPBACK) */ {
- animationTime = ANIM_TIME_SNAPBACK;
- }
-
- float progress;
- if (animationTime == 0) {
- progress = 1;
- } else {
- long now = SystemClock.uptimeMillis();
- progress = (now - mAnimationStartTime) / animationTime;
- }
-
- if (progress >= 1) {
- progress = 1;
- mCurrentX = mToX;
- mCurrentY = mToY;
- mCurrentScale = mToScale;
- mAnimationStartTime = LAST_ANIMATION;
- } else {
- float f = 1 - progress;
- if (mAnimationKind == ANIM_KIND_SCROLL) {
- f = 1 - f; // linear
- } else if (mAnimationKind == ANIM_KIND_SCALE) {
- f = 1 - f * f; // quadratic
- } else /* if mAnimationKind is
- ANIM_KIND_SNAPBACK or ANIM_KIND_SWITCHIMAGE */ {
- f = 1 - f * f * f * f * f; // x^5
- }
- mCurrentX = Math.round(mFromX + f * (mToX - mFromX));
- mCurrentY = Math.round(mFromY + f * (mToY - mFromY));
- mCurrentScale = mFromScale + f * (mToScale - mFromScale);
- }
- mViewer.setPosition(mCurrentX, mCurrentY, mCurrentScale);
- return true;
- }
-
- // Returns true if redraw is needed.
- private boolean startSnapbackIfNeeded() {
- if (mAnimationStartTime != NO_ANIMATION) return false;
- if (mInScale) return false;
- if (mAnimationKind == ANIM_KIND_SCROLL && mViewer.isDown()) {
- return false;
- }
-
- boolean needAnimation = false;
- int x = mCurrentX;
- int y = mCurrentY;
- float scale = mCurrentScale;
-
- if (mCurrentScale < mScaleMin || mCurrentScale > mScaleMax) {
- needAnimation = true;
- scale = Utils.clamp(mCurrentScale, mScaleMin, mScaleMax);
- }
-
- // The number of pixels when the edge is aliged.
- int left = (int) Math.ceil(mViewW / (2 * scale));
- int right = mImageW - left;
- int top = (int) Math.ceil(mViewH / (2 * scale));
- int bottom = mImageH - top;
-
- if (mImageW * scale > mViewW) {
- if (mCurrentX < left) {
- needAnimation = true;
- x = left;
- } else if (mCurrentX > right) {
- needAnimation = true;
- x = right;
- }
- } else {
- if (mCurrentX > left) {
- needAnimation = true;
- x = left;
- } else if (mCurrentX < right) {
- needAnimation = true;
- x = right;
- }
- }
-
- if (mImageH * scale > mViewH) {
- if (mCurrentY < top) {
- needAnimation = true;
- y = top;
- } else if (mCurrentY > bottom) {
- needAnimation = true;
- y = bottom;
- }
- } else {
- if (mCurrentY > top) {
- needAnimation = true;
- y = top;
- } else if (mCurrentY < bottom) {
- needAnimation = true;
- y = bottom;
- }
- }
-
- if (needAnimation) {
- startAnimation(x, y, scale, ANIM_KIND_SNAPBACK);
- }
-
- return needAnimation;
- }
-
- private float getTargetScale() {
- if (mAnimationStartTime == NO_ANIMATION
- || mAnimationKind == ANIM_KIND_SNAPBACK) return mCurrentScale;
- return mToScale;
- }
-
- private int getTargetX() {
- if (mAnimationStartTime == NO_ANIMATION
- || mAnimationKind == ANIM_KIND_SNAPBACK) return mCurrentX;
- return mToX;
- }
-
- private int getTargetY() {
- if (mAnimationStartTime == NO_ANIMATION
- || mAnimationKind == ANIM_KIND_SNAPBACK) return mCurrentY;
- return mToY;
- }
- }
-
- public void freeTextures() {
- isTextureFreed = true;
- mUploadIter = null;
- for (Tile texture : mActiveTiles.values()) {
- texture.recycle();
- }
- mTileRange.set(0, 0, 0, 0);
- mActiveTiles.clear();
- freeRecycledTile();
-
- for (ScreenNailEntry nail : mScreenNails) {
- if (nail.mTexture != null) nail.mTexture.recycle();
- if (nail.mBitmap != null) nail.mBitmap.recycle();
- }
- }
-
- public void prepareTextures() {
- if (isTextureFreed) {
- layoutTiles(mCenterX, mCenterY, mScale);
- isTextureFreed = false;
- }
- }
-
- @Override
- protected void render(GLCanvas canvas) {
-
- if (mScreenNails[ENTRY_CURRENT].mBitmap == null) return;
-
- // TODO: remove this line
- canvas.clearBuffer();
-
- mUploadQuota = UPLOAD_LIMIT;
- mRenderComplete = true;
-
-
- int level = mLevel;
-
- if (level != mLevelCount) {
- int size = (TILE_SIZE << level);
- float length = size * mScale;
- Rect r = mTileRange;
- for (int ty = r.top, i = 0; ty < r.bottom; ty += size, i++) {
- float y = mOffsetY + i * length;
- for (int tx = r.left, j = 0; tx < r.right; tx += size, j++) {
- float x = mOffsetX + j * length;
- Tile tile = getTile(tx, ty, level);
- tile.drawTile(canvas, x, y, length);
- }
- }
- }
-
- for (ScreenNailEntry entry : mScreenNails) {
- if (entry.mVisible) entry.draw(canvas);
- }
-
- if (mAnimationController.advanceAnimation()) {
- mRenderComplete = false;
- }
-
- if (mRenderComplete) {
- if (mUploadIter != null
- && mUploadIter.hasNext() && !mUploader.mActive) {
- mUploader.mActive = true;
- getGLRoot().addOnGLIdleListener(mUploader);
- }
- } else {
- invalidate();
- }
- }
-
- private Tile obtainTile(int x, int y, int level) {
- Tile tile;
- if (mRecycledHead != null) {
- tile = mRecycledHead;
- mRecycledHead = tile.mNextFree;
- tile.update(x, y, level);
- } else {
- tile = new Tile(x, y, level);
- }
- return tile;
- }
-
- private void recycleTile(Tile tile) {
- tile.mNextFree = mRecycledHead;
- mRecycledHead = tile;
- }
-
- private void freeRecycledTile() {
- Tile tile = mRecycledHead;
- while (tile != null) {
- tile.recycle();
- tile = tile.mNextFree;
- }
- mRecycledHead = null;
- }
-
- private void activateTile(int x, int y, int level) {
- Long key = makeTileKey(x, y, level);
- Tile tile = mActiveTiles.get(key);
- if (tile != null) return;
- tile = obtainTile(x, y, level);
- mActiveTiles.put(key, tile);
- }
-
- private Tile getTile(int x, int y, int level) {
- return mActiveTiles.get(makeTileKey(x, y, level));
- }
-
- public static Long makeTileKey(int x, int y, int level) {
- long result = x;
- result = (result << 16) | y;
- result = (result << 16) | level;
- return Long.valueOf(result);
- }
-
- // TODO: avoid drawing the unused part of the textures.
- static boolean drawTile(
- Tile tile, GLCanvas canvas, RectF source, RectF target) {
- while (true) {
- if (tile.isContentValid(canvas)) {
- // offset source rectangle for the texture border.
- source.offset(TILE_BORDER, TILE_BORDER);
- canvas.drawTexture(tile, source, target);
- return true;
- }
-
- // Parent can be divided to four quads and tile is one of the four.
- Tile parent = tile.getParentTile();
- if (parent == null) return false;
- if (tile.mX == parent.mX) {
- source.left /= 2f;
- source.right /= 2f;
- } else {
- source.left = (TILE_SIZE + source.left) / 2f;
- source.right = (TILE_SIZE + source.right) / 2f;
- }
- if (tile.mY == parent.mY) {
- source.top /= 2f;
- source.bottom /= 2f;
- } else {
- source.top = (TILE_SIZE + source.top) / 2f;
- source.bottom = (TILE_SIZE + source.bottom) / 2f;
- }
- tile = parent;
- }
- }
-
- private class Uploader implements GLRoot.OnGLIdleListener {
-
- protected boolean mActive;
-
- public boolean onGLIdle(GLRoot root, GLCanvas canvas) {
- int quota = UPLOAD_LIMIT;
-
- if (mUploadIter == null) return false;
- Iterator<Tile> iter = mUploadIter;
- while (iter.hasNext() && quota > 0) {
- Tile tile = iter.next();
- if (!tile.isContentValid(canvas)) {
- tile.updateContent(canvas);
- Log.v(TAG, String.format(
- "update tile in background: %s %s %s",
- tile.mX / TILE_SIZE, tile.mY / TILE_SIZE,
- tile.mTileLevel));
- --quota;
- }
- }
- mActive = iter.hasNext();
- return mActive;
- }
- }
-
- private class Tile extends UploadedTexture {
- int mX;
- int mY;
- int mTileLevel;
- Tile mNextFree;
-
- public Tile(int x, int y, int level) {
- mX = x;
- mY = y;
- mTileLevel = level;
- }
-
- @Override
- protected void onFreeBitmap(Bitmap bitmap) {
- bitmap.recycle();
- }
-
- @Override
- protected Bitmap onGetBitmap() {
- // Get a tile from the original image.
- // The tile is down-scaled by (1 << mTilelevel) from a region in the original image.
- int level = mTileLevel;
- int regionLength = (TILE_SIZE + 2 * TILE_BORDER) << level;
- int borderLength = TILE_BORDER << level;
- Rect rect = new Rect(0, 0, mLargeBitmap.getWidth(),
- mLargeBitmap.getHeight());
-
- // Get the intersected rect of the requested region and the image.
- boolean intersected = rect.intersect(mX - borderLength,
- mY - borderLength, mX + regionLength, mY + regionLength);
-
- Bitmap region = null;
- if (intersected) {
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inSampleSize = 1 << level;
- region = mLargeBitmap.decodeRegion(rect, options);
-
- int targetLength = TILE_SIZE + 2 * TILE_BORDER;
- int left = rect.left == 0 ? TILE_BORDER : 0;
- int top = rect.top == 0 ? TILE_BORDER : 0;
-
- // The returned region may not match with the targetLength.
- // If so, we fill black pixels on it.
- if ((region.getWidth() != targetLength)
- || (region.getHeight() != targetLength) || left != 0
- || top != 0) {
- Bitmap tile = Bitmap.createBitmap(targetLength,
- targetLength, region.hasAlpha()
- ? Config.ARGB_8888
- : Config.RGB_565);
- Canvas canvas = new Canvas(tile);
- canvas.drawBitmap(region, left, top, null);
- region.recycle();
- return tile;
- }
- } else {
- throw new AssertionError("The requested tile is not within the image!");
- }
- return region;
- }
-
- public void update(int x, int y, int level) {
- mX = x;
- mY = y;
- mTileLevel = level;
- invalidateContent();
- }
-
- // Draw the tile to a square at canvas that locates at (x, y) and
- // has a side length of length.
- public void drawTile(GLCanvas canvas, float x, float y, float length) {
- RectF source = mSourceRect;
- RectF target = mTargetRect;
- target.set(x, y, x + length, y + length);
- source.set(0, 0, TILE_SIZE, TILE_SIZE);
- drawTile(canvas, source, target);
- }
-
- public Tile getParentTile() {
- if (mTileLevel + 1 == mLevelCount) return null;
- int size = TILE_SIZE << (mTileLevel + 1);
- int x = size * (mX / size);
- int y = size * (mY / size);
- return getTile(x, y, mTileLevel + 1);
- }
-
- // Draw the tile to target at canvas.
- public void drawTile(GLCanvas canvas, RectF source, RectF target) {
- if (!isContentValid(canvas)) {
- if (mUploadQuota > 0) {
- --mUploadQuota;
- updateContent(canvas);
- } else {
- mRenderComplete = false;
- }
- }
- if (!ImageViewer.drawTile(this, canvas, source, target)) {
- BitmapTexture backup = mScreenNails[ENTRY_CURRENT].mTexture;
- int width = mImageWidth;
- int height = mImageHeight;
- float scaleX = (float) backup.getWidth() / width;
- float scaleY = (float) backup.getHeight() / height;
- int size = TILE_SIZE << mTileLevel;
-
- source.set(mX * scaleX, mY * scaleY, (mX + size) * scaleX,
- (mY + size) * scaleY);
-
- canvas.drawTexture(backup, source, target);
- }
- }
- }
-
- private class MyGestureListener
- extends GestureDetector.SimpleOnGestureListener {
- @Override
- public boolean onScroll(
- MotionEvent e1, MotionEvent e2, float dx, float dy) {
- lockRendering();
- try {
- if (mInTransition) return true;
- mAnimationController.scrollBy(dx, dy);
- } finally {
- unlockRendering();
- }
- return true;
- }
- }
-
- private class MyScaleListener
- extends ScaleGestureDetector.SimpleOnScaleGestureListener {
-
- @Override
- public boolean onScale(ScaleGestureDetector detector) {
- float scale = detector.getScaleFactor();
- if (Float.isNaN(scale)
- || Float.isInfinite(scale) || mInTransition) return true;
- mAnimationController.scaleBy(scale,
- detector.getFocusX(), detector.getFocusY());
- return true;
- }
-
- @Override
- public boolean onScaleBegin(ScaleGestureDetector detector) {
- if (mInTransition) return false;
- mAnimationController.beginScale(
- detector.getFocusX(), detector.getFocusY());
- return true;
- }
-
- @Override
- public void onScaleEnd(ScaleGestureDetector detector) {
- mAnimationController.endScale();
- }
- }
-
- private class MyDownUpListener implements DownUpDetector.DownUpListener {
- public void onDown(MotionEvent e) {
- }
-
- public void onUp(MotionEvent e) {
- if (mInTransition) return;
-
- ScreenNailEntry next = mScreenNails[ENTRY_NEXT];
- ScreenNailEntry prev = mScreenNails[ENTRY_PREVIOUS];
-
- int width = getWidth();
- int height = getHeight();
-
- int threshold = SWITCH_THRESHOLD + gapToSide(mImageWidth, width, mScale);
- int left = Math.round(width / 2 - mCenterX * mScale);
- int right = Math.round(left + mImageWidth * mScale);
-
- if (next.mBitmap != null && threshold < width - right) {
- mInTransition = true;
- mSwitchIndex = ENTRY_NEXT;
- float targetX = next.mX + next.mDrawWidth / 2;
- targetX = mImageWidth + (targetX - right) / mScale;
- mAnimationController.startSwitchTransition(Math.round(targetX));
- } else if (prev.mBitmap != null && threshold < left) {
- mInTransition = true;
- mSwitchIndex = ENTRY_PREVIOUS;
- float targetX = prev.mX + prev.mDrawWidth / 2;
- targetX = (targetX - left) / mScale;
- mAnimationController.startSwitchTransition(Math.round(targetX));
- } else {
- mAnimationController.up();
- }
- }
- }
-
- private void onTransitionComplete() {
- if (mModel == null) return;
-
- mInTransition = false;
-
- invalidateAllTiles();
-
- ScreenNailEntry screenNails[] = mScreenNails;
-
- if (mSwitchIndex == ENTRY_NEXT) {
- mModel.next();
- } else if (mSwitchIndex == ENTRY_PREVIOUS) {
- mModel.previous();
- } else {
- throw new AssertionError();
- }
- Utils.swap(screenNails, ENTRY_CURRENT, mSwitchIndex);
- Utils.swap(screenNails, ENTRY_PREVIOUS, ENTRY_NEXT);
-
- notifyScreenNailInvalidated(mSwitchIndex);
- notifyLargeBitmapInvalidated();
-
- resetCurrentImagePosition();
- }
-
- private boolean isDown() {
- return mDownUpDetector.isDown();
- }
-
- public static interface Model {
- public static final int INDEX_CURRENT = 1;
- public static final int INDEX_PREVIOUS = 0;
- public static final int INDEX_NEXT = 2;
-
- public void next();
- public void previous();
-
- // Return null if the specified image is unavailable.
- public ImageData getImageData(int which);
- public LargeBitmap getLargeBitmap();
- }
-
- public static class ImageData {
- public int fullWidth;
- public int fullHeight;
- public Bitmap screenNail;
-
- public ImageData(int width, int height, Bitmap screenNail) {
- fullWidth = width;
- fullHeight = height;
- this.screenNail = screenNail;
- }
- }
-
- private static class ScreenNailEntry {
- private int mWidth;
- private int mHeight;
-
- // if mBitmap is null then this entry is not valid
- private Bitmap mBitmap;
- private boolean mVisible;
-
- private int mX;
- private int mY;
- private int mDrawWidth;
- private int mDrawHeight;
-
- private BitmapTexture mTexture;
-
- public void set(int fullWidth, int fullHeight, Bitmap bitmap) {
- mWidth = fullWidth;
- mHeight = fullHeight;
- if (mBitmap != bitmap) {
- mBitmap = bitmap;
- if (mTexture != null) mTexture.recycle();
- if (bitmap != null) mTexture = new BitmapTexture(bitmap);
- }
- }
-
- public void draw(GLCanvas canvas) {
- mTexture.draw(canvas, mX, mY, mDrawWidth, mDrawHeight);
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/Log.java b/new3d/src/com/android/gallery3d/ui/Log.java
deleted file mode 100644
index 32adc98..0000000
--- a/new3d/src/com/android/gallery3d/ui/Log.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-public class Log {
- public static int v(String tag, String msg) {
- return android.util.Log.v(tag, msg);
- }
- public static int v(String tag, String msg, Throwable tr) {
- return android.util.Log.v(tag, msg, tr);
- }
- public static int d(String tag, String msg) {
- return android.util.Log.d(tag, msg);
- }
- public static int d(String tag, String msg, Throwable tr) {
- return android.util.Log.d(tag, msg, tr);
- }
- public static int i(String tag, String msg) {
- return android.util.Log.i(tag, msg);
- }
- public static int i(String tag, String msg, Throwable tr) {
- return android.util.Log.i(tag, msg, tr);
- }
- public static int w(String tag, String msg) {
- return android.util.Log.w(tag, msg);
- }
- public static int w(String tag, String msg, Throwable tr) {
- return android.util.Log.w(tag, msg, tr);
- }
- public static int w(String tag, Throwable tr) {
- return android.util.Log.w(tag, tr);
- }
- public static int e(String tag, String msg) {
- return android.util.Log.e(tag, msg);
- }
- public static int e(String tag, String msg, Throwable tr) {
- return android.util.Log.e(tag, msg, tr);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/MeasureHelper.java b/new3d/src/com/android/gallery3d/ui/MeasureHelper.java
deleted file mode 100644
index f65dc10..0000000
--- a/new3d/src/com/android/gallery3d/ui/MeasureHelper.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Rect;
-import android.view.View.MeasureSpec;
-
-class MeasureHelper {
-
- private static MeasureHelper sInstance = new MeasureHelper(null);
-
- private GLView mComponent;
- private int mPreferredWidth;
- private int mPreferredHeight;
-
- private MeasureHelper(GLView component) {
- mComponent = component;
- }
-
- public static MeasureHelper getInstance(GLView component) {
- sInstance.mComponent = component;
- return sInstance;
- }
-
- public MeasureHelper setPreferredContentSize(int width, int height) {
- mPreferredWidth = width;
- mPreferredHeight = height;
- return this;
- }
-
- public void measure(int widthSpec, int heightSpec) {
- Rect p = mComponent.getPaddings();
- setMeasuredSize(
- getLength(widthSpec, mPreferredWidth + p.left + p.right),
- getLength(heightSpec, mPreferredHeight + p.top + p.bottom));
- }
-
- private static int getLength(int measureSpec, int prefered) {
- int specLength = MeasureSpec.getSize(measureSpec);
- switch(MeasureSpec.getMode(measureSpec)) {
- case MeasureSpec.EXACTLY: return specLength;
- case MeasureSpec.AT_MOST: return Math.min(prefered, specLength);
- default: return prefered;
- }
- }
-
- protected void setMeasuredSize(int width, int height) {
- mComponent.setMeasuredSize(width, height);
- }
-
-}
diff --git a/new3d/src/com/android/gallery3d/ui/MenuBar.java b/new3d/src/com/android/gallery3d/ui/MenuBar.java
deleted file mode 100644
index f7e3b81..0000000
--- a/new3d/src/com/android/gallery3d/ui/MenuBar.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Rect;
-import android.view.View.MeasureSpec;
-
-public class MenuBar extends GLView {
-
- private static final int BORDER_SIZE = 1; // 1 pixel on all devices
- private static final int BORDER_COLOR = 0x33FFFFFF;
-
- private NinePatchTexture mBackground;
-
- public MenuBar(int visibility) {
- setVisibility(visibility);
- }
-
- public void setBackground(NinePatchTexture background) {
- if (mBackground == background) return;
- mBackground = background;
- if (background != null) {
- setPaddings(background.getPaddings());
- } else {
- setPaddings(0, 0, 0, 0);
- }
- invalidate();
- }
-
- @Override
- protected void onMeasure(int widthSpec, int heightSpec) {
- int width = 0;
- int height = 0;
- int n = getComponentCount();
- for (int i = 0; i < n; ++i) {
- GLView component = getComponent(i);
- component.measure(
- MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
- height = Math.max(height, component.getMeasuredHeight());
- width += component.getMeasuredWidth();
- }
- width += (n - 1) * BORDER_SIZE;
- height += 2 * BORDER_SIZE;
- MeasureHelper.getInstance(this)
- .setPreferredContentSize(width, height)
- .measure(widthSpec, heightSpec);
- }
-
- @Override
- protected void onLayout(
- boolean changed, int left, int top, int right, int bottom) {
- Rect p = mPaddings;
-
- int remainings = right - left - p.left - p.right;
- int n = getComponentCount();
- for (int i = 0; i < n; ++i) {
- GLView component = getComponent(i);
- component.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
- remainings -= component.getMeasuredWidth();
- }
- remainings -= (n - 1) * BORDER_SIZE;
-
- int layoutLeft = p.left;
- int layoutTop = p.top + BORDER_SIZE;
- int layoutBottom = bottom - top - p.bottom - BORDER_SIZE;
- for (int i = 0; i < n; ++i) {
- GLView component = getComponent(i);
- int space = remainings / (n - i);
- remainings -= space;
- int width = component.getMeasuredWidth() + space;
- int layoutRight = layoutLeft + width;
- component.layout(layoutLeft, layoutTop, layoutRight, layoutBottom);
- layoutLeft = layoutRight + BORDER_SIZE;
- }
- }
-
- @Override
- protected void renderBackground(GLCanvas canvas) {
- int width = getWidth();
- int height = getHeight();
- if (mBackground != null) {
- mBackground.draw(canvas, 0, 0, width, height);
- }
- Rect p = mPaddings;
-
- width -= p.left + p.right;
- height -= p.top + p.bottom;
-
- int top = p.top;
- int bottom = top + height;
- int left = p.left;
- int right = left + width;
-
- canvas.drawLine(left, top, right, top, BORDER_COLOR);
- canvas.drawLine(left, bottom - 1, right, bottom - 1, BORDER_COLOR);
- for (int i = 0, n = getComponentCount() - 1; i < n; ++i) {
- Rect bounds = getComponent(i).mBounds;
- canvas.drawLine(bounds.right, top + 1, bounds.right, bottom - 2, BORDER_COLOR);
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/MenuButton.java b/new3d/src/com/android/gallery3d/ui/MenuButton.java
deleted file mode 100644
index 0cedca9..0000000
--- a/new3d/src/com/android/gallery3d/ui/MenuButton.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.view.MotionEvent;
-
-public class MenuButton extends IconLabel {
-
- private boolean mPressed;
- private Texture mHighlight;
- private OnClickedListener mOnClickListener;
-
- public interface OnClickedListener {
- public void onClicked(GLView source);
- }
-
- public MenuButton(Context context, int icon, int label) {
- super(context, icon, label);
- }
-
- public void setOnClickListener(OnClickedListener listener) {
- mOnClickListener = listener;
- }
-
- public void setHighlight(Texture texture) {
- mHighlight = texture;
- }
-
- @SuppressWarnings("fallthrough")
- @Override
- protected boolean onTouch(MotionEvent event) {
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- mPressed = true;
- invalidate();
- break;
- case MotionEvent.ACTION_UP:
- if (mOnClickListener != null) {
- mOnClickListener.onClicked(this);
- }
- // fall-through
- case MotionEvent.ACTION_CANCEL:
- mPressed = false;
- invalidate();
- break;
- }
- return true;
- }
-
- @Override
- protected void render(GLCanvas canvas) {
- if (mPressed) {
- int width = getWidth();
- int height = getHeight();
- if (mHighlight instanceof NinePatchTexture) {
- Rect p = ((NinePatchTexture) mHighlight).getPaddings();
- mHighlight.draw(canvas, -p.left, -p.top,
- width + p.left + p.right, height + p.top + p.bottom);
- } else {
- mHighlight.draw(canvas, 0, 0, width, height);
- }
- }
- super.render(canvas);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/MenuExecutor.java b/new3d/src/com/android/gallery3d/ui/MenuExecutor.java
deleted file mode 100644
index eb2fe0e..0000000
--- a/new3d/src/com/android/gallery3d/ui/MenuExecutor.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.os.Handler;
-
-import com.android.gallery3d.data.DataManager;
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.FutureListener;
-import com.android.gallery3d.util.FutureTask;
-
-import java.util.ArrayList;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-
-public class MenuExecutor {
- private static final String TAG = "MenuExecutor";
-
- public static final int ACTION_DELETE = 1;
- public static final int ACTION_DETAILS = 2;
- public static final int ACTION_ROTATE_CW = 3;
- public static final int ACTION_ROTATE_CCW = 4;
-
- private Handler mHandler;
- private DataManager mDataManager;
-
- public MenuExecutor(DataManager manager) {
- mDataManager = manager;
- mHandler = new Handler(manager.getDataLooper());
- }
-
- public static interface OnProgressUpdateListener {
- public void onProgressUpdate(int index, Object result);
- public void onProgressComplete();
- }
-
- public class MediaOperation implements Callable<Void>, FutureListener<Void> {
- ArrayList<Long> mItems;
- int mOperation;
- int mIndex;
- FutureTask<Void> mTask;
- OnProgressUpdateListener mProgressUpdater;
-
- public MediaOperation(int operation, ArrayList<Long> items,
- OnProgressUpdateListener progressUpdater) {
- mItems = items;
- mIndex = 0;
- mOperation = operation;
- mProgressUpdater = progressUpdater;
- }
-
- public Void call() throws Exception {
- for (long id : mItems) {
- if (mTask.isCancelled()) return null;
-
- Object result = null;
- switch (mOperation) {
- case ACTION_DELETE:
- mDataManager.delete(id);
- break;
- case ACTION_ROTATE_CW:
- mDataManager.rotate(id, -90);
- break;
- case ACTION_ROTATE_CCW:
- mDataManager.rotate(id, 90);
- break;
- case ACTION_DETAILS:
- result = mDataManager.getDetails(id);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- mProgressUpdater.onProgressUpdate(mIndex++, result);
- }
- return null;
- }
-
- public void setTask(FutureTask<Void> task) {
- mTask = task;
- }
-
- public void onFutureDone(Future<? extends Void> future) {
- mProgressUpdater.onProgressComplete();
- }
-
- public void cancel() {
- mTask.requestCancel();
- try {
- mTask.get();
- } catch (CancellationException ce) {
- // ignore it.
- } catch (ExecutionException ee) {
- // ignore it.
- } catch (InterruptedException ie) {
- // ignore it.
- }
- }
- }
-
- public MediaOperation startMediaOperation(int opcode, ArrayList<Long> items,
- final OnProgressUpdateListener listener) {
- MediaOperation operation = new MediaOperation(opcode, items, listener);
- FutureTask<Void> task = new FutureTask<Void>(operation, operation);
- operation.setTask(task);
- mHandler.post(task);
- return operation;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/MenuItem.java b/new3d/src/com/android/gallery3d/ui/MenuItem.java
deleted file mode 100644
index 8356c23..0000000
--- a/new3d/src/com/android/gallery3d/ui/MenuItem.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.content.Context;
-import android.graphics.Rect;
-
-public class MenuItem extends IconLabel {
- private static final int ACTION_NONE = 0;
- private boolean mSelected;
- private Texture mHighlight;
- private int mItemId;
-
- public MenuItem(Context context, int icon, int label, Texture highlight) {
- this(context, icon, label, highlight, ACTION_NONE);
- }
-
- public MenuItem(Context context, int icon, int label, Texture highlight, int itemId) {
- super(context, icon, label);
- mHighlight = highlight;
- mItemId = itemId;
- }
-
- public MenuItem(Context context, BasicTexture texture, String label) {
- super(context, texture, label);
- }
-
- public int getItemId() {
- return mItemId;
- }
-
- public void setHighlight(Texture texture) {
- mHighlight = texture;
- }
-
- protected void setSelected(boolean selected) {
- if (selected == mSelected) return;
- mSelected = selected;
- invalidate();
- }
-
- @Override
- protected void render(GLCanvas canvas) {
- if (mSelected) {
- int width = getWidth();
- int height = getHeight();
- if (mHighlight instanceof NinePatchTexture) {
- Rect p = ((NinePatchTexture) mHighlight).getPaddings();
- mHighlight.draw(canvas, -p.left, -p.top,
- width + p.left + p.right, height + p.top + p.bottom);
- } else {
- mHighlight.draw(canvas, 0, 0, width, height);
- }
- }
- super.render(canvas);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/MenuItemBar.java b/new3d/src/com/android/gallery3d/ui/MenuItemBar.java
deleted file mode 100644
index 4850a18..0000000
--- a/new3d/src/com/android/gallery3d/ui/MenuItemBar.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.view.MotionEvent;
-
-public class MenuItemBar extends MenuBar {
- public static final int INDEX_NONE = -1;
-
- public MenuItemBar(int visibility) {
- super(visibility);
- }
-
- private OnSelectedListener mOnSelectedListener;
- private MenuItem mSelectedItem;
- private boolean mSelectionChanged = false;
-
- public void setSelectedItem(MenuItem source) {
- if (mSelectedItem == source) return;
- mSelectionChanged = true;
- if (mSelectedItem != null) mSelectedItem.setSelected(false);
- mSelectedItem = source;
- if (mSelectedItem != null) mSelectedItem.setSelected(true);
-
- if (mOnSelectedListener != null) {
- mOnSelectedListener.onSelected(mSelectedItem);
- }
- }
-
- public void setOnSelectedListener(OnSelectedListener listener) {
- mOnSelectedListener = listener;
- }
-
- @Override
- protected boolean dispatchTouchEvent(MotionEvent event) {
- // do not dispatch to children
- return onTouch(event);
- }
-
- @SuppressWarnings("fallthrough")
- @Override
- protected boolean onTouch(MotionEvent event) {
- int x = (int) event.getX();
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- mSelectionChanged = false;
- // fall-through
- case MotionEvent.ACTION_MOVE:
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- GLView component = getComponent(i);
- if (x <= component.mBounds.right) {
- setSelectedItem((MenuItem) component);
- return true;
- }
- }
- setSelectedItem(null);
- break;
- case MotionEvent.ACTION_UP:
- if (mSelectionChanged == false) {
- setSelectedItem(null);
- }
- }
- return true;
-
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/NinePatchChunk.java b/new3d/src/com/android/gallery3d/ui/NinePatchChunk.java
deleted file mode 100644
index 61bf22c..0000000
--- a/new3d/src/com/android/gallery3d/ui/NinePatchChunk.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Rect;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-// See "frameworks/base/include/utils/ResourceTypes.h" for the format of
-// NinePatch chunk.
-class NinePatchChunk {
-
- public static final int NO_COLOR = 0x00000001;
- public static final int TRANSPARENT_COLOR = 0x00000000;
-
- public Rect mPaddings = new Rect();
-
- public int mDivX[];
- public int mDivY[];
- public int mColor[];
-
- private static void readIntArray(int[] data, ByteBuffer buffer) {
- for (int i = 0, n = data.length; i < n; ++i) {
- data[i] = buffer.getInt();
- }
- }
-
- private static void checkDivCount(int length) {
- if (length == 0 || (length & 0x01) != 0) {
- throw new RuntimeException("invalid nine-patch: " + length);
- }
- }
-
- public static NinePatchChunk deserialize(byte[] data) {
- ByteBuffer byteBuffer =
- ByteBuffer.wrap(data).order(ByteOrder.nativeOrder());
-
- byte wasSerialized = byteBuffer.get();
- if (wasSerialized == 0) return null;
-
- NinePatchChunk chunk = new NinePatchChunk();
- chunk.mDivX = new int[byteBuffer.get()];
- chunk.mDivY = new int[byteBuffer.get()];
- chunk.mColor = new int[byteBuffer.get()];
-
- checkDivCount(chunk.mDivX.length);
- checkDivCount(chunk.mDivY.length);
-
- // skip 8 bytes
- byteBuffer.getInt();
- byteBuffer.getInt();
-
- chunk.mPaddings.left = byteBuffer.getInt();
- chunk.mPaddings.right = byteBuffer.getInt();
- chunk.mPaddings.top = byteBuffer.getInt();
- chunk.mPaddings.bottom = byteBuffer.getInt();
-
- // skip 4 bytes
- byteBuffer.getInt();
-
- readIntArray(chunk.mDivX, byteBuffer);
- readIntArray(chunk.mDivY, byteBuffer);
- readIntArray(chunk.mColor, byteBuffer);
-
- return chunk;
- }
-}
\ No newline at end of file
diff --git a/new3d/src/com/android/gallery3d/ui/NinePatchTexture.java b/new3d/src/com/android/gallery3d/ui/NinePatchTexture.java
deleted file mode 100644
index 0968f83..0000000
--- a/new3d/src/com/android/gallery3d/ui/NinePatchTexture.java
+++ /dev/null
@@ -1,401 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import com.android.gallery3d.util.Utils;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Rect;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.FloatBuffer;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import javax.microedition.khronos.opengles.GL11;
-
-// NinePatchTexture is a texture backed by a NinePatch resource.
-//
-// getPaddings() returns paddings specified in the NinePatch.
-// getNinePatchChunk() returns the layout data specified in the NinePatch.
-//
-public class NinePatchTexture extends ResourceTexture {
- private static final String TAG = "NinePatchTexture";
- private NinePatchChunk mChunk;
- private MyCacheMap<Long, NinePatchInstance> mInstanceCache =
- new MyCacheMap<Long, NinePatchInstance>();
-
- public NinePatchTexture(Context context, int resId) {
- super(context, resId);
- }
-
- @Override
- protected Bitmap onGetBitmap() {
- if (mBitmap != null) return mBitmap;
-
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- Bitmap bitmap = BitmapFactory.decodeResource(
- mContext.getResources(), mResId, options);
- mBitmap = bitmap;
- setSize(bitmap.getWidth(), bitmap.getHeight());
- byte[] chunkData = bitmap.getNinePatchChunk();
- mChunk = chunkData == null
- ? null
- : NinePatchChunk.deserialize(bitmap.getNinePatchChunk());
- if (mChunk == null) {
- throw new RuntimeException("invalid nine-patch image: " + mResId);
- }
- return bitmap;
- }
-
- public Rect getPaddings() {
- // get the paddings from nine patch
- if (mChunk == null) onGetBitmap();
- return mChunk.mPaddings;
- }
-
- public NinePatchChunk getNinePatchChunk() {
- if (mChunk == null) onGetBitmap();
- return mChunk;
- }
-
- private static class MyCacheMap<K, V> extends LinkedHashMap<K, V> {
- private int CACHE_SIZE = 16;
- private V mJustRemoved;
-
- public MyCacheMap() {
- super(4, 0.75f, true);
- }
-
- @Override
- protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
- if (size() > CACHE_SIZE) {
- mJustRemoved = eldest.getValue();
- return true;
- }
- return false;
- }
-
- public V getJustRemoved() {
- V result = mJustRemoved;
- mJustRemoved = null;
- return result;
- }
- }
-
- private NinePatchInstance findInstance(GLCanvas canvas, int w, int h) {
- long key = w;
- key = (key << 32) | h;
- NinePatchInstance instance = mInstanceCache.get(key);
-
- if (instance == null) {
- instance = new NinePatchInstance(this, w, h);
- mInstanceCache.put(key, instance);
- NinePatchInstance removed = mInstanceCache.getJustRemoved();
- if (removed != null) {
- removed.recycle(canvas);
- }
- }
-
- return instance;
- }
-
- @Override
- public void draw(GLCanvas canvas, int x, int y, int w, int h) {
- if (!isLoaded(canvas)) {
- mInstanceCache.clear();
- }
-
- findInstance(canvas, w, h).draw(canvas, this, x, y);
- }
-
- @Override
- public void recycle() {
- super.recycle();
- GLCanvas canvas = mCanvasRef == null ? null : mCanvasRef.get();
- if (canvas == null) return;
- for (NinePatchInstance instance : mInstanceCache.values()) {
- instance.recycle(canvas);
- }
- mInstanceCache.clear();
- }
-}
-
-// This keeps data for a specialization of NinePatchTexture with the size
-// (width, height). We pre-compute the coordinates for efficiency.
-class NinePatchInstance {
- private static final String TAG = "NinePatchInstance";
-
- // We need 16 vertices for a normal nine-patch image (the 4x4 vertices)
- private static final int VERTEX_BUFFER_SIZE = 16 * 2;
-
- // We need 22 indices for a normal nine-patch image, plus 2 for each
- // transparent region. Current there are at most 1 transparent region.
- private static final int INDEX_BUFFER_SIZE = 22 + 2;
-
- private FloatBuffer mXyBuffer;
- private FloatBuffer mUvBuffer;
- private ByteBuffer mIndexBuffer;
-
- // Names for buffer names: xy, uv, index.
- private int[] mBufferNames;
-
- private int mIdxCount;
-
- // These members are used by NinePatchTexture to maintain the cache.
- int mWidth, mHeight;
- NinePatchInstance mNext;
-
- public NinePatchInstance(NinePatchTexture tex, int width, int height) {
- NinePatchChunk chunk = tex.getNinePatchChunk();
-
- if (width <= 0 || height <= 0) {
- throw new RuntimeException("invalid dimension");
- }
-
- mWidth = width;
- mHeight = height;
-
- // The code should be easily extended to handle the general cases by
- // allocating more space for buffers. But let's just handle the only
- // use case.
- if (chunk.mDivX.length != 2 || chunk.mDivY.length != 2) {
- throw new RuntimeException("unsupported nine patch");
- }
-
- int divX[] = new int[4];
- int divY[] = new int[4];
- float divU[] = new float[4];
- float divV[] = new float[4];
-
- int nx = stretch(divX, divU, chunk.mDivX, tex.getWidth(), width);
- int ny = stretch(divY, divV, chunk.mDivY, tex.getHeight(), height);
-
- prepareVertexData(divX, divY, divU, divV, nx, ny, chunk.mColor);
- }
-
- /**
- * Stretches the texture according to the nine-patch rules. It will
- * linearly distribute the strechy parts defined in the nine-patch chunk to
- * the target area.
- *
- * <pre>
- * source
- * /--------------^---------------\
- * u0 u1 u2 u3 u4 u5
- * div ---> |fffff|ssssssss|fff|ssssss|ffff| ---> u
- * | div0 div1 div2 div3 |
- * | | / / / /
- * | | / / / /
- * | | / / / /
- * |fffff|ssss|fff|sss|ffff| ---> x
- * x0 x1 x2 x3 x4 x5
- * \----------v------------/
- * target
- *
- * f: fixed segment
- * s: stretchy segment
- * </pre>
- *
- * @param div the stretch parts defined in nine-patch chunk
- * @param source the length of the texture
- * @param target the length on the drawing plan
- * @param u output, the positions of these dividers in the texture
- * coordinate
- * @param x output, the corresponding position of these dividers on the
- * drawing plan
- * @return the number of these dividers.
- */
- private static int stretch(
- int x[], float u[], int div[], int source, int target) {
- int textureSize = Utils.nextPowerOf2(source);
- float textureBound = (source - 0.5f) / textureSize;
-
- int stretch = 0;
- for (int i = 0, n = div.length; i < n; i += 2) {
- stretch += div[i + 1] - div[i];
- }
-
- float remaining = target - source + stretch;
-
- int lastX = 0;
- int lastU = 0;
-
- x[0] = 0;
- u[0] = 0;
- for (int i = 0, n = div.length; i < n; i += 2) {
- // fixed segment
- x[i + 1] = lastX + (div[i] - lastU);
- u[i + 1] = Math.min((float) div[i] / textureSize, textureBound);
-
- // stretchy segment
- float partU = div[i + 1] - div[i];
- int partX = (int)(remaining * partU / stretch + 0.5f);
- remaining -= partX;
- stretch -= partU;
-
- lastX = x[i + 1] + partX;
- lastU = div[i + 1];
- x[i + 2] = lastX;
- u[i + 2] = Math.min((float) lastU / textureSize, textureBound);
- }
- // the last fixed segment
- x[div.length + 1] = target;
- u[div.length + 1] = textureBound;
-
- // remove segments with length 0.
- int last = 0;
- for (int i = 1, n = div.length + 2; i < n; ++i) {
- if (x[last] == x[i]) continue;
- x[++last] = x[i];
- u[last] = u[i];
- }
- return last + 1;
- }
-
- private void prepareVertexData(int x[], int y[], float u[], float v[],
- int nx, int ny, int[] color) {
- /*
- * Given a 3x3 nine-patch image, the vertex order is defined as the
- * following graph:
- *
- * (0) (1) (2) (3)
- * | /| /| /|
- * | / | / | / |
- * (4) (5) (6) (7)
- * | \ | \ | \ |
- * | \| \| \|
- * (8) (9) (A) (B)
- * | /| /| /|
- * | / | / | / |
- * (C) (D) (E) (F)
- *
- * And we draw the triangle strip in the following index order:
- *
- * index: 04152637B6A5948C9DAEBF
- */
- int pntCount = 0;
- float xy[] = new float[VERTEX_BUFFER_SIZE];;
- float uv[] = new float[VERTEX_BUFFER_SIZE];;
- for (int j = 0; j < ny; ++j) {
- for (int i = 0; i < nx; ++i) {
- int xIndex = (pntCount++) << 1;
- int yIndex = xIndex + 1;
- xy[xIndex] = x[i];
- xy[yIndex] = y[j];
- uv[xIndex] = u[i];
- uv[yIndex] = v[j];
- }
- }
-
- int idxCount = 1;
- boolean isForward = false;
- byte index[] = new byte[INDEX_BUFFER_SIZE];
- for (int row = 0; row < ny - 1; row++) {
- --idxCount;
- isForward = !isForward;
-
- int start, end, inc;
- if (isForward) {
- start = 0;
- end = nx;
- inc = 1;
- } else {
- start = nx - 1;
- end = -1;
- inc = -1;
- }
-
- for (int col = start; col != end; col += inc) {
- int k = row * nx + col;
- if (col != start) {
- int colorIdx = row * (nx - 1) + col;
- if (isForward) colorIdx--;
- if (color[colorIdx] == NinePatchChunk.TRANSPARENT_COLOR) {
- index[idxCount] = index[idxCount - 1];
- ++idxCount;
- index[idxCount++] = (byte) k;
- }
- }
-
- index[idxCount++] = (byte) k;
- index[idxCount++] = (byte) (k + nx);
- }
- }
-
- mIdxCount = idxCount;
-
- int size = (pntCount * 2) * (Float.SIZE / Byte.SIZE);
- mXyBuffer = allocateDirectNativeOrderBuffer(size).asFloatBuffer();
- mUvBuffer = allocateDirectNativeOrderBuffer(size).asFloatBuffer();
- mIndexBuffer = allocateDirectNativeOrderBuffer(mIdxCount);
-
- mXyBuffer.put(xy, 0, pntCount * 2).position(0);
- mUvBuffer.put(uv, 0, pntCount * 2).position(0);
- mIndexBuffer.put(index, 0, idxCount).position(0);
- }
-
- private static ByteBuffer allocateDirectNativeOrderBuffer(int size) {
- return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
- }
-
- private void prepareBuffers(GLCanvas canvas) {
- mBufferNames = new int[3];
- GL11 gl = canvas.getGLInstance();
- gl.glGenBuffers(3, mBufferNames, 0);
-
- gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBufferNames[0]);
- gl.glBufferData(GL11.GL_ARRAY_BUFFER,
- mXyBuffer.capacity() * (Float.SIZE / Byte.SIZE),
- mXyBuffer, GL11.GL_STATIC_DRAW);
-
- gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBufferNames[1]);
- gl.glBufferData(GL11.GL_ARRAY_BUFFER,
- mUvBuffer.capacity() * (Float.SIZE / Byte.SIZE),
- mUvBuffer, GL11.GL_STATIC_DRAW);
-
- gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, mBufferNames[2]);
- gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER,
- mIndexBuffer.capacity(),
- mIndexBuffer, GL11.GL_STATIC_DRAW);
-
- // These buffers are never used again.
- mXyBuffer = null;
- mUvBuffer = null;
- mIndexBuffer = null;
- }
-
- public void draw(GLCanvas canvas, NinePatchTexture tex, int x, int y) {
- if (mBufferNames == null) {
- prepareBuffers(canvas);
- }
- canvas.drawMesh(tex, x, y, mBufferNames[0], mBufferNames[1],
- mBufferNames[2], mIdxCount);
- }
-
- public void recycle(GLCanvas canvas) {
- if (mBufferNames != null) {
- canvas.deleteBuffer(mBufferNames[0]);
- canvas.deleteBuffer(mBufferNames[1]);
- canvas.deleteBuffer(mBufferNames[2]);
- mBufferNames = null;
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/OnSelectedListener.java b/new3d/src/com/android/gallery3d/ui/OnSelectedListener.java
deleted file mode 100644
index 2cc5809..0000000
--- a/new3d/src/com/android/gallery3d/ui/OnSelectedListener.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-public interface OnSelectedListener {
- public void onSelected(GLView source);
-}
diff --git a/new3d/src/com/android/gallery3d/ui/PopupWindow.java b/new3d/src/com/android/gallery3d/ui/PopupWindow.java
deleted file mode 100644
index 237c0cd..0000000
--- a/new3d/src/com/android/gallery3d/ui/PopupWindow.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Rect;
-import android.util.Log;
-import android.view.View.MeasureSpec;
-import android.view.animation.OvershootInterpolator;
-
-import com.android.gallery3d.anim.AlphaAnimation;
-import com.android.gallery3d.anim.AnimationSet;
-import com.android.gallery3d.anim.CanvasAnimation;
-import com.android.gallery3d.anim.ScaleAnimation;
-import com.android.gallery3d.util.Utils;
-
-import javax.microedition.khronos.opengles.GL11;
-
-class PopupWindow extends GLView {
- private static final String TAG = "PopupWindow";
-
- protected BasicTexture mAnchor;
- protected int mAnchorOffset;
-
- protected int mAnchorPosition;
- private GLView mContent;
-
- protected Texture mBackground;
- private boolean mUsingStencil;
-
- public PopupWindow() {
- }
-
- @Override
- protected void onAttachToRoot(GLRoot root) {
- super.onAttachToRoot(root);
- mUsingStencil = root.hasStencil();
- }
-
- public void setBackground(Texture background) {
- if (background == mBackground) return;
- mBackground = background;
- if (background != null && background instanceof NinePatchTexture) {
- setPaddings(((NinePatchTexture) mBackground).getPaddings());
- } else {
- setPaddings(0, 0, 0, 0);
- }
- invalidate();
- }
-
- public void setAnchor(BasicTexture anchor, int offset) {
- mAnchor = anchor;
- mAnchorOffset = offset;
- }
-
- @Override
- public void addComponent(GLView component) {
- throw new UnsupportedOperationException("use setContent(GLView)");
- }
-
- @Override
- protected void onMeasure(int widthSpec, int heightSpec) {
- Rect p = mPaddings;
-
- int widthMode = MeasureSpec.getMode(widthSpec);
- if (widthMode != MeasureSpec.UNSPECIFIED) {
- int width = MeasureSpec.getSize(widthSpec);
- widthSpec = MeasureSpec.makeMeasureSpec(
- Math.max(0, width - p.left - p.right), widthMode);
- }
-
- int heightMode = MeasureSpec.getMode(heightSpec);
- if (heightMode != MeasureSpec.UNSPECIFIED) {
- int height = MeasureSpec.getSize(heightSpec);
- heightSpec = MeasureSpec.makeMeasureSpec(
- Math.max(0, height - p.top - p.bottom
- - mAnchor.getHeight() + mAnchorOffset), heightMode);
- }
-
- GLView child = mContent;
- child.measure(widthSpec, heightSpec);
-
- setMeasuredSize(child.getMeasuredWidth() + p.left + p.right,
- child.getMeasuredHeight() + p.top + p.bottom
- + mAnchor.getHeight() - mAnchorOffset);
- }
-
- @Override
- protected void onLayout(
- boolean change, int left, int top, int right, int bottom) {
- Rect p = getPaddings();
- GLView view = mContent;
- view.layout(p.left, p.top, getWidth() - p.right,
- getHeight() - p.bottom - mAnchor.getHeight() + mAnchorOffset);
- }
-
- public void setAnchorPosition(int xoffset) {
- mAnchorPosition = xoffset;
- }
-
- private void renderBackgroundWithStencil(GLCanvas canvas) {
- int width = getWidth();
- int height = getHeight();
- int aWidth = mAnchor.getWidth();
- int aHeight = mAnchor.getHeight();
-
- Rect p = mPaddings;
-
- int aXoffset = Utils.clamp(mAnchorPosition - aWidth / 2,
- p.left, width - p.right - aWidth);
- int aYoffset = height - aHeight;
- GL11 gl = canvas.getGLInstance();
- if (mAnchor != null) {
- gl.glEnable(GL11.GL_STENCIL_TEST);
- gl.glClear(GL11.GL_STENCIL_BUFFER_BIT);
- gl.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_REPLACE);
- gl.glStencilFunc(GL11.GL_ALWAYS, 1, 1);
- mAnchor.draw(canvas, aXoffset, aYoffset);
- gl.glStencilFunc(GL11.GL_NOTEQUAL, 1, 1);
- gl.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
- }
-
- if (mBackground != null) {
- mBackground.draw(canvas, 0, 0,
- width, height - aHeight + mAnchorOffset);
- }
-
- if (mAnchor != null) {
- gl.glDisable(GL11.GL_STENCIL_TEST);
- }
- }
-
- private void renderBackgroundWithoutStencil(GLCanvas canvas) {
- int width = getWidth();
- int height = getHeight();
- int aWidth = mAnchor.getWidth();
- int aHeight = mAnchor.getHeight();
-
- Rect p = mPaddings;
-
- int aXoffset = Utils.clamp(mAnchorPosition - aWidth / 2,
- p.left, width - p.right - aWidth);
- int aYoffset = height - aHeight;
-
- if (mAnchor != null) {
- mAnchor.draw(canvas, aXoffset, aYoffset);
- }
-
- BasicTexture backup = null;
-
- // Copy the current drawing results of the triangle area into
- // "backup", so that we can restore the content after it is
- // overlaid by the background.
- backup = canvas.copyTexture(aXoffset, aYoffset, aWidth, aHeight);
-
- if (mBackground != null) {
- mBackground.draw(canvas, 0, 0,
- width, height - aHeight + mAnchorOffset);
- }
-
- // restore the backup with alpha = 1
- canvas.drawTexture(backup, aXoffset, aYoffset, aWidth, aHeight, 1f);
- backup.recycle();
- }
-
- @Override
- protected void renderBackground(GLCanvas root) {
- if (mUsingStencil) {
- renderBackgroundWithStencil(root);
- } else {
- renderBackgroundWithoutStencil(root);
- }
- }
-
- public void setContent(GLView content) {
- if (mContent != null) {
- super.removeComponent(mContent);
- }
- mContent = content;
- super.addComponent(content);
- }
-
- @Override
- public void removeAllComponents() {
- throw new UnsupportedOperationException();
- }
-
- public void popup() {
- setVisibility(GLView.VISIBLE);
-
- AnimationSet set = new AnimationSet();
- CanvasAnimation scale = new ScaleAnimation(
- 0.7f, 1f, 0.7f, 1f, mAnchorPosition, getHeight());
- CanvasAnimation alpha = new AlphaAnimation(0.5f, 1.0f);
- set.addAnimation(scale);
- set.addAnimation(alpha);
- scale.setDuration(150);
- alpha.setDuration(100);
- scale.setInterpolator(new OvershootInterpolator());
- startAnimation(set);
- }
-
- public void popoff() {
- setVisibility(GLView.INVISIBLE);
- AlphaAnimation alpha = new AlphaAnimation(0.7f, 0.0f);
- alpha.setDuration(100);
- startAnimation(alpha);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/PositionRepository.java b/new3d/src/com/android/gallery3d/ui/PositionRepository.java
deleted file mode 100644
index 6667b4c..0000000
--- a/new3d/src/com/android/gallery3d/ui/PositionRepository.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package com.android.gallery3d.ui;
-
-import java.util.HashMap;
-
-public class PositionRepository {
-
- public static class Position implements Cloneable {
- public float x;
- public float y;
- public float z;
- public float theta;
- public float alpha;
-
- public Position() {
- }
-
- public Position(float x, float y, float z) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.theta = 0f;
- this.alpha = 1f;
- }
-
- @Override
- public Position clone() {
- try {
- return (Position) super.clone();
- } catch (CloneNotSupportedException e) {
- throw new AssertionError(); // we do support clone.
- }
- }
-
- public void set(Position another) {
- x = another.x;
- y = another.y;
- z = another.z;
- theta = another.theta;
- alpha = another.alpha;
- }
-
- public void set(float x, float y, float z, float theta, float alpha) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.theta = theta;
- this.alpha = alpha;
- }
-
- @Override
- public boolean equals(Object object) {
- if (!(object instanceof Position)) return false;
- Position position = (Position) object;
- return x == position.x && y == position.y && z == position.z
- && theta == position.theta && alpha == position.alpha;
- }
-
- public static void interpolate(
- Position source, Position target, Position output, float interpolate) {
- if (interpolate < 1f) {
- output.set(interpolateScale(source.x, target.x, interpolate),
- interpolateScale(source.y, target.y, interpolate),
- interpolateScale(source.z, target.z, interpolate),
- interpolateAngle(source.theta, target.theta, interpolate),
- interpolateScale(source.alpha, target.alpha, interpolate));
- } else {
- output.set(target);
- }
- }
- }
-
- private HashMap<Long, Position> mData = new HashMap<Long, Position>();
- private float mOffsetX;
- private float mOffsetY;
- private float mOffsetZ;
-
- public Position get(Long identity) {
- return mData.get(identity);
- }
-
- public void setPositionOffset(int offsetX, int offsetY, int offsetZ) {
- float deltaX = offsetX - mOffsetX;
- float deltaY = offsetY - mOffsetY;
- float deltaZ = offsetZ - mOffsetZ;
- mOffsetX = offsetX;
- mOffsetY = offsetY;
- mOffsetZ = offsetZ;
- for (Position position : mData.values()) {
- position.x += deltaX;
- position.y += deltaY;
- position.z += deltaZ;
- }
- }
-
- public void putPosition(Long identity, Position position) {
- mData.put(identity, position);
- }
-
- public void clear() {
- mData.clear();
- }
-
- private static float interpolateScale(
- float source, float target, float interpolate) {
- return source + interpolate * (target - source);
- }
-
- private static float interpolateAngle(
- float source, float target, float interpolate) {
- // interpolate the angle from source to target
- // We make the difference in the range of [-179, 180], this is the
- // shortest path to change source to target.
- float diff = target - source;
- if (diff < 0) diff += 360f;
- if (diff > 180) diff -= 360f;
-
- float result = source + diff * interpolate;
- return result < 0 ? result + 360f : result;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/RawTexture.java b/new3d/src/com/android/gallery3d/ui/RawTexture.java
deleted file mode 100644
index c1be435..0000000
--- a/new3d/src/com/android/gallery3d/ui/RawTexture.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import javax.microedition.khronos.opengles.GL11;
-
-// RawTexture is used for texture created by glCopyTexImage2D.
-//
-// It will throw RuntimeException in onBind() if used with a different GL
-// context. It is only used internally by copyTexture() in GLCanvas.
-class RawTexture extends BasicTexture {
-
- private RawTexture(GLCanvas canvas, int id) {
- super(canvas, id, STATE_LOADED);
- }
-
- public static RawTexture newInstance(GLCanvas canvas) {
- int[] textureId = new int[1];
- GL11 gl = canvas.getGLInstance();
- gl.glGenTextures(1, textureId, 0);
- return new RawTexture(canvas, textureId[0]);
- }
-
- @Override
- protected boolean onBind(GLCanvas canvas) {
- if (mCanvasRef.get() != canvas) {
- throw new RuntimeException("cannot bind to different canvas");
- }
- return true;
- }
-
- public boolean isOpaque() {
- return true;
- }
-
- @Override
- public void yield() {
- // we cannot free the texture because we have no backup.
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/ResourceTexture.java b/new3d/src/com/android/gallery3d/ui/ResourceTexture.java
deleted file mode 100644
index c57b5dc..0000000
--- a/new3d/src/com/android/gallery3d/ui/ResourceTexture.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import com.android.gallery3d.util.Utils;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-
-// ResourceTexture is a texture whose Bitmap is decoded from a resource.
-// By default ResourceTexture is not opaque.
-class ResourceTexture extends UploadedTexture {
-
- protected final Context mContext;
- protected final int mResId;
-
- public ResourceTexture(Context context, int resId) {
- mContext = Utils.checkNotNull(context);
- mResId = resId;
- setOpaque(false);
- }
-
- @Override
- protected Bitmap onGetBitmap() {
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- return BitmapFactory.decodeResource(
- mContext.getResources(), mResId, options);
- }
-
- @Override
- protected void onFreeBitmap(Bitmap bitmap) {
- if (!inFinalizer()) {
- bitmap.recycle();
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/ScrollerHelper.java b/new3d/src/com/android/gallery3d/ui/ScrollerHelper.java
deleted file mode 100644
index f60349d..0000000
--- a/new3d/src/com/android/gallery3d/ui/ScrollerHelper.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import com.android.gallery3d.util.Utils;
-
-public class ScrollerHelper {
- private static final long START_ANIMATION = -1;
- private static final long NO_ANIMATION = -2;
-
- private static final int ANIM_KIND_FLING = 1;
- private static final int ANIM_KIND_SCROLL = 2;
-
- private static final int DECELERATED_FACTOR = 4;
-
- private long mStartTime = NO_ANIMATION;
-
- private int mDuration; // in millisecond
-
- private int mStart;
- private int mFinal;
- private int mPosition;
-
- private int mMin;
- private int mMax;
-
- private int mAnimationKind;
-
- // The fling duration when velocity is 1 pixel / second
- private float FLING_DURATION_PARAM = 200f; // 200ms
-
- /**
- * Call this when you want to know the new location. The position will be
- * updated and can be obtained by getPosition(). Returns true if the
- * animation is not yet finished.
- */
- public boolean advanceAnimation(long currentTimeMillis) {
- if (mStartTime == NO_ANIMATION) return false;
- if (mStartTime == START_ANIMATION) mStartTime = currentTimeMillis;
-
- int timePassed = (int)(currentTimeMillis - mStartTime);
- if (timePassed < mDuration) {
- float progress = (float) timePassed / mDuration;
- float f = 1 - progress;
- if (mAnimationKind == ANIM_KIND_SCROLL) {
- f = 1 - f; // linear
- } else if (mAnimationKind == ANIM_KIND_FLING) {
- f = 1 - (float) Math.pow(f, DECELERATED_FACTOR);
- }
- mPosition = Utils.clamp(
- Math.round(mStart + (mFinal - mStart) * f), mMin, mMax);
- if (mPosition == Utils.clamp(mFinal, mMin, mMax)) {
- mStartTime = NO_ANIMATION;
- return false;
- }
- return true;
- } else {
- mPosition = mFinal;
- mStartTime = NO_ANIMATION;
- return false;
- }
- }
-
- public void forceFinished() {
- mStartTime = NO_ANIMATION;
- mFinal = mPosition;
- }
-
- public int getPosition() {
- return mPosition;
- }
-
- public void setPosition(int position) {
- mPosition = position;
- }
-
- public void fling(float velocity, int min, int max) {
- /*
- * The position formula: x(t) = s + (e - s) * (1 - (1 - t / T) ^ d)
- * velocity formula: v(t) = d * (e - s) * (1 - t / T) ^ (d - 1) / T
- * Thus,
- * v0 = (e - s) / T * d => (e - s) = v0 * T / d
- */
- mStartTime = START_ANIMATION;
- mAnimationKind = ANIM_KIND_FLING;
- mStart = mPosition;
- mMin = min;
- mMax = max;
-
- // Ta = T_ref * (Va / V_ref) ^ (1 / (d - 1)); V_ref = 1 pixel/second;
- mDuration = (int) Math.round(FLING_DURATION_PARAM
- * Math.pow(Math.abs(velocity), 1.0 / (DECELERATED_FACTOR - 1)));
- mFinal = mStart + Math.round(
- velocity * mDuration / DECELERATED_FACTOR / 1000);
- }
-
- public void startScroll(int distance, int min, int max) {
- mPosition = Utils.clamp(mPosition + distance, min, max);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/SelectionDrawer.java b/new3d/src/com/android/gallery3d/ui/SelectionDrawer.java
deleted file mode 100644
index 670d771..0000000
--- a/new3d/src/com/android/gallery3d/ui/SelectionDrawer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.content.Context;
-import android.graphics.Rect;
-
-import com.android.gallery3d.R;
-
-/**
- * Drawer class responsible for drawing selectable frame.
- */
-public class SelectionDrawer {
- private final NinePatchTexture mFrame;
- private final ResourceTexture mCheckedItem;
- private final ResourceTexture mUnCheckedItem;
- private boolean mSelectionMode;
-
- public SelectionDrawer(Context context) {
- mFrame = new NinePatchTexture(context, R.drawable.grid_frame);
- mCheckedItem = new ResourceTexture(context, R.drawable.grid_check_on);
- mUnCheckedItem = new ResourceTexture(context, R.drawable.grid_check_off);
- }
-
- public void setSelectionMode(boolean selectionMode) {
- mSelectionMode = selectionMode;
- }
-
- public Rect getFramePadding() {
- return mFrame.getPaddings();
- }
-
- public void draw(GLCanvas canvas, Texture content, int width, int height,
- boolean checked, boolean drawCheckedBox) {
- int x = -width / 2;
- int y = -height / 2;
- Rect p = mFrame.getPaddings();
- content.draw(canvas, x + p.left, y + p.top,
- width - p.left - p.right, height - p.top - p.bottom);
- mFrame.draw(canvas, x, y, width, height);
-
- if (drawCheckedBox && mSelectionMode) {
- int w = mCheckedItem.getWidth() / 2;
- int h = mCheckedItem.getHeight() / 2;
- x = width / 2 - w - p.left;
- y = height / 2 - h - p.left;
- if (checked)
- mCheckedItem.draw(canvas, x, y, w, h);
- else
- mUnCheckedItem.draw(canvas, x, y, w, h);
- }
- }
-
- public void draw(GLCanvas canvas, Texture content, int width, int height, boolean checked) {
- draw(canvas, content, width, height, checked, true);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/SelectionManager.java b/new3d/src/com/android/gallery3d/ui/SelectionManager.java
deleted file mode 100644
index aa6414e..0000000
--- a/new3d/src/com/android/gallery3d/ui/SelectionManager.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.content.Context;
-import android.os.Vibrator;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.data.DataManager;
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.data.MediaSet;
-
-public class SelectionManager {
- private static final String TAG = "SelectionManager";
- private Set<Long> mClickedSet;
- private MediaSet mSourceMediaSet;
- private final Vibrator mVibrator;
- private final SelectionDrawer mDrawer;
- private SelectionListener mListener;
- private DataManager mDataManager;
- private boolean mInverseSelection;
- private boolean mIsAlbumSet;
- private int mTotal;
-
- public interface SelectionListener {
- public void onSelectionModeChange(boolean inSelectionMode);
- }
-
- public SelectionManager(GalleryContext galleryContext, boolean isAlbumSet) {
- Context context = galleryContext.getAndroidContext();
- mDrawer = new SelectionDrawer(context);
- mDataManager = galleryContext.getDataManager();
- mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
- mClickedSet = new HashSet<Long>();
- mIsAlbumSet = isAlbumSet;
- mTotal = -1;
- }
-
- public void setSelectionListener(SelectionListener listener) {
- mListener = listener;
- }
-
- public void selectAll() {
- enterSelectionMode();
- mInverseSelection = true;
- mClickedSet.clear();
- }
-
- public void deSelectAll() {
- leaveSelectionMode();
- mInverseSelection = false;
- mClickedSet.clear();
- }
-
- public SelectionDrawer getSelectionDrawer() {
- return mDrawer;
- }
-
- public boolean inSelectionMode() {
- return mInverseSelection || (mClickedSet.size() > 0);
- }
-
- private void enterSelectionMode() {
- if (inSelectionMode()) return;
-
- mVibrator.vibrate(100);
- mDrawer.setSelectionMode(true);
- if (mListener != null) mListener.onSelectionModeChange(true);
- }
-
- public void leaveSelectionMode() {
- if (!inSelectionMode()) return;
-
- mInverseSelection = false;
- mDrawer.setSelectionMode(false);
- mClickedSet.clear();
- if (mListener != null) mListener.onSelectionModeChange(false);
- }
-
- public boolean isItemSelected(long itemId) {
- return mInverseSelection ^ mClickedSet.contains(itemId);
- }
-
- public void toggle(long itemId) {
- if (mClickedSet.contains(itemId)) {
- mClickedSet.remove(itemId);
- } else {
- enterSelectionMode();
- mClickedSet.add(itemId);
- }
-
- if (mInverseSelection) {
- if (mTotal < 0) {
- mTotal = mIsAlbumSet
- ? mSourceMediaSet.getSubMediaSetCount()
- : mSourceMediaSet.getMediaItemCount();
- }
- if (mClickedSet.size() == mTotal) leaveSelectionMode();
- } else {
- if (mClickedSet.size() == 0) leaveSelectionMode();
- }
- }
-
- private static void expandMediaSet(ArrayList<Long> items, MediaSet set) {
- int subCount = set.getSubMediaSetCount();
- for (int i = 0; i < subCount; i++) {
- expandMediaSet(items, set.getSubMediaSet(i));
- }
- int total = set.getMediaItemCount();
- int batch = 50;
- int index = 0;
-
- while (index < total) {
- int count = index + batch < total
- ? batch
- : total - index;
- ArrayList<MediaItem> list = set.getMediaItem(index, count);
- for (MediaItem item : list) {
- items.add(item.getUniqueId());
- }
- index += batch;
- }
- }
-
- public ArrayList<Long> getSelected(boolean expandSet) {
- ArrayList<Long> selected = new ArrayList<Long>();
- if (mIsAlbumSet) {
- if (mInverseSelection) {
- int max = mSourceMediaSet.getSubMediaSetCount();
- for (int i = 0; i < max; i++) {
- MediaSet set = mSourceMediaSet.getSubMediaSet(i);
- long id = set.getUniqueId();
- if (!mClickedSet.contains(id)) {
- if (expandSet) {
- expandMediaSet(selected, set);
- } else {
- selected.add(id);
- }
- }
- }
- } else {
- for (long id : mClickedSet) {
- if (expandSet) {
- expandMediaSet(selected,
- mDataManager.getMediaSet(DataManager.extractSelfId(id)));
- } else {
- selected.add(id);
- }
- }
- }
- } else {
- if (mInverseSelection) {
- int batch = 50;
- int total = mSourceMediaSet.getMediaItemCount();
- int index = 0;
-
- while (index < total) {
- int count = index + batch < total
- ? batch
- : total - index;
- ArrayList<MediaItem> list = mSourceMediaSet.getMediaItem(index, count);
- for (MediaItem item : list) {
- long id = item.getUniqueId();
- if (!mClickedSet.contains(id)) selected.add(id);
- }
- index += batch;
- }
- } else {
- for (long id : mClickedSet) {
- selected.add(id);
- }
- }
- }
- return selected;
- }
-
- public void setSourceMediaSet(MediaSet set) {
- mSourceMediaSet = set;
- mTotal = -1;
- }
-
- public MediaSet getSourceMediaSet() {
- return mSourceMediaSet;
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/SlideshowView.java b/new3d/src/com/android/gallery3d/ui/SlideshowView.java
deleted file mode 100644
index 0c830d2..0000000
--- a/new3d/src/com/android/gallery3d/ui/SlideshowView.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-import android.graphics.PointF;
-
-import com.android.gallery3d.anim.CanvasAnimation;
-import com.android.gallery3d.anim.FloatAnimation;
-
-import java.util.Random;
-
-import javax.microedition.khronos.opengles.GL11;
-
-public class SlideshowView extends GLView {
- private static final String TAG = "SlideshowView";
-
- private static final int SLIDESHOW_DURATION = 3500;
- private static final int TRANSITION_DURATION = 1000;
-
- private static final float SCALE_SPEED = 0.20f ;
- private static final float MOVE_SPEED = SCALE_SPEED;
-
- private BitmapTexture mCurrentTexture;
- private SlideshowAnimation mCurrentAnimation;
-
- private BitmapTexture mPrevTexture;
- private SlideshowAnimation mPrevAnimation;
-
- private final FloatAnimation mTransitionAnimation =
- new FloatAnimation(0, 1, TRANSITION_DURATION);
-
- private Random mRandom = new Random();
-
- public static interface SlideshowListener {
- public void onSlideshowEnd();
- }
-
- public SlideshowView() {
- }
-
- public void next(Bitmap bitmap) {
-
- mTransitionAnimation.start();
-
- if (mPrevTexture != null) {
- mPrevTexture.getBitmap().recycle();
- mPrevTexture.recycle();
- }
-
- mPrevTexture = mCurrentTexture;
- mPrevAnimation = mCurrentAnimation;
-
- mCurrentTexture = new BitmapTexture(bitmap);
- mCurrentAnimation = new SlideshowAnimation(mCurrentTexture, mRandom);
- mCurrentAnimation.start();
-
- invalidate();
- }
-
- public void close() {
- if (mPrevTexture != null) {
- mPrevTexture.getBitmap().recycle();
- mPrevTexture.recycle();
- mPrevTexture = null;
- }
- if (mCurrentTexture != null) {
- mCurrentTexture.getBitmap().recycle();
- mCurrentTexture.recycle();
- mCurrentTexture = null;
- }
- }
-
- @Override
- protected void render(GLCanvas canvas) {
- long currentTimeMillis = canvas.currentAnimationTimeMillis();
- boolean requestRender = mTransitionAnimation.calculate(currentTimeMillis);
- GL11 gl = canvas.getGLInstance();
- gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
- float alpha = mPrevTexture == null ? 1f : mTransitionAnimation.get();
-
- if (mPrevTexture != null && alpha != 1f) {
- requestRender |= mPrevAnimation.calculate(currentTimeMillis);
- canvas.save(GLCanvas.SAVE_FLAG_ALPHA
- | mPrevAnimation.getCanvasSaveFlags());
- canvas.setAlpha(1f - alpha);
- mPrevAnimation.apply(canvas);
- mPrevTexture.draw(canvas, -mPrevTexture.getWidth() / 2,
- -mPrevTexture.getHeight() / 2);
- canvas.restore();
- }
- if (mCurrentTexture != null) {
- requestRender |= mCurrentAnimation.calculate(currentTimeMillis);
- canvas.save(GLCanvas.SAVE_FLAG_ALPHA
- | mCurrentAnimation.getCanvasSaveFlags());
- canvas.setAlpha(alpha);
- mCurrentAnimation.apply(canvas);
- mCurrentTexture.draw(canvas, -mCurrentTexture.getWidth() / 2,
- -mCurrentTexture.getHeight() / 2);
- canvas.restore();
- }
- if (requestRender) invalidate();
- gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- }
-
- private class SlideshowAnimation extends CanvasAnimation {
- private final int mWidth;
- private final int mHeight;
-
- private final PointF mMovingVector;
- private float mProgress;
-
- public SlideshowAnimation(Texture texture, Random random) {
- mWidth = texture.getWidth();
- mHeight = texture.getHeight();
- mMovingVector = new PointF(
- MOVE_SPEED * mWidth * (random.nextFloat() - 0.5f),
- MOVE_SPEED * mHeight * (random.nextFloat() - 0.5f));
- setDuration(SLIDESHOW_DURATION);
- }
-
- @Override
- public void apply(GLCanvas canvas) {
- int viewWidth = getWidth();
- int viewHeight = getHeight();
-
- float initScale = Math.min(2f, Math.min((float)
- viewWidth / mWidth, (float) viewHeight / mHeight));
- float scale = initScale * (1 + SCALE_SPEED * mProgress);
-
- float centerX = viewWidth / 2 + mMovingVector.x * mProgress;
- float centerY = viewHeight / 2 + mMovingVector.y * mProgress;
-
- canvas.translate(centerX, centerY, 0);
- canvas.scale(scale, scale, 0);
- }
-
- @Override
- public int getCanvasSaveFlags() {
- return GLCanvas.SAVE_FLAG_MATRIX;
- }
-
- @Override
- protected void onCalculate(float progress) {
- mProgress = progress;
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/SlotView.java b/new3d/src/com/android/gallery3d/ui/SlotView.java
deleted file mode 100644
index 10277d3..0000000
--- a/new3d/src/com/android/gallery3d/ui/SlotView.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.view.GestureDetector;
-import android.view.MotionEvent;
-import android.view.animation.DecelerateInterpolator;
-
-import com.android.gallery3d.anim.Animation;
-import com.android.gallery3d.ui.PositionRepository.Position;
-import com.android.gallery3d.util.Utils;
-
-import java.util.LinkedHashMap;
-
-public class SlotView extends GLView {
- private static final String TAG = "SlotView";
- private static final int MAX_VELOCITY = 3200;
- private static final boolean WIDE = false;
-
- private static final int INDEX_NONE = -1;
-
- public interface SlotTapListener {
- public void onSingleTapUp(int index);
- public void onLongTap(int index);
- }
-
- private final GestureDetector mGestureDetector;
- private final ScrollerHelper mScroller = new ScrollerHelper();
- private final PositionRepository mPositions;
-
- private SlotTapListener mSlotTapListener;
-
- private int mTransitionOffsetX;
-
- // Use linked hash map to keep the rendering order
- private LinkedHashMap<Long, ItemEntry> mItems =
- new LinkedHashMap<Long, ItemEntry>();
-
- private MyAnimation mAnimation = null;
- private final Position mTempPosition = new Position();
- private final Layout mLayout = new Layout();
-
- public SlotView(Context context, PositionRepository repository) {
- mPositions = repository;
- mGestureDetector =
- new GestureDetector(context, new MyGestureListener());
- }
-
- public void setSlotSize(int slotWidth, int slotHeight) {
- mLayout.setSlotSize(slotWidth, slotHeight);
- }
-
- public void setSlotGaps(int horizontalGap, int verticalGap, boolean center) {
- mLayout.setSlotGaps(horizontalGap, verticalGap, center);
- }
-
- @Override
- public void addComponent(GLView view) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean removeComponent(GLView view) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void onLayout(boolean changeSize, int l, int t, int r, int b) {
- if (!changeSize) return;
- mLayout.setSize(r - l, b - t);
- onLayoutChanged(r - l, b - t);
- }
-
- protected void onLayoutChanged(int width, int height) {
- }
-
- public void startTransition() {
- mAnimation = new MyAnimation();
- mAnimation.start();
- mTransitionOffsetX = mScrollX;
- if (mItems.size() != 0) invalidate();
- }
-
- public void savePositions() {
- mPositions.clear();
- for (ItemEntry entry : mItems.values()) {
- Position position = entry.target.clone();
- if (WIDE) {
- position.x -= mScrollX;
- } else {
- position.y -= mScrollY;
- }
- mPositions.putPosition(entry.item.getIdentity(), position);
- }
- }
-
- private void setScrollPosition(int position, boolean force) {
- position = Utils.clamp(position, 0, mLayout.getScrollLimit());
- if (!force && (WIDE ? position == mScrollX : position == mScrollY)) return;
- if (WIDE) {
- mScrollX = position;
- } else {
- mScrollY = position;
- }
- mLayout.setScrollPosition(position);
- onScrollPositionChanged(position);
- }
-
- protected void onScrollPositionChanged(int newPosition) {
- }
-
- public void putDisplayItem(Position target, DisplayItem item) {
- Long identity = Long.valueOf(item.getIdentity());
- Position source = mPositions.get(identity);
- if (source == null) {
- source = target.clone();
- source.alpha = 0f;
- } else {
- source = source.clone();
- source.x += mTransitionOffsetX;
- }
- mItems.put(identity, new ItemEntry(item, source, target));
- }
-
- public Rect getSlotRect(int slotIndex) {
- return mLayout.getSlotRect(slotIndex);
- }
-
- public void removeDisplayItem(DisplayItem item) {
- mItems.remove(item.getIdentity());
- }
-
- @Override
- protected boolean onTouch(MotionEvent event) {
- mGestureDetector.onTouchEvent(event);
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- mScroller.forceFinished();
- break;
- }
- return true;
- }
-
-
- public void setSlotTapListener(SlotTapListener listener) {
- mSlotTapListener = listener;
- }
-
- @Override
- protected void render(GLCanvas canvas) {
- super.render(canvas);
- long currentTimeMillis = canvas.currentAnimationTimeMillis();
- boolean more = mScroller.advanceAnimation(currentTimeMillis);
- setScrollPosition(mScroller.getPosition(), false);
- float interpolate = 1f;
- if (mAnimation != null) {
- more |= mAnimation.calculate(currentTimeMillis);
- interpolate = mAnimation.value;
- }
-
- if (WIDE) {
- canvas.translate(-mScrollX, 0, 0);
- } else {
- canvas.translate(0, -mScrollY, 0);
- }
- for (ItemEntry entry : mItems.values()) {
- renderItem(canvas, entry, interpolate);
- }
- if (WIDE) {
- canvas.translate(mScrollX, 0, 0);
- } else {
- canvas.translate(0, mScrollY, 0);
- }
-
- if (more) invalidate();
- }
-
- private void renderItem(
- GLCanvas canvas, ItemEntry entry, float interpolate) {
- canvas.save(GLCanvas.SAVE_FLAG_ALPHA | GLCanvas.SAVE_FLAG_MATRIX);
- Position position = mTempPosition;
- Position.interpolate(entry.source, entry.target, position, interpolate);
- canvas.multiplyAlpha(position.alpha);
- canvas.translate(position.x, position.y, position.z);
- canvas.rotate(position.theta, 0, 0, 1);
- entry.item.render(canvas);
- canvas.restore();
- }
-
- public static class MyAnimation extends Animation {
- public float value;
-
- public MyAnimation() {
- setInterpolator(new DecelerateInterpolator(4));
- }
-
- @Override
- protected void onCalculate(float progress) {
- value = progress;
- }
- }
-
- private static class ItemEntry {
- public DisplayItem item;
- public Position source;
- public Position target;
-
- public ItemEntry(DisplayItem item, Position source, Position target) {
- this.item = item;
- this.source = source;
- this.target = target;
- }
- }
-
- public static class Layout {
-
- private int mVisibleStart;
- private int mVisibleEnd;
-
- private int mSlotCount;
- private int mSlotWidth;
- private int mSlotHeight;
-
- private int mWidth;
- private int mHeight;
-
- private int mVerticalGap;
- private int mHorizontalGap;
- private boolean mCenter;
- private int mSideMargin;
-
- private int mUnitSize;
- private int mContentLength;
- private int mScrollPosition;
-
- public void setSlotSize(int slotWidth, int slotHeight) {
- mSlotWidth = slotWidth;
- mSlotHeight = slotHeight;
- }
-
- public void setSlotCount(int slotCount) {
- mSlotCount = slotCount;
- initLayoutParameters();
- }
-
- public void setSlotGaps(int horizontalGap, int verticalGap, boolean center) {
- mHorizontalGap = horizontalGap;
- mVerticalGap = verticalGap;
- mCenter = center;
- initLayoutParameters();
- }
-
- public Rect getSlotRect(int index) {
- int col, row;
- if (WIDE) {
- col = index / mUnitSize;
- row = index - col * mUnitSize;
- } else {
- row = index / mUnitSize;
- col = index - row * mUnitSize;
- }
-
- int x = col * (mHorizontalGap + mSlotWidth) + mHorizontalGap;
- int y = row * (mVerticalGap + mSlotHeight) + mVerticalGap;
- if (WIDE) {
- y += mSideMargin;
- } else {
- x += mSideMargin;
- }
- return new Rect(x, y, x + mSlotWidth, y + mSlotHeight);
- }
-
- public int getContentLength() {
- return mContentLength;
- }
-
- private void initLayoutParameters() {
- int unitSize = WIDE ?
- (mHeight - mVerticalGap) / (mVerticalGap + mSlotHeight) :
- (mWidth - mHorizontalGap) / (mHorizontalGap + mSlotWidth);
- if (unitSize == 0) unitSize = 1;
- mUnitSize = unitSize;
- if (mCenter) {
- mSideMargin = WIDE ?
- (mHeight - unitSize * (mVerticalGap + mSlotHeight)) / 2 :
- (mWidth - unitSize * (mHorizontalGap + mSlotWidth)) / 2;
- } else {
- mSideMargin = 0;
- }
- mContentLength = ((mSlotCount + unitSize - 1) / unitSize);
- mContentLength *= WIDE ?
- (mHorizontalGap + mSlotWidth) + mHorizontalGap :
- (mVerticalGap + mSlotHeight) + mVerticalGap;
- updateVisibleSlotRange();
- }
-
- public void setSize(int width, int height) {
- mWidth = width;
- mHeight = height;
- initLayoutParameters();
- }
-
- private void updateVisibleSlotRange() {
- int position = Utils.clamp(mScrollPosition, 0, getScrollLimit());
- int colWidth = mHorizontalGap + mSlotWidth;
- int rowHeight = mVerticalGap + mSlotHeight;
-
- if (WIDE) {
- int startColumn = position / colWidth;
- int endColumn = (position + mWidth + mSlotWidth - 1) / colWidth;
-
- setVisibleRange(startColumn * mUnitSize,
- Math.min(mSlotCount, endColumn * mUnitSize));
- } else {
- int startRow = position / rowHeight;
- int endRow = (position + mHeight + mSlotHeight - 1) / rowHeight;
-
- setVisibleRange(startRow * mUnitSize,
- Math.min(mSlotCount, endRow * mUnitSize));
- }
- }
-
- public void setScrollPosition(int position) {
- if (mScrollPosition == position) return;
- mScrollPosition = position;
- updateVisibleSlotRange();
- }
-
- private void setVisibleRange(int start, int end) {
- if (start == mVisibleStart && end == mVisibleEnd) return;
- mVisibleStart = start;
- mVisibleEnd = end;
- }
-
- public int getVisibleStart() {
- return mVisibleStart;
- }
-
- public int getVisibleEnd() {
- return mVisibleEnd;
- }
-
- public int getSlotIndexByPosition(float x, float y) {
- int columnWidth = mHorizontalGap + mSlotWidth;
- float absoluteX = x + (WIDE ? mScrollPosition : -mSideMargin);
- int columnIdx = (int) (absoluteX + 0.5) / columnWidth;
- if ((absoluteX - columnWidth * columnIdx) < mHorizontalGap
- || (!WIDE && columnIdx >= mUnitSize)) {
- return INDEX_NONE;
- }
-
- int rowHeight = mVerticalGap + mSlotHeight;
- float absoluteY = y + (WIDE ? -mSideMargin : mScrollPosition);
- int rowIdx = (int) (absoluteY + 0.5) / rowHeight;
- if (((absoluteY - rowHeight * rowIdx) < mVerticalGap)
- || (WIDE && rowIdx >= mUnitSize)) {
- return INDEX_NONE;
- }
- int index = WIDE ?
- (columnIdx * mUnitSize + rowIdx) :
- (rowIdx * mUnitSize + columnIdx);
-
- return index >= mSlotCount ? INDEX_NONE : index;
- }
-
- public int getScrollLimit() {
- int limit = WIDE ? mContentLength - mWidth : mContentLength - mHeight;
- return limit <= 0 ? 0 : limit;
- }
- }
-
- private class MyGestureListener
- extends GestureDetector.SimpleOnGestureListener {
-
- @Override
- public boolean onFling(MotionEvent e1,
- MotionEvent e2, float velocityX, float velocityY) {
- int scrollLimit = mLayout.getScrollLimit();
- if (scrollLimit == 0) return false;
- float velocity = WIDE ? velocityX : velocityY;
- velocityX = Utils.clamp(velocity, -MAX_VELOCITY, MAX_VELOCITY);
- mScroller.fling(-velocity, 0, scrollLimit);
- invalidate();
- return true;
- }
-
- @Override
- public boolean onScroll(MotionEvent e1,
- MotionEvent e2, float distanceX, float distanceY) {
- int limit = mLayout.getScrollLimit();
- if (limit == 0) return false;
- mScroller.startScroll(
- Math.round(WIDE ? distanceX : distanceY), 0,
- mLayout.getScrollLimit());
- invalidate();
- return true;
- }
-
- @Override
- public boolean onSingleTapUp(MotionEvent e) {
- int index = mLayout.getSlotIndexByPosition(e.getX(), e.getY());
- if (index != INDEX_NONE) mSlotTapListener.onSingleTapUp(index);
- return true;
- }
-
- @Override
- public void onLongPress(MotionEvent e) {
- int index = mLayout.getSlotIndexByPosition(e.getX(), e.getY());
- if (index != INDEX_NONE) mSlotTapListener.onLongTap(index);
- }
- }
-
- public void setSlotCount(int slotCount) {
- mLayout.setSlotCount(slotCount);
- }
-
- public int getVisibleStart() {
- return mLayout.getVisibleStart();
- }
-
- public int getVisibleEnd() {
- return mLayout.getVisibleEnd();
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/StringTexture.java b/new3d/src/com/android/gallery3d/ui/StringTexture.java
deleted file mode 100644
index a71097c..0000000
--- a/new3d/src/com/android/gallery3d/ui/StringTexture.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Paint.FontMetricsInt;
-
-// StringTexture is a texture shows the content of a specified String.
-//
-// To create a StringTexture, use the newInstance() method and specify
-// the String, the font size, and the color.
-class StringTexture extends CanvasTexture {
- private static int DEFAULT_PADDING = 1;
-
- private final String mText;
- private final Paint mPaint;
- private final FontMetricsInt mMetrics;
-
- private StringTexture(String text, Paint paint,
- FontMetricsInt metrics, int width, int height) {
- super(width, height);
- mText = text;
- mPaint = paint;
- mMetrics = metrics;
- }
-
- public static StringTexture newInstance(
- String text, float textSize, int color) {
- Paint paint = new Paint();
- paint.setTextSize(textSize);
- paint.setAntiAlias(true);
- paint.setColor(color);
-
- return newInstance(text, paint);
- }
-
- private static StringTexture newInstance(String text, Paint paint) {
- FontMetricsInt metrics = paint.getFontMetricsInt();
- int width = (int) (.5f + paint.measureText(text)) + DEFAULT_PADDING * 2;
- int height = metrics.bottom - metrics.top + DEFAULT_PADDING * 2;
- return new StringTexture(text, paint, metrics, width, height);
- }
-
- @Override
- protected void onDraw(Canvas canvas, Bitmap backing) {
- canvas.translate(DEFAULT_PADDING, DEFAULT_PADDING - mMetrics.ascent);
- canvas.drawText(mText, 0, 0, mPaint);
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/SynchronizedHandler.java b/new3d/src/com/android/gallery3d/ui/SynchronizedHandler.java
deleted file mode 100644
index 2f901f5..0000000
--- a/new3d/src/com/android/gallery3d/ui/SynchronizedHandler.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.os.Handler;
-import android.os.Message;
-
-import com.android.gallery3d.util.Utils;
-
-public class SynchronizedHandler extends Handler {
-
- private final GLRoot mRoot;
-
- public SynchronizedHandler(GLRoot root) {
- mRoot = Utils.checkNotNull(root);
- }
-
- @Override
- public void dispatchMessage(Message message) {
- mRoot.lockRenderThread();
- try {
- super.dispatchMessage(message);
- } finally {
- mRoot.unlockRenderThread();
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/ui/Texture.java b/new3d/src/com/android/gallery3d/ui/Texture.java
deleted file mode 100644
index feb7b0a..0000000
--- a/new3d/src/com/android/gallery3d/ui/Texture.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-// Texture is a rectangular image which can be drawn on GLCanvas.
-// The isOpaque() function gives a hint about whether the texture is opaque,
-// so the drawing can be done faster.
-//
-// This is the current texture hierarchy:
-//
-// Texture
-// -- ColorTexture
-// -- BasicTexture
-// -- RawTexture
-// -- UploadedTexture
-// -- BitmapTexture
-// -- Tile
-// -- ResourceTexture
-// -- NinePatchTexture
-// -- CanvasTexture
-// -- DrawableTexture
-// -- StringTexture
-//
-public interface Texture {
- public int getWidth();
- public int getHeight();
- public void draw(GLCanvas canvas, int x, int y);
- public void draw(GLCanvas canvas, int x, int y, int w, int h);
- public boolean isOpaque();
-}
diff --git a/new3d/src/com/android/gallery3d/ui/UploadedTexture.java b/new3d/src/com/android/gallery3d/ui/UploadedTexture.java
deleted file mode 100644
index 1be54a6..0000000
--- a/new3d/src/com/android/gallery3d/ui/UploadedTexture.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-import android.opengl.GLUtils;
-
-import com.android.gallery3d.util.Utils;
-
-import javax.microedition.khronos.opengles.GL11;
-import javax.microedition.khronos.opengles.GL11Ext;
-
-// UploadedTextures use a Bitmap for the content of the texture.
-//
-// Subclasses should implement onGetBitmap() to provide the Bitmap and
-// implement onFreeBitmap(mBitmap) which will be called when the Bitmap
-// is not needed anymore.
-//
-// isContentValid() is meaningful only when the isLoaded() returns true.
-// It means whether the content needs to be updated.
-//
-// The user of this class should call recycle() when the texture is not
-// needed anymore.
-//
-// By default an UploadedTexture is opaque (so it can be drawn faster without
-// blending). The user or subclass can override it using setOpaque().
-abstract class UploadedTexture extends BasicTexture {
-
- @SuppressWarnings("unused")
- private static final String TAG = "Texture";
- private boolean mContentValid = true;
- private boolean mOpaque = true;
- private boolean mThrottled = false;
- private static int sUploadedCount;
- private static final int UPLOAD_LIMIT = 1;
-
- protected Bitmap mBitmap;
-
- protected UploadedTexture() {
- super(null, 0, STATE_UNLOADED);
- }
-
- protected void setThrottled(boolean throttled) {
- mThrottled = throttled;
- }
-
- private Bitmap getBitmap() {
- if (mBitmap == null) {
- mBitmap = onGetBitmap();
- if (mWidth == UNSPECIFIED) {
- setSize(mBitmap.getWidth(), mBitmap.getHeight());
- } else if (mWidth != mBitmap.getWidth()
- || mHeight != mBitmap.getHeight()) {
- throw new IllegalStateException("cannot change content size");
- }
- }
- return mBitmap;
- }
-
- private void freeBitmap() {
- Utils.Assert(mBitmap != null);
- onFreeBitmap(mBitmap);
- mBitmap = null;
- }
-
- @Override
- public int getWidth() {
- if (mWidth == UNSPECIFIED) getBitmap();
- return mWidth;
- }
-
- @Override
- public int getHeight() {
- if (mWidth == UNSPECIFIED) getBitmap();
- return mHeight;
- }
-
- protected abstract Bitmap onGetBitmap();
-
- protected abstract void onFreeBitmap(Bitmap bitmap);
-
- protected void invalidateContent() {
- if (mBitmap != null) freeBitmap();
- mContentValid = false;
- }
-
- /**
- * Whether the content on GPU is valid.
- */
- public boolean isContentValid(GLCanvas canvas) {
- return isLoaded(canvas) && mContentValid;
- }
-
- /**
- * Updates the content on GPU's memory.
- * @param canvas
- */
- public void updateContent(GLCanvas canvas) {
- if (!isLoaded(canvas)) {
- if (mThrottled && ++sUploadedCount > UPLOAD_LIMIT) {
- return;
- }
- uploadToCanvas(canvas);
- } else if (!mContentValid) {
- Bitmap bitmap = getBitmap();
- int format = GLUtils.getInternalFormat(bitmap);
- int type = GLUtils.getType(bitmap);
- canvas.getGLInstance().glBindTexture(GL11.GL_TEXTURE_2D, mId);
- GLUtils.texSubImage2D(
- GL11.GL_TEXTURE_2D, 0, 0, 0, bitmap, format, type);
- freeBitmap();
- mContentValid = true;
- }
- }
-
- public static void resetUploadLimit() {
- sUploadedCount = 0;
- }
-
- public static boolean uploadLimitReached() {
- return sUploadedCount > UPLOAD_LIMIT;
- }
-
- static int[] sTextureId = new int[1];
- static int[] sCropRect = new int[4];
-
- private void uploadToCanvas(GLCanvas canvas) {
- GL11 gl = canvas.getGLInstance();
-
- Bitmap bitmap = getBitmap();
- if (bitmap != null) {
- try {
- // Define a vertically flipped crop rectangle for
- // OES_draw_texture.
- int width = bitmap.getWidth();
- int height = bitmap.getHeight();
- sCropRect[0] = 0;
- sCropRect[1] = height;
- sCropRect[2] = width;
- sCropRect[3] = -height;
-
- // Upload the bitmap to a new texture.
- gl.glGenTextures(1, sTextureId, 0);
- gl.glBindTexture(GL11.GL_TEXTURE_2D, sTextureId[0]);
- gl.glTexParameteriv(GL11.GL_TEXTURE_2D,
- GL11Ext.GL_TEXTURE_CROP_RECT_OES, sCropRect, 0);
- gl.glTexParameteri(GL11.GL_TEXTURE_2D,
- GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP_TO_EDGE);
- gl.glTexParameteri(GL11.GL_TEXTURE_2D,
- GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP_TO_EDGE);
- gl.glTexParameterf(GL11.GL_TEXTURE_2D,
- GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
- gl.glTexParameterf(GL11.GL_TEXTURE_2D,
- GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
-
- if (width == getTextureWidth() && height == getTextureWidth()) {
- GLUtils.texImage2D(GL11.GL_TEXTURE_2D, 0, bitmap, 0);
- } else {
- int format = GLUtils.getInternalFormat(bitmap);
- int type = GLUtils.getType(bitmap);
-
- gl.glTexImage2D(GL11.GL_TEXTURE_2D, 0, format,
- getTextureWidth(), getTextureHeight(),
- 0, format, type, null);
- GLUtils.texSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, bitmap,
- format, type);
- }
- } finally {
- freeBitmap();
- }
- // Update texture state.
- setAssociatedCanvas(canvas);
- mId = sTextureId[0];
- mState = UploadedTexture.STATE_LOADED;
- } else {
- mState = STATE_ERROR;
- throw new RuntimeException("Texture load fail, no bitmap");
- }
- }
-
- @Override
- protected boolean onBind(GLCanvas canvas) {
- updateContent(canvas);
- return isContentValid(canvas);
- }
-
- public void setOpaque(boolean isOpaque) {
- mOpaque = isOpaque;
- }
-
- public boolean isOpaque() {
- return mOpaque;
- }
-
- @Override
- public void recycle() {
- super.recycle();
- if (mBitmap != null) freeBitmap();
- }
-}
diff --git a/new3d/src/com/android/gallery3d/util/ComboFuture.java b/new3d/src/com/android/gallery3d/util/ComboFuture.java
deleted file mode 100644
index 575e824..0000000
--- a/new3d/src/com/android/gallery3d/util/ComboFuture.java
+++ /dev/null
@@ -1,48 +0,0 @@
-
-package com.android.gallery3d.util;
-
-
-// ComboFuture represents a sequence of Futures that will be executed one by one.
-public abstract class ComboFuture<E> extends FutureHelper<E>
- implements FutureListener<Object> {
-
- private static final String TAG = "ComboFuture";
-
- private Future<?> mCurrentTask;
- private int mStep = 0;
-
- public ComboFuture(FutureListener<? super E> listener) {
- super(listener);
- }
-
- @Override
- protected synchronized void onCancel() {
- if (mCurrentTask != null) mCurrentTask.requestCancel();
- }
-
- public synchronized void execute() {
- try {
- mCurrentTask = executeNextTask(0, null);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- Utils.Assert(mCurrentTask != null);
- }
-
- @SuppressWarnings("unchecked")
- public synchronized void onFutureDone(Future<?> currentTask) {
- try {
- mCurrentTask = executeNextTask(
- ++mStep, currentTask);
- if (!isCancelled() && mCurrentTask == null) {
- setResult((E) currentTask.get());
- }
- } catch (Throwable t) {
- setException(t);
- }
- }
-
- // This function will be called when the current task has been done.
- abstract protected Future<?>
- executeNextTask(int index, Future<?> current) throws Exception;
-}
diff --git a/new3d/src/com/android/gallery3d/util/Future.java b/new3d/src/com/android/gallery3d/util/Future.java
deleted file mode 100644
index 446a502..0000000
--- a/new3d/src/com/android/gallery3d/util/Future.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.android.gallery3d.util;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-/*
- * This is adapted from the java.util.concurrent.Future, but differs in how
- * "cancel" is handled. In java version, cancel() is completed only if the
- * result hasn't be set. If the answer arrives later than cancel(), the answer
- * is ignored and would be GC later. But this would be a problem if the result
- * holds an amount of resource. In this case, we have to free the resource of
- * the result before we can continue. To solve this, in the Future here,
- * requestCancel() is only a request. The implementation could ignore it or
- * try its best to cancel the computation. However, once the result has been
- * returned, the state of the future is "done" instead of "canceled".
- */
-public interface Future<V> {
- public V get() throws ExecutionException, InterruptedException;
-
- public V get(long duration, TimeUnit unit)
- throws ExecutionException, InterruptedException, TimeoutException;
-
- public void requestCancel();
-
- public boolean isCancelled();
- public boolean isDone();
-}
diff --git a/new3d/src/com/android/gallery3d/util/FutureHelper.java b/new3d/src/com/android/gallery3d/util/FutureHelper.java
deleted file mode 100644
index fe7efc4..0000000
--- a/new3d/src/com/android/gallery3d/util/FutureHelper.java
+++ /dev/null
@@ -1,170 +0,0 @@
-package com.android.gallery3d.util;
-
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.AbstractQueuedSynchronizer;
-
-/*
- * The state diagram:
- *
- * ready --> setResult() or setException() --> ran (done)
- * ready --> requestCancel() --> cancelling --> call onCancel()
- * cancelling --> setResult() or setException() --> ran (done)
- * cancelling --> cancelled() --> cancelled (done)
- */
-public class FutureHelper<V> implements Future<V> {
-
- private final Sync mSync = new Sync();
- private FutureListener<? super V> mListener;
-
- protected FutureHelper(FutureListener<? super V> listener) {
- mListener = listener;
- }
-
- public V get(long duration, TimeUnit unit)
- throws ExecutionException, InterruptedException, TimeoutException {
- return mSync.innerGet(duration, unit);
- }
-
- public V get() throws ExecutionException, InterruptedException {
- return mSync.innerGet();
- }
-
- public void setResult(V result) {
- mSync.innerSetResult(result);
- }
-
- public void setException(Throwable throwable) {
- mSync.innerSetException(throwable);
- }
-
- public void cancelled() {
- mSync.innerCancelled();
- }
-
- public void requestCancel() {
- mSync.innerRequestCancel();
- }
-
- public boolean isCancelled() {
- return mSync.innerIsCanclled();
- }
-
- public boolean isDone() {
- return mSync.innerIsDone();
- }
-
- protected boolean isCancelling() {
- return mSync.innerIsCanclling();
- }
-
- protected void onCancel() {
- throw new UnsupportedOperationException();
- }
-
- private void done() {
- if (mListener != null) {
- mListener.onFutureDone(this);
- mListener = null;
- }
- }
-
- private class Sync extends AbstractQueuedSynchronizer {
-
- private static final long serialVersionUID = -3545729446289780870L;
-
- private static final int STATE_READY = 0;
- private static final int STATE_CANCELLING = 1;
- private static final int STATE_CANCELLED = 2;
- private static final int STATE_RAN = 4;
-
- private AtomicInteger mState = new AtomicInteger(STATE_READY);
- private V mResult;
- private ExecutionException mException;
-
- @Override
- protected int tryAcquireShared(int ignore) {
- return (mState.get() & (STATE_RAN | STATE_CANCELLED)) != 0 ? 1 : -1;
- }
-
- @Override
- protected boolean tryReleaseShared(int ignore) {
- return true;
- }
-
- public V innerGet(long duration, TimeUnit unit)
- throws ExecutionException, InterruptedException, TimeoutException {
- if (!tryAcquireSharedNanos(0, unit.toNanos(duration))) {
- throw new TimeoutException();
- }
- int s = mState.get();
- if (s == STATE_CANCELLED) throw new CancellationException();
- if (mException != null) throw mException;
- return mResult;
- }
-
- public V innerGet() throws ExecutionException, InterruptedException {
- acquireSharedInterruptibly(0);
- int s = mState.get();
- if (s == STATE_CANCELLED) throw new CancellationException();
- if (mException != null) throw mException;
- return mResult;
- }
-
- public void innerCancelled() {
- if (mState.compareAndSet(STATE_CANCELLING, STATE_CANCELLED)) {
- releaseShared(0);
- done();
- } else {
- throw new IllegalStateException();
- }
- }
-
- public void innerSetResult(V result) {
- while (true) {
- int s = mState.get();
- if ((s & (STATE_CANCELLED | STATE_RAN)) != 0) {
- throw new IllegalStateException();
- }
- if (mState.compareAndSet(s, STATE_RAN)) break;
- }
- mResult = result;
- releaseShared(0);
- done();
- }
-
- public void innerSetException(Throwable throwable) {
- while (true) {
- int s = mState.get();
- if ((s & (STATE_CANCELLED | STATE_RAN)) != 0) {
- throw new IllegalStateException();
- }
- if (mState.compareAndSet(s, STATE_RAN)) break;
- }
- mException = new ExecutionException(throwable);
- releaseShared(0);
- done();
- }
-
- public void innerRequestCancel() {
- if (mState.compareAndSet(STATE_READY, STATE_CANCELLING)) {
- FutureHelper.this.onCancel();
- }
- }
-
- public boolean innerIsCanclled() {
- return mState.get() == STATE_CANCELLED;
- }
-
- public boolean innerIsDone() {
- return (mState.get() & (STATE_CANCELLED | STATE_RAN)) != 0;
- }
-
- public boolean innerIsCanclling() {
- return mState.get() == STATE_CANCELLING;
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/util/FutureListener.java b/new3d/src/com/android/gallery3d/util/FutureListener.java
deleted file mode 100644
index 0770660..0000000
--- a/new3d/src/com/android/gallery3d/util/FutureListener.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.android.gallery3d.util;
-
-public interface FutureListener<V> {
- public void onFutureDone(Future<? extends V> future);
-}
diff --git a/new3d/src/com/android/gallery3d/util/FutureTask.java b/new3d/src/com/android/gallery3d/util/FutureTask.java
deleted file mode 100644
index ca2c68c..0000000
--- a/new3d/src/com/android/gallery3d/util/FutureTask.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package com.android.gallery3d.util;
-
-import java.io.InterruptedIOException;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * State transition diagram:
- *
- * ready --> running
- * ready --> cancelled
- * running --> interrupted
- * running --> ran
- */
-public class FutureTask<V> implements Future<V>, Runnable {
-
- private static final int STATE_READY = 0;
- private static final int STATE_RUNNING = 1;
- private static final int STATE_CANCELLED = 2;
- private static final int STATE_INTERRUPTED = 4;
- private static final int STATE_RAN = 8;
-
- private Callable<V> mCallable;
- private final MyHelper mHelper;
- private volatile Thread mRunner;
- private AtomicInteger mState = new AtomicInteger(STATE_READY);
- private final boolean mInterruptible;
-
- public FutureTask(Callable<V> callable, FutureListener<? super V> listener) {
- this(callable, false, listener);
- }
-
- // @param interruptible Sets whether this task is interruptible, if true,
- // the thread running the task will be interrupted when canceling.
- public FutureTask(Callable<V> callable,
- boolean interruptible, FutureListener<? super V> listener) {
- mInterruptible = interruptible;
- mCallable = callable;
- mHelper = new MyHelper(listener);
- }
-
- public void requestCancel() {
- mHelper.requestCancel();
- }
-
- public V get() throws ExecutionException, InterruptedException {
- return mHelper.get();
- }
-
- public V get(long duration, TimeUnit unit) throws ExecutionException,
- InterruptedException, TimeoutException {
- return mHelper.get(duration, unit);
- }
-
- public boolean isCancelled() {
- return mHelper.isCancelled();
- }
-
- public boolean isDone() {
- return mHelper.isDone();
- }
-
- public void run() {
- mRunner = Thread.currentThread();
- if (!mState.compareAndSet(STATE_READY, STATE_RUNNING)) return;
-
- boolean noException = false;
- V result = null;
- try {
- result = mCallable.call();
- noException = true;
- } catch (InterruptedException e) {
- if (mHelper.isCancelling()) {
- mHelper.cancelled();
- } else {
- mHelper.setException(e);
- }
- } catch (InterruptedIOException e) {
- if (mHelper.isCancelling()) {
- mHelper.cancelled();
- } else {
- mHelper.setException(e);
- }
- } catch (Throwable t) {
- mHelper.setException(t);
- } finally {
- mCallable = null;
- }
-
- if (noException) {
- if (result == null && mHelper.isCancelling()) {
- mHelper.cancelled();
- } else {
- mHelper.setResult(result);
- }
- }
-
- if (mInterruptible &&
- !mState.compareAndSet(STATE_RUNNING, STATE_RAN)) {
- // STATE_INTERRUPTED
- synchronized (this) {
- Thread.interrupted(); // consume the interrupted signal
- }
- }
- mRunner = null;
- }
-
- protected void onRequestCancel() {
- }
-
- protected synchronized void cancelTask() {
- if (mState.compareAndSet(STATE_RUNNING, STATE_INTERRUPTED)){
- if (mInterruptible) mRunner.interrupt();
- onRequestCancel();
- }
- }
-
- private class MyHelper extends FutureHelper<V> {
-
- MyHelper(FutureListener<? super V> listener) {
- super(listener);
- }
-
- @Override
- protected void onCancel() {
- if (mState.compareAndSet(STATE_READY, STATE_CANCELLED)) {
- cancelled();
- } else if (mState.get() == STATE_RUNNING) {
- FutureTask.this.cancelTask();
- } // else mState == STATE_DONE;
- }
- }
-}
diff --git a/new3d/src/com/android/gallery3d/util/IdentityCache.java b/new3d/src/com/android/gallery3d/util/IdentityCache.java
deleted file mode 100644
index 321ca38..0000000
--- a/new3d/src/com/android/gallery3d/util/IdentityCache.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.util;
-
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.WeakReference;
-import java.util.HashMap;
-
-public class IdentityCache<K, V> {
-
- private final HashMap<K, Entry<K, V>> mWeakMap =
- new HashMap<K, Entry<K, V>>();
- private ReferenceQueue<V> mQueue = new ReferenceQueue<V>();
-
- public IdentityCache() {
- }
-
- private static class Entry<K, V> extends WeakReference<V> {
- K mKey;
-
- public Entry(K key, V value, ReferenceQueue<V> queue) {
- super(value, queue);
- mKey = key;
- }
- }
-
- private void cleanUpWeakMap() {
- Entry<K, V> entry = (Entry<K, V>) mQueue.poll();
- while (entry != null) {
- mWeakMap.remove(entry.mKey);
- entry = (Entry<K, V>) mQueue.poll();
- }
- }
-
- public synchronized V put(K key, V value) {
- cleanUpWeakMap();
- Entry<K, V> entry = mWeakMap.put(
- key, new Entry<K, V>(key, value, mQueue));
- return entry == null ? null : entry.get();
- }
-
- public synchronized V get(K key) {
- cleanUpWeakMap();
- Entry<K, V> entry = mWeakMap.get(key);
- return entry == null ? null : entry.get();
- }
-
- public synchronized void clear() {
- mWeakMap.clear();
- mQueue = new ReferenceQueue<V>();
- }
-}
diff --git a/new3d/src/com/android/gallery3d/util/IntArray.java b/new3d/src/com/android/gallery3d/util/IntArray.java
deleted file mode 100644
index 88657bb..0000000
--- a/new3d/src/com/android/gallery3d/util/IntArray.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.util;
-
-public class IntArray {
- private static final int INIT_CAPACITY = 8;
-
- private int mData[] = new int[INIT_CAPACITY];
- private int mSize = 0;
-
- public void add(int value) {
- if (mData.length == mSize) {
- int temp[] = new int[mSize + mSize];
- System.arraycopy(mData, 0, temp, 0, mSize);
- mData = temp;
- }
- mData[mSize++] = value;
- }
-
- public int size() {
- return mSize;
- }
-
- public int[] toArray(int[] result) {
- if (result == null || result.length < mSize) {
- result = new int[mSize];
- }
- System.arraycopy(mData, 0, result, 0, mSize);
- return result;
- }
-
- public int[] getInternalArray() {
- return mData;
- }
-
- public void clear() {
- mSize = 0;
- if (mData.length != INIT_CAPACITY) mData = new int[INIT_CAPACITY];
- }
-}
diff --git a/new3d/src/com/android/gallery3d/util/Utils.java b/new3d/src/com/android/gallery3d/util/Utils.java
deleted file mode 100644
index cac7d3f..0000000
--- a/new3d/src/com/android/gallery3d/util/Utils.java
+++ /dev/null
@@ -1,275 +0,0 @@
-package com.android.gallery3d.util;
-
-import android.app.Activity;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Bitmap.Config;
-import android.util.DisplayMetrics;
-import android.util.Log;
-
-import java.io.Closeable;
-import java.nio.charset.Charset;
-
-
-public class Utils {
- public static final int UNCONSTRAINED = -1;
- private static final String TAG = "Utils";
-
- private static final long POLY64REV = 0x95AC9329AC4BC9B5L;
- private static final long INITIALCRC = 0xFFFFFFFFFFFFFFFFL;
-
- private static boolean sInit = false;
- private static long[] sCrcTable = new long[256];
- private static Charset sUtf8Codec = Charset.forName("utf-8");
-
- /*
- * Compute the sample size as a function of minSideLength
- * and maxNumOfPixels.
- * minSideLength is used to specify that minimal width or height of a
- * bitmap.
- * maxNumOfPixels is used to specify the maximal size in pixels that is
- * tolerable in terms of memory usage.
- *
- * The function returns a sample size based on the constraints.
- * Both size and minSideLength can be passed in as UNCONSTRAINED,
- * which indicates no care of the corresponding constraint.
- * The functions prefers returning a sample size that
- * generates a smaller bitmap, unless minSideLength = UNCONSTRAINED.
- *
- * Also, the function rounds up the sample size to a power of 2 or multiple
- * of 8 because BitmapFactory only honors sample size this way.
- * For example, BitmapFactory downsamples an image by 2 even though the
- * request is 3. So we round up the sample size to avoid OOM.
- */
- public static int computeSampleSize(BitmapFactory.Options options,
- int minSideLength, int maxNumOfPixels) {
- int initialSize = computeInitialSampleSize(
- options, minSideLength, maxNumOfPixels);
-
- return initialSize <= 8
- ? Utils.nextPowerOf2(initialSize)
- : (initialSize + 7) / 8 * 8;
- }
-
- private static int computeInitialSampleSize(BitmapFactory.Options options,
- int minSideLength, int maxNumOfPixels) {
- if (maxNumOfPixels == UNCONSTRAINED && minSideLength == UNCONSTRAINED) {
- return 1;
- }
-
- int w = options.outWidth;
- int h = options.outHeight;
-
- int lowerBound = (maxNumOfPixels == UNCONSTRAINED) ? 1 :
- (int) Math.ceil(Math.sqrt((double) (w * h) / maxNumOfPixels));
-
- if (minSideLength == UNCONSTRAINED) {
- return lowerBound;
- } else {
- int sampeSize = Math.min(w / minSideLength, h / minSideLength);
- return Math.max(sampeSize, lowerBound);
- }
- }
-
- public static Bitmap resize(Bitmap original, int targetPixels) {
- int width = original.getWidth();
- int height = original.getHeight();
- float scale = (float) Math.sqrt(
- (double) targetPixels / (width * height));
- if (scale >= 1.0f) return original;
-
- int scaledWidth = (int) (width * scale + 0.5f);
- int scaledHeight = (int) (height * scale + 0.5f);
- Bitmap bitmap = Bitmap.createBitmap(scaledWidth, scaledHeight,
- original.hasAlpha() ? Config.ARGB_8888 : Config.RGB_565);
- Canvas canvas = new Canvas(bitmap);
- canvas.scale((float) scaledWidth / width, (float) scaledHeight / height);
- canvas.drawBitmap(original, 0, 0, null);
- original.recycle();
- return bitmap;
- }
-
- public static final Bitmap resizeBitmap(Bitmap bitmap, int maxSize) {
- int srcWidth = bitmap.getWidth();
- int srcHeight = bitmap.getHeight();
- float scale = Math.min(
- (float) maxSize / srcWidth, (float) maxSize / srcHeight);
- if (scale >= 1.0f) return bitmap;
-
- int width = Math.round(srcWidth * scale);
- int height = Math.round(srcHeight * scale);
- Bitmap target = Bitmap.createBitmap(width, height,
- bitmap.hasAlpha() ? Config.ARGB_8888 : Config.RGB_565);
- Canvas canvas = new Canvas(target);
- canvas.scale(scale, scale);
- canvas.drawBitmap(bitmap, 0, 0, null);
- bitmap.recycle();
- return target;
- }
-
- // Throws AssertionError if the input is false.
- public static void Assert(boolean cond) {
- if (!cond) {
- throw new AssertionError();
- }
- }
-
- // Throws AssertionError if the input is false.
- public static void Assert(boolean cond, String message) {
- if (!cond) {
- throw new AssertionError(message);
- }
- }
-
- // Throws NullPointerException if the input is null.
- public static <T> T checkNotNull(T object) {
- if (object == null) throw new NullPointerException();
- return object;
- }
-
- // Returns true if two input Object are both null or equal
- // to each other.
- public static boolean equals(Object a, Object b) {
- return (a == b) || (a == null ? false : a.equals(b));
- }
-
- // Returns true if the input is power of 2.
- // Throws IllegalArgumentException if the input is <= 0.
- public static boolean isPowerOf2(int n) {
- if (n <= 0) throw new IllegalArgumentException();
- return (n & -n) == n;
- }
-
- // Returns the next power of two.
- // Returns the input if it is already power of 2.
- // Throws IllegalArgumentException if the input is <= 0 or
- // the answer overflows.
- public static int nextPowerOf2(int n) {
- if (n <= 0 || n > (1 << 30)) throw new IllegalArgumentException();
- n -= 1;
- n |= n >> 16;
- n |= n >> 8;
- n |= n >> 4;
- n |= n >> 2;
- n |= n >> 1;
- return n + 1;
- }
-
- // Returns the euclidean distance between (x, y) and (sx, sy).
- public static float distance(float x, float y, float sx, float sy) {
- float dx = x - sx;
- float dy = y - sy;
- return (float) Math.hypot(dx, dy);
- }
-
- // Returns the input value x clamped to the range [min, max].
- public static int clamp(int x, int min, int max) {
- if (x > max) return max;
- if (x < min) return min;
- return x;
- }
-
- // Returns the input value x clamped to the range [min, max].
- public static float clamp(float x, float min, float max) {
- if (x > max) return max;
- if (x < min) return min;
- return x;
- }
-
- public synchronized static float dpToPixel(Context context, float dp) {
- if (Utils.sPixelDensity < 0) {
- DisplayMetrics metrics = new DisplayMetrics();
- ((Activity) context).getWindowManager()
- .getDefaultDisplay().getMetrics(metrics);
- Utils.sPixelDensity = metrics.density;
- }
- return Utils.sPixelDensity * dp;
- }
-
- static float sPixelDensity = -1f;
-
- public static int dpToPixel(Context context, int dp) {
- return Math.round(dpToPixel(context, (float) dp));
- }
-
- public static boolean isOpaque(int color) {
- return color >>> 24 == 0xFF;
- }
-
- public static <T> void swap(T[] array, int i, int j) {
- T temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- }
-
- /**
- * A function thats returns a 64-bit crc for string
- *
- * @param in: input string
- * @return 64-bit crc value
- */
- public static final long crc64Long(String in) {
- if (in == null || in.length() == 0) {
- return 0;
- }
- // http://bioinf.cs.ucl.ac.uk/downloads/crc64/crc64.c
- long crc = INITIALCRC, part;
- if (!sInit) {
- for (int i = 0; i < 256; i++) {
- part = i;
- for (int j = 0; j < 8; j++) {
- int value = ((int) part & 1);
- if (value != 0)
- part = (part >> 1) ^ POLY64REV;
- else
- part >>= 1;
- }
- sCrcTable[i] = part;
- }
- sInit = true;
- }
-
- byte[] buffer = getBytesInUtf8(in);
- for (int k = 0, n = buffer.length; k < n; ++k) {
- crc = sCrcTable[(((int) crc) ^ buffer[k]) & 0xff] ^ (crc >> 8);
- }
- return crc;
- }
-
- public static byte[] getBytesInUtf8(String in) {
- return sUtf8Codec.encode(in).array();
- }
-
- // Below are used the detect using database in the render thread. It only
- // works most of the time, but that's ok because it's for debugging only.
-
- private static volatile Thread sCurrentThread;
- private static volatile boolean sWarned;
-
- public static void setRenderThread() {
- sCurrentThread = Thread.currentThread();
- }
-
- public static void assertNotInRenderThread() {
- if (!sWarned) {
- if (Thread.currentThread() == sCurrentThread) {
- sWarned = true;
- Log.w(TAG, new Throwable("Should not do this in render thread"));
- }
- }
- }
-
- public static void closeSilently(Closeable closeable) {
- try {
- closeable.close();
- } catch (Throwable t) {
- Log.w(TAG, "close fail", t);
- }
- }
-
- public static int compare(long a, long b) {
- return a < b ? -1 : a == b ? 0 : 1;
- }
-}
diff --git a/new3d/tests/Android.mk b/new3d/tests/Android.mk
deleted file mode 100644
index 48d3f78..0000000
--- a/new3d/tests/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := GalleryNew3DTests
-LOCAL_CERTIFICATE := media
-
-LOCAL_INSTRUMENTATION_FOR := GalleryNew3D
-
-include $(BUILD_PACKAGE)
diff --git a/new3d/tests/AndroidManifest.xml b/new3d/tests/AndroidManifest.xml
deleted file mode 100644
index 0104295..0000000
--- a/new3d/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.gallery3d.tests">
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="com.android.gallery3d"
- android:label="Tests for GalleryNew3D application."/>
-</manifest>
diff --git a/new3d/tests/src/com/android/gallery3d/anim/AnimationTest.java b/new3d/tests/src/com/android/gallery3d/anim/AnimationTest.java
deleted file mode 100644
index d518991..0000000
--- a/new3d/tests/src/com/android/gallery3d/anim/AnimationTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.anim;
-
-import android.util.Log;
-import android.view.animation.Interpolator;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import junit.framework.TestCase;
-
-@SmallTest
-public class AnimationTest extends TestCase {
- private static final String TAG = "AnimationTest";
-
- public void testIntAnimation() {
- IntAnimation a = new IntAnimation(0, 100, 10); // value 0 to 100, duration 10
- a.start(); // start animation
- assertTrue(a.isActive()); // should be active now
- a.calculate(0); // set start time = 0
- assertTrue(a.get() == 0); // start value should be 0
- a.calculate(1); // calculate value for time 1
- assertTrue(a.get() == 10); //
- a.calculate(5); // calculate value for time 5
- assertTrue(a.get() == 50); //
- a.calculate(9); // calculate value for time 9
- assertTrue(a.get() == 90); //
- a.calculate(10); // calculate value for time 10
- assertTrue(!a.isActive()); // should be inactive now
- assertTrue(a.get() == 100);//
- a.start(); // restart
- assertTrue(a.isActive()); // should be active now
- a.calculate(5); // set start time = 5
- assertTrue(a.get() == 0); // start value should be 0
- a.calculate(5+9); // calculate for time 5+9
- assertTrue(a.get() == 90);
- }
-
- public void testFloatAnimation() {
- FloatAnimation a = new FloatAnimation(0f, 1f, 10); // value 0 to 1.0, duration 10
- a.start(); // start animation
- assertTrue(a.isActive()); // should be active now
- a.calculate(0); // set start time = 0
- assertTrue(a.get() == 0); // start value should be 0
- a.calculate(1); // calculate value for time 1
- assertFloatEq(a.get(), 0.1f);
- a.calculate(5); // calculate value for time 5
- assertTrue(a.get() == 0.5);//
- a.calculate(9); // calculate value for time 9
- assertFloatEq(a.get(), 0.9f);
- a.calculate(10); // calculate value for time 10
- assertTrue(!a.isActive()); // should be inactive now
- assertTrue(a.get() == 1.0);//
- a.start(); // restart
- assertTrue(a.isActive()); // should be active now
- a.calculate(5); // set start time = 5
- assertTrue(a.get() == 0); // start value should be 0
- a.calculate(5+9); // calculate for time 5+9
- assertFloatEq(a.get(), 0.9f);
- }
-
- private static class MyInterpolator implements Interpolator {
- public float getInterpolation(float input) {
- return 4f * (input - 0.5f); // maps [0,1] to [-2,2]
- }
- }
-
- public void testInterpolator() {
- FloatAnimation a = new FloatAnimation(0f, 1f, 10); // value 0 to 1.0, duration 10
- a.setInterpolator(new MyInterpolator());
- a.start(); // start animation
- a.calculate(0); // set start time = 0
- assertTrue(a.get() == -2); // start value should be -2
- a.calculate(1); // calculate value for time 1
- assertFloatEq(a.get(), -1.6f);
- a.calculate(5); // calculate value for time 5
- assertTrue(a.get() == 0); //
- a.calculate(9); // calculate value for time 9
- assertFloatEq(a.get(), 1.6f);
- a.calculate(10); // calculate value for time 10
- assertTrue(a.get() == 2); //
- }
-
- public static void assertFloatEq(float expected, float actual) {
- if (Math.abs(actual - expected) > 1e-6) {
- Log.v(TAG, "expected: " + expected + ", actual: " + actual);
- fail();
- }
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/data/BlobCacheTest.java b/new3d/tests/src/com/android/gallery3d/data/BlobCacheTest.java
deleted file mode 100644
index 6321fb9..0000000
--- a/new3d/tests/src/com/android/gallery3d/data/BlobCacheTest.java
+++ /dev/null
@@ -1,736 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Random;
-
-public class BlobCacheTest extends AndroidTestCase {
- private static final String TAG = "BlobCacheTest";
-
- @SmallTest
- public void testReadIntLong() {
- byte[] buf = new byte[9];
- assertEquals(0, BlobCache.readInt(buf, 0));
- assertEquals(0, BlobCache.readLong(buf, 0));
- buf[0] = 1;
- assertEquals(1, BlobCache.readInt(buf, 0));
- assertEquals(1, BlobCache.readLong(buf, 0));
- buf[3] = 0x7f;
- assertEquals(0x7f000001, BlobCache.readInt(buf, 0));
- assertEquals(0x7f000001, BlobCache.readLong(buf, 0));
- assertEquals(0x007f0000, BlobCache.readInt(buf, 1));
- assertEquals(0x007f0000, BlobCache.readLong(buf, 1));
- buf[3] = (byte) 0x80;
- buf[7] = (byte) 0xA0;
- buf[0] = 0;
- assertEquals(0x80000000, BlobCache.readInt(buf, 0));
- assertEquals(0xA000000080000000L, BlobCache.readLong(buf, 0));
- for (int i = 0; i < 8; i++) {
- buf[i] = (byte) (0x11 * (i+8));
- }
- assertEquals(0xbbaa9988, BlobCache.readInt(buf, 0));
- assertEquals(0xffeeddccbbaa9988L, BlobCache.readLong(buf, 0));
- buf[8] = 0x33;
- assertEquals(0x33ffeeddccbbaa99L, BlobCache.readLong(buf, 1));
- }
-
- @SmallTest
- public void testWriteIntLong() {
- byte[] buf = new byte[8];
- BlobCache.writeInt(buf, 0, 0x12345678);
- assertEquals(0x78, buf[0]);
- assertEquals(0x56, buf[1]);
- assertEquals(0x34, buf[2]);
- assertEquals(0x12, buf[3]);
- assertEquals(0x00, buf[4]);
- BlobCache.writeLong(buf, 0, 0xffeeddccbbaa9988L);
- for (int i = 0; i < 8; i++) {
- assertEquals((byte) (0x11 * (i+8)), buf[i]);
- }
- }
-
- @MediumTest
- public void testChecksum() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
- byte[] buf = new byte[0];
- assertEquals(0x1, bc.checkSum(buf));
- buf = new byte[1];
- assertEquals(0x10001, bc.checkSum(buf));
- buf[0] = 0x47;
- assertEquals(0x480048, bc.checkSum(buf));
- buf = new byte[3];
- buf[0] = 0x10;
- buf[1] = 0x30;
- buf[2] = 0x01;
- assertEquals(0x940042, bc.checkSum(buf));
- assertEquals(0x310031, bc.checkSum(buf, 1, 1));
- assertEquals(0x1, bc.checkSum(buf, 1, 0));
- assertEquals(0x630032, bc.checkSum(buf, 1, 2));
- buf = new byte[1024];
- for (int i = 0; i < buf.length; i++) {
- buf[i] = (byte)(i*i);
- }
- assertEquals(0x3574a610, bc.checkSum(buf));
- bc.close();
- }
-
- private static final int HEADER_SIZE = 32;
- private static final int DATA_HEADER_SIZE = 4;
- private static final int BLOB_HEADER_SIZE = 20;
-
- private static final String TEST_FILE_NAME = "/sdcard/btest";
- private static final int MAX_ENTRIES = 100;
- private static final int MAX_BYTES = 1000;
- private static final int INDEX_SIZE = HEADER_SIZE + MAX_ENTRIES * 12 * 2;
- private static final long KEY_0 = 0x1122334455667788L;
- private static final long KEY_1 = 0x1122334455667789L;
- private static final long KEY_2 = 0x112233445566778AL;
- private static byte[] DATA_0 = new byte[10];
- private static byte[] DATA_1 = new byte[10];
-
- @MediumTest
- public void testBasic() throws IOException {
- String name = TEST_FILE_NAME;
- BlobCache bc;
- File idxFile = new File(name + ".idx");
- File data0File = new File(name + ".0");
- File data1File = new File(name + ".1");
-
- // Create a brand new cache.
- bc = new BlobCache(name, MAX_ENTRIES, MAX_BYTES, true);
- bc.close();
-
- // Make sure the initial state is correct.
- assertTrue(idxFile.exists());
- assertTrue(data0File.exists());
- assertTrue(data1File.exists());
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE, data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
- assertEquals(0, bc.getActiveCount());
-
- // Re-open it.
- bc = new BlobCache(name, MAX_ENTRIES, MAX_BYTES, false);
- assertNull(bc.lookup(KEY_0));
-
- // insert one blob
- genData(DATA_0, 1);
- bc.insert(KEY_0, DATA_0);
- assertSameData(DATA_0, bc.lookup(KEY_0));
- assertEquals(1, bc.getActiveCount());
- bc.close();
-
- // Make sure the file size is right.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + BLOB_HEADER_SIZE + DATA_0.length,
- data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
-
- // Re-open it and make sure we can get the old data
- bc = new BlobCache(name, MAX_ENTRIES, MAX_BYTES, false);
- assertSameData(DATA_0, bc.lookup(KEY_0));
-
- // insert with the same key (but using a different blob)
- genData(DATA_0, 2);
- bc.insert(KEY_0, DATA_0);
- assertSameData(DATA_0, bc.lookup(KEY_0));
- assertEquals(1, bc.getActiveCount());
- bc.close();
-
- // Make sure the file size is right.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + 2 * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
-
- // Re-open it and make sure we can get the old data
- bc = new BlobCache(name, MAX_ENTRIES, MAX_BYTES, false);
- assertSameData(DATA_0, bc.lookup(KEY_0));
-
- // insert another key and make sure we can get both key.
- assertNull(bc.lookup(KEY_1));
- genData(DATA_1, 3);
- bc.insert(KEY_1, DATA_1);
- assertSameData(DATA_0, bc.lookup(KEY_0));
- assertSameData(DATA_1, bc.lookup(KEY_1));
- assertEquals(2, bc.getActiveCount());
- bc.close();
-
- // Make sure the file size is right.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + 3 * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
-
- // Re-open it and make sure we can get the old data
- bc = new BlobCache(name, 100, 1000, false);
- assertSameData(DATA_0, bc.lookup(KEY_0));
- assertSameData(DATA_1, bc.lookup(KEY_1));
- assertEquals(2, bc.getActiveCount());
- bc.close();
- }
-
- @MediumTest
- public void testNegativeKey() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
-
- // insert one blob
- genData(DATA_0, 1);
- bc.insert(-123, DATA_0);
- assertSameData(DATA_0, bc.lookup(-123));
- bc.close();
- }
-
- @MediumTest
- public void testEmptyBlob() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
-
- byte[] data = new byte[0];
- bc.insert(123, data);
- assertSameData(data, bc.lookup(123));
- bc.close();
- }
-
- @MediumTest
- public void testLookupRequest() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
-
- // insert one blob
- genData(DATA_0, 1);
- bc.insert(1, DATA_0);
- assertSameData(DATA_0, bc.lookup(1));
-
- // the same size buffer
- byte[] buf = new byte[DATA_0.length];
- BlobCache.LookupRequest req = new BlobCache.LookupRequest();
- req.key = 1;
- req.buffer = buf;
- assertTrue(bc.lookup(req));
- assertEquals(1, req.key);
- assertSame(buf, req.buffer);
- assertEquals(DATA_0.length, req.length);
-
- // larger buffer
- buf = new byte[DATA_0.length + 22];
- req = new BlobCache.LookupRequest();
- req.key = 1;
- req.buffer = buf;
- assertTrue(bc.lookup(req));
- assertEquals(1, req.key);
- assertSame(buf, req.buffer);
- assertEquals(DATA_0.length, req.length);
-
- // smaller buffer
- buf = new byte[DATA_0.length - 1];
- req = new BlobCache.LookupRequest();
- req.key = 1;
- req.buffer = buf;
- assertTrue(bc.lookup(req));
- assertEquals(1, req.key);
- assertNotSame(buf, req.buffer);
- assertEquals(DATA_0.length, req.length);
- assertSameData(DATA_0, req.buffer, DATA_0.length);
-
- // null buffer
- req = new BlobCache.LookupRequest();
- req.key = 1;
- req.buffer = null;
- assertTrue(bc.lookup(req));
- assertEquals(1, req.key);
- assertNotNull(req.buffer);
- assertEquals(DATA_0.length, req.length);
- assertSameData(DATA_0, req.buffer, DATA_0.length);
-
- bc.close();
- }
-
- @MediumTest
- public void testKeyCollision() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
-
- for (int i = 0; i < MAX_ENTRIES / 2; i++) {
- genData(DATA_0, i);
- long key = KEY_1 + i * MAX_ENTRIES;
- bc.insert(key, DATA_0);
- }
-
- for (int i = 0; i < MAX_ENTRIES / 2; i++) {
- genData(DATA_0, i);
- long key = KEY_1 + i * MAX_ENTRIES;
- assertSameData(DATA_0, bc.lookup(key));
- }
- bc.close();
- }
-
- @MediumTest
- public void testRegionFlip() throws IOException {
- String name = TEST_FILE_NAME;
- BlobCache bc;
- File idxFile = new File(name + ".idx");
- File data0File = new File(name + ".0");
- File data1File = new File(name + ".1");
-
- // Create a brand new cache.
- bc = new BlobCache(name, MAX_ENTRIES, MAX_BYTES, true);
-
- // This is the number of blobs fits into a region.
- int maxFit = (MAX_BYTES - DATA_HEADER_SIZE) /
- (BLOB_HEADER_SIZE + DATA_0.length);
-
- for (int k = 0; k < maxFit; k++) {
- genData(DATA_0, k);
- bc.insert(k, DATA_0);
- }
- assertEquals(maxFit, bc.getActiveCount());
-
- // Make sure the file size is right.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
-
- // Now insert another one and let it flip.
- genData(DATA_0, 777);
- bc.insert(KEY_1, DATA_0);
- assertEquals(1, bc.getActiveCount());
-
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + 1 * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
-
- // Make sure we can find the new data
- assertSameData(DATA_0, bc.lookup(KEY_1));
-
- // Now find an old blob
- int old = maxFit / 2;
- genData(DATA_0, old);
- assertSameData(DATA_0, bc.lookup(old));
- assertEquals(2, bc.getActiveCount());
-
- // Observed data is copied.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + 2 * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
-
- // Now copy everything over (except we should have no space for the last one)
- assertTrue(old < maxFit - 1);
- for (int k = 0; k < maxFit; k++) {
- genData(DATA_0, k);
- assertSameData(DATA_0, bc.lookup(k));
- }
- assertEquals(maxFit, bc.getActiveCount());
-
- // Now both file should be full.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
-
- // Now insert one to make it flip.
- genData(DATA_0, 888);
- bc.insert(KEY_2, DATA_0);
- assertEquals(1, bc.getActiveCount());
-
- // Check the size after the second flip.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + 1 * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
-
- // Now the last key should be gone.
- assertNull(bc.lookup(maxFit - 1));
-
- // But others should remain
- for (int k = 0; k < maxFit - 1; k++) {
- genData(DATA_0, k);
- assertSameData(DATA_0, bc.lookup(k));
- }
-
- assertEquals(maxFit, bc.getActiveCount());
- genData(DATA_0, 777);
- assertSameData(DATA_0, bc.lookup(KEY_1));
- genData(DATA_0, 888);
- assertSameData(DATA_0, bc.lookup(KEY_2));
- assertEquals(maxFit, bc.getActiveCount());
-
- // Now two files should be full.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
-
- bc.close();
- }
-
- @MediumTest
- public void testEntryLimit() throws IOException {
- String name = TEST_FILE_NAME;
- BlobCache bc;
- File idxFile = new File(name + ".idx");
- File data0File = new File(name + ".0");
- File data1File = new File(name + ".1");
- int maxEntries = 10;
- int maxFit = maxEntries / 2;
- int indexSize = HEADER_SIZE + maxEntries * 12 * 2;
-
- // Create a brand new cache with a small entry limit.
- bc = new BlobCache(name, maxEntries, MAX_BYTES, true);
-
- // Fill to just before flipping
- for (int i = 0; i < maxFit; i++) {
- genData(DATA_0, i);
- bc.insert(i, DATA_0);
- }
- assertEquals(maxFit, bc.getActiveCount());
-
- // Check the file size.
- assertEquals(indexSize, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
-
- // Insert one and make it flip
- genData(DATA_0, 777);
- bc.insert(777, DATA_0);
- assertEquals(1, bc.getActiveCount());
-
- // Check the file size.
- assertEquals(indexSize, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + 1 * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
- bc.close();
- }
-
- @LargeTest
- public void testDataIntegrity() throws IOException {
- String name = TEST_FILE_NAME;
- File idxFile = new File(name + ".idx");
- File data0File = new File(name + ".0");
- File data1File = new File(name + ".1");
- RandomAccessFile f;
-
- Log.v(TAG, "It should be readable if the content is not changed.");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(1);
- byte b = f.readByte();
- f.seek(1);
- f.write(b);
- f.close();
- assertReadable();
-
- Log.v(TAG, "Change the data file magic field");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(1);
- f.write(0xFF);
- f.close();
- assertUnreadable();
-
- prepareNewCache();
- f = new RandomAccessFile(data1File, "rw");
- f.write(0xFF);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob key");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4);
- f.write(0x00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob checksum");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 8);
- f.write(0x00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob offset");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 12);
- f.write(0x20);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob length: some other value");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 16);
- f.write(0x20);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob length: -1");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 16);
- f.writeInt(0xFFFFFFFF);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob length: big value");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 16);
- f.writeInt(0xFFFFFF00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob content");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 20);
- f.write(0x01);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the index magic");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(1);
- f.write(0x00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the active region");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(12);
- f.write(0x01);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the reserved data");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(24);
- f.write(0x01);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the checksum");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(29);
- f.write(0x00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the key");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(32 + 12 * (KEY_1 % MAX_ENTRIES));
- f.write(0x00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the offset");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(32 + 12 * (KEY_1 % MAX_ENTRIES) + 8);
- f.write(0x05);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the offset");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(32 + 12 * (KEY_1 % MAX_ENTRIES) + 8 + 3);
- f.write(0xFF);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Garbage index");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- int n = (int) idxFile.length();
- f.seek(32);
- byte[] garbage = new byte[1024];
- for (int i = 0; i < garbage.length; i++) {
- garbage[i] = (byte) 0x80;
- }
- int i = 32;
- while (i < n) {
- int todo = Math.min(garbage.length, n - i);
- f.write(garbage, 0, todo);
- i += todo;
- }
- f.close();
- assertUnreadable();
- }
-
- // Create a brand new cache and put one entry into it.
- private void prepareNewCache() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
- genData(DATA_0, 777);
- bc.insert(KEY_1, DATA_0);
- bc.close();
- }
-
- private void assertReadable() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, false);
- genData(DATA_0, 777);
- assertSameData(DATA_0, bc.lookup(KEY_1));
- bc.close();
- }
-
- private void assertUnreadable() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, false);
- genData(DATA_0, 777);
- assertNull(bc.lookup(KEY_1));
- bc.close();
- }
-
- @LargeTest
- public void testRandomSize() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
-
- // Random size test
- Random rand = new Random(0);
- for (int i = 0; i < 100; i++) {
- byte[] data = new byte[rand.nextInt(MAX_BYTES*12/10)];
- try {
- bc.insert(rand.nextLong(), data);
- if (data.length > MAX_BYTES - 4 - 20) fail();
- } catch (RuntimeException ex) {
- if (data.length <= MAX_BYTES - 4 - 20) fail();
- }
- }
-
- bc.close();
- }
-
- @LargeTest
- public void testBandwidth() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, 1000, 10000000, true);
-
- // Write
- int count = 0;
- byte[] data = new byte[20000];
- long t0 = System.nanoTime();
- for (int i = 0; i < 1000; i++) {
- bc.insert(i, data);
- count += data.length;
- }
- bc.syncAll();
- float delta = (System.nanoTime() - t0) * 1e-3f;
- Log.v(TAG, "write bandwidth = " + (count / delta) + " M/s");
-
- // Copy over
- BlobCache.LookupRequest req = new BlobCache.LookupRequest();
- count = 0;
- t0 = System.nanoTime();
- for (int i = 0; i < 1000; i++) {
- req.key = i;
- req.buffer = data;
- if (bc.lookup(req)) {
- count += req.length;
- }
- }
- bc.syncAll();
- delta = (System.nanoTime() - t0) * 1e-3f;
- Log.v(TAG, "copy over bandwidth = " + (count / delta) + " M/s");
-
- // Read
- count = 0;
- t0 = System.nanoTime();
- for (int i = 0; i < 1000; i++) {
- req.key = i;
- req.buffer = data;
- if (bc.lookup(req)) {
- count += req.length;
- }
- }
- bc.syncAll();
- delta = (System.nanoTime() - t0) * 1e-3f;
- Log.v(TAG, "read bandwidth = " + (count / delta) + " M/s");
-
- bc.close();
- }
-
- @LargeTest
- public void testSmallSize() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, 40, true);
-
- // Small size test
- Random rand = new Random(0);
- for (int i = 0; i < 100; i++) {
- byte[] data = new byte[rand.nextInt(3)];
- bc.insert(rand.nextLong(), data);
- }
-
- bc.close();
- }
-
- @LargeTest
- public void testManyEntries() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, 1, MAX_BYTES, true);
-
- // Many entries test
- Random rand = new Random(0);
- for (int i = 0; i < 100; i++) {
- byte[] data = new byte[rand.nextInt(10)];
- }
-
- bc.close();
- }
-
- private void genData(byte[] data, int seed) {
- for(int i = 0; i < data.length; i++) {
- data[i] = (byte) (seed * i);
- }
- }
-
- private void assertSameData(byte[] data1, byte[] data2) {
- if (data1 == null && data2 == null) return;
- if (data1 == null || data2 == null) fail();
- if (data1.length != data2.length) fail();
- for (int i = 0; i < data1.length; i++) {
- if (data1[i] != data2[i]) fail();
- }
- }
-
- private void assertSameData(byte[] data1, byte[] data2, int n) {
- if (data1 == null || data2 == null) fail();
- for (int i = 0; i < n; i++) {
- if (data1[i] != data2[i]) fail();
- }
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/data/GalleryContextMock.java b/new3d/tests/src/com/android/gallery3d/data/GalleryContextMock.java
deleted file mode 100644
index 534aa7c..0000000
--- a/new3d/tests/src/com/android/gallery3d/data/GalleryContextMock.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.android.gallery3d.data;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.os.Looper;
-
-import com.android.gallery3d.ui.GLRoot;
-import com.android.gallery3d.ui.GLRootStub;
-
-class GalleryContextMock extends GalleryContextStub {
- GLRoot mGLRoot = new GLRootStub();
- DataManager mDataManager = new DataManager(this);
- ContentResolver mResolver;
- Context mContext;
- Looper mMainLooper;
-
- GalleryContextMock(Context context,
- ContentResolver resolver, Looper mainLooper) {
- mContext = context;
- mResolver = resolver;
- mMainLooper = mainLooper;
- }
-
- @Override
- public GLRoot getGLRoot() { return mGLRoot; }
- @Override
- public DataManager getDataManager() { return mDataManager; }
- @Override
- public Context getAndroidContext() { return mContext; }
- @Override
- public ContentResolver getContentResolver() { return mResolver; }
- @Override
- public Looper getMainLooper() { return mMainLooper; }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/data/GalleryContextStub.java b/new3d/tests/src/com/android/gallery3d/data/GalleryContextStub.java
deleted file mode 100644
index 1e3d023..0000000
--- a/new3d/tests/src/com/android/gallery3d/data/GalleryContextStub.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.res.Resources;
-import android.os.Looper;
-
-import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.app.StateManager;
-import com.android.gallery3d.ui.GLRoot;
-import com.android.gallery3d.ui.PositionRepository;
-
-class GalleryContextStub implements GalleryContext {
- public ImageService getImageService() { return null; }
- public StateManager getStateManager() { return null; }
- public DataManager getDataManager() { return null; }
- public DownloadService getDownloadService() { return null; }
- public DecodeService getDecodeService() { return null; }
-
- public GLRoot getGLRoot() { return null; }
- public PositionRepository getPositionRepository() { return null; }
-
- public Context getAndroidContext() { return null; }
-
- public Looper getMainLooper() { return null; }
- public Resources getResources() { return null; }
- public ContentResolver getContentResolver() { return null; }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/data/LocalDataTest.java b/new3d/tests/src/com/android/gallery3d/data/LocalDataTest.java
deleted file mode 100644
index 3347e79..0000000
--- a/new3d/tests/src/com/android/gallery3d/data/LocalDataTest.java
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.content.ContentProvider;
-import android.content.ContentResolver;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteQueryBuilder;
-import android.net.Uri;
-import android.os.Looper;
-import android.test.AndroidTestCase;
-import android.test.mock.MockContentProvider;
-import android.test.mock.MockContentResolver;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.util.Log;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-public class LocalDataTest extends AndroidTestCase {
- private static final String TAG = "LocalDataTest";
- private static final int DUMMY_PARENT_ID = 0x777;
- private static final int KEY_LOCAL = 1;
- private static final long DEFAULT_TIMEOUT = 1000; // one second
-
- @MediumTest
- public void testLocalAlbum() throws Exception {
- new TestZeroImage().run();
- new TestOneImage().run();
- new TestMoreImages().run();
- new TestZeroVideo().run();
- new TestOneVideo().run();
- new TestMoreVideos().run();
- new TestDeleteOneImage().run();
- new TestDeleteOneAlbum().run();
- }
-
- abstract class TestLocalAlbumBase {
- private boolean mIsImage;
- protected GalleryContextStub mContext;
- protected LocalAlbumSet mAlbumSet;
-
- TestLocalAlbumBase(boolean isImage) {
- mIsImage = isImage;
- }
-
- public void run() throws Exception {
- SQLiteDatabase db = SQLiteDatabase.create(null);
- prepareData(db);
- mContext = newGalleryContext(db, Looper.getMainLooper());
- mAlbumSet = new LocalAlbumSet(DUMMY_PARENT_ID, KEY_LOCAL, mContext, mIsImage);
- mAlbumSet.reload();
- verifyResult();
- }
-
- abstract void prepareData(SQLiteDatabase db);
- abstract void verifyResult() throws Exception;
- }
-
- abstract class TestLocalImageAlbum extends TestLocalAlbumBase {
- TestLocalImageAlbum() {
- super(true);
- }
- }
-
- abstract class TestLocalVideoAlbum extends TestLocalAlbumBase {
- TestLocalVideoAlbum() {
- super(false);
- }
- }
-
- class TestZeroImage extends TestLocalImageAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- createImageTable(db);
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(0, mAlbumSet.getSubMediaSetCount());
- assertEquals(0, mAlbumSet.getTotalMediaItemCount());
- assertEquals(DataManager.makeId(DUMMY_PARENT_ID, 1),
- mAlbumSet.getUniqueId());
- }
- }
-
- class TestOneImage extends TestLocalImageAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- createImageTable(db);
- insertImageData(db);
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(1, mAlbumSet.getSubMediaSetCount());
- assertEquals(1, mAlbumSet.getTotalMediaItemCount());
- MediaSet sub = mAlbumSet.getSubMediaSet(0);
- assertEquals(1, sub.getMediaItemCount());
- assertEquals(0, sub.getSubMediaSetCount());
- LocalMediaItem item = (LocalMediaItem) sub.getMediaItem(0, 1).get(0);
- assertEquals(1, item.mId);
- assertEquals("IMG_0072", item.mCaption);
- assertEquals("image/jpeg", item.mMimeType);
- assertEquals(12.0, item.mLatitude);
- assertEquals(34.0, item.mLongitude);
- assertEquals(0xD000, item.mDateTakenInMs);
- assertEquals(1280395646L, item.mDateAddedInSec);
- assertEquals(1275934796L, item.mDateModifiedInSec);
- assertEquals("/mnt/sdcard/DCIM/100CANON/IMG_0072.JPG", item.mFilePath);
- assertEquals(sub.getMergeId(), 0xB000);
- int subId = sub.getMyId();
- assertEquals(DataManager.makeId(subId, 1), item.getUniqueId());
- }
- }
-
- class TestMoreImages extends TestLocalImageAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- // Albums are sorted by names, and items are sorted by
- // dateTimeTaken (descending)
- createImageTable(db);
- // bucket 0xB000
- insertImageData(db, 1000, 0xB000, "second"); // id 1
- insertImageData(db, 2000, 0xB000, "second"); // id 2
- // bucket 0xB001
- insertImageData(db, 3000, 0xB001, "first"); // id 3
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(2, mAlbumSet.getSubMediaSetCount());
- assertEquals(3, mAlbumSet.getTotalMediaItemCount());
-
- MediaSet first = mAlbumSet.getSubMediaSet(0);
- assertEquals(1, first.getMediaItemCount());
- LocalMediaItem item = (LocalMediaItem) first.getMediaItem(0, 1).get(0);
- assertEquals(3, item.mId);
- assertEquals(3000L, item.mDateTakenInMs);
-
- MediaSet second = mAlbumSet.getSubMediaSet(1);
- assertEquals(2, second.getMediaItemCount());
- item = (LocalMediaItem) second.getMediaItem(0, 1).get(0);
- assertEquals(2, item.mId);
- assertEquals(2000L, item.mDateTakenInMs);
- item = (LocalMediaItem) second.getMediaItem(1, 1).get(0);
- assertEquals(1, item.mId);
- assertEquals(1000L, item.mDateTakenInMs);
-
- assertEquals(first.getMergeId(), 0xB001);
- assertEquals(second.getMergeId(), 0xB000);
- }
- }
-
- class OnContentDirtyLatch implements MediaSet.MediaSetListener {
- private CountDownLatch mLatch = new CountDownLatch(1);
-
- public void onContentDirty() {
- mLatch.countDown();
- }
-
- public boolean isOnContentDirtyBeCalled(long timeout)
- throws InterruptedException {
- return mLatch.await(timeout, TimeUnit.MILLISECONDS);
- }
- }
-
- class TestDeleteOneAlbum extends TestLocalImageAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- // Albums are sorted by names, and items are sorted by
- // dateTimeTaken (descending)
- createImageTable(db);
- // bucket 0xB000
- insertImageData(db, 1000, 0xB000, "second"); // id 1
- insertImageData(db, 2000, 0xB000, "second"); // id 2
- // bucket 0xB001
- insertImageData(db, 3000, 0xB001, "first"); // id 3
- }
-
- @Override
- public void verifyResult() throws Exception {
- MediaSet sub = mAlbumSet.getSubMediaSet(1); // "second"
- assertEquals(2, mAlbumSet.getSubMediaSetCount());
- OnContentDirtyLatch latch = new OnContentDirtyLatch();
- sub.setContentListener(latch);
- long uid = sub.getUniqueId();
- assertTrue((sub.getSupportedOperations(uid) & MediaSet.SUPPORT_DELETE) != 0);
- mContext.getDataManager().delete(uid);
- mAlbumSet.fakeChange();
- latch.isOnContentDirtyBeCalled(DEFAULT_TIMEOUT);
- mAlbumSet.reload();
- assertEquals(1, mAlbumSet.getSubMediaSetCount());
- }
- }
-
- class TestDeleteOneImage extends TestLocalImageAlbum {
-
- @Override
- public void prepareData(SQLiteDatabase db) {
- createImageTable(db);
- insertImageData(db);
- }
-
- @Override
- public void verifyResult() {
- MediaSet sub = mAlbumSet.getSubMediaSet(0);
- LocalMediaItem item = (LocalMediaItem) sub.getMediaItem(0, 1).get(0);
- assertEquals(1, sub.getMediaItemCount());
- long uid = item.getUniqueId();
- assertTrue((sub.getSupportedOperations(uid) & MediaSet.SUPPORT_DELETE) != 0);
- mContext.getDataManager().delete(uid);
- sub.reload();
- assertEquals(0, sub.getMediaItemCount());
- }
- }
-
- static void createImageTable(SQLiteDatabase db) {
- // This is copied from MediaProvider
- db.execSQL("CREATE TABLE IF NOT EXISTS images (" +
- "_id INTEGER PRIMARY KEY," +
- "_data TEXT," +
- "_size INTEGER," +
- "_display_name TEXT," +
- "mime_type TEXT," +
- "title TEXT," +
- "date_added INTEGER," +
- "date_modified INTEGER," +
- "description TEXT," +
- "picasa_id TEXT," +
- "isprivate INTEGER," +
- "latitude DOUBLE," +
- "longitude DOUBLE," +
- "datetaken INTEGER," +
- "orientation INTEGER," +
- "mini_thumb_magic INTEGER," +
- "bucket_id TEXT," +
- "bucket_display_name TEXT" +
- ");");
- }
-
- static void insertImageData(SQLiteDatabase db) {
- insertImageData(db, 0xD000, 0xB000, "name");
- }
-
- static void insertImageData(SQLiteDatabase db, long dateTaken,
- int bucketId, String bucketName) {
- db.execSQL("INSERT INTO images (title, mime_type, latitude, longitude, "
- + "datetaken, date_added, date_modified, bucket_id, "
- + "bucket_display_name, _data, orientation) "
- + "VALUES ('IMG_0072', 'image/jpeg', 12, 34, "
- + dateTaken + ", 1280395646, 1275934796, '" + bucketId + "', "
- + "'" + bucketName + "', "
- + "'/mnt/sdcard/DCIM/100CANON/IMG_0072.JPG', 0)");
- }
-
- class TestZeroVideo extends TestLocalVideoAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- createVideoTable(db);
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(0, mAlbumSet.getSubMediaSetCount());
- assertEquals(0, mAlbumSet.getTotalMediaItemCount());
- assertEquals(DataManager.makeId(DUMMY_PARENT_ID, 1),
- mAlbumSet.getUniqueId());
- }
- }
-
- class TestOneVideo extends TestLocalVideoAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- createVideoTable(db);
- insertVideoData(db);
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(1, mAlbumSet.getSubMediaSetCount());
- assertEquals(1, mAlbumSet.getTotalMediaItemCount());
- MediaSet sub = mAlbumSet.getSubMediaSet(0);
- assertEquals(1, sub.getMediaItemCount());
- assertEquals(0, sub.getSubMediaSetCount());
- LocalMediaItem item = (LocalMediaItem) sub.getMediaItem(0, 1).get(0);
- assertEquals(1, item.mId);
- assertEquals("VID_20100811_051413", item.mCaption);
- assertEquals("video/mp4", item.mMimeType);
- assertEquals(11.0, item.mLatitude);
- assertEquals(22.0, item.mLongitude);
- assertEquals(0xD000, item.mDateTakenInMs);
- assertEquals(1281503663L, item.mDateAddedInSec);
- assertEquals(1281503662L, item.mDateModifiedInSec);
- assertEquals("/mnt/sdcard/DCIM/Camera/VID_20100811_051413.3gp",
- item.mFilePath);
- assertEquals(sub.getMergeId(), 0xB000);
- int subId = sub.getMyId();
- assertEquals(DataManager.makeId(subId, 1), item.getUniqueId());
- }
- }
-
- class TestMoreVideos extends TestLocalVideoAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- // Albums are sorted by names, and items are sorted by
- // dateTimeTaken (descending)
- createVideoTable(db);
- // bucket 0xB002
- insertVideoData(db, 1000, 0xB000, "second"); // id 1
- insertVideoData(db, 2000, 0xB000, "second"); // id 2
- // bucket 0xB001
- insertVideoData(db, 3000, 0xB001, "first"); // id 3
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(2, mAlbumSet.getSubMediaSetCount());
- assertEquals(3, mAlbumSet.getTotalMediaItemCount());
-
- MediaSet first = mAlbumSet.getSubMediaSet(0);
- assertEquals(1, first.getMediaItemCount());
- LocalMediaItem item = (LocalMediaItem) first.getMediaItem(0, 1).get(0);
- assertEquals(3, item.mId);
- assertEquals(3000L, item.mDateTakenInMs);
-
- MediaSet second = mAlbumSet.getSubMediaSet(1);
- assertEquals(2, second.getMediaItemCount());
- item = (LocalMediaItem) second.getMediaItem(0, 1).get(0);
- assertEquals(2, item.mId);
- assertEquals(2000L, item.mDateTakenInMs);
- item = (LocalMediaItem) second.getMediaItem(1, 1).get(0);
- assertEquals(1, item.mId);
- assertEquals(1000L, item.mDateTakenInMs);
-
- assertEquals(first.getMergeId(), 0xB001);
- assertEquals(second.getMergeId(), 0xB000);
- }
- }
-
- static void createVideoTable(SQLiteDatabase db) {
- db.execSQL("CREATE TABLE IF NOT EXISTS video (" +
- "_id INTEGER PRIMARY KEY," +
- "_data TEXT NOT NULL," +
- "_display_name TEXT," +
- "_size INTEGER," +
- "mime_type TEXT," +
- "date_added INTEGER," +
- "date_modified INTEGER," +
- "title TEXT," +
- "duration INTEGER," +
- "artist TEXT," +
- "album TEXT," +
- "resolution TEXT," +
- "description TEXT," +
- "isprivate INTEGER," + // for YouTube videos
- "tags TEXT," + // for YouTube videos
- "category TEXT," + // for YouTube videos
- "language TEXT," + // for YouTube videos
- "mini_thumb_data TEXT," +
- "latitude DOUBLE," +
- "longitude DOUBLE," +
- "datetaken INTEGER," +
- "mini_thumb_magic INTEGER" +
- ");");
- db.execSQL("ALTER TABLE video ADD COLUMN bucket_id TEXT;");
- db.execSQL("ALTER TABLE video ADD COLUMN bucket_display_name TEXT");
- }
-
- static void insertVideoData(SQLiteDatabase db) {
- insertVideoData(db, 0xD000, 0xB000, "name");
- }
-
- static void insertVideoData(SQLiteDatabase db, long dateTaken,
- int bucketId, String bucketName) {
- db.execSQL("INSERT INTO video (title, mime_type, latitude, longitude, "
- + "datetaken, date_added, date_modified, bucket_id, "
- + "bucket_display_name, _data, duration) "
- + "VALUES ('VID_20100811_051413', 'video/mp4', 11, 22, "
- + dateTaken + ", 1281503663, 1281503662, '" + bucketId + "', "
- + "'" + bucketName + "', "
- + "'/mnt/sdcard/DCIM/Camera/VID_20100811_051413.3gp', 2964)");
- }
-
- static GalleryContextStub newGalleryContext(SQLiteDatabase db, Looper mainLooper) {
- MockContentResolver cr = new MockContentResolver();
- ContentProvider cp = new DbContentProvider(db, cr);
- cr.addProvider("media", cp);
- return new GalleryContextMock(null, cr, mainLooper);
- }
-}
-
-class DbContentProvider extends MockContentProvider {
- private static final String TAG = "DbContentProvider";
- private SQLiteDatabase mDatabase;
- private ContentResolver mContentResolver;
-
- DbContentProvider(SQLiteDatabase db, ContentResolver cr) {
- mDatabase = db;
- mContentResolver = cr;
- }
-
- @Override
- public Cursor query(Uri uri, String[] projection,
- String selection, String[] selectionArgs, String sortOrder) {
- // This is a simplified version extracted from MediaProvider.
-
- String tableName = getTableName(uri);
- if (tableName == null) return null;
-
- SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
- qb.setTables(tableName);
-
- String groupBy = null;
- String limit = uri.getQueryParameter("limit");
-
- if (uri.getQueryParameter("distinct") != null) {
- qb.setDistinct(true);
- }
-
- Log.v(TAG, "query = " + qb.buildQuery(projection, selection,
- selectionArgs, groupBy, null, sortOrder, limit));
-
- if (selectionArgs != null) {
- for (String s : selectionArgs) {
- Log.v(TAG, " selectionArgs = " + s);
- }
- }
-
- Cursor c = qb.query(mDatabase, projection, selection,
- selectionArgs, groupBy, null, sortOrder, limit);
-
- return c;
- }
-
- @Override
- public int delete(Uri uri, String whereClause, String[] whereArgs) {
- Log.v(TAG, "delete " + uri + "," + whereClause + "," + whereArgs[0]);
- String tableName = getTableName(uri);
- if (tableName == null) return 0;
- int count = mDatabase.delete(tableName, whereClause, whereArgs);
- mContentResolver.notifyChange(uri, null);
- return count;
- }
-
- private String getTableName(Uri uri) {
- String uriString = uri.toString();
- if (uriString.startsWith("content://media/external/images/media")) {
- return "images";
- } else if (uriString.startsWith("content://media/external/video/media")) {
- return "video";
- } else {
- return null;
- }
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/data/MediaItemMock.java b/new3d/tests/src/com/android/gallery3d/data/MediaItemMock.java
deleted file mode 100644
index 8a6da3b..0000000
--- a/new3d/tests/src/com/android/gallery3d/data/MediaItemMock.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.graphics.Bitmap;
-import android.graphics.LargeBitmap;
-
-import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.FutureListener;
-
-public class MediaItemMock extends MediaItem {
- long mUniqueId;
-
- public MediaItemMock(int parentId, int itemId) {
- mUniqueId = DataManager.makeId(parentId, itemId);
- }
-
- public Future<Bitmap>
- requestImage(int type, FutureListener<? super Bitmap> listener) {
- return null;
- }
-
- public Future<LargeBitmap> requestLargeImage(
- int type, FutureListener<LargeBitmap> listener) {
- return null;
- }
-
- public long getUniqueId() {
- return mUniqueId;
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/data/MediaSetMock.java b/new3d/tests/src/com/android/gallery3d/data/MediaSetMock.java
deleted file mode 100644
index 0d3de30..0000000
--- a/new3d/tests/src/com/android/gallery3d/data/MediaSetMock.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import java.util.ArrayList;
-
-public class MediaSetMock extends MediaSet {
- ArrayList<MediaItem> mItems = new ArrayList<MediaItem>();
- ArrayList<MediaSet> mSets = new ArrayList<MediaSet>();
- long mUniqueId;
- int mMergeId;
-
- public MediaSetMock(DataManager dataManager, int childKey, int parentId) {
- mUniqueId = dataManager.obtainSetId(parentId, childKey, this);
- mMergeId = 0;
- }
-
- public MediaSetMock(DataManager dataManager, int parentId, int childKey,
- int mergeId, int items, int item_id_start) {
- mUniqueId = dataManager.obtainSetId(parentId, childKey, this);
- mMergeId = mergeId;
- for (int i = 0; i < items; i++) {
- mItems.add(new MediaItemMock(getMyId(), item_id_start + i));
- }
- }
-
- public MediaSetMock(DataManager dataManager, int parentId, int childKey,
- int items, int item_id_start) {
- mUniqueId = dataManager.obtainSetId(parentId, childKey, this);
- mMergeId = 0;
- for (int i = 0; i < items; i++) {
- mItems.add(new MediaItemMock(getMyId(), item_id_start + i));
- }
- }
-
- public void addMediaSet(MediaSet sub) {
- mSets.add(sub);
- }
-
- @Override
- public int getMediaItemCount() {
- return mItems.size();
- }
-
- @Override
- public ArrayList<MediaItem> getMediaItem(int start, int count) {
- ArrayList<MediaItem> result = new ArrayList<MediaItem>();
- int end = Math.min(start + count, mItems.size());
-
- for (int i = start; i < end; i++) {
- result.add(mItems.get(i));
- }
- return result;
- }
-
- @Override
- public int getSubMediaSetCount() {
- return mSets.size();
- }
-
- @Override
- public MediaSet getSubMediaSet(int index) {
- return mSets.get(index);
- }
-
- @Override
- public int getTotalMediaItemCount() {
- int result = mItems.size();
- for (MediaSet s : mSets) {
- result += s.getTotalMediaItemCount();
- }
- return result;
- }
-
- @Override
- public long getUniqueId() {
- return mUniqueId;
- }
-
- @Override
- public String getName() {
- return "Set " + mUniqueId;
- }
-
- @Override
- public boolean reload() {
- return true;
- }
-
- @Override
- public int getMergeId() {
- return mMergeId;
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/data/MediaSetTest.java b/new3d/tests/src/com/android/gallery3d/data/MediaSetTest.java
deleted file mode 100644
index 8674df9..0000000
--- a/new3d/tests/src/com/android/gallery3d/data/MediaSetTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-
-public class MediaSetTest extends AndroidTestCase {
- private static final String TAG = "MediaSetTest";
- private static final int DUMMY_PARENT_ID = 0x777;
- private static final int KEY_COMBO = 1;
- private static final int KEY_MERGE = 2;
-
- @SmallTest
- public void testComboAlbumSet() {
- DataManager dataManager = new GalleryContextMock(null, null, null)
- .getDataManager();
-
- MediaSetMock set00 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 0, 0, 2000);
- MediaSetMock set01 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 1, 1, 3000);
- MediaSetMock set10 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 2, 2, 4000);
- MediaSetMock set11 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 3, 3, 5000);
- MediaSetMock set12 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 4, 4, 6000);
-
- MediaSetMock set0 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 5, 7, 7000);
- set0.addMediaSet(set00);
- set0.addMediaSet(set01);
-
- MediaSetMock set1 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 6, 8, 8000);
- set1.addMediaSet(set10);
- set1.addMediaSet(set11);
- set1.addMediaSet(set12);
-
- MediaSet combo = new ComboAlbumSet(dataManager, DUMMY_PARENT_ID,
- KEY_COMBO, set0, set1);
- assertEquals(DUMMY_PARENT_ID, DataManager.extractParentId(combo.getUniqueId()));
- assertEquals(5, combo.getSubMediaSetCount());
- assertEquals(0, combo.getMediaItemCount());
- assertEquals(0x77700000001L, combo.getSubMediaSet(0).getUniqueId());
- assertEquals(0x77700000002L, combo.getSubMediaSet(1).getUniqueId());
- assertEquals(0x77700000003L, combo.getSubMediaSet(2).getUniqueId());
- assertEquals(0x77700000004L, combo.getSubMediaSet(3).getUniqueId());
- assertEquals(0x77700000005L, combo.getSubMediaSet(4).getUniqueId());
-
- assertEquals(25, combo.getTotalMediaItemCount());
- }
-
- @SmallTest
- public void testMergeAlbumSet() {
- DataManager dataManager = new GalleryContextMock(null, null, null)
- .getDataManager();
-
- MediaSetMock set00 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 0, 0, 3, 0x4000);
- MediaSetMock set01 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 1, 1, 4, 0x3000);
- MediaSetMock set11 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 2, 1, 6, 0x2000);
- MediaSetMock set12 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 3, 2, 1, 0x1000);
-
- MediaSetMock set0 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 4);
- set0.addMediaSet(set00);
- set0.addMediaSet(set01);
- MediaSetMock set1 = new MediaSetMock(dataManager, DUMMY_PARENT_ID, 5);
- set1.addMediaSet(set11);
- set1.addMediaSet(set12);
-
- Comparator<MediaItem> comparator = new Comparator<MediaItem>() {
- public int compare(MediaItem object1, MediaItem object2) {
- int id1 = DataManager.extractSelfId(object1.getUniqueId());
- int id2 = DataManager.extractSelfId(object2.getUniqueId());
- if (id1 > id2) return 1;
- else if (id1 < id2) return -1;
- else return 0;
- }
- };
-
- // set01 and set11 will be merged, but not set00 or set12.
- MediaSet merge = new MergeAlbumSet(dataManager, DUMMY_PARENT_ID,
- KEY_MERGE, comparator, set0, set1);
-
- assertEquals(3, merge.getSubMediaSetCount());
- MediaSet s0 = merge.getSubMediaSet(0);
- MediaSet s1 = merge.getSubMediaSet(1);
- MediaSet s2 = merge.getSubMediaSet(2);
-
- assertEquals(3, s0.getMediaItemCount());
- assertEquals(10, s1.getMediaItemCount());
- assertEquals(1, s2.getMediaItemCount());
-
- ArrayList<MediaItem> items = s1.getMediaItem(0, 10);
- assertEquals(0x300002000L, items.get(0).getUniqueId());
- assertEquals(0x300002005L, items.get(5).getUniqueId());
- assertEquals(0x200003000L, items.get(6).getUniqueId());
- assertEquals(0x200003003L, items.get(9).getUniqueId());
-
- assertEquals(14, merge.getTotalMediaItemCount());
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/data/RealDataTest.java b/new3d/tests/src/com/android/gallery3d/data/RealDataTest.java
deleted file mode 100644
index 96a57aa..0000000
--- a/new3d/tests/src/com/android/gallery3d/data/RealDataTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-import android.os.Looper;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-
-import com.android.gallery3d.app.GalleryContext;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-
-// This test reads real data directly and dump information out in the log.
-public class RealDataTest extends AndroidTestCase {
- private static final String TAG = "RealDataTest";
- private static final int DUMMY_PARENT_ID = 0x777;
- private static final int KEY_LOCAL_IMAGE = 1;
- private static final int KEY_LOCAL_VIDEO = 2;
- private static final int KEY_PICASA = 3;
-
- private HashSet<Long> mUsedId = new HashSet<Long>();
- private GalleryContext mGalleryContext;
-
- @LargeTest
- public void testRealData() {
- mUsedId.clear();
- mGalleryContext = new GalleryContextMock(
- mContext,
- mContext.getContentResolver(),
- Looper.myLooper());
- new TestLocalImage().run();
- new TestLocalVideo().run();
- new TestPicasa().run();
- }
-
- class TestLocalImage {
- public void run() {
- LocalAlbumSet albumSet = new LocalAlbumSet(
- DUMMY_PARENT_ID, KEY_LOCAL_IMAGE, mGalleryContext, true);
- albumSet.reload();
- Log.v(TAG, "LocalAlbumSet (Image)");
- dumpMediaSet(albumSet, "");
- }
- }
-
- class TestLocalVideo {
- public void run() {
- LocalAlbumSet albumSet = new LocalAlbumSet(
- DUMMY_PARENT_ID, KEY_LOCAL_VIDEO, mGalleryContext, false);
- albumSet.reload();
- Log.v(TAG, "LocalAlbumSet (Video)");
- dumpMediaSet(albumSet, "");
- }
- }
-
- class TestPicasa implements Runnable {
- public void run() {
- PicasaAlbumSet albumSet = new PicasaAlbumSet(
- DUMMY_PARENT_ID, KEY_PICASA, mGalleryContext);
- albumSet.reload();
- Log.v(TAG, "PicasaAlbumSet");
- dumpMediaSet(albumSet, "");
- }
- }
-
- void dumpMediaSet(MediaSet set, String prefix) {
- Log.v(TAG, "getName() = " + set.getName());
- Log.v(TAG, "getUniqueId() = " + Long.toHexString(set.getUniqueId()));
- Log.v(TAG, "getMediaItemCount() = " + set.getMediaItemCount());
- Log.v(TAG, "getSubMediaSetCount() = " + set.getSubMediaSetCount());
- Log.v(TAG, "getTotalMediaItemCount() = " + set.getTotalMediaItemCount());
- assertNewId(set.getUniqueId());
- for (int i = 0, n = set.getSubMediaSetCount(); i < n; i++) {
- MediaSet sub = set.getSubMediaSet(i);
- Log.v(TAG, prefix + "got set " + i);
- dumpMediaSet(sub, prefix + " ");
- }
- for (int i = 0, n = set.getMediaItemCount(); i < n; i += 10) {
- ArrayList<MediaItem> list = set.getMediaItem(i, 10);
- Log.v(TAG, prefix + "got item " + i + " (+" + list.size() + ")");
- for (MediaItem item : list) {
- dumpMediaItem(item, prefix + "..");
- }
- }
- }
-
- void dumpMediaItem(MediaItem item, String prefix) {
- assertNewId(item.getUniqueId());
- Log.v(TAG, prefix + "getUniqueId() = "
- + Long.toHexString(item.getUniqueId()));
- }
-
- void assertNewId(Long key) {
- assertFalse(Long.toHexString(key) + " has already appeared.",
- mUsedId.contains(key));
- mUsedId.add(key);
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/ui/GLCanvasMock.java b/new3d/tests/src/com/android/gallery3d/ui/GLCanvasMock.java
deleted file mode 100644
index 357ce59..0000000
--- a/new3d/tests/src/com/android/gallery3d/ui/GLCanvasMock.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.android.gallery3d.ui;
-
-import android.util.Log;
-
-import javax.microedition.khronos.opengles.GL;
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL10Ext;
-import javax.microedition.khronos.opengles.GL11;
-import javax.microedition.khronos.opengles.GL11Ext;
-import javax.microedition.khronos.opengles.GL11ExtensionPack;
-
-public class GLCanvasMock extends GLCanvasStub {
- // fillRect
- int mFillRectCalled;
- float mFillRectWidth;
- float mFillRectHeight;
- int mFillRectColor;
- // drawMixed
- int mDrawMixedCalled;
- float mDrawMixedRatio;
- // drawTexture;
- int mDrawTextureCalled;
-
- private GL11 mGL;
-
- public GLCanvasMock(GL11 gl) {
- mGL = gl;
- }
-
- public GLCanvasMock() {
- mGL = new GLStub();
- }
-
- public GL11 getGLInstance() {
- return mGL;
- }
-
- public void fillRect(float x, float y, float width, float height, int color) {
- mFillRectCalled++;
- mFillRectWidth = width;
- mFillRectHeight = height;
- mFillRectColor = color;
- }
-
- public void drawTexture(
- BasicTexture texture, int x, int y, int width, int height) {
- mDrawTextureCalled++;
- }
-
- public void drawMixed(BasicTexture from, BasicTexture to,
- float ratio, int x, int y, int w, int h) {
- mDrawMixedCalled++;
- mDrawMixedRatio = ratio;
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/ui/GLCanvasStub.java b/new3d/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
deleted file mode 100644
index ca07cc3..0000000
--- a/new3d/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.android.gallery3d.ui;
-
-import android.graphics.Rect;
-import android.graphics.RectF;
-
-import javax.microedition.khronos.opengles.GL11;
-
-public class GLCanvasStub implements GLCanvas {
- public void setSize(int width, int height) {}
- public void clearBuffer() {}
- public void setCurrentAnimationTimeMillis(long time) {}
- public long currentAnimationTimeMillis() {
- throw new UnsupportedOperationException();
- }
- public void setAlpha(float alpha) {}
- public float getAlpha() {
- throw new UnsupportedOperationException();
- }
- public void multiplyAlpha(float alpha) {}
- public void translate(float x, float y, float z) {}
- public void scale(float sx, float sy, float sz) {}
- public void rotate(float angle, float x, float y, float z) {}
- public boolean clipRect(int left, int top, int right, int bottom) {
- throw new UnsupportedOperationException();
- }
- public int save() {
- throw new UnsupportedOperationException();
- }
- public int save(int saveFlags) {
- throw new UnsupportedOperationException();
- }
- public void restore() {}
- public void drawLine(int x1, int y1, int x2, int y2, int color) {}
- public void fillRect(float x, float y, float width, float height, int color) {}
- public void drawTexture(
- BasicTexture texture, int x, int y, int width, int height) {}
- public void drawMesh(BasicTexture tex, int x, int y, int xyBuffer,
- int uvBuffer, int indexBuffer, int indexCount) {}
- public void drawTexture(BasicTexture texture,
- int x, int y, int width, int height, float alpha) {}
- public void drawTexture(BasicTexture texture, RectF source, RectF target) {}
- public void drawMixed(BasicTexture from, BasicTexture to,
- float ratio, int x, int y, int w, int h) {}
- public void drawMixed(BasicTexture from, BasicTexture to,
- float ratio, int x, int y, int width, int height, float alpha) {}
- public BasicTexture copyTexture(int x, int y, int width, int height) {
- throw new UnsupportedOperationException();
- }
- public GL11 getGLInstance() {
- throw new UnsupportedOperationException();
- }
- public boolean unloadTexture(BasicTexture texture) {
- throw new UnsupportedOperationException();
- }
- public void deleteBuffer(int bufferId) {
- throw new UnsupportedOperationException();
- }
- public void deleteRecycledResources() {}
-}
diff --git a/new3d/tests/src/com/android/gallery3d/ui/GLCanvasTest.java b/new3d/tests/src/com/android/gallery3d/ui/GLCanvasTest.java
deleted file mode 100644
index bb1dd8d..0000000
--- a/new3d/tests/src/com/android/gallery3d/ui/GLCanvasTest.java
+++ /dev/null
@@ -1,756 +0,0 @@
-package com.android.gallery3d.ui;
-
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-
-import junit.framework.TestCase;
-
-import java.util.Arrays;
-
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL11;
-
-@SmallTest
-public class GLCanvasTest extends TestCase {
- private static final String TAG = "GLCanvasTest";
-
- @SmallTest
- public void testSetSize() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImp(glStub);
- canvas.setSize(100, 200);
- canvas.setSize(1000, 100);
- try {
- canvas.setSize(-1, 100);
- fail();
- } catch (Throwable ex) {
- // expected.
- }
- }
-
- @SmallTest
- public void testClearBuffer() {
- new ClearBufferTest().run();
- }
-
- private static class ClearBufferTest extends GLMock {
- void run() {
- GLCanvas canvas = new GLCanvasImp(this);
- assertEquals(0, mGLClearCalled);
- canvas.clearBuffer();
- assertEquals(GL10.GL_COLOR_BUFFER_BIT, mGLClearMask);
- assertEquals(1, mGLClearCalled);
- }
- }
-
- @SmallTest
- public void testAnimationTime() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImp(glStub);
-
- long[] testData = {0, 1, 2, 1000, 10000, Long.MAX_VALUE};
-
- for (long v : testData) {
- canvas.setCurrentAnimationTimeMillis(v);
- assertEquals(v, canvas.currentAnimationTimeMillis());
- }
-
- try {
- canvas.setCurrentAnimationTimeMillis(-1);
- fail();
- } catch (Throwable ex) {
- // expected.
- }
- }
-
- @SmallTest
- public void testSetColor() {
- new SetColorTest().run();
- }
-
- // This test assumes we use pre-multipled alpha blending and should
- // set the blending function and color correctly.
- private static class SetColorTest extends GLMock {
- void run() {
- int[] testColors = new int[] {
- 0, 0xFFFFFFFF, 0xFF000000, 0x00FFFFFF, 0x80FF8001,
- 0x7F010101, 0xFEFEFDFC, 0x017F8081, 0x027F8081, 0x2ADE4C4D
- };
-
- GLCanvas canvas = new GLCanvasImp(this);
- canvas.setSize(400, 300);
- // Test one color to make sure blend function is set.
- assertEquals(0, mGLColorCalled);
- canvas.drawLine(0, 0, 1, 1, 0x7F804020);
- assertEquals(1, mGLColorCalled);
- assertEquals(0x7F402010, mGLColor);
- assertPremultipliedBlending(this);
-
- // Test other colors to make sure premultiplication is right
- for (int c : testColors) {
- float a = (c >>> 24) / 255f;
- float r = ((c >> 16) & 0xff) / 255f;
- float g = ((c >> 8) & 0xff) / 255f;
- float b = (c & 0xff) / 255f;
- int pre = makeColor4f(a * r, a * g, a * b, a);
-
- mGLColorCalled = 0;
- canvas.drawLine(0, 0, 1, 1, c);
- assertEquals(1, mGLColorCalled);
- assertEquals(pre, mGLColor);
- }
- }
- }
-
- @SmallTest
- public void testSetGetMultiplyAlpha() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImp(glStub);
-
- canvas.setAlpha(1f);
- assertEquals(1f, canvas.getAlpha());
-
- canvas.setAlpha(0f);
- assertEquals(0f, canvas.getAlpha());
-
- canvas.setAlpha(0.5f);
- assertEquals(0.5f, canvas.getAlpha());
-
- canvas.multiplyAlpha(0.5f);
- assertEquals(0.25f, canvas.getAlpha());
-
- canvas.multiplyAlpha(0f);
- assertEquals(0f, canvas.getAlpha());
-
- try {
- canvas.setAlpha(-0.01f);
- fail();
- } catch (Throwable ex) {
- // expected.
- }
-
- try {
- canvas.setAlpha(1.01f);
- fail();
- } catch (Throwable ex) {
- // expected.
- }
- }
-
- @SmallTest
- public void testAlpha() {
- new AlphaTest().run();
- }
-
- private static class AlphaTest extends GLMock {
- void run() {
- GLCanvas canvas = new GLCanvasImp(this);
- canvas.setSize(400, 300);
-
- assertEquals(0, mGLColorCalled);
- canvas.setAlpha(0.48f);
- canvas.drawLine(0, 0, 1, 1, 0xFF804020);
- assertPremultipliedBlending(this);
- assertEquals(1, mGLColorCalled);
- assertEquals(0x7A3D1F0F, mGLColor);
- }
- }
-
- @SmallTest
- public void testDrawLine() {
- new DrawLineTest().run();
- }
-
- // This test assumes the drawLine() function use glDrawArrays() with
- // GL_LINE_STRIP mode to draw the line and the input coordinates are used
- // directly.
- private static class DrawLineTest extends GLMock {
- private int mDrawArrayCalled = 0;
- private final int[] mResult = new int[4];
-
- @Override
- public void glDrawArrays(int mode, int first, int count) {
- assertNotNull(mGLVertexPointer);
- assertEquals(GL10.GL_LINE_STRIP, mode);
- assertEquals(2, count);
- mGLVertexPointer.bindByteBuffer();
-
- double[] coord = new double[4];
- mGLVertexPointer.getArrayElement(first, coord);
- mResult[0] = (int) coord[0];
- mResult[1] = (int) coord[1];
- mGLVertexPointer.getArrayElement(first + 1, coord);
- mResult[2] = (int) coord[0];
- mResult[3] = (int) coord[1];
- mDrawArrayCalled++;
- }
-
- void run() {
- GLCanvas canvas = new GLCanvasImp(this);
- canvas.setSize(400, 300);
- canvas.drawLine(2, 7, 1, 8, 0 /* color */);
- assertTrue(mGLVertexArrayEnabled);
- assertEquals(1, mDrawArrayCalled);
-
- Log.v(TAG, "result = " + Arrays.toString(mResult));
- int[] answer = new int[] {2, 7, 1, 8};
- for (int i = 0; i < answer.length; i++) {
- assertEquals(answer[i], mResult[i]);
- }
- }
- }
-
- @SmallTest
- public void testFillRect() {
- new FillRectTest().run();
- }
-
- // This test assumes the drawLine() function use glDrawArrays() with
- // GL_TRIANGLE_STRIP mode to draw the line and the input coordinates
- // are used directly.
- private static class FillRectTest extends GLMock {
- private int mDrawArrayCalled = 0;
- private final int[] mResult = new int[8];
-
- @Override
- public void glDrawArrays(int mode, int first, int count) {
- assertNotNull(mGLVertexPointer);
- assertEquals(GL10.GL_TRIANGLE_STRIP, mode);
- assertEquals(4, count);
- mGLVertexPointer.bindByteBuffer();
-
- double[] coord = new double[4];
- for (int i = 0; i < 4; i++) {
- mGLVertexPointer.getArrayElement(first + i, coord);
- mResult[i * 2 + 0] = (int) coord[0];
- mResult[i * 2 + 1] = (int) coord[1];
- }
-
- mDrawArrayCalled++;
- }
-
- void run() {
- GLCanvas canvas = new GLCanvasImp(this);
- canvas.setSize(400, 300);
- canvas.fillRect(2, 7, 1, 8, 0 /* color */);
- assertTrue(mGLVertexArrayEnabled);
- assertEquals(1, mDrawArrayCalled);
- Log.v(TAG, "result = " + Arrays.toString(mResult));
-
- // These are the four vertics that should be used.
- int[] answer = new int[] {
- 2, 7,
- 3, 7,
- 3, 15,
- 2, 15};
- int count[] = new int[4];
-
- // Count the number of appearances for each vertex.
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < 4; j++) {
- if (answer[i * 2] == mResult[j * 2] &&
- answer[i * 2 + 1] == mResult[j * 2 + 1]) {
- count[i]++;
- }
- }
- }
-
- // Each vertex should appear exactly once.
- for (int i = 0; i < 4; i++) {
- assertEquals(1, count[i]);
- }
- }
- }
-
- @SmallTest
- public void testTransform() {
- new TransformTest().run();
- }
-
- // This test assumes glLoadMatrixf is used to load the model view matrix,
- // and glOrthof is used to load the projection matrix.
- //
- // The projection matrix is set to an orthogonal projection which is the
- // inverse of viewport transform. So the model view matrix maps input
- // directly to screen coordinates (default no scaling, and the y-axis is
- // reversed).
- //
- // The matrix here are all listed in column major order.
- //
- private static class TransformTest extends GLMock {
- private final float[] mModelViewMatrixUsed = new float[16];
- private final float[] mProjectionMatrixUsed = new float[16];
-
- @Override
- public void glDrawArrays(int mode, int first, int count) {
- copy(mModelViewMatrixUsed, mGLModelViewMatrix);
- copy(mProjectionMatrixUsed, mGLProjectionMatrix);
- }
-
- private void copy(float[] dest, float[] src) {
- System.arraycopy(src, 0, dest, 0, 16);
- }
-
- void run() {
- GLCanvas canvas = new GLCanvasImp(this);
- canvas.setSize(40, 50);
- int color = 0;
-
- // Initial matrix
- canvas.drawLine(0, 0, 1, 1, color);
- assertMatrixEq(new float[] {
- 1, 0, 0, 0,
- 0, -1, 0, 0,
- 0, 0, 1, 0,
- 0, 50, 0, 1
- }, mModelViewMatrixUsed);
-
- assertMatrixEq(new float[] {
- 2f / 40, 0, 0, 0,
- 0, 2f / 50, 0, 0,
- 0, 0, -1, 0,
- -1, -1, 0, 1
- }, mProjectionMatrixUsed);
-
- // Translation
- canvas.translate(3, 4, 5);
- canvas.drawLine(0, 0, 1, 1, color);
- assertMatrixEq(new float[] {
- 1, 0, 0, 0,
- 0, -1, 0, 0,
- 0, 0, 1, 0,
- 3, 46, 5, 1
- }, mModelViewMatrixUsed);
- canvas.save();
-
- // Scaling
- canvas.scale(0.7f, 0.6f, 0.5f);
- canvas.drawLine(0, 0, 1, 1, color);
- assertMatrixEq(new float[] {
- 0.7f, 0, 0, 0,
- 0, -0.6f, 0, 0,
- 0, 0, 0.5f, 0,
- 3, 46, 5, 1
- }, mModelViewMatrixUsed);
-
- // Rotation
- canvas.rotate(90, 0, 0, 1);
- canvas.drawLine(0, 0, 1, 1, color);
- assertMatrixEq(new float[] {
- 0, -0.6f, 0, 0,
- -0.7f, 0, 0, 0,
- 0, 0, 0.5f, 0,
- 3, 46, 5, 1
- }, mModelViewMatrixUsed);
- canvas.restore();
-
- // After restoring to the point just after translation,
- // do rotation again.
- canvas.rotate(180, 1, 0, 0);
- canvas.drawLine(0, 0, 1, 1, color);
- assertMatrixEq(new float[] {
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, -1, 0,
- 3, 46, 5, 1
- }, mModelViewMatrixUsed);
- }
- }
-
- @SmallTest
- public void testClipRect() {
- // The test is currently broken, waiting for the fix
- // new ClipRectTest().run();
- }
-
- private static class ClipRectTest extends GLStub {
- int mX, mY, mWidth, mHeight;
-
- @Override
- public void glScissor(int x, int y, int width, int height) {
- mX = x;
- mY = 100 - y - height; // flip in Y direction
- mWidth = width;
- mHeight = height;
- }
-
- private void assertClipRect(int x, int y, int width, int height) {
- assertEquals(x, mX);
- assertEquals(y, mY);
- assertEquals(width, mWidth);
- assertEquals(height, mHeight);
- }
-
- private void assertEmptyClipRect() {
- assertEquals(0, mWidth);
- assertEquals(0, mHeight);
- }
-
- void run() {
- GLCanvas canvas = new GLCanvasImp(this);
- canvas.setSize(100, 100);
- canvas.save();
- assertClipRect(0, 0, 100, 100);
-
- assertTrue(canvas.clipRect(10, 10, 70, 70));
- canvas.save();
- assertClipRect(10, 10, 60, 60);
-
- assertTrue(canvas.clipRect(30, 30, 90, 90));
- canvas.save();
- assertClipRect(30, 30, 40, 40);
-
- assertTrue(canvas.clipRect(40, 40, 60, 90));
- assertClipRect(40, 40, 20, 30);
-
- assertFalse(canvas.clipRect(30, 30, 70, 40));
- assertEmptyClipRect();
- assertFalse(canvas.clipRect(0, 0, 100, 100));
- assertEmptyClipRect();
-
- canvas.restore();
- assertClipRect(30, 30, 40, 40);
-
- canvas.restore();
- assertClipRect(10, 10, 60, 60);
-
- canvas.restore();
- assertClipRect(0, 0, 100, 100);
-
- canvas.translate(10, 20, 30);
- assertTrue(canvas.clipRect(10, 10, 70, 70));
- canvas.save();
- assertClipRect(20, 30, 60, 60);
- }
- }
-
- @SmallTest
- public void testSaveRestore() {
- new SaveRestoreTest().run();
- }
-
- private static class SaveRestoreTest extends GLStub {
- int mX, mY, mWidth, mHeight;
-
- @Override
- public void glScissor(int x, int y, int width, int height) {
- mX = x;
- mY = 100 - y - height; // flip in Y direction
- mWidth = width;
- mHeight = height;
- }
-
- private void assertClipRect(int x, int y, int width, int height) {
- assertEquals(x, mX);
- assertEquals(y, mY);
- assertEquals(width, mWidth);
- assertEquals(height, mHeight);
- }
-
- void run() {
- GLCanvas canvas = new GLCanvasImp(this);
- canvas.setSize(100, 100);
-
- canvas.setAlpha(0.7f);
- assertTrue(canvas.clipRect(10, 10, 70, 70));
-
- canvas.save(canvas.SAVE_FLAG_CLIP);
- canvas.setAlpha(0.6f);
- assertTrue(canvas.clipRect(30, 30, 90, 90));
-
- canvas.save(canvas.SAVE_FLAG_CLIP | canvas.SAVE_FLAG_ALPHA);
- canvas.setAlpha(0.5f);
- assertTrue(canvas.clipRect(40, 40, 60, 90));
-
- assertEquals(0.5f, canvas.getAlpha());
- assertClipRect(40, 40, 20, 30);
-
- canvas.restore(); // now both clipping rect and alpha are restored.
- assertEquals(0.6f, canvas.getAlpha());
- assertClipRect(30, 30, 40, 40);
-
- canvas.restore(); // now only clipping rect is restored.
-
- canvas.save(0);
- canvas.save(0);
- canvas.restore();
- canvas.restore();
-
- assertEquals(0.6f, canvas.getAlpha());
- assertTrue(canvas.clipRect(10, 10, 60, 60));
- }
- }
-
- @SmallTest
- public void testDrawTexture() {
- new DrawTextureTest().run();
- new DrawTextureMixedTest().run();
- }
-
- private static class MyTexture extends BasicTexture {
- boolean mIsOpaque;
- int mBindCalled;
-
- MyTexture(GLCanvas canvas, int id, boolean isOpaque) {
- super(canvas, id, STATE_LOADED);
- setSize(1, 1);
- mIsOpaque = isOpaque;
- }
-
- @Override
- protected boolean onBind(GLCanvas canvas) {
- mBindCalled++;
- return true;
- }
-
- public boolean isOpaque() {
- return mIsOpaque;
- }
- }
-
- private static class DrawTextureTest extends GLMock {
- int mDrawTexiOESCalled;
- int mDrawArrayCalled;
- int[] mResult = new int[4];
-
- @Override
- public void glDrawTexiOES(int x, int y, int z,
- int width, int height) {
- mDrawTexiOESCalled++;
- }
-
- @Override
- public void glDrawArrays(int mode, int first, int count) {
- assertNotNull(mGLVertexPointer);
- assertEquals(GL10.GL_TRIANGLE_STRIP, mode);
- assertEquals(4, count);
- mGLVertexPointer.bindByteBuffer();
-
- double[] coord = new double[4];
- mGLVertexPointer.getArrayElement(first, coord);
- mResult[0] = (int) coord[0];
- mResult[1] = (int) coord[1];
- mGLVertexPointer.getArrayElement(first + 1, coord);
- mResult[2] = (int) coord[0];
- mResult[3] = (int) coord[1];
- mDrawArrayCalled++;
- }
-
- void run() {
- GLCanvas canvas = new GLCanvasImp(this);
- canvas.setSize(400, 300);
- MyTexture texture = new MyTexture(canvas, 42, false); // non-opaque
- MyTexture texture_o = new MyTexture(canvas, 47, true); // opaque
-
- // Draw a non-opaque texture
- canvas.drawTexture(texture, 100, 200, 300, 400);
- assertEquals(42, mGLBindTextureId);
- assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE_ENV_MODE));
- assertPremultipliedBlending(this);
- assertFalse(mGLStencilEnabled);
-
- // Draw an opaque texture
- canvas.drawTexture(texture_o, 100, 200, 300, 400);
- assertEquals(47, mGLBindTextureId);
- assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE_ENV_MODE));
- assertFalse(mGLBlendEnabled);
-
- // Draw a non-opaque texture with alpha = 0.5
- canvas.setAlpha(0.5f);
- canvas.drawTexture(texture, 100, 200, 300, 400);
- assertEquals(42, mGLBindTextureId);
- assertEquals(0x80808080, mGLColor);
- assertEquals(GL_MODULATE, getTexEnvi(GL_TEXTURE_ENV_MODE));
- assertPremultipliedBlending(this);
- assertFalse(mGLStencilEnabled);
-
- // Draw an non-opaque texture with overriden alpha = 1
- canvas.drawTexture(texture, 100, 200, 300, 400, 1f);
- assertEquals(42, mGLBindTextureId);
- assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE_ENV_MODE));
- assertPremultipliedBlending(this);
-
- // Draw an opaque texture with overriden alpha = 1
- canvas.drawTexture(texture_o, 100, 200, 300, 400, 1f);
- assertEquals(47, mGLBindTextureId);
- assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE_ENV_MODE));
- assertFalse(mGLBlendEnabled);
-
- // Draw an opaque texture with overridden alpha = 0.25
- canvas.drawTexture(texture_o, 100, 200, 300, 400, 0.25f);
- assertEquals(47, mGLBindTextureId);
- assertEquals(0x40404040, mGLColor);
- assertEquals(GL_MODULATE, getTexEnvi(GL_TEXTURE_ENV_MODE));
- assertPremultipliedBlending(this);
-
- // Draw an opaque texture with overridden alpha = 0.125
- // but with some rotation so it will use DrawArray.
- canvas.save();
- canvas.rotate(30, 0, 0, 1);
- canvas.drawTexture(texture_o, 100, 200, 300, 400, 0.125f);
- canvas.restore();
- assertEquals(47, mGLBindTextureId);
- assertEquals(0x20202020, mGLColor);
- assertEquals(GL_MODULATE, getTexEnvi(GL_TEXTURE_ENV_MODE));
- assertPremultipliedBlending(this);
-
- // We have drawn seven textures above.
- assertEquals(1, mDrawArrayCalled);
- assertEquals(6, mDrawTexiOESCalled);
-
- // translate and scale does not affect whether we
- // can use glDrawTexiOES, but rotate may.
- canvas.translate(10, 20, 30);
- canvas.drawTexture(texture, 100, 200, 300, 400);
- assertEquals(7, mDrawTexiOESCalled);
-
- canvas.scale(10, 20, 30);
- canvas.drawTexture(texture, 100, 200, 300, 400);
- assertEquals(8, mDrawTexiOESCalled);
-
- canvas.rotate(90, 1, 2, 3);
- canvas.drawTexture(texture, 100, 200, 300, 400);
- assertEquals(8, mDrawTexiOESCalled);
-
- canvas.rotate(-90, 1, 2, 3);
- canvas.drawTexture(texture, 100, 200, 300, 400);
- assertEquals(9, mDrawTexiOESCalled);
-
- canvas.rotate(180, 0, 0, 1);
- canvas.drawTexture(texture, 100, 200, 300, 400);
- assertEquals(9, mDrawTexiOESCalled);
-
- canvas.rotate(180, 0, 0, 1);
- canvas.drawTexture(texture, 100, 200, 300, 400);
- assertEquals(10, mDrawTexiOESCalled);
-
- assertEquals(3, mDrawArrayCalled);
-
- assertTrue(texture.isLoaded(canvas));
- texture.recycle();
- assertFalse(texture.isLoaded(canvas));
- canvas.deleteRecycledResources();
-
- assertTrue(texture_o.isLoaded(canvas));
- texture_o.recycle();
- assertFalse(texture_o.isLoaded(canvas));
- }
- }
-
- private static class DrawTextureMixedTest extends GLMock {
-
- boolean mTexture2DEnabled0, mTexture2DEnabled1;
- int mBindTexture0;
- int mBindTexture1;
-
- @Override
- public void glEnable(int cap) {
- if (cap == GL_TEXTURE_2D) {
- texture2DEnable(true);
- }
- }
-
- @Override
- public void glDisable(int cap) {
- if (cap == GL_TEXTURE_2D) {
- texture2DEnable(false);
- }
- }
-
- private void texture2DEnable(boolean enable) {
- if (mGLActiveTexture == GL_TEXTURE0) {
- mTexture2DEnabled0 = enable;
- } else if (mGLActiveTexture == GL_TEXTURE1) {
- mTexture2DEnabled1 = enable;
- } else {
- fail();
- }
- }
-
- @Override
- public void glTexEnvfv(int target, int pname, float[] params, int offset) {
- if (target == GL_TEXTURE_ENV && pname == GL_TEXTURE_ENV_COLOR) {
- assertEquals(0.5f, params[offset + 3]);
- }
- }
-
- @Override
- public void glBindTexture(int target, int texture) {
- if (target == GL_TEXTURE_2D) {
- if (mGLActiveTexture == GL_TEXTURE0) {
- mBindTexture0 = texture;
- } else if (mGLActiveTexture == GL_TEXTURE1) {
- mBindTexture1 = texture;
- } else {
- fail();
- }
- }
- }
-
- void run() {
- GLCanvas canvas = new GLCanvasImp(this);
- canvas.setSize(400, 300);
- MyTexture from = new MyTexture(canvas, 42, false); // non-opaque
- MyTexture to = new MyTexture(canvas, 47, true); // opaque
-
- canvas.drawMixed(from, to, 0.5f, 100, 200, 300, 400);
- assertEquals(42, mBindTexture0);
- assertEquals(47, mBindTexture1);
- assertTrue(mTexture2DEnabled0);
- assertFalse(mTexture2DEnabled1);
-
- assertEquals(GL_COMBINE, getTexEnvi(GL_TEXTURE1, GL_TEXTURE_ENV_MODE));
- assertEquals(GL_INTERPOLATE, getTexEnvi(GL_TEXTURE1, GL_COMBINE_RGB));
- assertEquals(GL_INTERPOLATE, getTexEnvi(GL_TEXTURE1, GL_COMBINE_ALPHA));
- assertEquals(GL_CONSTANT, getTexEnvi(GL_TEXTURE1, GL_SRC2_RGB));
- assertEquals(GL_CONSTANT, getTexEnvi(GL_TEXTURE1, GL_SRC2_ALPHA));
- assertEquals(GL_SRC_ALPHA, getTexEnvi(GL_TEXTURE1, GL_OPERAND2_RGB));
- assertEquals(GL_SRC_ALPHA, getTexEnvi(GL_TEXTURE1, GL_OPERAND2_ALPHA));
-
- assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE0, GL_TEXTURE_ENV_MODE));
-
- assertFalse(mGLBlendEnabled);
-
- canvas.drawMixed(from, to, 0, 100, 200, 300, 400);
- assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE0, GL_TEXTURE_ENV_MODE));
- assertEquals(42, mBindTexture0);
-
- canvas.drawMixed(from, to, 1, 100, 200, 300, 400);
- assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE0, GL_TEXTURE_ENV_MODE));
- assertEquals(47, mBindTexture0);
- }
- }
-
- @SmallTest
- public void testGetGLInstance() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImp(glStub);
- assertSame(glStub, canvas.getGLInstance());
- }
-
- private static void assertPremultipliedBlending(GLMock mock) {
- assertTrue(mock.mGLBlendFuncCalled > 0);
- assertTrue(mock.mGLBlendEnabled);
- assertEquals(GL11.GL_ONE, mock.mGLBlendFuncSFactor);
- assertEquals(GL11.GL_ONE_MINUS_SRC_ALPHA, mock.mGLBlendFuncDFactor);
- }
-
- private static void assertMatrixEq(float[] expected, float[] actual) {
- try {
- for (int i = 0; i < 16; i++) {
- assertFloatEq(expected[i], actual[i]);
- }
- } catch (Throwable t) {
- Log.v(TAG, "expected = " + Arrays.toString(expected) +
- ", actual = " + Arrays.toString(actual));
- fail();
- }
- }
-
- public static void assertFloatEq(float expected, float actual) {
- if (Math.abs(actual - expected) > 1e-6) {
- Log.v(TAG, "expected: " + expected + ", actual: " + actual);
- fail();
- }
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/ui/GLMock.java b/new3d/tests/src/com/android/gallery3d/ui/GLMock.java
deleted file mode 100644
index 4d59a29..0000000
--- a/new3d/tests/src/com/android/gallery3d/ui/GLMock.java
+++ /dev/null
@@ -1,179 +0,0 @@
-package com.android.gallery3d.ui;
-
-import java.nio.Buffer;
-import java.util.HashMap;
-
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL11;
-
-public class GLMock extends GLStub {
- private static final String TAG = "GLMock";
-
- // glClear
- int mGLClearCalled;
- int mGLClearMask;
- // glBlendFunc
- int mGLBlendFuncCalled;
- int mGLBlendFuncSFactor;
- int mGLBlendFuncDFactor;
- // glColor4[fx]
- int mGLColorCalled;
- int mGLColor;
- // glEnable, glDisable
- boolean mGLBlendEnabled;
- boolean mGLStencilEnabled;
- // glEnableClientState
- boolean mGLVertexArrayEnabled;
- // glVertexPointer
- PointerInfo mGLVertexPointer;
- // glMatrixMode
- int mGLMatrixMode = GL10.GL_MODELVIEW;
- // glLoadMatrixf
- float[] mGLModelViewMatrix = new float[16];
- float[] mGLProjectionMatrix = new float[16];
- // glBindTexture
- int mGLBindTextureId;
- // glTexEnvf
- HashMap<Integer, Float> mGLTexEnv0 = new HashMap<Integer, Float>();
- HashMap<Integer, Float> mGLTexEnv1 = new HashMap<Integer, Float>();
- // glActiveTexture
- int mGLActiveTexture = GL11.GL_TEXTURE0;
-
- @Override
- public void glClear(int mask) {
- mGLClearCalled++;
- mGLClearMask = mask;
- };
-
- @Override
- public void glBlendFunc(int sfactor, int dfactor) {
- mGLBlendFuncSFactor = sfactor;
- mGLBlendFuncDFactor = dfactor;
- mGLBlendFuncCalled++;
- }
-
- @Override
- public void glColor4f(float red, float green, float blue,
- float alpha) {
- mGLColorCalled++;
- mGLColor = makeColor4f(red, green, blue, alpha);
- }
-
- @Override
- public void glColor4x(int red, int green, int blue, int alpha) {
- mGLColorCalled++;
- mGLColor = makeColor4x(red, green, blue, alpha);
- }
-
- @Override
- public void glEnable(int cap) {
- if (cap == GL11.GL_BLEND) {
- mGLBlendEnabled = true;
- } else if (cap == GL11.GL_STENCIL_TEST) {
- mGLStencilEnabled = true;
- }
- }
-
- @Override
- public void glDisable(int cap) {
- if (cap == GL11.GL_BLEND) {
- mGLBlendEnabled = false;
- } else if (cap == GL11.GL_STENCIL_TEST) {
- mGLStencilEnabled = false;
- }
- }
-
- @Override
- public void glEnableClientState(int array) {
- if (array == GL10.GL_VERTEX_ARRAY) {
- mGLVertexArrayEnabled = true;
- }
- }
-
- @Override
- public void glVertexPointer(int size, int type, int stride, Buffer pointer) {
- mGLVertexPointer = new PointerInfo(size, type, stride, pointer);
- }
-
- @Override
- public void glMatrixMode(int mode) {
- mGLMatrixMode = mode;
- }
-
- @Override
- public void glLoadMatrixf(float[] m, int offset) {
- if (mGLMatrixMode == GL10.GL_MODELVIEW) {
- System.arraycopy(m, offset, mGLModelViewMatrix, 0, 16);
- } else if (mGLMatrixMode == GL10.GL_PROJECTION) {
- System.arraycopy(m, offset, mGLProjectionMatrix, 0, 16);
- }
- }
-
- @Override
- public void glOrthof(
- float left, float right, float bottom, float top,
- float zNear, float zFar) {
- float tx = -(right + left) / (right - left);
- float ty = -(top + bottom) / (top - bottom);
- float tz = - (zFar + zNear) / (zFar - zNear);
- float[] m = new float[] {
- 2 / (right - left), 0, 0, 0,
- 0, 2 / (top - bottom), 0, 0,
- 0, 0, -2 / (zFar - zNear), 0,
- tx, ty, tz, 1
- };
- glLoadMatrixf(m, 0);
- }
-
- @Override
- public void glBindTexture(int target, int texture) {
- if (target == GL11.GL_TEXTURE_2D) {
- mGLBindTextureId = texture;
- }
- }
-
- @Override
- public void glTexEnvf(int target, int pname, float param) {
- if (target == GL11.GL_TEXTURE_ENV) {
- if (mGLActiveTexture == GL11.GL_TEXTURE0) {
- mGLTexEnv0.put(pname, param);
- } else if (mGLActiveTexture == GL11.GL_TEXTURE1) {
- mGLTexEnv1.put(pname, param);
- } else {
- throw new AssertionError();
- }
- }
- }
-
- public int getTexEnvi(int pname) {
- return getTexEnvi(mGLActiveTexture, pname);
- }
-
- public int getTexEnvi(int activeTexture, int pname) {
- if (activeTexture == GL11.GL_TEXTURE0) {
- return (int) mGLTexEnv0.get(pname).floatValue();
- } else if (activeTexture == GL11.GL_TEXTURE1) {
- return (int) mGLTexEnv1.get(pname).floatValue();
- } else {
- throw new AssertionError();
- }
- }
-
- @Override
- public void glActiveTexture(int texture) {
- mGLActiveTexture = texture;
- }
-
- public static int makeColor4f(float red, float green, float blue,
- float alpha) {
- return (Math.round(alpha * 255) << 24) |
- (Math.round(red * 255) << 16) |
- (Math.round(green * 255) << 8) |
- Math.round(blue * 255);
- }
-
- public static int makeColor4x(int red, int green, int blue, int alpha) {
- final float X = 65536f;
- return makeColor4f(red / X, green / X, blue / X, alpha / X);
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/ui/GLRootMock.java b/new3d/tests/src/com/android/gallery3d/ui/GLRootMock.java
deleted file mode 100644
index c83e943..0000000
--- a/new3d/tests/src/com/android/gallery3d/ui/GLRootMock.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import com.android.gallery3d.anim.CanvasAnimation;
-
-public class GLRootMock implements GLRoot {
- int mRequestRenderCalled;
- int mRequestLayoutContentPaneCalled;
-
- public void addOnGLIdleListener(OnGLIdleListener listener) {}
- public void registerLaunchedAnimation(CanvasAnimation animation) {}
- public void requestRender() {
- mRequestRenderCalled++;
- }
- public void requestLayoutContentPane() {
- mRequestLayoutContentPaneCalled++;
- }
- public boolean hasStencil() { return true; }
- public void lockRenderThread() {}
- public void unlockRenderThread() {}
- public void setContentPane(GLView content) {}
-}
diff --git a/new3d/tests/src/com/android/gallery3d/ui/GLRootStub.java b/new3d/tests/src/com/android/gallery3d/ui/GLRootStub.java
deleted file mode 100644
index d6bc678..0000000
--- a/new3d/tests/src/com/android/gallery3d/ui/GLRootStub.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import com.android.gallery3d.anim.CanvasAnimation;
-
-public class GLRootStub implements GLRoot {
- public void addOnGLIdleListener(OnGLIdleListener listener) {}
- public void registerLaunchedAnimation(CanvasAnimation animation) {}
- public void requestRender() {}
- public void requestLayoutContentPane() {}
- public boolean hasStencil() { return true; }
- public void lockRenderThread() {}
- public void unlockRenderThread() {}
- public void setContentPane(GLView content) {}
-}
diff --git a/new3d/tests/src/com/android/gallery3d/ui/GLStub.java b/new3d/tests/src/com/android/gallery3d/ui/GLStub.java
deleted file mode 100644
index 3b4d7d6..0000000
--- a/new3d/tests/src/com/android/gallery3d/ui/GLStub.java
+++ /dev/null
@@ -1,1476 +0,0 @@
-package com.android.gallery3d.ui;
-
-import android.util.Log;
-
-import javax.microedition.khronos.opengles.GL;
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL10Ext;
-import javax.microedition.khronos.opengles.GL11;
-import javax.microedition.khronos.opengles.GL11Ext;
-import javax.microedition.khronos.opengles.GL11ExtensionPack;
-
-public class GLStub implements GL, GL10, GL10Ext, GL11, GL11Ext {
- private static final String TAG = "GLStub";
-
- public void glActiveTexture(
- int texture
- ){}
-
- public void glAlphaFunc(
- int func,
- float ref
- ){}
-
- public void glAlphaFuncx(
- int func,
- int ref
- ){}
-
- public void glBindTexture(
- int target,
- int texture
- ){}
-
- public void glBlendFunc(
- int sfactor,
- int dfactor
- ){}
-
- public void glClear(
- int mask
- ){}
-
- public void glClearColor(
- float red,
- float green,
- float blue,
- float alpha
- ){}
-
- public void glClearColorx(
- int red,
- int green,
- int blue,
- int alpha
- ){}
-
- public void glClearDepthf(
- float depth
- ){}
-
- public void glClearDepthx(
- int depth
- ){}
-
- public void glClearStencil(
- int s
- ){}
-
- public void glClientActiveTexture(
- int texture
- ){}
-
- public void glColor4f(
- float red,
- float green,
- float blue,
- float alpha
- ){}
-
- public void glColor4x(
- int red,
- int green,
- int blue,
- int alpha
- ){}
-
- public void glColorMask(
- boolean red,
- boolean green,
- boolean blue,
- boolean alpha
- ){}
-
- public void glColorPointer(
- int size,
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glCompressedTexImage2D(
- int target,
- int level,
- int internalformat,
- int width,
- int height,
- int border,
- int imageSize,
- java.nio.Buffer data
- ){}
-
- public void glCompressedTexSubImage2D(
- int target,
- int level,
- int xoffset,
- int yoffset,
- int width,
- int height,
- int format,
- int imageSize,
- java.nio.Buffer data
- ){}
-
- public void glCopyTexImage2D(
- int target,
- int level,
- int internalformat,
- int x,
- int y,
- int width,
- int height,
- int border
- ){}
-
- public void glCopyTexSubImage2D(
- int target,
- int level,
- int xoffset,
- int yoffset,
- int x,
- int y,
- int width,
- int height
- ){}
-
- public void glCullFace(
- int mode
- ){}
-
- public void glDeleteTextures(
- int n,
- int[] textures,
- int offset
- ){}
-
- public void glDeleteTextures(
- int n,
- java.nio.IntBuffer textures
- ){}
-
- public void glDepthFunc(
- int func
- ){}
-
- public void glDepthMask(
- boolean flag
- ){}
-
- public void glDepthRangef(
- float zNear,
- float zFar
- ){}
-
- public void glDepthRangex(
- int zNear,
- int zFar
- ){}
-
- public void glDisable(
- int cap
- ){}
-
- public void glDisableClientState(
- int array
- ){}
-
- public void glDrawArrays(
- int mode,
- int first,
- int count
- ){}
-
- public void glDrawElements(
- int mode,
- int count,
- int type,
- java.nio.Buffer indices
- ){}
-
- public void glEnable(
- int cap
- ){}
-
- public void glEnableClientState(
- int array
- ){}
-
- public void glFinish(
- ){}
-
- public void glFlush(
- ){}
-
- public void glFogf(
- int pname,
- float param
- ){}
-
- public void glFogfv(
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glFogfv(
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glFogx(
- int pname,
- int param
- ){}
-
- public void glFogxv(
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glFogxv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glFrontFace(
- int mode
- ){}
-
- public void glFrustumf(
- float left,
- float right,
- float bottom,
- float top,
- float zNear,
- float zFar
- ){}
-
- public void glFrustumx(
- int left,
- int right,
- int bottom,
- int top,
- int zNear,
- int zFar
- ){}
-
- public void glGenTextures(
- int n,
- int[] textures,
- int offset
- ){}
-
- public void glGenTextures(
- int n,
- java.nio.IntBuffer textures
- ){}
-
- public int glGetError(
- ){ throw new UnsupportedOperationException(); }
-
- public void glGetIntegerv(
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetIntegerv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public String glGetString(
- int name
- ){ throw new UnsupportedOperationException(); }
-
- public void glHint(
- int target,
- int mode
- ){}
-
- public void glLightModelf(
- int pname,
- float param
- ){}
-
- public void glLightModelfv(
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glLightModelfv(
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glLightModelx(
- int pname,
- int param
- ){}
-
- public void glLightModelxv(
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glLightModelxv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glLightf(
- int light,
- int pname,
- float param
- ){}
-
- public void glLightfv(
- int light,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glLightfv(
- int light,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glLightx(
- int light,
- int pname,
- int param
- ){}
-
- public void glLightxv(
- int light,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glLightxv(
- int light,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glLineWidth(
- float width
- ){}
-
- public void glLineWidthx(
- int width
- ){}
-
- public void glLoadIdentity(
- ){}
-
- public void glLoadMatrixf(
- float[] m,
- int offset
- ){}
-
- public void glLoadMatrixf(
- java.nio.FloatBuffer m
- ){}
-
- public void glLoadMatrixx(
- int[] m,
- int offset
- ){}
-
- public void glLoadMatrixx(
- java.nio.IntBuffer m
- ){}
-
- public void glLogicOp(
- int opcode
- ){}
-
- public void glMaterialf(
- int face,
- int pname,
- float param
- ){}
-
- public void glMaterialfv(
- int face,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glMaterialfv(
- int face,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glMaterialx(
- int face,
- int pname,
- int param
- ){}
-
- public void glMaterialxv(
- int face,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glMaterialxv(
- int face,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glMatrixMode(
- int mode
- ){}
-
- public void glMultMatrixf(
- float[] m,
- int offset
- ){}
-
- public void glMultMatrixf(
- java.nio.FloatBuffer m
- ){}
-
- public void glMultMatrixx(
- int[] m,
- int offset
- ){}
-
- public void glMultMatrixx(
- java.nio.IntBuffer m
- ){}
-
- public void glMultiTexCoord4f(
- int target,
- float s,
- float t,
- float r,
- float q
- ){}
-
- public void glMultiTexCoord4x(
- int target,
- int s,
- int t,
- int r,
- int q
- ){}
-
- public void glNormal3f(
- float nx,
- float ny,
- float nz
- ){}
-
- public void glNormal3x(
- int nx,
- int ny,
- int nz
- ){}
-
- public void glNormalPointer(
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glOrthof(
- float left,
- float right,
- float bottom,
- float top,
- float zNear,
- float zFar
- ){}
-
- public void glOrthox(
- int left,
- int right,
- int bottom,
- int top,
- int zNear,
- int zFar
- ){}
-
- public void glPixelStorei(
- int pname,
- int param
- ){}
-
- public void glPointSize(
- float size
- ){}
-
- public void glPointSizex(
- int size
- ){}
-
- public void glPolygonOffset(
- float factor,
- float units
- ){}
-
- public void glPolygonOffsetx(
- int factor,
- int units
- ){}
-
- public void glPopMatrix(
- ){}
-
- public void glPushMatrix(
- ){}
-
- public void glReadPixels(
- int x,
- int y,
- int width,
- int height,
- int format,
- int type,
- java.nio.Buffer pixels
- ){}
-
- public void glRotatef(
- float angle,
- float x,
- float y,
- float z
- ){}
-
- public void glRotatex(
- int angle,
- int x,
- int y,
- int z
- ){}
-
- public void glSampleCoverage(
- float value,
- boolean invert
- ){}
-
- public void glSampleCoveragex(
- int value,
- boolean invert
- ){}
-
- public void glScalef(
- float x,
- float y,
- float z
- ){}
-
- public void glScalex(
- int x,
- int y,
- int z
- ){}
-
- public void glScissor(
- int x,
- int y,
- int width,
- int height
- ){}
-
- public void glShadeModel(
- int mode
- ){}
-
- public void glStencilFunc(
- int func,
- int ref,
- int mask
- ){}
-
- public void glStencilMask(
- int mask
- ){}
-
- public void glStencilOp(
- int fail,
- int zfail,
- int zpass
- ){}
-
- public void glTexCoordPointer(
- int size,
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glTexEnvf(
- int target,
- int pname,
- float param
- ){}
-
- public void glTexEnvfv(
- int target,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glTexEnvfv(
- int target,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glTexEnvx(
- int target,
- int pname,
- int param
- ){}
-
- public void glTexEnvxv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexEnvxv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glTexImage2D(
- int target,
- int level,
- int internalformat,
- int width,
- int height,
- int border,
- int format,
- int type,
- java.nio.Buffer pixels
- ){}
-
- public void glTexParameterf(
- int target,
- int pname,
- float param
- ){}
-
- public void glTexParameterx(
- int target,
- int pname,
- int param
- ){}
-
- public void glTexSubImage2D(
- int target,
- int level,
- int xoffset,
- int yoffset,
- int width,
- int height,
- int format,
- int type,
- java.nio.Buffer pixels
- ){}
-
- public void glTranslatef(
- float x,
- float y,
- float z
- ){}
-
- public void glTranslatex(
- int x,
- int y,
- int z
- ){}
-
- public void glVertexPointer(
- int size,
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glViewport(
- int x,
- int y,
- int width,
- int height
- ){}
-
- public int glQueryMatrixxOES(
- int[] mantissa,
- int mantissaOffset,
- int[] exponent,
- int exponentOffset
- ){ throw new UnsupportedOperationException(); }
-
- public int glQueryMatrixxOES(
- java.nio.IntBuffer mantissa,
- java.nio.IntBuffer exponent
- ){ throw new UnsupportedOperationException(); }
-
- public void glGetPointerv(int pname, java.nio.Buffer[] params){}
- public void glBindBuffer(
- int target,
- int buffer
- ){}
-
- public void glBufferData(
- int target,
- int size,
- java.nio.Buffer data,
- int usage
- ){}
-
- public void glBufferSubData(
- int target,
- int offset,
- int size,
- java.nio.Buffer data
- ){}
-
- public void glClipPlanef(
- int plane,
- float[] equation,
- int offset
- ){}
-
- public void glClipPlanef(
- int plane,
- java.nio.FloatBuffer equation
- ){}
-
- public void glClipPlanex(
- int plane,
- int[] equation,
- int offset
- ){}
-
- public void glClipPlanex(
- int plane,
- java.nio.IntBuffer equation
- ){}
-
- public void glColor4ub(
- byte red,
- byte green,
- byte blue,
- byte alpha
- ){}
-
- public void glColorPointer(
- int size,
- int type,
- int stride,
- int offset
- ){}
-
- public void glDeleteBuffers(
- int n,
- int[] buffers,
- int offset
- ){}
-
- public void glDeleteBuffers(
- int n,
- java.nio.IntBuffer buffers
- ){}
-
- public void glDrawElements(
- int mode,
- int count,
- int type,
- int offset
- ){}
-
- public void glGenBuffers(
- int n,
- int[] buffers,
- int offset
- ){}
-
- public void glGenBuffers(
- int n,
- java.nio.IntBuffer buffers
- ){}
-
- public void glGetBooleanv(
- int pname,
- boolean[] params,
- int offset
- ){}
-
- public void glGetBooleanv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetBufferParameteriv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetBufferParameteriv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetClipPlanef(
- int pname,
- float[] eqn,
- int offset
- ){}
-
- public void glGetClipPlanef(
- int pname,
- java.nio.FloatBuffer eqn
- ){}
-
- public void glGetClipPlanex(
- int pname,
- int[] eqn,
- int offset
- ){}
-
- public void glGetClipPlanex(
- int pname,
- java.nio.IntBuffer eqn
- ){}
-
- public void glGetFixedv(
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetFixedv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetFloatv(
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glGetFloatv(
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glGetLightfv(
- int light,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glGetLightfv(
- int light,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glGetLightxv(
- int light,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetLightxv(
- int light,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetMaterialfv(
- int face,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glGetMaterialfv(
- int face,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glGetMaterialxv(
- int face,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetMaterialxv(
- int face,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexEnviv(
- int env,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexEnviv(
- int env,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexEnvxv(
- int env,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexEnvxv(
- int env,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexParameterfv(
- int target,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glGetTexParameterfv(
- int target,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glGetTexParameteriv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexParameteriv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexParameterxv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexParameterxv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public boolean glIsBuffer(
- int buffer
- ){ throw new UnsupportedOperationException(); }
-
- public boolean glIsEnabled(
- int cap
- ){ throw new UnsupportedOperationException(); }
-
- public boolean glIsTexture(
- int texture
- ){ throw new UnsupportedOperationException(); }
-
- public void glNormalPointer(
- int type,
- int stride,
- int offset
- ){}
-
- public void glPointParameterf(
- int pname,
- float param
- ){}
-
- public void glPointParameterfv(
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glPointParameterfv(
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glPointParameterx(
- int pname,
- int param
- ){}
-
- public void glPointParameterxv(
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glPointParameterxv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glPointSizePointerOES(
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glTexCoordPointer(
- int size,
- int type,
- int stride,
- int offset
- ){}
-
- public void glTexEnvi(
- int target,
- int pname,
- int param
- ){}
-
- public void glTexEnviv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexEnviv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glTexParameterfv(
- int target,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glTexParameterfv(
- int target,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glTexParameteri(
- int target,
- int pname,
- int param
- ){}
-
- public void glTexParameteriv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexParameteriv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glTexParameterxv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexParameterxv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glVertexPointer(
- int size,
- int type,
- int stride,
- int offset
- ){}
-
- public void glCurrentPaletteMatrixOES(
- int matrixpaletteindex
- ){}
-
- public void glDrawTexfOES(
- float x,
- float y,
- float z,
- float width,
- float height
- ){}
-
- public void glDrawTexfvOES(
- float[] coords,
- int offset
- ){}
-
- public void glDrawTexfvOES(
- java.nio.FloatBuffer coords
- ){}
-
- public void glDrawTexiOES(
- int x,
- int y,
- int z,
- int width,
- int height
- ){}
-
- public void glDrawTexivOES(
- int[] coords,
- int offset
- ){}
-
- public void glDrawTexivOES(
- java.nio.IntBuffer coords
- ){}
-
- public void glDrawTexsOES(
- short x,
- short y,
- short z,
- short width,
- short height
- ){}
-
- public void glDrawTexsvOES(
- short[] coords,
- int offset
- ){}
-
- public void glDrawTexsvOES(
- java.nio.ShortBuffer coords
- ){}
-
- public void glDrawTexxOES(
- int x,
- int y,
- int z,
- int width,
- int height
- ){}
-
- public void glDrawTexxvOES(
- int[] coords,
- int offset
- ){}
-
- public void glDrawTexxvOES(
- java.nio.IntBuffer coords
- ){}
-
- public void glLoadPaletteFromModelViewMatrixOES(
- ){}
-
- public void glMatrixIndexPointerOES(
- int size,
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glMatrixIndexPointerOES(
- int size,
- int type,
- int stride,
- int offset
- ){}
-
- public void glWeightPointerOES(
- int size,
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glWeightPointerOES(
- int size,
- int type,
- int stride,
- int offset
- ){}
-
- public void glBindFramebufferOES(
- int target,
- int framebuffer
- ){}
-
- public void glBindRenderbufferOES(
- int target,
- int renderbuffer
- ){}
-
- public void glBlendEquation(
- int mode
- ){}
-
- public void glBlendEquationSeparate(
- int modeRGB,
- int modeAlpha
- ){}
-
- public void glBlendFuncSeparate(
- int srcRGB,
- int dstRGB,
- int srcAlpha,
- int dstAlpha
- ){}
-
- public int glCheckFramebufferStatusOES(
- int target
- ){ throw new UnsupportedOperationException(); }
-
- public void glDeleteFramebuffersOES(
- int n,
- int[] framebuffers,
- int offset
- ){}
-
- public void glDeleteFramebuffersOES(
- int n,
- java.nio.IntBuffer framebuffers
- ){}
-
- public void glDeleteRenderbuffersOES(
- int n,
- int[] renderbuffers,
- int offset
- ){}
-
- public void glDeleteRenderbuffersOES(
- int n,
- java.nio.IntBuffer renderbuffers
- ){}
-
- public void glFramebufferRenderbufferOES(
- int target,
- int attachment,
- int renderbuffertarget,
- int renderbuffer
- ){}
-
- public void glFramebufferTexture2DOES(
- int target,
- int attachment,
- int textarget,
- int texture,
- int level
- ){}
-
- public void glGenerateMipmapOES(
- int target
- ){}
-
- public void glGenFramebuffersOES(
- int n,
- int[] framebuffers,
- int offset
- ){}
-
- public void glGenFramebuffersOES(
- int n,
- java.nio.IntBuffer framebuffers
- ){}
-
- public void glGenRenderbuffersOES(
- int n,
- int[] renderbuffers,
- int offset
- ){}
-
- public void glGenRenderbuffersOES(
- int n,
- java.nio.IntBuffer renderbuffers
- ){}
-
- public void glGetFramebufferAttachmentParameterivOES(
- int target,
- int attachment,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetFramebufferAttachmentParameterivOES(
- int target,
- int attachment,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetRenderbufferParameterivOES(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetRenderbufferParameterivOES(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexGenfv(
- int coord,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glGetTexGenfv(
- int coord,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glGetTexGeniv(
- int coord,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexGeniv(
- int coord,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexGenxv(
- int coord,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexGenxv(
- int coord,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public boolean glIsFramebufferOES(
- int framebuffer
- ){ throw new UnsupportedOperationException(); }
-
- public boolean glIsRenderbufferOES(
- int renderbuffer
- ){ throw new UnsupportedOperationException(); }
-
- public void glRenderbufferStorageOES(
- int target,
- int internalformat,
- int width,
- int height
- ){}
-
- public void glTexGenf(
- int coord,
- int pname,
- float param
- ){}
-
- public void glTexGenfv(
- int coord,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glTexGenfv(
- int coord,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glTexGeni(
- int coord,
- int pname,
- int param
- ){}
-
- public void glTexGeniv(
- int coord,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexGeniv(
- int coord,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glTexGenx(
- int coord,
- int pname,
- int param
- ){}
-
- public void glTexGenxv(
- int coord,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexGenxv(
- int coord,
- int pname,
- java.nio.IntBuffer params
- ){}
-}
diff --git a/new3d/tests/src/com/android/gallery3d/ui/GLViewMock.java b/new3d/tests/src/com/android/gallery3d/ui/GLViewMock.java
deleted file mode 100644
index 0ba5e63..0000000
--- a/new3d/tests/src/com/android/gallery3d/ui/GLViewMock.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.android.gallery3d.ui;
-
-class GLViewMock extends GLView {
- // onAttachToRoot
- int mOnAttachCalled;
- GLRoot mRoot;
- // onDetachFromRoot
- int mOnDetachCalled;
- // onVisibilityChanged
- int mOnVisibilityChangedCalled;
- // onLayout
- int mOnLayoutCalled;
- boolean mOnLayoutChangeSize;
- // renderBackground
- int mRenderBackgroundCalled;
- // onMeasure
- int mOnMeasureCalled;
- int mOnMeasureWidthSpec;
- int mOnMeasureHeightSpec;
-
- @Override
- public void onAttachToRoot(GLRoot root) {
- mRoot = root;
- mOnAttachCalled++;
- super.onAttachToRoot(root);
- }
-
- @Override
- public void onDetachFromRoot() {
- mRoot = null;
- mOnDetachCalled++;
- super.onDetachFromRoot();
- }
-
- @Override
- protected void onVisibilityChanged(int visibility) {
- mOnVisibilityChangedCalled++;
- }
-
- @Override
- protected void onLayout(boolean changeSize, int left, int top,
- int right, int bottom) {
- mOnLayoutCalled++;
- mOnLayoutChangeSize = changeSize;
- // call children's layout.
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- GLView item = getComponent(i);
- item.layout(left, top, right, bottom);
- }
- }
-
- @Override
- protected void onMeasure(int widthSpec, int heightSpec) {
- mOnMeasureCalled++;
- mOnMeasureWidthSpec = widthSpec;
- mOnMeasureHeightSpec = heightSpec;
- // call children's measure.
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- GLView item = getComponent(i);
- item.measure(widthSpec, heightSpec);
- }
- setMeasuredSize(widthSpec, heightSpec);
- }
-
- @Override
- protected void renderBackground(GLCanvas view) {
- mRenderBackgroundCalled++;
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/ui/GLViewTest.java b/new3d/tests/src/com/android/gallery3d/ui/GLViewTest.java
deleted file mode 100644
index c6b1ed6..0000000
--- a/new3d/tests/src/com/android/gallery3d/ui/GLViewTest.java
+++ /dev/null
@@ -1,410 +0,0 @@
-package com.android.gallery3d.ui;
-
-import android.graphics.Rect;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.view.MotionEvent;
-import android.util.Log;
-
-import junit.framework.TestCase;
-
-import javax.microedition.khronos.opengles.GL11;
-
-@SmallTest
-public class GLViewTest extends TestCase {
- private static final String TAG = "GLViewTest";
-
- @SmallTest
- public void testVisibility() {
- GLViewMock a = new GLViewMock();
- assertEquals(GLView.VISIBLE, a.getVisibility());
- assertEquals(0, a.mOnVisibilityChangedCalled);
- a.setVisibility(GLView.INVISIBLE);
- assertEquals(GLView.INVISIBLE, a.getVisibility());
- assertEquals(1, a.mOnVisibilityChangedCalled);
- a.setVisibility(GLView.VISIBLE);
- assertEquals(GLView.VISIBLE, a.getVisibility());
- assertEquals(2, a.mOnVisibilityChangedCalled);
- }
-
- @SmallTest
- public void testComponents() {
- GLView view = new GLView();
- assertEquals(0, view.getComponentCount());
- try {
- view.getComponent(0);
- fail();
- } catch (IndexOutOfBoundsException ex) {
- // expected
- }
-
- GLView x = new GLView();
- GLView y = new GLView();
- view.addComponent(x);
- view.addComponent(y);
- assertEquals(2, view.getComponentCount());
- assertSame(x, view.getComponent(0));
- assertSame(y, view.getComponent(1));
- view.removeComponent(x);
- assertSame(y, view.getComponent(0));
- try {
- view.getComponent(1);
- fail();
- } catch (IndexOutOfBoundsException ex) {
- // expected
- }
- try {
- view.addComponent(y);
- fail();
- } catch (IllegalStateException ex) {
- // expected
- }
- view.addComponent(x);
- view.removeAllComponents();
- assertEquals(0, view.getComponentCount());
- }
-
- @SmallTest
- public void testBounds() {
- GLView view = new GLView();
-
- assertEquals(0, view.getWidth());
- assertEquals(0, view.getHeight());
-
- Rect b = view.bounds();
- assertEquals(0, b.left);
- assertEquals(0, b.top);
- assertEquals(0, b.right);
- assertEquals(0, b.bottom);
-
- view.layout(10, 20, 30, 100);
- assertEquals(20, view.getWidth());
- assertEquals(80, view.getHeight());
-
- b = view.bounds();
- assertEquals(10, b.left);
- assertEquals(20, b.top);
- assertEquals(30, b.right);
- assertEquals(100, b.bottom);
- }
-
- @SmallTest
- public void testPaddings() {
- GLView view = new GLView();
-
- Rect p = view.getPaddings();
- assertEquals(0, p.left);
- assertEquals(0, p.top);
- assertEquals(0, p.right);
- assertEquals(0, p.bottom);
-
- view.setPaddings(10, 20, 30, 100);
- p = view.getPaddings();
- assertEquals(10, p.left);
- assertEquals(20, p.top);
- assertEquals(30, p.right);
- assertEquals(100, p.bottom);
-
- p = new Rect(11, 22, 33, 104);
- view.setPaddings(p);
- p = view.getPaddings();
- assertEquals(11, p.left);
- assertEquals(22, p.top);
- assertEquals(33, p.right);
- assertEquals(104, p.bottom);
- }
-
- @SmallTest
- public void testParent() {
- GLView a = new GLView();
- GLView b = new GLView();
- assertNull(b.mParent);
- a.addComponent(b);
- assertSame(a, b.mParent);
- a.removeComponent(b);
- assertNull(b.mParent);
- }
-
- @SmallTest
- public void testRoot() {
- GLViewMock a = new GLViewMock();
- GLViewMock b = new GLViewMock();
- GLRoot r = new GLRootStub();
- GLRoot r2 = new GLRootStub();
- a.addComponent(b);
-
- // Attach to root r
- assertEquals(0, a.mOnAttachCalled);
- assertEquals(0, b.mOnAttachCalled);
- a.attachToRoot(r);
- assertEquals(1, a.mOnAttachCalled);
- assertEquals(1, b.mOnAttachCalled);
- assertSame(r, a.getGLRoot());
- assertSame(r, b.getGLRoot());
-
- // Detach from r
- assertEquals(0, a.mOnDetachCalled);
- assertEquals(0, b.mOnDetachCalled);
- a.detachFromRoot();
- assertEquals(1, a.mOnDetachCalled);
- assertEquals(1, b.mOnDetachCalled);
-
- // Attach to another root r2
- assertEquals(1, a.mOnAttachCalled);
- assertEquals(1, b.mOnAttachCalled);
- a.attachToRoot(r2);
- assertEquals(2, a.mOnAttachCalled);
- assertEquals(2, b.mOnAttachCalled);
- assertSame(r2, a.getGLRoot());
- assertSame(r2, b.getGLRoot());
-
- // Detach from r2
- assertEquals(1, a.mOnDetachCalled);
- assertEquals(1, b.mOnDetachCalled);
- a.detachFromRoot();
- assertEquals(2, a.mOnDetachCalled);
- assertEquals(2, b.mOnDetachCalled);
- }
-
- @SmallTest
- public void testRoot2() {
- GLView a = new GLViewMock();
- GLViewMock b = new GLViewMock();
- GLRoot r = new GLRootStub();
-
- a.attachToRoot(r);
-
- assertEquals(0, b.mOnAttachCalled);
- a.addComponent(b);
- assertEquals(1, b.mOnAttachCalled);
-
- assertEquals(0, b.mOnDetachCalled);
- a.removeComponent(b);
- assertEquals(1, b.mOnDetachCalled);
- }
-
- @SmallTest
- public void testInvalidate() {
- GLView a = new GLView();
- GLRootMock r = new GLRootMock();
- a.attachToRoot(r);
- assertEquals(0, r.mRequestRenderCalled);
- a.invalidate();
- assertEquals(1, r.mRequestRenderCalled);
- }
-
- @SmallTest
- public void testRequestLayout() {
- GLView a = new GLView();
- GLView b = new GLView();
- GLRootMock r = new GLRootMock();
- a.attachToRoot(r);
- a.addComponent(b);
- assertEquals(0, r.mRequestLayoutContentPaneCalled);
- b.requestLayout();
- assertEquals(1, r.mRequestLayoutContentPaneCalled);
- }
-
- @SmallTest
- public void testLayout() {
- GLViewMock a = new GLViewMock();
- GLViewMock b = new GLViewMock();
- GLViewMock c = new GLViewMock();
- GLRootMock r = new GLRootMock();
-
- a.attachToRoot(r);
- a.addComponent(b);
- a.addComponent(c);
-
- assertEquals(0, a.mOnLayoutCalled);
- a.layout(10, 20, 60, 100);
- assertEquals(1, a.mOnLayoutCalled);
- assertEquals(1, b.mOnLayoutCalled);
- assertEquals(1, c.mOnLayoutCalled);
- assertTrue(a.mOnLayoutChangeSize);
- assertTrue(b.mOnLayoutChangeSize);
- assertTrue(c.mOnLayoutChangeSize);
-
- // same size should not trigger onLayout
- a.layout(10, 20, 60, 100);
- assertEquals(1, a.mOnLayoutCalled);
-
- // unless someone requested it, but only those on the path
- // to the requester.
- assertEquals(0, r.mRequestLayoutContentPaneCalled);
- b.requestLayout();
- a.layout(10, 20, 60, 100);
- assertEquals(1, r.mRequestLayoutContentPaneCalled);
- assertEquals(2, a.mOnLayoutCalled);
- assertEquals(2, b.mOnLayoutCalled);
- assertEquals(1, c.mOnLayoutCalled);
- }
-
- @SmallTest
- public void testRender() {
- GLViewMock a = new GLViewMock();
- GLViewMock b = new GLViewMock();
-
- a.addComponent(b);
- GLCanvasStub canvas = new GLCanvasStub();
- assertEquals(0, a.mRenderBackgroundCalled);
- assertEquals(0, b.mRenderBackgroundCalled);
- a.render(canvas);
- assertEquals(1, a.mRenderBackgroundCalled);
- assertEquals(1, b.mRenderBackgroundCalled);
- }
-
- @SmallTest
- public void testMeasure() {
- GLViewMock a = new GLViewMock();
- GLViewMock b = new GLViewMock();
- GLViewMock c = new GLViewMock();
- GLRootMock r = new GLRootMock();
-
- a.addComponent(b);
- a.addComponent(c);
- a.attachToRoot(r);
-
- assertEquals(0, a.mOnMeasureCalled);
- a.measure(100, 200);
- assertEquals(1, a.mOnMeasureCalled);
- assertEquals(1, b.mOnMeasureCalled);
- assertEquals(100, a.mOnMeasureWidthSpec);
- assertEquals(200, a.mOnMeasureHeightSpec);
- assertEquals(100, b.mOnMeasureWidthSpec);
- assertEquals(200, b.mOnMeasureHeightSpec);
- assertEquals(100, a.getMeasuredWidth());
- assertEquals(200, b.getMeasuredHeight());
-
- // same spec should not trigger onMeasure
- a.measure(100, 200);
- assertEquals(1, a.mOnMeasureCalled);
-
- // unless someone requested it, but only those on the path
- // to the requester.
- b.requestLayout();
- a.measure(100, 200);
- assertEquals(2, a.mOnMeasureCalled);
- assertEquals(2, b.mOnMeasureCalled);
- assertEquals(1, c.mOnMeasureCalled);
- }
-
- class MyGLView extends GLView {
- private int mWidth;
- int mOnTouchCalled;
- int mOnTouchX;
- int mOnTouchY;
- int mOnTouchAction;
-
- public MyGLView(int width) {
- mWidth = width;
- }
-
- @Override
- protected void onLayout(boolean changeSize, int left, int top,
- int right, int bottom) {
- // layout children from left to right
- // call children's layout.
- int x = 0;
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- GLView item = getComponent(i);
- item.measure(0, 0);
- int w = item.getMeasuredWidth();
- int h = item.getMeasuredHeight();
- item.layout(x, 0, x + w, h);
- x += w;
- }
- }
-
- @Override
- protected void onMeasure(int widthSpec, int heightSpec) {
- setMeasuredSize(mWidth, 100);
- }
-
- @Override
- protected boolean onTouch(MotionEvent event) {
- mOnTouchCalled++;
- mOnTouchX = (int) event.getX();
- mOnTouchY = (int) event.getY();
- mOnTouchAction = event.getAction();
- return true;
- }
- }
-
- private MotionEvent NewMotionEvent(int action, int x, int y) {
- return MotionEvent.obtain(0, 0, action, x, y, 0);
- }
-
- @SmallTest
- public void testTouchEvent() {
- // We construct a tree with four nodes. Only the x coordinate is used:
- // A = [0..............................300)
- // B = [0......100)
- // C = [100......200)
- // D = [100..150)
-
- MyGLView a = new MyGLView(300);
- MyGLView b = new MyGLView(100);
- MyGLView c = new MyGLView(100);
- MyGLView d = new MyGLView(50);
- GLRoot r = new GLRootStub();
-
- a.addComponent(b);
- a.addComponent(c);
- c.addComponent(d);
- a.attachToRoot(r);
- a.layout(0, 0, 300, 100);
-
- int DOWN = MotionEvent.ACTION_DOWN;
- int UP = MotionEvent.ACTION_UP;
- int MOVE = MotionEvent.ACTION_MOVE;
- int CANCEL = MotionEvent.ACTION_CANCEL;
-
- // simple case
- assertEquals(0, a.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 250, 0));
- assertEquals(DOWN, a.mOnTouchAction);
- a.dispatchTouchEvent(NewMotionEvent(UP, 250, 0));
- assertEquals(UP, a.mOnTouchAction);
- assertEquals(2, a.mOnTouchCalled);
-
- // pass to a child, check the location is offseted.
- assertEquals(0, c.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 175, 0));
- a.dispatchTouchEvent(NewMotionEvent(UP, 175, 0));
- assertEquals(75, c.mOnTouchX);
- assertEquals(0, c.mOnTouchY);
- assertEquals(2, c.mOnTouchCalled);
- assertEquals(2, a.mOnTouchCalled);
-
- // motion target cancel event
- assertEquals(0, d.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 125, 0));
- assertEquals(1, d.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(MOVE, 250, 0));
- assertEquals(2, d.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(MOVE, 50, 0));
- assertEquals(3, d.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 175, 0));
- assertEquals(4, d.mOnTouchCalled);
- assertEquals(CANCEL, d.mOnTouchAction);
- assertEquals(3, c.mOnTouchCalled);
- assertEquals(DOWN, c.mOnTouchAction);
- a.dispatchTouchEvent(NewMotionEvent(UP, 175, 0));
-
- // motion target is removed
- assertEquals(4, d.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 125, 0));
- assertEquals(5, d.mOnTouchCalled);
- a.removeComponent(c);
- assertEquals(6, d.mOnTouchCalled);
- assertEquals(CANCEL, d.mOnTouchAction);
-
- // invisible component should not get events
- assertEquals(2, a.mOnTouchCalled);
- assertEquals(0, b.mOnTouchCalled);
- b.setVisibility(GLView.INVISIBLE);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 50, 0));
- assertEquals(3, a.mOnTouchCalled);
- assertEquals(0, b.mOnTouchCalled);
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/ui/PointerInfo.java b/new3d/tests/src/com/android/gallery3d/ui/PointerInfo.java
deleted file mode 100644
index 7d004be..0000000
--- a/new3d/tests/src/com/android/gallery3d/ui/PointerInfo.java
+++ /dev/null
@@ -1,206 +0,0 @@
-package com.android.gallery3d.ui;
-
-import java.nio.Buffer;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.CharBuffer;
-import java.nio.DoubleBuffer;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.LongBuffer;
-import java.nio.ShortBuffer;
-
-import javax.microedition.khronos.opengles.GL10;
-
-public class PointerInfo {
-
- /**
- * The number of coordinates per vertex. 1..4
- */
- public int mSize;
-
- /**
- * The type of each coordinate.
- */
- public int mType;
-
- /**
- * The byte offset between consecutive vertices. 0 means mSize *
- * sizeof(mType)
- */
- public int mStride;
- public Buffer mPointer;
- public ByteBuffer mTempByteBuffer;
-
- public PointerInfo(int size, int type, int stride, Buffer pointer) {
- mSize = size;
- mType = type;
- mStride = stride;
- mPointer = pointer;
- }
-
- private int getStride() {
- return mStride > 0 ? mStride : sizeof(mType) * mSize;
- }
-
- public void bindByteBuffer() {
- mTempByteBuffer = mPointer == null ? null : toByteBuffer(-1, mPointer);
- }
-
- public void unbindByteBuffer() {
- mTempByteBuffer = null;
- }
-
- private static int sizeof(int type) {
- switch (type) {
- case GL10.GL_UNSIGNED_BYTE:
- return 1;
- case GL10.GL_BYTE:
- return 1;
- case GL10.GL_SHORT:
- return 2;
- case GL10.GL_FIXED:
- return 4;
- case GL10.GL_FLOAT:
- return 4;
- default:
- return 0;
- }
- }
-
- private static ByteBuffer toByteBuffer(int byteCount, Buffer input) {
- ByteBuffer result = null;
- boolean convertWholeBuffer = (byteCount < 0);
- if (input instanceof ByteBuffer) {
- ByteBuffer input2 = (ByteBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = input2.limit() - position;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- for (int i = 0; i < byteCount; i++) {
- result.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof CharBuffer) {
- CharBuffer input2 = (CharBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position) * 2;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- CharBuffer result2 = result.asCharBuffer();
- for (int i = 0; i < byteCount / 2; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof ShortBuffer) {
- ShortBuffer input2 = (ShortBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position)* 2;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- ShortBuffer result2 = result.asShortBuffer();
- for (int i = 0; i < byteCount / 2; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof IntBuffer) {
- IntBuffer input2 = (IntBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position) * 4;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- IntBuffer result2 = result.asIntBuffer();
- for (int i = 0; i < byteCount / 4; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof FloatBuffer) {
- FloatBuffer input2 = (FloatBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position) * 4;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- FloatBuffer result2 = result.asFloatBuffer();
- for (int i = 0; i < byteCount / 4; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof DoubleBuffer) {
- DoubleBuffer input2 = (DoubleBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position) * 8;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- DoubleBuffer result2 = result.asDoubleBuffer();
- for (int i = 0; i < byteCount / 8; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof LongBuffer) {
- LongBuffer input2 = (LongBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position) * 8;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- LongBuffer result2 = result.asLongBuffer();
- for (int i = 0; i < byteCount / 8; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else {
- throw new RuntimeException("Unimplemented Buffer subclass.");
- }
- result.rewind();
- // The OpenGL API will interpret the result in hardware byte order,
- // so we better do that as well:
- result.order(ByteOrder.nativeOrder());
- return result;
- }
-
- public void getArrayElement(int index, double[] result) {
- if (mTempByteBuffer == null) {
- throw new IllegalArgumentException("undefined pointer");
- }
- if (mStride < 0) {
- throw new IllegalArgumentException("invalid stride");
- }
-
- int stride = getStride();
- ByteBuffer byteBuffer = mTempByteBuffer;
- int size = mSize;
- int type = mType;
- int sizeofType = sizeof(type);
- int byteOffset = stride * index;
-
- for (int i = 0; i < size; i++) {
- switch (type) {
- case GL10.GL_BYTE:
- case GL10.GL_UNSIGNED_BYTE:
- result[i] = byteBuffer.get(byteOffset);
- break;
- case GL10.GL_SHORT:
- ShortBuffer shortBuffer = byteBuffer.asShortBuffer();
- result[i] = shortBuffer.get(byteOffset / 2);
- break;
- case GL10.GL_FIXED:
- IntBuffer intBuffer = byteBuffer.asIntBuffer();
- result[i] = intBuffer.get(byteOffset / 4);
- break;
- case GL10.GL_FLOAT:
- FloatBuffer floatBuffer = byteBuffer.asFloatBuffer();
- result[i] = floatBuffer.get(byteOffset / 4);
- break;
- default:
- throw new UnsupportedOperationException("unknown type");
- }
- byteOffset += sizeofType;
- }
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/ui/TextureTest.java b/new3d/tests/src/com/android/gallery3d/ui/TextureTest.java
deleted file mode 100644
index bee401a..0000000
--- a/new3d/tests/src/com/android/gallery3d/ui/TextureTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-package com.android.gallery3d.ui;
-
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import junit.framework.TestCase;
-
-import javax.microedition.khronos.opengles.GL11;
-
-@SmallTest
-public class TextureTest extends TestCase {
- private static final String TAG = "TextureTest";
-
- class MyBasicTexture extends BasicTexture {
- int mOnBindCalled;
- int mOpaqueCalled;
-
- MyBasicTexture(GLCanvas canvas, int id) {
- super(canvas, id, BasicTexture.STATE_UNLOADED);
- }
-
- @Override
- protected boolean onBind(GLCanvas canvas) {
- mOnBindCalled++;
- return true;
- }
-
- public boolean isOpaque() {
- mOpaqueCalled++;
- return true;
- }
-
- void upload() {
- mState = STATE_LOADED;
- }
- }
-
- @SmallTest
- public void testBasicTexture() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImp(glStub);
- MyBasicTexture texture = new MyBasicTexture(canvas, 47);
-
- assertEquals(47, texture.getId());
- texture.setSize(1, 1);
- assertEquals(1, texture.getWidth());
- assertEquals(1, texture.getHeight());
- assertEquals(1, texture.getTextureWidth());
- assertEquals(1, texture.getTextureHeight());
- texture.setSize(3, 5);
- assertEquals(3, texture.getWidth());
- assertEquals(5, texture.getHeight());
- assertEquals(4, texture.getTextureWidth());
- assertEquals(8, texture.getTextureHeight());
-
- assertFalse(texture.isLoaded(canvas));
- texture.upload();
- assertTrue(texture.isLoaded(canvas));
-
- // For a different GL, it's not loaded.
- GLCanvas canvas2 = new GLCanvasImp(new GLStub());
- assertFalse(texture.isLoaded(canvas2));
-
- assertEquals(0, texture.mOnBindCalled);
- assertEquals(0, texture.mOpaqueCalled);
- texture.draw(canvas, 100, 200, 1, 1);
- assertEquals(1, texture.mOnBindCalled);
- assertEquals(1, texture.mOpaqueCalled);
- texture.draw(canvas, 0, 0);
- assertEquals(2, texture.mOnBindCalled);
- assertEquals(2, texture.mOpaqueCalled);
- }
-
- @SmallTest
- public void testRawTexture() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImp(glStub);
- RawTexture texture = RawTexture.newInstance(canvas);
- texture.onBind(canvas);
-
- GLCanvas canvas2 = new GLCanvasImp(new GLStub());
- try {
- texture.onBind(canvas2);
- fail();
- } catch (RuntimeException ex) {
- // expected.
- }
-
- assertTrue(texture.isOpaque());
- }
-
- @SmallTest
- public void testColorTexture() {
- GLCanvasMock canvas = new GLCanvasMock();
- ColorTexture texture = new ColorTexture(0x12345678);
-
- texture.setSize(42, 47);
- assertEquals(texture.getWidth(), 42);
- assertEquals(texture.getHeight(), 47);
- assertEquals(0, canvas.mFillRectCalled);
- texture.draw(canvas, 0, 0);
- assertEquals(1, canvas.mFillRectCalled);
- assertEquals(0x12345678, canvas.mFillRectColor);
- assertEquals(42f, canvas.mFillRectWidth);
- assertEquals(47f, canvas.mFillRectHeight);
- assertFalse(texture.isOpaque());
- assertTrue(new ColorTexture(0xFF000000).isOpaque());
- }
-
- private class MyUploadedTexture extends UploadedTexture {
- int mGetCalled;
- int mFreeCalled;
- Bitmap mBitmap;
- @Override
- protected Bitmap onGetBitmap() {
- mGetCalled++;
- Config config = Config.ARGB_8888;
- mBitmap = Bitmap.createBitmap(47, 42, config);
- return mBitmap;
- }
- @Override
- protected void onFreeBitmap(Bitmap bitmap) {
- mFreeCalled++;
- assertSame(mBitmap, bitmap);
- mBitmap.recycle();
- mBitmap = null;
- }
- }
-
- @SmallTest
- public void testUploadedTexture() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImp(glStub);
- MyUploadedTexture texture = new MyUploadedTexture();
-
- // draw it and the bitmap should be fetched.
- assertEquals(0, texture.mFreeCalled);
- assertEquals(0, texture.mGetCalled);
- texture.draw(canvas, 0, 0);
- assertEquals(1, texture.mGetCalled);
- assertTrue(texture.isLoaded(canvas));
- assertTrue(texture.isContentValid(canvas));
-
- // invalidate content and it should be freed.
- texture.invalidateContent();
- assertFalse(texture.isContentValid(canvas));
- assertEquals(1, texture.mFreeCalled);
- assertTrue(texture.isLoaded(canvas)); // But it's still loaded
-
- // draw it again and the bitmap should be fetched again.
- texture.draw(canvas, 0, 0);
- assertEquals(2, texture.mGetCalled);
- assertTrue(texture.isLoaded(canvas));
- assertTrue(texture.isContentValid(canvas));
-
- // recycle the texture and it should be freed again.
- texture.recycle();
- assertEquals(2, texture.mFreeCalled);
- // TODO: these two are broken and waiting for fix.
- //assertFalse(texture.isLoaded(canvas));
- //assertFalse(texture.isContentValid(canvas));
- }
-
- class MyTextureForMixed extends BasicTexture {
- MyTextureForMixed(GLCanvas canvas, int id) {
- super(canvas, id, BasicTexture.STATE_UNLOADED);
- }
-
- @Override
- protected boolean onBind(GLCanvas canvas) {
- return true;
- }
-
- public boolean isOpaque() {
- return true;
- }
- }
-
- @SmallTest
- public void testBitmapTexture() {
- Config config = Config.ARGB_8888;
- Bitmap bitmap = Bitmap.createBitmap(47, 42, config);
- assertFalse(bitmap.isRecycled());
- BitmapTexture texture = new BitmapTexture(bitmap);
- texture.recycle();
- assertFalse(bitmap.isRecycled());
- bitmap.recycle();
- assertTrue(bitmap.isRecycled());
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/util/IntArrayTest.java b/new3d/tests/src/com/android/gallery3d/util/IntArrayTest.java
deleted file mode 100644
index 83e6050..0000000
--- a/new3d/tests/src/com/android/gallery3d/util/IntArrayTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.util;
-
-import com.android.gallery3d.util.IntArray;
-
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-
-import java.util.Arrays;
-import junit.framework.TestCase;
-
-@SmallTest
-public class IntArrayTest extends TestCase {
- private static final String TAG = "IntArrayTest";
-
- public void testIntArray() {
- IntArray a = new IntArray();
- assertEquals(0, a.size());
- assertTrue(Arrays.equals(new int[] {}, a.toArray(null)));
-
- a.add(0);
- assertEquals(1, a.size());
- assertTrue(Arrays.equals(new int[] {0}, a.toArray(null)));
-
- a.add(1);
- assertEquals(2, a.size());
- assertTrue(Arrays.equals(new int[] {0, 1}, a.toArray(null)));
-
- int[] buf = new int[2];
- int[] result = a.toArray(buf);
- assertSame(buf, result);
-
- IntArray b = new IntArray();
- for (int i = 0; i < 100; i++) {
- b.add(i * i);
- }
-
- assertEquals(100, b.size());
- result = b.toArray(buf);
- assertEquals(100, result.length);
- for (int i = 0; i < 100; i++) {
- assertEquals(i * i, result[i]);
- }
- }
-}
diff --git a/new3d/tests/src/com/android/gallery3d/util/UtilsTest.java b/new3d/tests/src/com/android/gallery3d/util/UtilsTest.java
deleted file mode 100644
index 1a80d79..0000000
--- a/new3d/tests/src/com/android/gallery3d/util/UtilsTest.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.util;
-
-import android.graphics.BitmapFactory.Options;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-
-public class UtilsTest extends AndroidTestCase {
- private static final String TAG = "UtilsTest";
-
- private static final int [] testData = new int [] {
- /* outWidth, outHeight, minSideLength, maxNumOfPixels, sample size */
- 1, 1, Utils.UNCONSTRAINED, Utils.UNCONSTRAINED, 1,
- 1, 1, 1, 1, 1,
- 100, 100, 100, 10000, 1,
- 100, 100, 100, 2500, 2,
- 99, 66, 33, 10000, 2,
- 66, 99, 33, 10000, 2,
- 99, 66, 34, 10000, 1,
- 99, 66, 22, 10000, 4,
- 99, 66, 16, 10000, 4,
-
- 10000, 10000, 20000, 1000000, 16,
-
- 100, 100, 100, 10000, 1, // 1
- 100, 100, 50, 10000, 2, // 2
- 100, 100, 30, 10000, 4, // 3->4
- 100, 100, 22, 10000, 4, // 4
- 100, 100, 20, 10000, 8, // 5->8
- 100, 100, 11, 10000, 16, // 9->16
- 100, 100, 5, 10000, 24, // 20->24
- 100, 100, 2, 10000, 56, // 50->56
-
- 100, 100, 100, 10000 - 1, 2, // a bit less than 1
- 100, 100, 100, 10000 / (2 * 2) - 1, 4, // a bit less than 2
- 100, 100, 100, 10000 / (3 * 3) - 1, 4, // a bit less than 3
- 100, 100, 100, 10000 / (4 * 4) - 1, 8, // a bit less than 4
- 100, 100, 100, 10000 / (8 * 8) - 1, 16, // a bit less than 8
- 100, 100, 100, 10000 / (16 * 16) - 1, 24, // a bit less than 16
- 100, 100, 100, 10000 / (24 * 24) - 1, 32, // a bit less than 24
- 100, 100, 100, 10000 / (32 * 32) - 1, 40, // a bit less than 32
-
- 640, 480, 480, Utils.UNCONSTRAINED, 1, // 1
- 640, 480, 240, Utils.UNCONSTRAINED, 2, // 2
- 640, 480, 160, Utils.UNCONSTRAINED, 4, // 3->4
- 640, 480, 120, Utils.UNCONSTRAINED, 4, // 4
- 640, 480, 96, Utils.UNCONSTRAINED, 8, // 5->8
- 640, 480, 80, Utils.UNCONSTRAINED, 8, // 6->8
- 640, 480, 60, Utils.UNCONSTRAINED, 8, // 8
- 640, 480, 48, Utils.UNCONSTRAINED, 16, // 10->16
- 640, 480, 40, Utils.UNCONSTRAINED, 16, // 12->16
- 640, 480, 30, Utils.UNCONSTRAINED, 16, // 16
- 640, 480, 24, Utils.UNCONSTRAINED, 24, // 20->24
- 640, 480, 20, Utils.UNCONSTRAINED, 24, // 24
- 640, 480, 16, Utils.UNCONSTRAINED, 32, // 30->32
- 640, 480, 12, Utils.UNCONSTRAINED, 40, // 40
- 640, 480, 10, Utils.UNCONSTRAINED, 48, // 48
- 640, 480, 8, Utils.UNCONSTRAINED, 64, // 60->64
- 640, 480, 6, Utils.UNCONSTRAINED, 80, // 80
- 640, 480, 4, Utils.UNCONSTRAINED, 120, // 120
- 640, 480, 3, Utils.UNCONSTRAINED, 160, // 160
- 640, 480, 2, Utils.UNCONSTRAINED, 240, // 240
- 640, 480, 1, Utils.UNCONSTRAINED, 480, // 480
-
- 640, 480, Utils.UNCONSTRAINED, Utils.UNCONSTRAINED, 1,
- 640, 480, Utils.UNCONSTRAINED, 640 * 480, 1, // 1
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 - 1, 2, // a bit less than 1
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 / 4, 2, // 2
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 / 4 - 1, 4, // a bit less than 2
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 / 9, 4, // 3
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 / 9 - 1, 4, // a bit less than 3
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 / 16, 4, // 4
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 / 16 - 1, 8, // a bit less than 4
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 / 64, 8, // 8
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 / 64 - 1, 16, // a bit less than 8
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 / 256, 16, // 16
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 / 256 - 1, 24, // a bit less than 16
- 640, 480, Utils.UNCONSTRAINED, 640 * 480 / (24 * 24) - 1, 32, // a bit less than 24
- };
-
- @SmallTest
- public void testComputeSampleSize() {
- Options options = new Options();
-
- for (int i = 0; i < testData.length; i += 5) {
- int w = testData[i];
- int h = testData[i + 1];
- int minSide = testData[i + 2];
- int maxPixels = testData[i + 3];
- int sampleSize = testData[i + 4];
- options.outWidth = w;
- options.outHeight = h;
- int result = Utils.computeSampleSize(options, minSide, maxPixels);
- if (result != sampleSize) {
- Log.v(TAG, w + "x" + h + ", minSide = " + minSide + ", maxPixels = "
- + maxPixels + ", sampleSize = " + sampleSize + ", result = "
- + result);
- }
- assertTrue(sampleSize == result);
- }
- }
-
- public void testAssert() {
- // This should not throw an exception.
- Utils.Assert(true);
-
- // This should throw an exception.
- try {
- Utils.Assert(false);
- fail();
- } catch (AssertionError ex) {
- // expected.
- }
- }
-
- public void testCheckNotNull() {
- // These should not throw an expection.
- Utils.checkNotNull(new Object());
- Utils.checkNotNull(0);
- Utils.checkNotNull("");
-
- // This should throw an expection.
- try {
- Utils.checkNotNull(null);
- fail();
- } catch (NullPointerException ex) {
- // expected.
- }
- }
-
- public void testEquals() {
- Object a = new Object();
- Object b = new Object();
-
- assertTrue(Utils.equals(null, null));
- assertTrue(Utils.equals(a, a));
- assertFalse(Utils.equals(null, a));
- assertFalse(Utils.equals(a, null));
- assertFalse(Utils.equals(a, b));
- }
-
- public void testIsPowerOf2() {
- for (int i = 0; i < 31; i++) {
- int v = (1 << i);
- assertTrue(Utils.isPowerOf2(v));
- }
-
- int[] f = new int[] {3, 5, 6, 7, 9, 10, 65535, Integer.MAX_VALUE - 1,
- Integer.MAX_VALUE };
- for (int v : f) {
- assertFalse(Utils.isPowerOf2(v));
- }
-
- int[] e = new int[] {0, -1, -2, -4, -65536, Integer.MIN_VALUE + 1,
- Integer.MIN_VALUE };
- for (int v : e) {
- try {
- Utils.isPowerOf2(v);
- fail();
- } catch (IllegalArgumentException ex) {
- // expected.
- }
- }
- }
-
- public void testNextPowerOf2() {
- int[] q = new int[] {1, 2, 3, 4, 5, 6, 10, 65535, (1 << 30) - 1, (1 << 30)};
- int[] a = new int[] {1, 2, 4, 4, 8, 8, 16, 65536, (1 << 30) , (1 << 30)};
-
- for (int i = 0; i < q.length; i++) {
- assertEquals(a[i], Utils.nextPowerOf2(q[i]));
- }
-
- int[] e = new int[] {0, -1, -2, -4, -65536, (1 << 30) + 1, Integer.MAX_VALUE};
-
- for (int v : e) {
- try {
- Utils.nextPowerOf2(v);
- fail();
- } catch (IllegalArgumentException ex) {
- // expected.
- }
- }
- }
-
- public void testDistance() {
- assertFloatEq(0f, Utils.distance(0, 0, 0, 0));
- assertFloatEq(1f, Utils.distance(0, 1, 0, 0));
- assertFloatEq(1f, Utils.distance(0, 0, 0, 1));
- assertFloatEq(2f, Utils.distance(1, 2, 3, 2));
- assertFloatEq(5f, Utils.distance(1, 2, 1 + 3, 2 + 4));
- assertFloatEq(5f, Utils.distance(1, 2, 1 + 3, 2 + 4));
- assertFloatEq(Float.MAX_VALUE, Utils.distance(Float.MAX_VALUE, 0, 0, 0));
- }
-
- public void testClamp() {
- assertEquals(1000, Utils.clamp(300, 1000, 2000));
- assertEquals(1300, Utils.clamp(1300, 1000, 2000));
- assertEquals(2000, Utils.clamp(2300, 1000, 2000));
-
- assertEquals(0.125f, Utils.clamp(0.1f, 0.125f, 0.5f));
- assertEquals(0.25f, Utils.clamp(0.25f, 0.125f, 0.5f));
- assertEquals(0.5f, Utils.clamp(0.9f, 0.125f, 0.5f));
- }
-
- public void testIsOpaque() {
- assertTrue(Utils.isOpaque(0xFF000000));
- assertTrue(Utils.isOpaque(0xFFFFFFFF));
- assertTrue(Utils.isOpaque(0xFF123456));
-
- assertFalse(Utils.isOpaque(0xFEFFFFFF));
- assertFalse(Utils.isOpaque(0x8FFFFFFF));
- assertFalse(Utils.isOpaque(0x00FF0000));
- assertFalse(Utils.isOpaque(0x5500FF00));
- assertFalse(Utils.isOpaque(0xAA0000FF));
- }
-
- public static void testSwap() {
- Integer[] a = {1, 2, 3};
- Utils.swap(a, 0, 2);
- assertEquals(a[0].intValue(), 3);
- assertEquals(a[1].intValue(), 2);
- assertEquals(a[2].intValue(), 1);
- }
-
- public static void assertFloatEq(float expected, float actual) {
- if (Math.abs(actual - expected) > 1e-6) {
- Log.v(TAG, "expected: " + expected + ", actual: " + actual);
- fail();
- }
- }
-}