summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShih-chia Cheng <shihchia@google.com>2011-08-03 12:10:59 +0800
committerShih-chia Cheng <shihchia@google.com>2011-08-09 16:23:48 +0800
commitfe7b065c18808ac3bd15ea5a1248b3af66b50fb7 (patch)
tree27e7a95af66d7eff1074da0be40dcfd1b268d51f
parent0202160743a65ef1b6f946266390351de4aaed73 (diff)
downloadVideoEditor-fe7b065c18808ac3bd15ea5a1248b3af66b50fb7.tar.gz
New UI: Re-org action bar icons, menu options, and title picker.
This patch does the following changes: 1. Group video/image capturing and import functions together under the same menu 2. Group project related operations including "change project name", "export movie", and "delete project" together under the same menu 3. Change the interaction flow of applying effects onto media items: 3.1 Cluster effect operations under the same menu (including adding transitions) 3.2 In the effects menu, effects are grouped as a sigle selection checkbox group (not including transitions) 3.3 Put other functions such as "remove" under "more menu" 4. Show text along with menu icons where there is enough room on the screen 5. Change the interaction flow of adding title overlay on media items: title operations are put in a separate menu and its menu items are dynamically adjusted. Title picker are also re-implemented and make its layout work on both portrait and landscape modes This patch also does a huge refactoring including extracting duplicate code, removing dead code, simplying user interaction by removing redundant activity/adapter EffectsActivity and EffectsAdapter. Bug: 5026629 Change-Id: I846225994175e737690c6d2d7d7708909efba918
-rw-r--r--AndroidManifest.xml16
-rw-r--r--res/drawable-hdpi/ic_menu_add_audio_clip.pngbin1130 -> 1510 bytes
-rw-r--r--res/drawable-mdpi/ic_menu_add_audio_clip.pngbin1130 -> 1510 bytes
-rwxr-xr-xres/layout-w320dp-port/overlay_title_editor.xml (renamed from res/layout/overlay_title.xml)61
-rwxr-xr-xres/layout-w533dp-land/overlay_title_editor.xml100
-rw-r--r--res/menu/action_bar_menu.xml57
-rwxr-xr-xres/menu/media_item_mode_menu.xml72
-rwxr-xr-xres/menu/overlay_mode_menu.xml8
-rwxr-xr-xres/values/strings.xml38
-rwxr-xr-xsrc/com/android/videoeditor/BaseAdapterWithImages.java68
-rwxr-xr-xsrc/com/android/videoeditor/EffectsActivity.java154
-rwxr-xr-xsrc/com/android/videoeditor/EffectsAdapter.java104
-rwxr-xr-xsrc/com/android/videoeditor/KenBurnsActivity.java60
-rw-r--r--[-rwxr-xr-x]src/com/android/videoeditor/OverlayTitleEditor.java (renamed from src/com/android/videoeditor/OverlayTitleActivity.java)126
-rw-r--r--src/com/android/videoeditor/OverlayTitleTemplatePicker.java80
-rwxr-xr-xsrc/com/android/videoeditor/OverlaysActivity.java142
-rwxr-xr-xsrc/com/android/videoeditor/VideoEditorActivity.java361
-rwxr-xr-xsrc/com/android/videoeditor/VideoEditorBaseActivity.java4
-rwxr-xr-xsrc/com/android/videoeditor/service/ApiService.java12
-rwxr-xr-xsrc/com/android/videoeditor/service/MovieMediaItem.java4
-rwxr-xr-xsrc/com/android/videoeditor/widgets/AudioTrackLinearLayout.java79
-rwxr-xr-xsrc/com/android/videoeditor/widgets/AudioTrackView.java30
-rwxr-xr-xsrc/com/android/videoeditor/widgets/EditorRelativeLayout.java10
-rwxr-xr-xsrc/com/android/videoeditor/widgets/ImageViewTouchBase.java3
-rwxr-xr-xsrc/com/android/videoeditor/widgets/MediaItemView.java48
-rwxr-xr-xsrc/com/android/videoeditor/widgets/MediaLinearLayout.java631
-rw-r--r--src/com/android/videoeditor/widgets/MediaLinearLayoutListener.java70
-rwxr-xr-xsrc/com/android/videoeditor/widgets/OverlayLinearLayout.java126
-rwxr-xr-xsrc/com/android/videoeditor/widgets/OverlayView.java24
-rwxr-xr-xsrc/com/android/videoeditor/widgets/TimelineHorizontalScrollView.java24
-rwxr-xr-xsrc/com/android/videoeditor/widgets/TimelineRelativeLayout.java15
-rwxr-xr-xsrc/com/android/videoeditor/widgets/TransitionView.java39
-rwxr-xr-xsrc/com/android/videoeditor/widgets/ZoomControl.java21
33 files changed, 975 insertions, 1612 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ae9c18d..964f852 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -34,19 +34,19 @@
</intent-filter>
</activity>
- <activity android:name=".OverlaysActivity"
- android:theme="@android:style/Theme.Holo.DialogWhenLarge"
- android:label="@string/overlays_select_type">
+ <activity android:name=".OverlayTitleEditor"
+ android:theme="@android:style/Theme.Holo.Dialog"
+ android:label="@string/overlay_title">
<intent-filter>
- <action android:name="android.intent.action.PICK" />
+ <action android:name="android.intent.action.EDIT" />
</intent-filter>
</activity>
- <activity android:name=".OverlayTitleActivity"
- android:theme="@android:style/Theme.Holo.Dialog"
- android:label="@string/overlay_title">
+ <activity android:name=".OverlayTitleTemplatePicker"
+ android:theme="@android:style/Theme.Holo.DialogWhenLarge"
+ android:label="@string/overlays_select_type">
<intent-filter>
- <action android:name="android.intent.action.EDIT" />
+ <action android:name="android.intent.action.PICK" />
</intent-filter>
</activity>
diff --git a/res/drawable-hdpi/ic_menu_add_audio_clip.png b/res/drawable-hdpi/ic_menu_add_audio_clip.png
index 7e98bc3..bf139de 100644
--- a/res/drawable-hdpi/ic_menu_add_audio_clip.png
+++ b/res/drawable-hdpi/ic_menu_add_audio_clip.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_add_audio_clip.png b/res/drawable-mdpi/ic_menu_add_audio_clip.png
index 7e98bc3..bf139de 100644
--- a/res/drawable-mdpi/ic_menu_add_audio_clip.png
+++ b/res/drawable-mdpi/ic_menu_add_audio_clip.png
Binary files differ
diff --git a/res/layout/overlay_title.xml b/res/layout-w320dp-port/overlay_title_editor.xml
index 81e99af..a1868e3 100755
--- a/res/layout/overlay_title.xml
+++ b/res/layout-w320dp-port/overlay_title_editor.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (C) 2010 The Android Open Source Project
+ Copyright (C) 2011 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.
@@ -15,47 +15,60 @@
limitations under the License.
-->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingLeft="15dip"
- android:paddingRight="15dip"
- android:paddingTop="5dip"
- android:paddingBottom="5dip">
+ android:layout_gravity="center_vertical"
+ android:orientation="vertical"
+ android:layout_marginTop="15dip"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:layout_marginBottom="15dip">
- <ImageView android:id="@+id/overlay_generic"
- android:layout_width="wrap_content"
+ <RelativeLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:src="@drawable/effects_generic"/>
- <ImageView android:id="@+id/overlay_layer"
+ android:layout_gravity="center_vertical"
+ android:layout_marginLeft="10dip"
+ android:layout_marginRight="10dip">
+ <ImageView android:id="@+id/overlay_generic"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/effects_generic"/>
+ <ImageView android:id="@+id/overlay_preview"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+ </RelativeLayout>
+
+ <Button android:id="@+id/overlay_change_title_template"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ android:layout_height="wrap_content"
+ android:layout_marginTop="15dip"
+ android:text="@string/overlay_change_title_template_button_text" />
<EditText android:id="@+id/overlay_title"
- android:layout_width="256dip"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_toRightOf="@id/overlay_generic"
android:layout_marginTop="20dip"
- android:layout_marginLeft="20dip"
+ android:layout_marginLeft="10dip"
+ android:layout_marginRight="10dip"
android:hint="@string/overlay_title_label"
android:singleLine="true"/>
<EditText android:id="@+id/overlay_subtitle"
- android:layout_width="256dip"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_toRightOf="@id/overlay_generic"
- android:layout_below="@id/overlay_title"
android:layout_marginTop="10dip"
- android:layout_marginLeft="20dip"
+ android:layout_marginLeft="10dip"
+ android:layout_marginRight="10dip"
android:hint="@string/overlay_subtitle_label"
android:singleLine="true"/>
<LinearLayout
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_below="@id/overlay_generic"
- android:layout_alignLeft="@id/overlay_generic"
- android:layout_alignRight="@id/overlay_subtitle"
+ android:orientation="horizontal"
+ android:layout_gravity="center_horizontal"
android:layout_marginTop="20dip">
<Button android:id="@+id/overlay_ok"
@@ -71,4 +84,4 @@
android:layout_weight="1.0"
android:text="@android:string/cancel"/>
</LinearLayout>
-</RelativeLayout>
+</LinearLayout>
diff --git a/res/layout-w533dp-land/overlay_title_editor.xml b/res/layout-w533dp-land/overlay_title_editor.xml
new file mode 100755
index 0000000..817695a
--- /dev/null
+++ b/res/layout-w533dp-land/overlay_title_editor.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2011 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:orientation="horizontal"
+ android:layout_marginTop="10dip"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:layout_marginBottom="15dip">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:orientation="vertical">
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="10dip">
+ <ImageView android:id="@+id/overlay_generic"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/effects_generic"/>
+ <ImageView android:id="@+id/overlay_preview"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+ </RelativeLayout>
+
+ <Button android:id="@+id/overlay_change_title_template"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dip"
+ android:text="@string/overlay_change_title_template_button_text" />
+ </LinearLayout>>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:orientation="vertical"
+ android:layout_marginLeft="30dip"
+ android:layout_marginTop="5dip">
+ <EditText android:id="@+id/overlay_title"
+ android:layout_width="192dip"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dip"
+ android:layout_marginRight="10dip"
+ android:hint="@string/overlay_title_label"
+ android:singleLine="true"/>
+
+ <EditText android:id="@+id/overlay_subtitle"
+ android:layout_width="192dip"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="5dip"
+ android:layout_marginLeft="10dip"
+ android:layout_marginRight="10dip"
+ android:hint="@string/overlay_subtitle_label"
+ android:singleLine="true"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="20dip">
+
+ <Button android:id="@+id/overlay_ok"
+ android:onClick="onClickHandler"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1.0"
+ android:text="@android:string/ok"/>
+ <Button android:id="@+id/overlay_cancel"
+ android:onClick="onClickHandler"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1.0"
+ android:text="@android:string/cancel"/>
+ </LinearLayout>
+ </LinearLayout>
+</LinearLayout>
diff --git a/res/menu/action_bar_menu.xml b/res/menu/action_bar_menu.xml
new file mode 100644
index 0000000..fda6651
--- /dev/null
+++ b/res/menu/action_bar_menu.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!-- Main action bar contains two sub-menus: one for adding media item into the project,
+and one for project preferences and operations. -->
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/add_new_media_item_menu"
+ android:icon="@drawable/ic_menu_add_video"
+ android:title="@string/editor_add"
+ android:showAsAction="ifRoom|withText">
+ <menu>
+ <item android:id="@+id/menu_item_capture_video"
+ android:title="@string/editor_capture_video" />
+ <item android:id="@+id/menu_item_capture_image"
+ android:title="@string/editor_capture_image" />
+ <item android:id="@+id/menu_item_import_video"
+ android:title="@string/editor_import_video" />
+ <item android:id="@+id/menu_item_import_image"
+ android:title="@string/editor_import_image" />
+ <item android:id="@+id/menu_item_import_audio"
+ android:title="@string/editor_import_audio" />
+ </menu>
+ </item>
+
+ <!-- Project related menu are always grouped into the more option. -->
+ <item android:id="@+id/menu_item_change_aspect_ratio"
+ android:title="@string/editor_change_aspect_ratio"
+ android:showAsAction="never" />
+ <item android:id="@+id/menu_item_edit_project_name"
+ android:title="@string/editor_edit_project_name"
+ android:showAsAction="never" />
+ <item android:id="@+id/menu_item_export_movie"
+ android:title="@string/editor_export_movie"
+ android:showAsAction="never" />
+ <item android:id="@+id/menu_item_delete_project"
+ android:title="@string/editor_delete_project"
+ android:showAsAction="never" />
+ <item android:id="@+id/menu_item_play_exported_movie"
+ android:title="@string/editor_play_exported_movie"
+ android:showAsAction="never" />
+ <item android:id="@+id/menu_item_share_movie"
+ android:title="@string/editor_share_movie"
+ android:showAsAction="never" />
+</menu>
diff --git a/res/menu/media_item_mode_menu.xml b/res/menu/media_item_mode_menu.xml
index 9268df7..fd636a9 100755
--- a/res/menu/media_item_mode_menu.xml
+++ b/res/menu/media_item_mode_menu.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
+<!-- Copyright (C) 2011 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.
@@ -15,28 +15,58 @@
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/action_add_effect"
- android:title="@string/editor_add_effect"
- android:icon="@drawable/ic_menu_add_effect_selector"/>
- <item android:id="@+id/action_change_effect"
- android:title="@string/editor_change_effect"
- android:icon="@drawable/ic_menu_edit_effect_selector"/>
- <item android:id="@+id/action_remove_effect"
- android:title="@string/editor_remove_effect"
- android:icon="@drawable/ic_menu_remove_effect_selector"/>
- <item android:id="@+id/action_add_overlay"
- android:title="@string/editor_add_overlay"
- android:icon="@drawable/ic_menu_add_title_selector"/>
- <item android:id="@+id/action_add_begin_transition"
- android:title="@string/editor_add_begin_transition"
- android:icon="@drawable/ic_menu_add_trans_start_selector"/>
- <item android:id="@+id/action_add_end_transition"
- android:title="@string/editor_add_end_transition"
- android:icon="@drawable/ic_menu_add_trans_end_selector"/>
+ <item android:id="@+id/media_item_title_menu"
+ android:title="@string/editor_title_menu_header"
+ android:icon="@drawable/ic_menu_add_title_selector"
+ android:showAsAction="always|withText" >
+ <menu>
+ <item android:id="@+id/action_add_overlay"
+ android:title="@string/editor_add_overlay" />
+ <item android:id="@+id/action_remove_overlay"
+ android:title="@string/editor_remove_overlay" />
+ </menu>
+ </item>
+
+ <item android:id="@+id/media_item_effect_menu"
+ android:title="@string/editor_effect_menu_header"
+ android:icon="@drawable/ic_menu_add_effects"
+ android:showAsAction="always|withText" >
+ <menu>
+ <!-- Menu items for adding transitions -->
+ <item android:id="@+id/action_add_begin_transition"
+ android:title="@string/editor_add_begin_transition"
+ android:icon="@drawable/ic_menu_add_trans_start_selector" />
+ <item android:id="@+id/action_add_end_transition"
+ android:title="@string/editor_add_end_transition"
+ android:icon="@drawable/ic_menu_add_trans_end_selector" />
+
+ <!-- Menu items for adding effects -->
+ <group android:checkableBehavior="single">
+ <item android:id="@+id/action_pan_zoom_effect"
+ android:title="@string/editor_pan_zoom_effect"
+ android:icon="@drawable/effects_pan_zoom" />
+ <item android:id="@+id/action_gradient_effect"
+ android:title="@string/editor_gradient_effect"
+ android:icon="@drawable/effects_gradient" />
+ <item android:id="@+id/action_sepia_effect"
+ android:title="@string/editor_sepia_effect"
+ android:icon="@drawable/effects_sepia" />
+ <item android:id="@+id/action_negative_effect"
+ android:title="@string/editor_negative_effect"
+ android:icon="@drawable/effects_negative" />
+ <item android:id="@+id/action_no_effect"
+ android:title="@string/editor_no_effect"
+ android:icon="@drawable/effects_generic"
+ android:checked="true" />
+ </group>
+ </menu>
+ </item>
+
+ <!-- The following menu items are always put into the more option. -->
<item android:id="@+id/action_rendering_mode"
android:title="@string/editor_change_rendering_mode"
- android:icon="@drawable/ic_menu_rendermode"/>
+ android:showAsAction="never" />
<item android:id="@+id/action_delete_media_item"
android:title="@string/remove"
- android:icon="@drawable/ic_menu_delete_selector"/>
+ android:showAsAction="never" />
</menu>
diff --git a/res/menu/overlay_mode_menu.xml b/res/menu/overlay_mode_menu.xml
index 8654833..123cdb8 100755
--- a/res/menu/overlay_mode_menu.xml
+++ b/res/menu/overlay_mode_menu.xml
@@ -16,9 +16,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_edit_overlay"
- android:title="@string/editor_edit_overlay"
- android:icon="@drawable/ic_menu_edit_selector"/>
+ android:title="@string/edit"
+ android:icon="@drawable/ic_menu_edit_selector"
+ android:showAsAction="ifRoom|withText" />
<item android:id="@+id/action_remove_overlay"
android:title="@string/remove"
- android:icon="@drawable/ic_menu_delete_selector"/>
+ android:icon="@drawable/ic_menu_delete_selector"
+ android:showAsAction="ifRoom|withText" />
</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index db11e21..668d95b 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7,6 +7,8 @@
<string name="editor_loading_project">Loading project...</string>
<!-- Displayed in the center of the activity if a project could not be loaded. -->
<string name="editor_no_project">No project found</string>
+ <!-- Menu text displayed for adding new media item. -->
+ <string name="editor_add">Add</string>
<!-- Menu item used to launch the Gallery video clip picker. -->
<string name="editor_import_video">Import video clip</string>
<!-- Menu item used to launch the Gallery image picker. -->
@@ -26,17 +28,23 @@
<!-- Menu item used to delete the project. -->
<string name="editor_delete_project">Delete project</string>
<!-- Menu item for capturing a new video clip. -->
- <string name="editor_capture_video">New video clip</string>
+ <string name="editor_capture_video">Record a video</string>
<!-- Menu item for capturing a new image. -->
- <string name="editor_capture_image">New image</string>
+ <string name="editor_capture_image">Take a photo</string>
<!-- Text displayed in the delete project confirmation dialog. -->
<string name="editor_delete_project_question">Do you want to delete this project?</string>
<!-- Text displayed in the playback widget to indicate the current playhead time position [CHAR_LIMIT=11] -->
<string name="editor_zero_time_stamp">00:00:00.0</string>
<!-- Text displayed in the remove audio track confirmation dialog. -->
<string name="editor_remove_audio_track_question">Do you want to remove this audio track?</string>
- <!-- Menu item used to change the overlay text. -->
- <string name="editor_edit_overlay">Edit</string>
+ <!-- Menu header of title overlay menu. -->
+ <string name="editor_title_menu_header">Title</string>
+ <!-- Menu item used to add a new title (overlay title). -->
+ <string name="editor_add_overlay">Add title</string>
+ <!-- Menu item used to change the overlay title. -->
+ <string name="editor_edit_overlay">Edit title</string>
+ <!-- Menu item used to remove a title (overlay title). -->
+ <string name="editor_remove_overlay">Remove title</string>
<!-- Text displayed in the remove overlay confirmation dialog. -->
<string name="editor_remove_overlay_question">Do you want to remove this overlay?</string>
<!-- Menu item used to change the rendering mode. Launches a single choice dialog. -->
@@ -49,18 +57,28 @@
<string name="editor_remove_video_question">Do you want to remove this video clip?</string>
<!-- Text displayed in the remove image confirmation dialog. -->
<string name="editor_remove_image_question">Do you want to remove this image?</string>
+ <!-- Text displayed as the header of effect menu. -->
+ <string name="editor_effect_menu_header">effect</string>
<!-- Menu item used to add an effect. -->
<string name="editor_add_effect">Add effect</string>
<!-- Menu item used to change an effect type and/or duration. -->
<string name="editor_change_effect">Change effect</string>
<!-- Menu item used to remove an effect. -->
<string name="editor_remove_effect">Remove effect</string>
- <!-- Menu item used to add a new title (overlay title). -->
- <string name="editor_add_overlay">Add title</string>
+ <!-- Menu item text for effect pan zoom. -->
+ <string name="editor_pan_zoom_effect">Pan Zoom</string>
+ <!-- Menu item text for effect gradient. -->
+ <string name="editor_gradient_effect">Gradient</string>
+ <!-- Menu item text for effect sepia. -->
+ <string name="editor_sepia_effect">Sepia</string>
+ <!-- Menu item text for effect negative. -->
+ <string name="editor_negative_effect">Negative</string>
+ <!-- Menu item text for no effect. -->
+ <string name="editor_no_effect">no effect</string>
<!-- Menu item used to add a transition at the beginning of the image or video clip. -->
- <string name="editor_add_begin_transition">Add beginning transition</string>
+ <string name="editor_add_begin_transition">Transition into clip</string>
<!-- Menu item used to add a transition at the end of the image or video clip. -->
- <string name="editor_add_end_transition">Add ending transition</string>
+ <string name="editor_add_end_transition">Transition out of clip</string>
<!-- Menu item used to change a transition type and/or duration. -->
<string name="editor_change_transition">Change transition</string>
<!-- Toast message used when a video clip needs to be downloaded before it can be used -->
@@ -228,6 +246,8 @@
<string name="overlay_title_label">Title</string>
<!-- The dialog label for the overlay sample subtitle. -->
<string name="overlay_subtitle_label">Subtitle</string>
+ <!-- The text displayed on the button used to change overlay title template. -->
+ <string name="overlay_change_title_template_button_text">Change template</string>
<!-- Effect names-->
<!-- The effects selection dialog title. -->
@@ -281,6 +301,8 @@
<!-- Displayed in dialog buttons. -->
<string name="done">Done</string>
<!-- Displayed in dialog buttons and menu items. -->
+ <string name="edit">Edit</string>
+ <!-- Displayed in dialog buttons and menu items. -->
<string name="remove">Remove</string>
<!-- Displayed in the carousel if the project does not have a name. -->
<string name="untitled">Untitled</string>
diff --git a/src/com/android/videoeditor/BaseAdapterWithImages.java b/src/com/android/videoeditor/BaseAdapterWithImages.java
index d67e271..f5a11d1 100755
--- a/src/com/android/videoeditor/BaseAdapterWithImages.java
+++ b/src/com/android/videoeditor/BaseAdapterWithImages.java
@@ -26,41 +26,34 @@ import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.AsyncTask;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
/**
- * The base class for BaseAdapters which load images.
+ * Base class for BaseAdapters which load images.
*/
-public abstract class BaseAdapterWithImages<T> extends BaseAdapter {
+public abstract class BaseAdapterWithImages<K> extends BaseAdapter {
protected final Context mContext;
- private final List<ImageViewHolder<T>> mViewHolders;
+ private final List<ImageViewHolder<K>> mViewHolders;
// For recording keys of images that are being loaded
- private final Set<T> mLoadingImages;
+ private final Set<K> mLoadingImages;
private final AbsListView mListView;
/**
* View holder class
*/
- protected static class ImageViewHolder<T> {
+ protected static class ImageViewHolder<K> {
private final ImageView mImageView;
- private T mKey;
+ private K mKey;
- /**
- * Constructor
- *
- * @param rowView The row view
- */
public ImageViewHolder(View rowView) {
- mImageView = (ImageView)rowView.findViewById(R.id.item_preview);
+ mImageView = (ImageView) rowView.findViewById(R.id.item_preview);
}
- /**
- * @param key The key
- */
- public void setKey(T key) {
+ public void setKey(K key) {
mKey = key;
}
}
@@ -68,17 +61,12 @@ public abstract class BaseAdapterWithImages<T> extends BaseAdapter {
/**
* View holder class
*/
- protected static class ImageTextViewHolder<T> extends ImageViewHolder<T> {
+ protected static class ImageTextViewHolder<K> extends ImageViewHolder<K> {
protected final TextView mNameView;
- /**
- * Constructor
- *
- * @param rowView The row view
- */
public ImageTextViewHolder(View rowView) {
super(rowView);
- mNameView = (TextView)rowView.findViewById(R.id.item_name);
+ mNameView = (TextView) rowView.findViewById(R.id.item_name);
}
}
@@ -86,7 +74,7 @@ public abstract class BaseAdapterWithImages<T> extends BaseAdapter {
* Image loader class
*/
protected class ImageLoaderAsyncTask extends AsyncTask<Void, Void, Bitmap> {
- private final T mKey;
+ private final K mKey;
private final Object mData;
/**
@@ -95,7 +83,7 @@ public abstract class BaseAdapterWithImages<T> extends BaseAdapter {
* @param key The bitmap key
* @param data The data
*/
- public ImageLoaderAsyncTask(T key, Object data) {
+ public ImageLoaderAsyncTask(K key, Object data) {
mKey = key;
mData = data;
}
@@ -112,7 +100,7 @@ public abstract class BaseAdapterWithImages<T> extends BaseAdapter {
return;
}
- for (ImageViewHolder<T> viewHolder : mViewHolders) {
+ for (ImageViewHolder<K> viewHolder : mViewHolders) {
if (mKey.equals(viewHolder.mKey)) {
viewHolder.mImageView.setImageBitmap(bitmap);
return;
@@ -121,7 +109,7 @@ public abstract class BaseAdapterWithImages<T> extends BaseAdapter {
bitmap.recycle();
}
- };
+ }
/**
* Constructor
@@ -132,16 +120,14 @@ public abstract class BaseAdapterWithImages<T> extends BaseAdapter {
public BaseAdapterWithImages(Context context, AbsListView listView) {
mContext = context;
mListView = listView;
- mLoadingImages = new HashSet<T>();
- mViewHolders = new ArrayList<ImageViewHolder<T>>();
+ mLoadingImages = new HashSet<K>();
+ mViewHolders = new ArrayList<ImageViewHolder<K>>();
- listView.setRecyclerListener(new AbsListView.RecyclerListener() {
- /*
- * {@inheritDoc}
- */
+ mListView.setRecyclerListener(new AbsListView.RecyclerListener() {
+ @Override
@SuppressWarnings("unchecked")
public void onMovedToScrapHeap(View view) {
- final ImageViewHolder<T> viewHolder = (ImageViewHolder<T>)view.getTag();
+ final ImageViewHolder<K> viewHolder = (ImageViewHolder<K>)view.getTag();
mViewHolders.remove(viewHolder);
viewHolder.setKey(null);
@@ -179,14 +165,14 @@ public abstract class BaseAdapterWithImages<T> extends BaseAdapter {
}
/**
- * Start the AsyncTask which loads the bitmap
+ * Starts the AsyncTask which loads the bitmap.
*
* @param key The bitmap key
* @param data The data
* @param viewHolder The view holder
*/
- protected void initiateLoad(T key, Object data, ImageViewHolder<T> viewHolder) {
- // The adapter may recycle a view and then reuse it
+ protected void initiateLoad(K key, Object data, ImageViewHolder<K> viewHolder) {
+ // The adapter may recycle a view and then reuse it.
if (!mViewHolders.contains(viewHolder)) {
mViewHolders.add(viewHolder);
}
@@ -206,8 +192,14 @@ public abstract class BaseAdapterWithImages<T> extends BaseAdapter {
@Override
public abstract int getCount();
+ @Override
+ public abstract Object getItem(int position);
+
+ @Override
+ public abstract View getView(int position, View convertView, ViewGroup parent);
+
/**
- * Load an image based on its key
+ * Loads an image based on its key.
*
* @param data The data required to load the image
*
diff --git a/src/com/android/videoeditor/EffectsActivity.java b/src/com/android/videoeditor/EffectsActivity.java
deleted file mode 100755
index 26cecfe..0000000
--- a/src/com/android/videoeditor/EffectsActivity.java
+++ /dev/null
@@ -1,154 +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.videoeditor;
-
-import android.app.ListActivity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ListView;
-
-/**
- * Displays a list of effects that can be applied to an image.
- */
-public class EffectsActivity extends ListActivity {
- // Input effect category
- public static final String PARAM_CATEGORY = "category";
- public static final String PARAM_MEDIA_ITEM_ID = "media_item_id";
- // Output effect type
- public static final String PARAM_EFFECT_TYPE = "effect";
- public static final String PARAM_FILENAME = "filename";
- public static final String PARAM_WIDTH = "width";
- public static final String PARAM_HEIGHT = "height";
- public static final String PARAM_START_RECT = "start_rect";
- public static final String PARAM_END_RECT = "end_rect";
-
- // Request codes
- public static final int REQUEST_CODE_KEN_BURNS = 11;
-
- // Instance variables
- private EffectsAdapter mAdapter;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.list_view);
- setFinishOnTouchOutside(true);
-
- // Create the list adapter
- mAdapter = new EffectsAdapter(this, getListView(), getIntent().getIntExtra(PARAM_CATEGORY,
- EffectType.CATEGORY_VIDEO));
- setListAdapter(mAdapter);
-
- final int effectType = getIntent().getIntExtra(PARAM_EFFECT_TYPE, -1);
- if (effectType >= 0) {
- // Select the current effect
- final EffectType[] effects = mAdapter.getEffects();
- for (int i = 0; i < effects.length; i++) {
- if (effects[i].getType() == effectType) {
- setSelection(i);
- break;
- }
- }
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
-
- if (mAdapter != null) {
- mAdapter.onPause();
- }
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
-
- if (mAdapter != null) {
- mAdapter.onDestroy();
- }
- }
-
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
- final int effectType = ((EffectType)mAdapter.getItem(position)).getType();
- if (effectType == EffectType.EFFECT_KEN_BURNS) {
- final Intent intent = new Intent(this, KenBurnsActivity.class);
- intent.putExtra(KenBurnsActivity.PARAM_MEDIA_ITEM_ID, getIntent().getStringExtra(
- PARAM_MEDIA_ITEM_ID));
- intent.putExtra(KenBurnsActivity.PARAM_FILENAME, getIntent().getStringExtra(
- PARAM_FILENAME));
- intent.putExtra(KenBurnsActivity.PARAM_WIDTH, getIntent().getIntExtra(PARAM_WIDTH, 0));
- intent.putExtra(KenBurnsActivity.PARAM_HEIGHT, getIntent().getIntExtra(
- PARAM_HEIGHT, 0));
- intent.putExtra(KenBurnsActivity.PARAM_START_RECT, getIntent().getParcelableExtra(
- PARAM_START_RECT));
- intent.putExtra(KenBurnsActivity.PARAM_END_RECT, getIntent().getParcelableExtra(
- PARAM_END_RECT));
-
- startActivityForResult(intent, REQUEST_CODE_KEN_BURNS);
- } else {
- final Intent extras = new Intent();
- extras.putExtra(PARAM_EFFECT_TYPE, ((EffectType)mAdapter.getItem(position)).getType());
- extras.putExtra(PARAM_MEDIA_ITEM_ID, getIntent().getStringExtra(PARAM_MEDIA_ITEM_ID));
-
- // Release the adapter now
- mAdapter.onDestroy();
- mAdapter = null;
-
- setResult(RESULT_OK, extras);
- finish();
- }
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent extras) {
- super.onActivityResult(requestCode, resultCode, extras);
- if (resultCode == RESULT_CANCELED) {
- return;
- }
-
- switch(requestCode) {
- case REQUEST_CODE_KEN_BURNS: {
- final Intent intent = new Intent();
- intent.putExtra(PARAM_EFFECT_TYPE, EffectType.EFFECT_KEN_BURNS);
- intent.putExtra(PARAM_MEDIA_ITEM_ID,
- getIntent().getStringExtra(PARAM_MEDIA_ITEM_ID));
- intent.putExtra(PARAM_EFFECT_TYPE, EffectType.EFFECT_KEN_BURNS);
- intent.putExtra(PARAM_START_RECT, extras.getParcelableExtra(
- KenBurnsActivity.PARAM_START_RECT));
- intent.putExtra(PARAM_END_RECT, extras.getParcelableExtra(
- KenBurnsActivity.PARAM_END_RECT));
-
- setResult(RESULT_OK, intent);
- finish();
- break;
- }
-
- default: {
- break;
- }
- }
- }
-
- @Override
- public boolean onSearchRequested() {
- return false;
- }
-}
diff --git a/src/com/android/videoeditor/EffectsAdapter.java b/src/com/android/videoeditor/EffectsAdapter.java
deleted file mode 100755
index 2cbe37c..0000000
--- a/src/com/android/videoeditor/EffectsAdapter.java
+++ /dev/null
@@ -1,104 +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.videoeditor;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AbsListView;
-
-/**
- * Adapter which displays a list of supported effects
- */
-public class EffectsAdapter extends BaseAdapterWithImages<Integer> {
- // Instance variables
- private final EffectType[] mEffects;
-
- /**
- * Constructor
- *
- * @param context The context
- * @param listView The list view
- * @param category The category
- */
- public EffectsAdapter(Context context, AbsListView listView, int category) {
- super(context, listView);
-
- mEffects = EffectType.getEffects(context, category);
- }
-
- /**
- * @return The array of effects
- */
- public EffectType[] getEffects() {
- return mEffects;
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public int getCount() {
- return mEffects.length;
- }
-
- /*
- * {@inheritDoc}
- */
- public Object getItem(int position) {
- return mEffects[position];
- }
-
- /*
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public View getView(int position, View convertView, ViewGroup parent) {
- final ImageTextViewHolder<Integer> viewHolder;
- final View rowView;
- if (convertView == null) {
- final LayoutInflater vi = (LayoutInflater)mContext.getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
- rowView = vi.inflate(R.layout.image_with_text_row_view, null);
- viewHolder = new ImageTextViewHolder<Integer>(rowView);
- rowView.setTag(viewHolder);
- } else {
- rowView = convertView;
- viewHolder = (ImageTextViewHolder<Integer>)convertView.getTag();
- }
-
- final EffectType effect = mEffects[position];
- initiateLoad(effect.getType(), effect.getType(), viewHolder);
-
- // Set the data in the views
- viewHolder.mNameView.setText(effect.getName());
-
- return rowView;
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- protected Bitmap loadImage(Object data) {
- return BitmapFactory.decodeResource(mContext.getResources(),
- EffectType.EFFECT_RESOURCE_IDS[(Integer)data]);
- }
-}
diff --git a/src/com/android/videoeditor/KenBurnsActivity.java b/src/com/android/videoeditor/KenBurnsActivity.java
index d359f24..1d71b3d 100755
--- a/src/com/android/videoeditor/KenBurnsActivity.java
+++ b/src/com/android/videoeditor/KenBurnsActivity.java
@@ -81,9 +81,6 @@ public class KenBurnsActivity extends Activity {
* The simple gestures listener
*/
private class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
- /*
- * {@inheritDoc}
- */
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (mImageView.getScale() > 1F) {
@@ -94,17 +91,11 @@ public class KenBurnsActivity extends Activity {
return true;
}
- /*
- * {@inheritDoc}
- */
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
- /*
- * {@inheritDoc}
- */
@Override
public boolean onDoubleTap(MotionEvent e) {
// Switch between the original scale and 3x scale.
@@ -123,16 +114,12 @@ public class KenBurnsActivity extends Activity {
* Scale gesture listener
*/
private class MyScaleGestureListener implements OnScaleGestureListener {
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onScale(ScaleGestureDetector detector) {
final float relativeScaleFactor = detector.getScaleFactor();
final float newAbsoluteScale = relativeScaleFactor * mImageView.getScale();
@@ -144,9 +131,7 @@ public class KenBurnsActivity extends Activity {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onScaleEnd(ScaleGestureDetector detector) {
saveBitmapRectangle();
}
@@ -169,9 +154,6 @@ public class KenBurnsActivity extends Activity {
showProgress(true);
}
- /*
- * {@inheritDoc}
- */
@Override
protected Bitmap doInBackground(Void... zzz) {
if (mPaused) {
@@ -195,9 +177,6 @@ public class KenBurnsActivity extends Activity {
}
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onPostExecute(Bitmap bitmap) {
if (bitmap == null) {
@@ -222,11 +201,8 @@ public class KenBurnsActivity extends Activity {
bitmap.recycle();
}
}
- };
+ }
- /*
- * {@inheritDoc}
- */
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
@@ -316,9 +292,7 @@ public class KenBurnsActivity extends Activity {
mRadioGroup.setEnabled(false);
mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.start_rectangle: {
@@ -349,12 +323,10 @@ public class KenBurnsActivity extends Activity {
}
});
- mBitmap = (Bitmap)getLastNonConfigurationInstance();
+ mBitmap = (Bitmap) getLastNonConfigurationInstance();
mImageView.setEventListener(new ImageViewTouchBase.ImageTouchEventListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onImageTouchEvent(MotionEvent ev) {
if (null != mScaleGestureDetector) {
mScaleGestureDetector.onTouchEvent(ev);
@@ -369,9 +341,6 @@ public class KenBurnsActivity extends Activity {
});
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onResume() {
super.onResume();
@@ -381,9 +350,6 @@ public class KenBurnsActivity extends Activity {
new ImageLoaderAsyncTask(getIntent().getStringExtra(PARAM_FILENAME)).execute();
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onPause() {
super.onPause();
@@ -391,9 +357,6 @@ public class KenBurnsActivity extends Activity {
mPaused = true;
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onDestroy() {
super.onDestroy();
@@ -407,17 +370,11 @@ public class KenBurnsActivity extends Activity {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public Object onRetainNonConfigurationInstance() {
return mBitmap;
}
- /*
- * {@inheritDoc}
- */
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
@@ -428,9 +385,6 @@ public class KenBurnsActivity extends Activity {
outState.putParcelable(STATE_END_RECTANGLE, mEndRect);
}
- /*
- * {@inheritDoc}
- */
public void onClickHandler(View target) {
switch (target.getId()) {
case R.id.done: {
diff --git a/src/com/android/videoeditor/OverlayTitleActivity.java b/src/com/android/videoeditor/OverlayTitleEditor.java
index a2183d8..ad87e86 100755..100644
--- a/src/com/android/videoeditor/OverlayTitleActivity.java
+++ b/src/com/android/videoeditor/OverlayTitleEditor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2011 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.
@@ -16,14 +16,15 @@
package com.android.videoeditor;
-import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
+import android.util.Log;
import android.view.View;
+import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
@@ -31,106 +32,141 @@ import com.android.videoeditor.service.MovieOverlay;
import com.android.videoeditor.util.ImageUtils;
/**
- * This activity enables the user to enter the title and subtitle for an
- * overlay.
+ * Activity that lets user add or edit title overlay of a media item.
*/
-public class OverlayTitleActivity extends Activity {
+public class OverlayTitleEditor extends NoSearchActivity {
// Parameter names
public static final String PARAM_OVERLAY_ATTRIBUTES = "attributes";
public static final String PARAM_OVERLAY_ID = "overlay_id";
public static final String PARAM_MEDIA_ITEM_ID = "media_item_id";
- // Instance variables
+ private static final String LOG_TAG = "OverlayTitleEditor";
+ private static final int REQUEST_CODE_PICK_TITLE_TEMPLATE = 1;
+
private int mOverlayType;
private ImageView mOverlayImageView;
+ private Button mOverlayChangeTitleTemplateButton;
private TextView mTitleView, mSubtitleView;
private Bitmap mOverlayBitmap;
private int mPreviewWidth, mPreviewHeight;
private final TextWatcher mTextWatcher = new TextWatcher() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
+ // no-op
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // no-op
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void afterTextChanged(Editable s) {
- mOverlayBitmap = ImageUtils.buildOverlayBitmap(OverlayTitleActivity.this,
- mOverlayBitmap, mOverlayType, mTitleView.getText().toString(),
- mSubtitleView.getText().toString(), mPreviewWidth, mPreviewHeight);
- mOverlayImageView.setImageBitmap(mOverlayBitmap);
-
+ // Update preview image as user types in the title or sub-title fields.
+ updatePreviewImage();
invalidateOptionsMenu();
}
};
- /*
- * {@inheritDoc}
- */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.overlay_title);
+ setContentView(R.layout.overlay_title_editor);
setFinishOnTouchOutside(true);
- final Bundle attributes = getIntent().getBundleExtra(PARAM_OVERLAY_ATTRIBUTES);
- mOverlayType = MovieOverlay.getType(attributes);
- mOverlayImageView = (ImageView)findViewById(R.id.overlay_layer);
+ mOverlayImageView = (ImageView) findViewById(R.id.overlay_preview);
+
+ mOverlayChangeTitleTemplateButton = (Button) findViewById(
+ R.id.overlay_change_title_template);
+ mOverlayChangeTitleTemplateButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ launchOverlayTitleTemplatePicker();
+ }
+ });
+
+ mTitleView = (TextView) findViewById(R.id.overlay_title);
+ mTitleView.addTextChangedListener(mTextWatcher);
- // Determine the bitmap dimensions
+ mSubtitleView = (TextView) findViewById(R.id.overlay_subtitle);
+ mSubtitleView.addTextChangedListener(mTextWatcher);
+
+ // Determine bitmap dimensions.
final BitmapFactory.Options dbo = new BitmapFactory.Options();
dbo.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), R.drawable.effects_generic, dbo);
mPreviewWidth = dbo.outWidth;
mPreviewHeight = dbo.outHeight;
- mTitleView = (TextView)findViewById(R.id.overlay_title);
- mTitleView.addTextChangedListener(mTextWatcher);
-
- mSubtitleView = (TextView)findViewById(R.id.overlay_subtitle);
- mSubtitleView.addTextChangedListener(mTextWatcher);
-
- if (savedInstanceState == null) {
+ final Bundle attributes = getIntent().getBundleExtra(PARAM_OVERLAY_ATTRIBUTES);
+ if (attributes != null) {
+ // The media item already has a title overlay. Fill in the contents in the input fields
+ // and let user edit them.
+ mOverlayType = MovieOverlay.getType(attributes);
mTitleView.setText(MovieOverlay.getTitle(attributes));
mSubtitleView.setText(MovieOverlay.getSubtitle(attributes));
+ } else {
+ // Default overlay type that puts title at the bottom of the media item.
+ mOverlayType = MovieOverlay.OVERLAY_TYPE_BOTTOM_1;
}
+ updatePreviewImage();
+ }
+
+ private void launchOverlayTitleTemplatePicker() {
+ final Intent intent = new Intent(this, OverlayTitleTemplatePicker.class);
+ startActivityForResult(intent, REQUEST_CODE_PICK_TITLE_TEMPLATE);
+ }
+ private void updatePreviewImage() {
mOverlayBitmap = ImageUtils.buildOverlayBitmap(this, mOverlayBitmap, mOverlayType,
mTitleView.getText().toString(), mSubtitleView.getText().toString(),
mPreviewWidth, mPreviewHeight);
mOverlayImageView.setImageBitmap(mOverlayBitmap);
}
- /*
- * {@inheritDoc}
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent extras) {
+ if (resultCode != RESULT_OK)
+ return;
+
+ switch (requestCode) {
+ case REQUEST_CODE_PICK_TITLE_TEMPLATE:
+ // Get chosen overlay type from extras and then update preview image.
+ final Bundle attributes = extras.getBundleExtra(
+ OverlayTitleTemplatePicker.PARAM_OVERLAY_ATTRIBUTES);
+ mOverlayType = MovieOverlay.getType(attributes);
+ updatePreviewImage();
+ break;
+ default:
+ Log.w(LOG_TAG, "Invalid request code received: " + requestCode);
+ break;
+ }
+ }
+
+ /**
+ * Handler used to responds to "OK" and "Cancel" buttons.
+ * @param target "OK" or "Cancel" button
*/
public void onClickHandler(View target) {
switch (target.getId()) {
case R.id.overlay_ok: {
+ // Extras to be returned to the caller of this activity.
final Intent extras = new Intent();
extras.putExtra(PARAM_MEDIA_ITEM_ID,
getIntent().getStringExtra(PARAM_MEDIA_ITEM_ID));
- final String overlayId = getIntent().getStringExtra(PARAM_OVERLAY_ID);
+ String overlayId = getIntent().getStringExtra(PARAM_OVERLAY_ID);
if (overlayId != null) {
extras.putExtra(PARAM_OVERLAY_ID, overlayId);
}
- final TextView titleView = (TextView)findViewById(R.id.overlay_title);
- final TextView subTitleView = (TextView)findViewById(R.id.overlay_subtitle);
+ final TextView titleView = (TextView) findViewById(R.id.overlay_title);
+ final TextView subTitleView = (TextView) findViewById(R.id.overlay_subtitle);
final Bundle attributes = MovieOverlay.buildUserAttributes(mOverlayType,
titleView.getText().toString(), subTitleView.getText().toString());
-
extras.putExtra(PARAM_OVERLAY_ATTRIBUTES, attributes);
+
setResult(RESULT_OK, extras);
finish();
break;
@@ -142,12 +178,4 @@ public class OverlayTitleActivity extends Activity {
}
}
}
-
- /*
- * {@inheritDoc}
- */
- @Override
- public boolean onSearchRequested() {
- return false;
- }
}
diff --git a/src/com/android/videoeditor/OverlayTitleTemplatePicker.java b/src/com/android/videoeditor/OverlayTitleTemplatePicker.java
new file mode 100644
index 0000000..436bfb7
--- /dev/null
+++ b/src/com/android/videoeditor/OverlayTitleTemplatePicker.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2011 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.videoeditor;
+
+import android.app.ListActivity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ListView;
+
+import com.android.videoeditor.service.MovieOverlay;
+
+
+public class OverlayTitleTemplatePicker extends ListActivity {
+ // Incoming parameter keys.
+ public static final String PARAM_MEDIA_ITEM_ID = "media_item_id";
+ public static final String PARAM_OVERLAY_ATTRIBUTES = "attributes";
+ public static final String PARAM_OVERLAY_ID = "overlay_id";
+
+ private OverlaysAdapter mAdapter;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.list_view);
+ setFinishOnTouchOutside(true);
+
+ // Create the list adapter
+ mAdapter = new OverlaysAdapter(this, getListView());
+ setListAdapter(mAdapter);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+
+ if (mAdapter != null) {
+ mAdapter.onPause();
+ }
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+
+ if (mAdapter != null) {
+ mAdapter.onDestroy();
+ }
+ }
+
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ // Put selected overlay type into extras and finish.
+ final Intent extras = new Intent();
+ final int overlayType = ((OverlayType) mAdapter.getItem(position)).getType();
+ final Bundle bundle = MovieOverlay.buildUserAttributes(overlayType, "", "");
+ extras.putExtra(PARAM_OVERLAY_ATTRIBUTES, bundle);
+ setResult(RESULT_OK, extras);
+ finish();
+ }
+
+ @Override
+ public boolean onSearchRequested() {
+ return false;
+ }
+}
diff --git a/src/com/android/videoeditor/OverlaysActivity.java b/src/com/android/videoeditor/OverlaysActivity.java
deleted file mode 100755
index 85c1d8b..0000000
--- a/src/com/android/videoeditor/OverlaysActivity.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.videoeditor;
-
-import android.app.ListActivity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ListView;
-
-import com.android.videoeditor.service.MovieOverlay;
-
-/**
- * The overlays activity
- */
-public class OverlaysActivity extends ListActivity {
- // Input overlay category
- public static final String PARAM_MEDIA_ITEM_ID = "media_item_id";
- public static final String PARAM_OVERLAY_ATTRIBUTES = "attributes";
- public static final String PARAM_OVERLAY_ID = "overlay_id";
-
- // Request code ids
- private static final int REQUEST_CODE_SET_TITLE = 1;
-
- // Instance variables
- private OverlaysAdapter mAdapter;
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.list_view);
- setFinishOnTouchOutside(true);
-
- // Create the list adapter
- mAdapter = new OverlaysAdapter(this, getListView());
- setListAdapter(mAdapter);
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void onPause() {
- super.onPause();
-
- if (mAdapter != null) {
- mAdapter.onPause();
- }
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void onDestroy() {
- super.onDestroy();
-
- if (mAdapter != null) {
- mAdapter.onDestroy();
- }
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
- final Intent intent = new Intent(this, OverlayTitleActivity.class);
- intent.putExtra(OverlayTitleActivity.PARAM_MEDIA_ITEM_ID,
- getIntent().getStringExtra(PARAM_MEDIA_ITEM_ID));
-
- final int type = ((OverlayType)mAdapter.getItem(position)).getType();
- final Bundle bundle = getIntent().getBundleExtra(PARAM_OVERLAY_ATTRIBUTES);
- if (bundle != null) {
- intent.putExtra(OverlayTitleActivity.PARAM_OVERLAY_ATTRIBUTES,
- MovieOverlay.buildUserAttributes(type,
- MovieOverlay.getTitle(bundle), MovieOverlay.getSubtitle(bundle)));
- } else {
- intent.putExtra(OverlayTitleActivity.PARAM_OVERLAY_ATTRIBUTES,
- MovieOverlay.buildUserAttributes(type, null, null));
- }
-
- final String overlayId = getIntent().getStringExtra(PARAM_OVERLAY_ID);
- if (overlayId != null) {
- intent.putExtra(OverlayTitleActivity.PARAM_OVERLAY_ID, overlayId);
- }
-
- startActivityForResult(intent, REQUEST_CODE_SET_TITLE);
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent extras) {
- super.onActivityResult(requestCode, resultCode, extras);
- if (resultCode == RESULT_CANCELED) {
- return;
- }
-
- switch (requestCode) {
- case REQUEST_CODE_SET_TITLE: {
- // Release the adapter now
- mAdapter.onDestroy();
- mAdapter = null;
-
- setResult(RESULT_OK, extras);
- finish();
- break;
- }
-
- default: {
- break;
- }
- }
- }
-
- /*
- * {@inheritDoc}
- */
- @Override
- public boolean onSearchRequested() {
- return false;
- }
-}
diff --git a/src/com/android/videoeditor/VideoEditorActivity.java b/src/com/android/videoeditor/VideoEditorActivity.java
index 45aeff5..43d46eb 100755
--- a/src/com/android/videoeditor/VideoEditorActivity.java
+++ b/src/com/android/videoeditor/VideoEditorActivity.java
@@ -48,6 +48,7 @@ import android.util.Log;
import android.view.Display;
import android.view.GestureDetector;
import android.view.Menu;
+import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
@@ -69,6 +70,7 @@ import com.android.videoeditor.util.MediaItemUtils;
import com.android.videoeditor.util.StringUtils;
import com.android.videoeditor.widgets.AudioTrackLinearLayout;
import com.android.videoeditor.widgets.MediaLinearLayout;
+import com.android.videoeditor.widgets.MediaLinearLayoutListener;
import com.android.videoeditor.widgets.OverlayLinearLayout;
import com.android.videoeditor.widgets.PlayheadView;
import com.android.videoeditor.widgets.PreviewSurfaceView;
@@ -83,7 +85,6 @@ import com.android.videoeditor.widgets.ZoomControl;
*/
public class VideoEditorActivity extends VideoEditorBaseActivity
implements SurfaceHolder.Callback {
- // Logging
private static final String TAG = "VideoEditorActivity";
// State keys
@@ -91,19 +92,6 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
private static final String STATE_PLAYING = "playing";
private static final String STATE_CAPTURE_URI = "capture_uri";
- // Menu ids
- private static final int MENU_IMPORT_IMAGE_ID = 2;
- private static final int MENU_IMPORT_VIDEO_ID = 3;
- private static final int MENU_IMPORT_AUDIO_ID = 4;
- private static final int MENU_CHANGE_ASPECT_RATIO_ID = 5;
- private static final int MENU_EDIT_PROJECT_NAME_ID = 6;
- private static final int MENU_DELETE_PROJECT_ID = 7;
- private static final int MENU_EXPORT_MOVIE_ID = 8;
- private static final int MENU_PLAY_EXPORTED_MOVIE = 9;
- private static final int MENU_SHARE_VIDEO = 10;
- private static final int MENU_CAPTURE_VIDEO_ID = 11;
- private static final int MENU_CAPTURE_IMAGE_ID = 12;
-
// Dialog ids
private static final int DIALOG_DELETE_PROJECT_ID = 1;
private static final int DIALOG_EDIT_PROJECT_NAME_ID = 2;
@@ -131,9 +119,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
public static final int REQUEST_CODE_EDIT_TRANSITION = 10;
public static final int REQUEST_CODE_PICK_TRANSITION = 11;
public static final int REQUEST_CODE_PICK_OVERLAY = 12;
- public static final int REQUEST_CODE_EDIT_OVERLAY = 13;
- public static final int REQUEST_CODE_PICK_EFFECT = 14;
- public static final int REQUEST_CODE_EDIT_EFFECT = 15;
+ public static final int REQUEST_CODE_KEN_BURNS = 13;
// The maximum zoom level
private static final int MAX_ZOOM_LEVEL = 120;
@@ -148,7 +134,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
@Override
public void onLayoutComplete() {
// Scroll the timeline such that the specified position
- // is in the center of the screen
+ // is in the center of the screen.
mTimelineScroller.appScrollTo(timeToDimension(mProject.getPlayheadPos()), false);
}
};
@@ -195,10 +181,6 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
private int mAddEffectType;
private Rect mAddKenBurnsStartRect;
private Rect mAddKenBurnsEndRect;
- private String mEditEffectMediaItemId;
- private int mEditEffectType;
- private Rect mEditKenBurnsStartRect;
- private Rect mEditKenBurnsEndRect;
private boolean mRestartPreview;
private Uri mCaptureMediaUri;
@@ -242,7 +224,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
actionBar.setDisplayHomeAsUpEnabled(true);
- mMediaLayout.setListener(new MediaLinearLayout.MediaLayoutListener() {
+ mMediaLayout.setListener(new MediaLinearLayoutListener() {
@Override
public void onRequestScrollBy(int scrollBy, boolean smooth) {
mTimelineScroller.appScrollBy(scrollBy, smooth);
@@ -271,7 +253,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
@Override
public void onTrimMediaItem(MovieMediaItem mediaItem, long timeMs) {
updateTimelineDuration();
- if (mProject != null && mPreviewThread != null && !mPreviewThread.isPlaying()) {
+ if (mProject != null && isPreviewPlaying()) {
if (mediaItem.isVideoClip()) {
if (timeMs >= 0) {
mPreviewThread.renderMediaItemFrame(mediaItem, timeMs);
@@ -288,7 +270,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
public void onTrimMediaItemEnd(MovieMediaItem mediaItem, long timeMs) {
onProjectEditStateChange(false);
// We need to repaint the timeline layout to clear the old
- // playhead position (the one drawn during trimming)
+ // playhead position (the one drawn during trimming).
mTimelineLayout.invalidate();
showPreviewFrame();
}
@@ -421,7 +403,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
- if (mPreviewThread != null && mPreviewThread.isPlaying()) {
+ if (isPreviewPlaying()) {
return false;
}
@@ -432,7 +414,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
- if (mPreviewThread != null && mPreviewThread.isPlaying()) {
+ if (isPreviewPlaying()) {
return false;
}
@@ -458,6 +440,14 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
}
@Override
+ public void onStart() {
+ super.onStart();
+
+ ActionBar actionBar = this.getActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ }
+
+ @Override
public void onPause() {
super.onPause();
@@ -484,73 +474,47 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
super.onSaveInstanceState(outState);
outState.putString(STATE_INSERT_AFTER_MEDIA_ITEM_ID, mInsertMediaItemAfterMediaItemId);
- outState.putBoolean(STATE_PLAYING,
- mPreviewThread != null ? mPreviewThread.isPlaying() : false);
+ outState.putBoolean(STATE_PLAYING, isPreviewPlaying());
outState.putParcelable(STATE_CAPTURE_URI, mCaptureMediaUri);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(Menu.NONE, MENU_CAPTURE_VIDEO_ID, Menu.NONE,
- R.string.editor_capture_video).setIcon(
- R.drawable.ic_menu_video_camera).setShowAsAction(
- MenuItem.SHOW_AS_ACTION_ALWAYS);
- menu.add(Menu.NONE, MENU_CAPTURE_IMAGE_ID, Menu.NONE,
- R.string.editor_capture_image).setIcon(
- R.drawable.ic_menu_camera).setShowAsAction(
- MenuItem.SHOW_AS_ACTION_ALWAYS);
- menu.add(Menu.NONE, MENU_IMPORT_VIDEO_ID, Menu.NONE,
- R.string.editor_import_video).setIcon(
- R.drawable.ic_menu_add_video).setShowAsAction(
- MenuItem.SHOW_AS_ACTION_ALWAYS);
- menu.add(Menu.NONE, MENU_IMPORT_IMAGE_ID, Menu.NONE,
- R.string.editor_import_image).setIcon(
- R.drawable.ic_menu_add_image).setShowAsAction(
- MenuItem.SHOW_AS_ACTION_ALWAYS);
- menu.add(Menu.NONE, MENU_IMPORT_AUDIO_ID, Menu.NONE, R.string.editor_import_audio).setIcon(
- R.drawable.ic_menu_add_audio_clip);
- menu.add(Menu.NONE, MENU_CHANGE_ASPECT_RATIO_ID, Menu.NONE,
- R.string.editor_change_aspect_ratio);
- menu.add(Menu.NONE, MENU_EDIT_PROJECT_NAME_ID, Menu.NONE,
- R.string.editor_edit_project_name);
- menu.add(Menu.NONE, MENU_EXPORT_MOVIE_ID, Menu.NONE, R.string.editor_export_movie);
- menu.add(Menu.NONE, MENU_PLAY_EXPORTED_MOVIE, Menu.NONE,
- R.string.editor_play_exported_movie);
- menu.add(Menu.NONE, MENU_SHARE_VIDEO, Menu.NONE, R.string.editor_share_movie);
- menu.add(Menu.NONE, MENU_DELETE_PROJECT_ID, Menu.NONE, R.string.editor_delete_project);
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.action_bar_menu, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
- final boolean haveProject = mProject != null;
+ final boolean haveProject = (mProject != null);
final boolean haveMediaItems = haveProject && mProject.getMediaItemCount() > 0;
- menu.findItem(MENU_CAPTURE_VIDEO_ID).setVisible(haveProject);
- menu.findItem(MENU_CAPTURE_IMAGE_ID).setVisible(haveProject);
- menu.findItem(MENU_IMPORT_VIDEO_ID).setVisible(haveProject);
- menu.findItem(MENU_IMPORT_IMAGE_ID).setVisible(haveProject);
- menu.findItem(MENU_IMPORT_AUDIO_ID).setVisible(haveProject &&
+ menu.findItem(R.id.menu_item_capture_video).setVisible(haveProject);
+ menu.findItem(R.id.menu_item_capture_image).setVisible(haveProject);
+ menu.findItem(R.id.menu_item_import_video).setVisible(haveProject);
+ menu.findItem(R.id.menu_item_import_image).setVisible(haveProject);
+ menu.findItem(R.id.menu_item_import_audio).setVisible(haveProject &&
mProject.getAudioTracks().size() == 0 && haveMediaItems);
- menu.findItem(MENU_CHANGE_ASPECT_RATIO_ID).setVisible(haveProject &&
+ menu.findItem(R.id.menu_item_change_aspect_ratio).setVisible(haveProject &&
mProject.hasMultipleAspectRatios());
- menu.findItem(MENU_EDIT_PROJECT_NAME_ID).setVisible(haveProject);
+ menu.findItem(R.id.menu_item_edit_project_name).setVisible(haveProject);
- // Check if there is an operation pending or preview is on
+ // Check if there is an operation pending or preview is on.
boolean enableMenu = haveProject;
if (enableMenu && mPreviewThread != null) {
// Preview is in progress
enableMenu = mPreviewThread.isStopped();
if (enableMenu && mProjectPath != null) {
- enableMenu = !ApiService.isProjectEdited(mProjectPath);
+ enableMenu = !ApiService.isProjectBeingEdited(mProjectPath);
}
}
- menu.findItem(MENU_EXPORT_MOVIE_ID).setVisible(enableMenu && haveMediaItems);
- menu.findItem(MENU_PLAY_EXPORTED_MOVIE).setVisible(enableMenu &&
+ menu.findItem(R.id.menu_item_export_movie).setVisible(enableMenu && haveMediaItems);
+ menu.findItem(R.id.menu_item_delete_project).setVisible(enableMenu);
+ menu.findItem(R.id.menu_item_play_exported_movie).setVisible(enableMenu &&
mProject.getExportedMovieUri() != null);
- menu.findItem(MENU_SHARE_VIDEO).setVisible(enableMenu &&
+ menu.findItem(R.id.menu_item_share_movie).setVisible(enableMenu &&
mProject.getExportedMovieUri() != null);
- menu.findItem(MENU_DELETE_PROJECT_ID).setVisible(enableMenu);
return true;
}
@@ -558,15 +522,15 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home: {
+ // Returns to project picker if user clicks on the app icon in the action bar.
final Intent intent = new Intent(this, ProjectsActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
-
finish();
return true;
}
- case MENU_CAPTURE_VIDEO_ID: {
+ case R.id.menu_item_capture_video: {
final MovieMediaItem mediaItem = mProject.getInsertAfterMediaItem(
mProject.getPlayheadPos());
if (mediaItem != null) {
@@ -586,7 +550,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
return true;
}
- case MENU_CAPTURE_IMAGE_ID: {
+ case R.id.menu_item_capture_image: {
final MovieMediaItem mediaItem = mProject.getInsertAfterMediaItem(
mProject.getPlayheadPos());
if (mediaItem != null) {
@@ -606,7 +570,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
return true;
}
- case MENU_IMPORT_VIDEO_ID: {
+ case R.id.menu_item_import_video: {
final MovieMediaItem mediaItem = mProject.getInsertAfterMediaItem(
mProject.getPlayheadPos());
if (mediaItem != null) {
@@ -622,7 +586,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
return true;
}
- case MENU_IMPORT_IMAGE_ID: {
+ case R.id.menu_item_import_image: {
final MovieMediaItem mediaItem = mProject.getInsertAfterMediaItem(
mProject.getPlayheadPos());
if (mediaItem != null) {
@@ -638,14 +602,14 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
return true;
}
- case MENU_IMPORT_AUDIO_ID: {
+ case R.id.menu_item_import_audio: {
final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("audio/*");
startActivityForResult(intent, REQUEST_CODE_IMPORT_MUSIC);
return true;
}
- case MENU_CHANGE_ASPECT_RATIO_ID: {
+ case R.id.menu_item_change_aspect_ratio: {
final ArrayList<Integer> aspectRatiosList = mProject.getUniqueAspectRatiosList();
final int size = aspectRatiosList.size();
if (size > 1) {
@@ -668,24 +632,24 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
return true;
}
- case MENU_EDIT_PROJECT_NAME_ID: {
+ case R.id.menu_item_edit_project_name: {
showDialog(DIALOG_EDIT_PROJECT_NAME_ID);
return true;
}
- case MENU_DELETE_PROJECT_ID: {
+ case R.id.menu_item_delete_project: {
// Confirm project delete
showDialog(DIALOG_DELETE_PROJECT_ID);
return true;
}
- case MENU_EXPORT_MOVIE_ID: {
+ case R.id.menu_item_export_movie: {
// Present the user with a dialog to choose export options
showDialog(DIALOG_EXPORT_OPTIONS_ID);
return true;
}
- case MENU_PLAY_EXPORTED_MOVIE: {
+ case R.id.menu_item_play_exported_movie: {
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(mProject.getExportedMovieUri(), "video/*");
intent.putExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION, false);
@@ -693,7 +657,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
return true;
}
- case MENU_SHARE_VIDEO: {
+ case R.id.menu_item_share_movie: {
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, mProject.getExportedMovieUri());
intent.setType("video/*");
@@ -925,8 +889,11 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
}
}
- /*
- * {@inheritDoc}
+
+ /**
+ * Called when user clicks on the button in the control panel.
+ * @param target one of the "play", "rewind", "next",
+ * and "prev" buttons in the control panel
*/
public void onClickHandler(View target) {
final long playheadPosMs = mProject.getPlayheadPos();
@@ -936,7 +903,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
if (mProject != null && mPreviewThread != null) {
if (mPreviewThread.isPlaying()) {
mPreviewThread.stopPreviewPlayback();
- } else if (mProject.getMediaItemCount() > 0){
+ } else if (mProject.getMediaItemCount() > 0) {
mPreviewThread.startPreviewPlayback(mProject, playheadPosMs);
}
}
@@ -1165,85 +1132,58 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
}
case REQUEST_CODE_PICK_OVERLAY: {
+ // If there is no overlay id, it means we are adding a new overlay.
+ // Otherwise we generate a unique new id for the new overlay.
final String mediaItemId =
- extras.getStringExtra(OverlayTitleActivity.PARAM_MEDIA_ITEM_ID);
+ extras.getStringExtra(OverlayTitleEditor.PARAM_MEDIA_ITEM_ID);
+ final String overlayId =
+ extras.getStringExtra(OverlayTitleEditor.PARAM_OVERLAY_ID);
final Bundle bundle =
- extras.getBundleExtra(OverlayTitleActivity.PARAM_OVERLAY_ATTRIBUTES);
+ extras.getBundleExtra(OverlayTitleEditor.PARAM_OVERLAY_ATTRIBUTES);
if (mProject != null) {
final MovieMediaItem mediaItem = mProject.getMediaItem(mediaItemId);
if (mediaItem != null) {
- ApiService.addOverlay(this, mProject.getPath(), mediaItemId,
- ApiService.generateId(), bundle,
- mediaItem.getAppBoundaryBeginTime(),
- OverlayLinearLayout.DEFAULT_TITLE_DURATION);
+ if (overlayId == null) {
+ ApiService.addOverlay(this, mProject.getPath(), mediaItemId,
+ ApiService.generateId(), bundle,
+ mediaItem.getAppBoundaryBeginTime(),
+ OverlayLinearLayout.DEFAULT_TITLE_DURATION);
+ } else {
+ ApiService.setOverlayUserAttributes(this, mProject.getPath(),
+ mediaItemId, overlayId, bundle);
+ }
mOverlayLayout.invalidateCAB();
}
} else {
- // Add this overlay after you load the project
+ // Add this overlay after you load the project.
mAddOverlayMediaItemId = mediaItemId;
mAddOverlayUserAttributes = bundle;
- }
- break;
- }
-
- case REQUEST_CODE_EDIT_OVERLAY: {
- final Bundle bundle =
- extras.getBundleExtra(OverlayTitleActivity.PARAM_OVERLAY_ATTRIBUTES);
- final String mediaItemId =
- extras.getStringExtra(OverlayTitleActivity.PARAM_MEDIA_ITEM_ID);
- final String overlayId =
- extras.getStringExtra(OverlayTitleActivity.PARAM_OVERLAY_ID);
- if (mProject != null) {
- ApiService.setOverlayUserAttributes(this, mProject.getPath(), mediaItemId,
- overlayId, bundle);
- mOverlayLayout.invalidateCAB();
- } else {
- // Edit this overlay after you load the project
- mEditOverlayMediaItemId = mediaItemId;
mEditOverlayId = overlayId;
- mEditOverlayUserAttributes = bundle;
}
break;
}
- case REQUEST_CODE_PICK_EFFECT: {
- final String mediaItemId =
- extras.getStringExtra(EffectsActivity.PARAM_MEDIA_ITEM_ID);
- final int type = extras.getIntExtra(EffectsActivity.PARAM_EFFECT_TYPE,
- EffectType.EFFECT_COLOR_GRADIENT);
- final Rect startRect = extras.getParcelableExtra(EffectsActivity.PARAM_START_RECT);
- final Rect endRect = extras.getParcelableExtra(EffectsActivity.PARAM_END_RECT);
+ case REQUEST_CODE_KEN_BURNS: {
+ final String mediaItemId = extras.getStringExtra(
+ KenBurnsActivity.PARAM_MEDIA_ITEM_ID);
+ final Rect startRect = extras.getParcelableExtra(
+ KenBurnsActivity.PARAM_START_RECT);
+ final Rect endRect = extras.getParcelableExtra(
+ KenBurnsActivity.PARAM_END_RECT);
if (mProject != null) {
- mMediaLayout.addEffect(type, mediaItemId, startRect, endRect);
+ mMediaLayout.addEffect(EffectType.EFFECT_KEN_BURNS, mediaItemId,
+ startRect, endRect);
+ mMediaLayout.invalidateActionBar();
} else {
- // Add this effect after you load the project
+ // Add this effect after you load the project.
mAddEffectMediaItemId = mediaItemId;
- mAddEffectType = type;
+ mAddEffectType = EffectType.EFFECT_KEN_BURNS;
mAddKenBurnsStartRect = startRect;
mAddKenBurnsEndRect = endRect;
}
break;
}
- case REQUEST_CODE_EDIT_EFFECT: {
- final String mediaItemId =
- extras.getStringExtra(EffectsActivity.PARAM_MEDIA_ITEM_ID);
- final int type = extras.getIntExtra(EffectsActivity.PARAM_EFFECT_TYPE,
- EffectType.EFFECT_COLOR_GRADIENT);
- final Rect startRect = extras.getParcelableExtra(EffectsActivity.PARAM_START_RECT);
- final Rect endRect = extras.getParcelableExtra(EffectsActivity.PARAM_END_RECT);
- if (mProject != null) {
- mMediaLayout.editEffect(type, mediaItemId, startRect, endRect);
- } else {
- // Add this effect after you load the project
- mEditEffectMediaItemId = mediaItemId;
- mEditEffectType = type;
- mEditKenBurnsStartRect = startRect;
- mEditKenBurnsEndRect = endRect;
- }
- break;
- }
-
default: {
break;
}
@@ -1252,20 +1192,15 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
@Override
public void surfaceCreated(SurfaceHolder holder) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "surfaceCreated");
- }
+ logd("surfaceCreated");
mPreviewThread = new PreviewThread(mSurfaceHolder);
-
restartPreview();
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "surfaceChanged: " + width + "x" + height);
- }
+ logd("surfaceChanged: " + width + "x" + height);
if (mPreviewThread != null) {
mPreviewThread.onSurfaceChanged(width, height);
@@ -1274,9 +1209,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "surfaceDestroyed");
- }
+ logd("surfaceDestroyed");
// Stop the preview playback if pending and quit the preview thread
if (mPreviewThread != null) {
@@ -1314,7 +1247,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
@Override
protected boolean showPreviewFrame() {
- if (mPreviewThread == null) { // The surface is not ready
+ if (mPreviewThread == null) { // The surface is not ready yet.
return false;
}
@@ -1476,9 +1409,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
}
}
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "setAspectRatio: " + aspectRatio + ", size: " + lp.width + "x" + lp.height);
- }
+ logd("setAspectRatio: " + aspectRatio + ", size: " + lp.width + "x" + lp.height);
mSurfaceView.setLayoutParams(lp);
mOverlayView.setLayoutParams(lp);
}
@@ -1515,9 +1446,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
@Override
protected void onProjectEditStateChange(boolean projectEdited) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "onProjectEditStateChange: " + projectEdited);
- }
+ logd("onProjectEditStateChange: " + projectEdited);
mPreviewPlayButton.setAlpha(projectEdited ? 100 : 255);
mPreviewPlayButton.setEnabled(!projectEdited);
@@ -1525,15 +1454,13 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
mPreviewNextButton.setEnabled(!projectEdited);
mPreviewPrevButton.setEnabled(!projectEdited);
- mMediaLayout.invalidateCAB();
+ mMediaLayout.invalidateActionBar();
mOverlayLayout.invalidateCAB();
}
@Override
protected void initializeFromProject(boolean updateUI) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Project was clean: " + mProject.isClean());
- }
+ logd("Project was clean: " + mProject.isClean());
if (updateUI || !mProject.isClean()) {
getActionBar().setTitle(mProject.getName());
@@ -1644,12 +1571,6 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
mAddEffectMediaItemId = null;
}
- if (mEditEffectMediaItemId != null) {
- mMediaLayout.editEffect(mEditEffectType, mEditEffectMediaItemId,
- mEditKenBurnsStartRect, mEditKenBurnsEndRect);
- mEditEffectMediaItemId = null;
- }
-
enterReadyState();
if (mPendingExportFilename != null) {
@@ -1737,6 +1658,13 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
mExportProgressDialog = null;
}
+ private boolean isPreviewPlaying() {
+ if (mPreviewThread == null)
+ return false;
+
+ return mPreviewThread.isPlaying();
+ }
+
/**
* The preview thread
*/
@@ -1800,9 +1728,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
stopPreviewPlayback();
}
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Preview frame at: " + timeMs + " " + clear);
- }
+ logd("Preview frame at: " + timeMs + " " + clear);
// We only need to see the last frame
mQueue.clear();
@@ -1838,10 +1764,8 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
try {
if (project.renderPreviewFrame(mSurfaceHolder, timeMs, overlayData)
< 0) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Cannot render preview frame at: " + timeMs +
- " of " + mProject.computeDuration());
- }
+ logd("Cannot render preview frame at: " + timeMs +
+ " of " + mProject.computeDuration());
mOverlayDataQueue.add(overlayData);
} else {
@@ -1867,9 +1791,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
}
}
} catch (Exception ex) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "renderPreviewFrame failed at timeMs: " + timeMs, ex);
- }
+ logd("renderPreviewFrame failed at timeMs: " + timeMs + "\n" + ex);
mOverlayDataQueue.add(overlayData);
}
}
@@ -1905,15 +1827,11 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
try {
if (mProject.renderMediaItemFrame(mSurfaceHolder, mediaItem.getId(),
timeMs) < 0) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Cannot render media item frame at: " + timeMs +
- " of " + mediaItem.getDuration());
+ logd("Cannot render media item frame at: " + timeMs +
+ " of " + mediaItem.getDuration());
}
- }
} catch (Exception ex) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Cannot render preview frame at: " + timeMs, ex);
- }
+ logd("Cannot render preview frame at: " + timeMs + "\n" + ex);
}
}
});
@@ -1931,16 +1849,12 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
*/
private void startPreviewPlayback(final VideoEditorProject project, final long fromMs) {
if (mPreviewState != PREVIEW_STATE_STOPPED) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Preview did not start: " + mPreviewState);
- }
+ logd("Preview did not start: " + mPreviewState);
return;
}
previewStarted(project);
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Start preview at: " + fromMs);
- }
+ logd("Start preview at: " + fromMs);
// Clear any pending preview frames
mQueue.clear();
@@ -2001,9 +1915,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
// This exception may occur when trying to play frames
// at the end of the timeline
// (e.g. when fromMs == clip duration)
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Cannot start preview at: " + fromMs, ex);
- }
+ logd("Cannot start preview at: " + fromMs + "\n" + ex);
mMainHandler.post(new Runnable() {
@Override
@@ -2044,30 +1956,23 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
}
/**
- * Stop previewing
+ * Stops the preview.
*/
private void stopPreviewPlayback() {
switch (mPreviewState) {
case PREVIEW_STATE_STOPPED: {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "stopPreviewPlayback: State was PREVIEW_STATE_STOPPED");
- }
+ logd("stopPreviewPlayback: State was PREVIEW_STATE_STOPPED");
return;
}
case PREVIEW_STATE_STOPPING: {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "stopPreviewPlayback: State was PREVIEW_STATE_STOPPING");
- }
+ logd("stopPreviewPlayback: State was PREVIEW_STATE_STOPPING");
return;
}
case PREVIEW_STATE_STARTING: {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "stopPreviewPlayback: State was PREVIEW_STATE_STARTING " +
- "now PREVIEW_STATE_STOPPING");
- }
-
+ logd("stopPreviewPlayback: State was PREVIEW_STATE_STARTING " +
+ "now PREVIEW_STATE_STOPPING");
mPreviewState = PREVIEW_STATE_STOPPING;
// We need to wait until the preview starts
@@ -2076,40 +1981,26 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
public void run() {
if (isFinishing() || isChangingConfigurations()) {
// The activity is shutting down. Force stopping now.
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "stopPreviewPlayback: Activity is shutting down");
- }
-
+ logd("stopPreviewPlayback: Activity is shutting down");
mPreviewState = PREVIEW_STATE_STARTED;
previewStopped(true);
} else if (mPreviewState == PREVIEW_STATE_STARTED) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "stopPreviewPlayback: Now PREVIEW_STATE_STARTED");
- }
-
+ logd("stopPreviewPlayback: Now PREVIEW_STATE_STARTED");
previewStopped(false);
} else if (mPreviewState == PREVIEW_STATE_STOPPING) {
// Keep waiting
mMainHandler.postDelayed(this, 100);
-
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "stopPreviewPlayback: Waiting for PREVIEW_STATE_STARTED");
- }
+ logd("stopPreviewPlayback: Waiting for PREVIEW_STATE_STARTED");
} else {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "stopPreviewPlayback: PREVIEW_STATE_STOPPED while waiting");
- }
+ logd("stopPreviewPlayback: PREVIEW_STATE_STOPPED while waiting");
}
}
}, 50);
-
break;
}
case PREVIEW_STATE_STARTED: {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "stopPreviewPlayback: State was PREVIEW_STATE_STARTED");
- }
+ logd("stopPreviewPlayback: State was PREVIEW_STATE_STARTED");
// We need to stop
previewStopped(false);
@@ -2142,9 +2033,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
}
// Create the overlay bitmap
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Overlay size: " + width + " x " + height);
- }
+ logd("Overlay size: " + width + " x " + height);
mOverlayBitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
mOverlayView.setImageBitmap(mOverlayBitmap);
@@ -2172,13 +2061,9 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
// Set the playhead position at the position where the playback stopped
final long stopTimeMs = mProject.stopPreview();
movePlayhead(stopTimeMs);
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "PREVIEW_STATE_STOPPED: " + stopTimeMs);
- }
+ logd("PREVIEW_STATE_STOPPED: " + stopTimeMs);
} else {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "PREVIEW_STATE_STOPPED due to error");
- }
+ logd("PREVIEW_STATE_STOPPED due to error");
}
mPreviewState = PREVIEW_STATE_STOPPED;
@@ -2199,7 +2084,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
*/
private boolean isPlaying() {
return mPreviewState == PREVIEW_STATE_STARTING ||
- mPreviewState == PREVIEW_STATE_STARTED;
+ mPreviewState == PREVIEW_STATE_STARTED;
}
/**
@@ -2229,7 +2114,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
}
/**
- * Quit the thread
+ * Quits the thread
*/
public void quit() {
// Release the overlay bitmap
@@ -2251,4 +2136,10 @@ public class VideoEditorActivity extends VideoEditorBaseActivity
mQueue.clear();
}
}
+
+ private static void logd(String message) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, message);
+ }
+ }
}
diff --git a/src/com/android/videoeditor/VideoEditorBaseActivity.java b/src/com/android/videoeditor/VideoEditorBaseActivity.java
index 37bc0ae..c2dbd7c 100755
--- a/src/com/android/videoeditor/VideoEditorBaseActivity.java
+++ b/src/com/android/videoeditor/VideoEditorBaseActivity.java
@@ -580,7 +580,7 @@ public abstract class VideoEditorBaseActivity extends Activity {
Toast.makeText(VideoEditorBaseActivity.this, R.string.editor_add_overlay_error,
Toast.LENGTH_LONG).show();
} else {
- getMediaLayout().invalidateCAB();
+ getMediaLayout().invalidateActionBar();
getOverlayLayout().addOverlay(mediaItemId, overlay);
}
}
@@ -820,7 +820,7 @@ public abstract class VideoEditorBaseActivity extends Activity {
public void onResume() {
super.onResume();
- mProjectEditState = ApiService.isProjectEdited(mProjectPath);
+ mProjectEditState = ApiService.isProjectBeingEdited(mProjectPath);
onProjectEditStateChange(mProjectEditState);
ApiService.registerListener(mServiceListener);
diff --git a/src/com/android/videoeditor/service/ApiService.java b/src/com/android/videoeditor/service/ApiService.java
index e4ddd14..3988f9a 100755
--- a/src/com/android/videoeditor/service/ApiService.java
+++ b/src/com/android/videoeditor/service/ApiService.java
@@ -433,19 +433,19 @@ public class ApiService extends Service {
}
/**
- * Check if the service is busy modifying the timeline. While
+ * Checks if the service is busy modifying the timeline. While
* the video editor is busy the application should not attempt
* to preview the movie.
*
* @param projectPath The project path
*
- * @return true if the video editor is busy
+ * @return {@code true} if the video editor is modifying the timeline
*/
- public static boolean isProjectEdited(String projectPath) {
+ public static boolean isProjectBeingEdited(String projectPath) {
for (Intent intent : mPendingIntents.values()) {
final int op = intent.getIntExtra(PARAM_OP, -1);
switch (op) {
- // When these operations are pending the video editor is not busy
+ // When these operations are pending the video editor is not busy.
case OP_VIDEO_EDITOR_LOAD_PROJECTS:
case OP_VIDEO_EDITOR_SAVE:
case OP_MEDIA_ITEM_SET_VOLUME:
@@ -1377,7 +1377,7 @@ public class ApiService extends Service {
final String projectPath = intent.getStringExtra(PARAM_PROJECT_PATH);
if (projectPath != null) {
- final boolean projectEdited = isProjectEdited(projectPath);
+ final boolean projectEdited = isProjectBeingEdited(projectPath);
if (projectEdited) {
for (ApiServiceListener listener : mListeners) {
listener.onProjectEditState(projectPath, projectEdited);
@@ -4065,7 +4065,7 @@ public class ApiService extends Service {
final String projectPath = intent.getStringExtra(PARAM_PROJECT_PATH);
if (projectPath != null) {
- final boolean projectEdited = isProjectEdited(projectPath);
+ final boolean projectEdited = isProjectBeingEdited(projectPath);
if (projectEdited == false) {
for (ApiServiceListener listener : mListeners) {
listener.onProjectEditState(projectPath, projectEdited);
diff --git a/src/com/android/videoeditor/service/MovieMediaItem.java b/src/com/android/videoeditor/service/MovieMediaItem.java
index b8c0b16..b9d9565 100755
--- a/src/com/android/videoeditor/service/MovieMediaItem.java
+++ b/src/com/android/videoeditor/service/MovieMediaItem.java
@@ -366,7 +366,7 @@ public class MovieMediaItem {
}
/**
- * @param The begin transition
+ * @param beginTransition Begin transition
*/
void setBeginTransition(MovieTransition beginTransition) {
mBeginTransition = beginTransition;
@@ -380,7 +380,7 @@ public class MovieMediaItem {
}
/**
- * @param The end transition
+ * @param endTransition end transition
*/
void setEndTransition(MovieTransition endTransition) {
mEndTransition = endTransition;
diff --git a/src/com/android/videoeditor/widgets/AudioTrackLinearLayout.java b/src/com/android/videoeditor/widgets/AudioTrackLinearLayout.java
index 60e2ff0..1a66c97 100755
--- a/src/com/android/videoeditor/widgets/AudioTrackLinearLayout.java
+++ b/src/com/android/videoeditor/widgets/AudioTrackLinearLayout.java
@@ -94,9 +94,7 @@ public class AudioTrackLinearLayout extends LinearLayout {
mAudioTrack = audioTrack;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mAudioTrackActionMode = mode;
@@ -117,9 +115,7 @@ public class AudioTrackLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
final View view = mode.getCustomView();
@@ -133,16 +129,12 @@ public class AudioTrackLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.action_duck: {
@@ -170,9 +162,7 @@ public class AudioTrackLinearLayout extends LinearLayout {
}
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
mAudioTrack.setAppVolume(progress);
@@ -181,21 +171,15 @@ public class AudioTrackLinearLayout extends LinearLayout {
}
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onDestroyActionMode(ActionMode mode) {
final View audioTrackView = getAudioTrackView(mAudioTrack.getId());
if (audioTrackView != null) {
@@ -206,16 +190,11 @@ public class AudioTrackLinearLayout extends LinearLayout {
}
}
- /*
- * {@inheritDoc}
- */
public AudioTrackLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mAudioTrackGestureListener = new ItemSimpleGestureListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onSingleTapConfirmed(View view, int area, MotionEvent e) {
if (mPlaybackInProgress) {
return false;
@@ -228,9 +207,7 @@ public class AudioTrackLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onLongPress(View view, MotionEvent e) {
if (mPlaybackInProgress) {
return;
@@ -250,9 +227,7 @@ public class AudioTrackLinearLayout extends LinearLayout {
// Add the beginning timeline item
final View beginView = inflate(getContext(), R.layout.empty_timeline_item, null);
beginView.setOnClickListener(new View.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(View view) {
unselectAllViews();
}
@@ -262,9 +237,7 @@ public class AudioTrackLinearLayout extends LinearLayout {
// Add the end timeline item
final View endView = inflate(context, R.layout.empty_timeline_item, null);
endView.setOnClickListener(new View.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(View view) {
unselectAllViews();
}
@@ -275,9 +248,7 @@ public class AudioTrackLinearLayout extends LinearLayout {
mAddAudioTrackButtonView = inflate(getContext(), R.layout.add_audio_track_button, null);
addView(mAddAudioTrackButtonView, 1);
mAddAudioTrackButtonView.setOnClickListener(new View.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(View view) {
if (mListener != null) {
mListener.onAddAudioTrack();
@@ -297,16 +268,10 @@ public class AudioTrackLinearLayout extends LinearLayout {
setMotionEventSplittingEnabled(false);
}
- /*
- * {@inheritDoc}
- */
public AudioTrackLinearLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- /*
- * {@inheritDoc}
- */
public AudioTrackLinearLayout(Context context) {
this(context, null, 0);
}
@@ -555,9 +520,6 @@ public class AudioTrackLinearLayout extends LinearLayout {
invalidate();
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int childrenCount = getChildCount();
@@ -650,9 +612,7 @@ public class AudioTrackLinearLayout extends LinearLayout {
activity.getString(R.string.editor_remove_audio_track_question),
activity.getString(R.string.yes),
new DialogInterface.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(DialogInterface dialog, int which) {
if (mAudioTrackActionMode != null) {
mAudioTrackActionMode.finish();
@@ -664,16 +624,12 @@ public class AudioTrackLinearLayout extends LinearLayout {
audioTrack.getId());
}
}, activity.getString(R.string.no), new DialogInterface.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(DialogInterface dialog, int which) {
activity.removeDialog(VideoEditorActivity.DIALOG_REMOVE_AUDIO_TRACK_ID);
}
}, new DialogInterface.OnCancelListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onCancel(DialogInterface dialog) {
activity.removeDialog(VideoEditorActivity.DIALOG_REMOVE_AUDIO_TRACK_ID);
}
@@ -739,9 +695,6 @@ public class AudioTrackLinearLayout extends LinearLayout {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public void setSelected(boolean selected) {
if (selected == false) {
diff --git a/src/com/android/videoeditor/widgets/AudioTrackView.java b/src/com/android/videoeditor/widgets/AudioTrackView.java
index 0440459..022d1cd 100755
--- a/src/com/android/videoeditor/widgets/AudioTrackView.java
+++ b/src/com/android/videoeditor/widgets/AudioTrackView.java
@@ -107,21 +107,15 @@ public class AudioTrackView extends View {
});
mScrollListener = new ScrollViewListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onScrollBegin(View view, int scrollX, int scrollY, boolean appScroll) {
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onScrollProgress(View view, int scrollX, int scrollY, boolean appScroll) {
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onScrollEnd(View view, int scrollX, int scrollY, boolean appScroll) {
mScrollX = scrollX;
invalidate();
@@ -138,23 +132,14 @@ public class AudioTrackView extends View {
mProgress = -1;
}
- /*
- * {@inheritDoc}
- */
public AudioTrackView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- /*
- * {@inheritDoc}
- */
public AudioTrackView(Context context) {
this(context, null, 0);
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onAttachedToWindow() {
final TimelineHorizontalScrollView scrollView =
@@ -163,9 +148,6 @@ public class AudioTrackView extends View {
scrollView.addScrollListener(mScrollListener);
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onDetachedFromWindow() {
final TimelineHorizontalScrollView scrollView =
@@ -303,9 +285,6 @@ public class AudioTrackView extends View {
return mWaveformData;
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
@@ -359,9 +338,6 @@ public class AudioTrackView extends View {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public boolean onTouchEvent(MotionEvent ev) {
// Let the gesture detector inspect all events.
diff --git a/src/com/android/videoeditor/widgets/EditorRelativeLayout.java b/src/com/android/videoeditor/widgets/EditorRelativeLayout.java
index 990bf01..6772b3d 100755
--- a/src/com/android/videoeditor/widgets/EditorRelativeLayout.java
+++ b/src/com/android/videoeditor/widgets/EditorRelativeLayout.java
@@ -39,23 +39,15 @@ public class EditorRelativeLayout extends RelativeLayout implements View.OnClick
setOnClickListener(this);
}
- /*
- * {@inheritDoc}
- */
public EditorRelativeLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- /*
- * {@inheritDoc}
- */
public EditorRelativeLayout(Context context) {
this(context, null, 0);
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(View view) {
findViewById(R.id.timeline).setSelected(false);
}
diff --git a/src/com/android/videoeditor/widgets/ImageViewTouchBase.java b/src/com/android/videoeditor/widgets/ImageViewTouchBase.java
index 5383ed9..ababd71 100755
--- a/src/com/android/videoeditor/widgets/ImageViewTouchBase.java
+++ b/src/com/android/videoeditor/widgets/ImageViewTouchBase.java
@@ -183,6 +183,7 @@ public class ImageViewTouchBase extends ImageView {
final int viewWidth = getWidth();
if (viewWidth <= 0) {
mOnLayoutRunnable = new Runnable() {
+ @Override
public void run() {
setImageBitmapResetBase(bitmap, resetSupp);
}
@@ -248,8 +249,6 @@ public class ImageViewTouchBase extends ImageView {
/**
* @param rect The input/output rectangle
- *
- * @return The transform matrix
*/
public void mapRect(RectF rect) {
mSuppMatrix.mapRect(rect);
diff --git a/src/com/android/videoeditor/widgets/MediaItemView.java b/src/com/android/videoeditor/widgets/MediaItemView.java
index 42ac0db..feacef1 100755
--- a/src/com/android/videoeditor/widgets/MediaItemView.java
+++ b/src/com/android/videoeditor/widgets/MediaItemView.java
@@ -82,27 +82,18 @@ public class MediaItemView extends View {
// Instance variables
private final Drawable mFrame;
- /*
- * {@inheritDoc}
- */
public MediaItemShadowBuilder(View view) {
super(view);
mFrame = view.getContext().getResources().getDrawable(R.drawable.timeline_item_pressed);
}
- /*
- * {@inheritDoc}
- */
@Override
public void onProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) {
shadowSize.set(getShadowWidth(), getShadowHeight());
shadowTouchPoint.set(shadowSize.x / 2, shadowSize.y);
}
- /*
- * {@inheritDoc}
- */
@Override
public void onDrawShadow(Canvas canvas) {
//super.onDrawShadow(canvas);
@@ -116,18 +107,12 @@ public class MediaItemView extends View {
}
}
- /*
- * {@inheritDoc}
- */
public MediaItemView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// Setup the gesture listener
mGestureDetector = new GestureDetector(context,
new GestureDetector.SimpleOnGestureListener() {
- /*
- * {@inheritDoc}
- */
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
if (mGestureListener == null) {
@@ -156,9 +141,6 @@ public class MediaItemView extends View {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public void onLongPress (MotionEvent e) {
if (mGestureListener != null) {
@@ -168,24 +150,18 @@ public class MediaItemView extends View {
});
mScrollListener = new ScrollViewListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onScrollBegin(View view, int scrollX, int scrollY, boolean appScroll) {
mIsScrolling = true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onScrollProgress(View view, int scrollX, int scrollY, boolean appScroll) {
mScrollingX = scrollX;
invalidate();
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onScrollEnd(View view, int scrollX, int scrollY, boolean appScroll) {
mIsScrolling = false;
mScrollX = scrollX;
@@ -231,23 +207,14 @@ public class MediaItemView extends View {
mRightState = View.EMPTY_STATE_SET;
}
- /*
- * {@inheritDoc}
- */
public MediaItemView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- /*
- * {@inheritDoc}
- */
public MediaItemView(Context context) {
this(context, null, 0);
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onAttachedToWindow() {
// Add the horizontal scroll view listener
@@ -257,9 +224,6 @@ public class MediaItemView extends View {
scrollView.addScrollListener(mScrollListener);
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onDetachedFromWindow() {
final TimelineHorizontalScrollView scrollView =
@@ -425,9 +389,6 @@ public class MediaItemView extends View {
return true;
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
@@ -575,9 +536,6 @@ public class MediaItemView extends View {
2 * mAddTransitionDrawable.getIntrinsicWidth());
}
- /*
- * {@inheritDoc}
- */
@Override
public boolean onTouchEvent(MotionEvent ev) {
// Let the gesture detector inspect all events.
diff --git a/src/com/android/videoeditor/widgets/MediaLinearLayout.java b/src/com/android/videoeditor/widgets/MediaLinearLayout.java
index e15d882..c88344c 100755
--- a/src/com/android/videoeditor/widgets/MediaLinearLayout.java
+++ b/src/com/android/videoeditor/widgets/MediaLinearLayout.java
@@ -49,14 +49,15 @@ import android.widget.Toast;
import com.android.videoeditor.AlertDialogs;
import com.android.videoeditor.EffectType;
-import com.android.videoeditor.EffectsActivity;
-import com.android.videoeditor.OverlaysActivity;
+import com.android.videoeditor.KenBurnsActivity;
+import com.android.videoeditor.OverlayTitleEditor;
import com.android.videoeditor.TransitionType;
import com.android.videoeditor.TransitionsActivity;
import com.android.videoeditor.VideoEditorActivity;
import com.android.videoeditor.service.ApiService;
import com.android.videoeditor.service.MovieEffect;
import com.android.videoeditor.service.MovieMediaItem;
+import com.android.videoeditor.service.MovieOverlay;
import com.android.videoeditor.service.MovieTransition;
import com.android.videoeditor.service.VideoEditorProject;
import com.android.videoeditor.util.FileUtils;
@@ -64,7 +65,7 @@ import com.android.videoeditor.util.MediaItemUtils;
import com.android.videoeditor.R;
/**
- * The LinearLayout which holds media items and transitions
+ * LinearLayout which holds media items and transitions.
*/
public class MediaLinearLayout extends LinearLayout {
// Logging
@@ -90,7 +91,7 @@ public class MediaLinearLayout extends LinearLayout {
private final int mHandleWidth;
private final int mTransitionVerticalInset;
private final ImageButton mLeftAddClipButton, mRightAddClipButton;
- private MediaLayoutListener mListener;
+ private MediaLinearLayoutListener mListener;
private ActionMode mMediaItemActionMode;
private ActionMode mTransitionActionMode;
private VideoEditorProject mProject;
@@ -106,108 +107,77 @@ public class MediaLinearLayout extends LinearLayout {
private boolean mFirstEntered;
/**
- * Activity listener
- */
- public interface MediaLayoutListener {
- /**
- * Request scrolling by an offset amount
- *
- * @param scrollBy The amount to scroll
- * @param smooth true to scroll smoothly
- */
- public void onRequestScrollBy(int scrollBy, boolean smooth);
-
- /**
- * Request scrolling to a specified time position
- *
- * @param scrollToTime The scroll position
- * @param smooth true to scroll smoothly
- */
- public void onRequestMovePlayhead(long scrollToTime, boolean smooth);
-
- /**
- * Add a new media item
- *
- * @param afterMediaItemId Add media item after this media item id
- */
- public void onAddMediaItem(String afterMediaItemId);
-
- /**
- * A media item enters trimming mode
- *
- * @param mediaItem The media item
- */
- public void onTrimMediaItemBegin(MovieMediaItem mediaItem);
-
- /**
- * A media item is being trimmed
- *
- * @param mediaItem The media item
- * @param timeMs The time where the trim occurs
- */
- public void onTrimMediaItem(MovieMediaItem mediaItem, long timeMs);
-
- /**
- * A media has been trimmed
- *
- * @param mediaItem The media item
- * @param timeMs The time where the trim occurs
- */
- public void onTrimMediaItemEnd(MovieMediaItem mediaItem, long timeMs);
- };
-
- /**
- * The media item action mode handler
+ * The media item action mode handler.
*/
private class MediaItemActionModeCallback implements ActionMode.Callback {
- // Instance variables
+ // Media item associated with this callback.
private final MovieMediaItem mMediaItem;
- /**
- * Constructor
- *
- * @param mediaItem The media item
- */
public MediaItemActionModeCallback(MovieMediaItem mediaItem) {
mMediaItem = mediaItem;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mMediaItemActionMode = mode;
- final Activity activity = (Activity)getContext();
+ final Activity activity = (Activity) getContext();
activity.getMenuInflater().inflate(R.menu.media_item_mode_menu, menu);
- mode.setTitle(FileUtils.getSimpleName(mMediaItem.getFilename()));
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- final boolean enable = !ApiService.isProjectEdited(mProject.getPath()) &&
+ final boolean enable = !ApiService.isProjectBeingEdited(mProject.getPath()) &&
!mPlaybackInProgress;
- final MenuItem aemi = menu.findItem(R.id.action_add_effect);
- aemi.setVisible(mMediaItem.getEffect() == null);
- aemi.setEnabled(enable);
-
- final MenuItem eemi = menu.findItem(R.id.action_change_effect);
- eemi.setVisible(mMediaItem.getEffect() != null);
- eemi.setEnabled(enable);
-
- final MenuItem remi = menu.findItem(R.id.action_remove_effect);
- remi.setVisible(mMediaItem.getEffect() != null);
- remi.setEnabled(enable);
+ // Pan zoom effect is only for images. Hide it from video clips.
+ MenuItem item;
+ if (!mMediaItem.isImage()) {
+ item = menu.findItem(R.id.action_pan_zoom_effect);
+ item.setVisible(false);
+ item.setEnabled(false);
+ }
+
+ // If the selected media item already has an effect applied on it, check the
+ // corresponding effect menu item.
+ MovieEffect effect = mMediaItem.getEffect();
+ if (effect != null) {
+ switch (mMediaItem.getEffect().getType()) {
+ case EffectType.EFFECT_KEN_BURNS:
+ item = menu.findItem(R.id.action_pan_zoom_effect);
+ break;
+ case EffectType.EFFECT_COLOR_GRADIENT:
+ item = menu.findItem(R.id.action_gradient_effect);
+ break;
+ case EffectType.EFFECT_COLOR_SEPIA:
+ item = menu.findItem(R.id.action_sepia_effect);
+ break;
+ case EffectType.EFFECT_COLOR_NEGATIVE:
+ item = menu.findItem(R.id.action_negative_effect);
+ break;
+ default:
+ item = menu.findItem(R.id.action_no_effect);
+ break;
+ }
+ } else {
+ item = menu.findItem(R.id.action_no_effect);
+ }
+ item.setChecked(true);
+ menu.findItem(R.id.media_item_effect_menu).setEnabled(enable);
+ // Menu item for adding a new overlay. It is also used to edit
+ // existing overlay. We change the displayed text accordingly.
final MenuItem aomi = menu.findItem(R.id.action_add_overlay);
- aomi.setVisible(mMediaItem.getOverlay() == null);
+ aomi.setTitle((mMediaItem.getOverlay() == null) ?
+ R.string.editor_add_overlay : R.string.editor_edit_overlay);
aomi.setEnabled(enable);
+ final MenuItem romi = menu.findItem(R.id.action_remove_overlay);
+ romi.setVisible(mMediaItem.getOverlay() != null);
+ romi.setEnabled(enable);
+
final MenuItem btmi = menu.findItem(R.id.action_add_begin_transition);
btmi.setVisible(mMediaItem.getBeginTransition() == null);
btmi.setEnabled(enable);
@@ -223,39 +193,16 @@ public class MediaLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch (item.getItemId()) {
- case R.id.action_add_effect: {
- if (mMediaItem.isImage()) {
- pickEffect(EffectType.CATEGORY_IMAGE, mMediaItem);
- } else {
- pickEffect(EffectType.CATEGORY_VIDEO, mMediaItem);
- }
- break;
- }
-
- case R.id.action_change_effect: {
- if (mMediaItem.isImage()) {
- editEffect(EffectType.CATEGORY_IMAGE, mMediaItem, mMediaItem.getEffect());
- } else {
- editEffect(EffectType.CATEGORY_VIDEO, mMediaItem, mMediaItem.getEffect());
- }
- break;
- }
-
- case R.id.action_remove_effect: {
- final Bundle bundle = new Bundle();
- bundle.putString(PARAM_DIALOG_MEDIA_ITEM_ID, mMediaItem.getId());
- ((Activity)getContext()).showDialog(
- VideoEditorActivity.DIALOG_REMOVE_EFFECT_ID, bundle);
+ case R.id.action_add_overlay: {
+ editOverlay(mMediaItem);
break;
}
- case R.id.action_add_overlay: {
- pickOverlay(mMediaItem.getId());
+ case R.id.action_remove_overlay: {
+ removeOverlay(mMediaItem);
break;
}
@@ -271,12 +218,30 @@ public class MediaLinearLayout extends LinearLayout {
break;
}
+ case R.id.action_gradient_effect:
+ case R.id.action_sepia_effect:
+ case R.id.action_negative_effect:
+ case R.id.action_pan_zoom_effect: {
+ applyEffect(item);
+ break;
+ }
+
+ case R.id.action_no_effect: {
+ if (!item.isChecked()) {
+ final Bundle bundle = new Bundle();
+ bundle.putString(PARAM_DIALOG_MEDIA_ITEM_ID, mMediaItem.getId());
+ ((Activity) getContext()).showDialog(
+ VideoEditorActivity.DIALOG_REMOVE_EFFECT_ID, bundle);
+ }
+ break;
+ }
+
case R.id.action_rendering_mode: {
final Bundle bundle = new Bundle();
bundle.putString(PARAM_DIALOG_MEDIA_ITEM_ID, mMediaItem.getId());
bundle.putInt(PARAM_DIALOG_CURRENT_RENDERING_MODE,
mMediaItem.getAppRenderingMode());
- ((Activity)getContext()).showDialog(
+ ((Activity) getContext()).showDialog(
VideoEditorActivity.DIALOG_CHANGE_RENDERING_MODE_ID, bundle);
break;
}
@@ -284,7 +249,7 @@ public class MediaLinearLayout extends LinearLayout {
case R.id.action_delete_media_item: {
final Bundle bundle = new Bundle();
bundle.putString(PARAM_DIALOG_MEDIA_ITEM_ID, mMediaItem.getId());
- ((Activity)getContext()).showDialog(
+ ((Activity) getContext()).showDialog(
VideoEditorActivity.DIALOG_REMOVE_MEDIA_ITEM_ID, bundle);
break;
}
@@ -297,9 +262,7 @@ public class MediaLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onDestroyActionMode(ActionMode mode) {
final View mediaItemView = getMediaItemView(mMediaItem.getId());
if (mSelectedView != null) {
@@ -315,43 +278,71 @@ public class MediaLinearLayout extends LinearLayout {
showAddMediaItemButtons(true);
}
+
+ private void applyEffect(MenuItem clickedItem) {
+ if (!clickedItem.isChecked()) {
+ switch(clickedItem.getItemId()) {
+ case R.id.action_gradient_effect:
+ addEffect(EffectType.EFFECT_COLOR_GRADIENT,
+ mMediaItem.getId(), null, null);
+ clickedItem.setChecked(true);
+ break;
+ case R.id.action_sepia_effect:
+ addEffect(EffectType.EFFECT_COLOR_SEPIA,
+ mMediaItem.getId(), null, null);
+ clickedItem.setChecked(true);
+ break;
+ case R.id.action_negative_effect:
+ addEffect(EffectType.EFFECT_COLOR_NEGATIVE,
+ mMediaItem.getId(), null, null);
+ clickedItem.setChecked(true);
+ break;
+ case R.id.action_pan_zoom_effect: {
+ // Note that we don't check the pan zoom checkbox here.
+ // Because pan zoom effect will start a new activity and users
+ // could cancel applying the effect. Once pan zoom effect has
+ // really been applied. The action mode will be invalidated in
+ // onActivityResult() method and the checkbox is then checked.
+ final Intent intent = new Intent(getContext(), KenBurnsActivity.class);
+ intent.putExtra(KenBurnsActivity.PARAM_MEDIA_ITEM_ID, mMediaItem.getId());
+ intent.putExtra(KenBurnsActivity.PARAM_FILENAME, mMediaItem.getFilename());
+ intent.putExtra(KenBurnsActivity.PARAM_WIDTH, mMediaItem.getWidth());
+ intent.putExtra(KenBurnsActivity.PARAM_HEIGHT, mMediaItem.getHeight());
+ ((Activity) getContext()).startActivityForResult(intent,
+ VideoEditorActivity.REQUEST_CODE_KEN_BURNS);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
}
/**
- * The transition action mode handler
+ * The transition action mode handler.
*/
private class TransitionActionModeCallback implements ActionMode.Callback {
- // Instance variables
private final MovieTransition mTransition;
- /**
- * Constructor
- *
- * @param transition The transition
- */
public TransitionActionModeCallback(MovieTransition transition) {
mTransition = transition;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mTransitionActionMode = mode;
- final Activity activity = (Activity)getContext();
+ final Activity activity = (Activity) getContext();
activity.getMenuInflater().inflate(R.menu.transition_mode_menu, menu);
-
mode.setTitle(activity.getString(R.string.editor_transition_title));
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- final boolean enable = !ApiService.isProjectEdited(mProject.getPath()) &&
+ final boolean enable = !ApiService.isProjectBeingEdited(mProject.getPath()) &&
!mPlaybackInProgress;
final MenuItem etmi = menu.findItem(R.id.action_change_transition);
@@ -363,15 +354,13 @@ public class MediaLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch (item.getItemId()) {
case R.id.action_remove_transition: {
final Bundle bundle = new Bundle();
bundle.putString(PARAM_DIALOG_TRANSITION_ID, mTransition.getId());
- ((Activity)getContext()).showDialog(
+ ((Activity) getContext()).showDialog(
VideoEditorActivity.DIALOG_REMOVE_TRANSITION_ID, bundle);
break;
}
@@ -389,9 +378,7 @@ public class MediaLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onDestroyActionMode(ActionMode mode) {
final View transitionView = getTransitionView(mTransition.getId());
if (transitionView != null) {
@@ -404,16 +391,11 @@ public class MediaLinearLayout extends LinearLayout {
}
}
- /*
- * {@inheritDoc}
- */
public MediaLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mMediaItemGestureListener = new ItemSimpleGestureListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onSingleTapConfirmed(View view, int area, MotionEvent e) {
if (mPlaybackInProgress) {
return false;
@@ -449,9 +431,7 @@ public class MediaLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onLongPress(View view, MotionEvent e) {
if (mPlaybackInProgress) {
return;
@@ -474,9 +454,7 @@ public class MediaLinearLayout extends LinearLayout {
};
mTransitionGestureListener = new ItemSimpleGestureListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onSingleTapConfirmed(View view, int area, MotionEvent e) {
if (mPlaybackInProgress) {
return false;
@@ -489,9 +467,7 @@ public class MediaLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onLongPress(View view, MotionEvent e) {
if (mPlaybackInProgress) {
return;
@@ -511,9 +487,7 @@ public class MediaLinearLayout extends LinearLayout {
// Add the beginning timeline item
final View beginView = inflate(getContext(), R.layout.empty_left_timeline_item, null);
beginView.setOnClickListener(new View.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(View view) {
unselectAllViews();
}
@@ -523,9 +497,7 @@ public class MediaLinearLayout extends LinearLayout {
R.id.add_left_media_item_button);
mLeftAddClipButton.setVisibility(View.GONE);
mLeftAddClipButton.setOnClickListener(new View.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(View view) {
if (mProject != null && mProject.getMediaItemCount() > 0) {
unselectAllViews();
@@ -540,20 +512,16 @@ public class MediaLinearLayout extends LinearLayout {
// Add the end timeline item
final View endView = inflate(getContext(), R.layout.empty_right_timeline_item, null);
endView.setOnClickListener(new View.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(View view) {
unselectAllViews();
}
});
- mRightAddClipButton = (ImageButton)endView.findViewById(
+ mRightAddClipButton = (ImageButton) endView.findViewById(
R.id.add_right_media_item_button);
mRightAddClipButton.setOnClickListener(new View.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(View view) {
if (mProject != null) {
unselectAllViews();
@@ -589,52 +557,40 @@ public class MediaLinearLayout extends LinearLayout {
setMotionEventSplittingEnabled(false);
}
- /*
- * {@inheritDoc}
- */
public MediaLinearLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- /*
- * {@inheritDoc}
- */
public MediaLinearLayout(Context context) {
this(context, null, 0);
}
/**
- * The activity was resumed
+ * Called when the containing activity is resumed.
*/
public void onResume() {
- // Invalidate all progress in case the transition generation
- // or Ken Burns effect completed while the activity was be paused.
+ // Invalidate all progress in case the transition generation or
+ // Ken Burns effect completed while the activity was being paused.
final int childrenCount = getChildCount();
for (int i = 0; i < childrenCount; i++) {
final View childView = getChildAt(i);
- final Object tag = childView.getTag();
- if (tag != null) {
- if (tag instanceof MovieMediaItem) {
- ((MediaItemView)childView).setProgress(-1);
- } else if (tag instanceof MovieTransition) {
- ((TransitionView)childView).setProgress(-1);
+ final Object item = childView.getTag();
+ if (item != null) {
+ if (item instanceof MovieMediaItem) {
+ ((MediaItemView) childView).setProgress(-1);
+ } else if (item instanceof MovieTransition) {
+ ((TransitionView) childView).setProgress(-1);
}
}
}
}
- /**
- * @param listener The listener
- */
- public void setListener(MediaLayoutListener listener) {
+ public void setListener(MediaLinearLayoutListener listener) {
mListener = listener;
}
- /**
- * @param project The project
- */
public void setProject(VideoEditorProject project) {
- // Close the contextual action bar
+ // Close the contextual action bar.
if (mMediaItemActionMode != null) {
mMediaItemActionMode.finish();
mMediaItemActionMode = null;
@@ -656,7 +612,7 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * @param inProgress true if playback is in progress
+ * @param inProgress {@code true} if playback is in progress, false otherwise
*/
public void setPlaybackInProgress(boolean inProgress) {
mPlaybackInProgress = inProgress;
@@ -676,7 +632,7 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Add all the media items
+ * Adds all given media items.
*
* @param mediaItems The list of media items
*/
@@ -699,7 +655,7 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Add a new media item at the end of the timeline
+ * Adds a new media item at the end of the timeline.
*
* @param mediaItem The media item
*/
@@ -712,11 +668,12 @@ public class MediaLinearLayout extends LinearLayout {
// Add the new view
final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT);
- // Add the view before the end, handle left and handle right views
+ LinearLayout.LayoutParams.WRAP_CONTENT,
+ LinearLayout.LayoutParams.FILL_PARENT);
+ // Add the view before the end view, left handle and right handle views.
addView(mediaItemView, getChildCount() - 3, lp);
- // If the new media item has beginning and end transitions add them
+ // If the new media item has beginning and end transitions, add them.
final MovieTransition beginTransition = mediaItem.getBeginTransition();
if (beginTransition != null) {
final int cc = getChildCount();
@@ -751,7 +708,7 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Insert a new media item after the specified media item id
+ * Inserts a new media item after the specified media item id.
*
* @param mediaItem The media item
* @param afterMediaItemId The id of the media item preceding the media item
@@ -827,7 +784,7 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Update media item
+ * Updates media item.
*
* @param mediaItem The media item
*/
@@ -882,7 +839,7 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Remove a media item view
+ * Removes a media item view.
*
* @param mediaItemId The media item id
* @param transition The transition inserted at the removal position
@@ -1162,16 +1119,19 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Invalidate the CAB
+ * Invalidates the available action modes. Used to refresh menu contents.
*/
- public void invalidateCAB() {
+ public void invalidateActionBar() {
if (mMediaItemActionMode != null) {
mMediaItemActionMode.invalidate();
}
+ if (mTransitionActionMode != null) {
+ mTransitionActionMode.invalidate();
+ }
}
/**
- * A Ken Burns movie is encoded for an MediaImageItem
+ * A Ken Burns movie is encoded for an MediaImageItem.
*
* @param mediaItemId The media item id
* @param action The action
@@ -1222,7 +1182,7 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Create a new effect
+ * Creates a new effect on the specified media item.
*
* @param effectType The effect type
* @param mediaItemId Add the effect for this media item id
@@ -1280,78 +1240,6 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Create a new effect
- *
- * @param effectType The effect type
- * @param mediaItemId Add the effect for this media item id
- * @param startRect The start rectangle
- * @param endRect The end rectangle
- */
- public void editEffect(int effectType, String mediaItemId, Rect startRect, Rect endRect) {
- final MovieMediaItem mediaItem = mProject.getMediaItem(mediaItemId);
- if (mediaItem == null) {
- Log.e(TAG, "editEffect media item not found: " + mediaItemId);
- return;
- }
-
- final MovieEffect effect = mediaItem.getEffect();
-
- final String id = ApiService.generateId();
- switch (effectType) {
- case EffectType.EFFECT_KEN_BURNS: {
- ApiService.addEffectKenBurns(getContext(), mProject.getPath(), mediaItemId,
- id, 0, mediaItem.getDuration(), startRect, endRect);
- break;
- }
-
- case EffectType.EFFECT_COLOR_GRADIENT: {
- // Check if the type has changed
- if (effect.getType() != effectType) {
- ApiService.addEffectColor(getContext(), mProject.getPath(), mediaItemId, id, 0,
- mediaItem.getDuration(), EffectColor.TYPE_GRADIENT,
- EffectColor.GRAY);
- }
- break;
- }
-
- case EffectType.EFFECT_COLOR_SEPIA: {
- // Check if the type has changed
- if (effect.getType() != effectType) {
- ApiService.addEffectColor(getContext(), mProject.getPath(), mediaItemId, id, 0,
- mediaItem.getDuration(), EffectColor.TYPE_SEPIA, 0);
- }
- break;
- }
-
- case EffectType.EFFECT_COLOR_NEGATIVE: {
- // Check if the type has changed
- if (effect.getType() != effectType) {
- ApiService.addEffectColor(getContext(), mProject.getPath(), mediaItemId, id, 0,
- mediaItem.getDuration(), EffectColor.TYPE_NEGATIVE, 0);
- }
- break;
- }
-
- case EffectType.EFFECT_COLOR_FIFTIES: {
- // Check if the type has changed
- if (effect.getType() != effectType) {
- ApiService.addEffectColor(getContext(), mProject.getPath(), mediaItemId, id, 0,
- mediaItem.getDuration(), EffectColor.TYPE_FIFTIES, 0);
- }
- break;
- }
-
- default: {
- break;
- }
- }
-
- if (mMediaItemActionMode != null) {
- mMediaItemActionMode.invalidate();
- }
- }
-
- /**
* Set the media item thumbnails.
*
* @param mediaItemId The media item id
@@ -1378,7 +1266,7 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Set the transition thumbnails.
+ * Sets the transition thumbnails.
*
* @param transitionId The transition id
* @param bitmaps The bitmaps array
@@ -1400,9 +1288,6 @@ public class MediaLinearLayout extends LinearLayout {
return false;
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// Compute the total duration
@@ -1567,7 +1452,7 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Create a new dialog
+ * Creates a new dialog.
*
* @param id The dialog id
* @param bundle The dialog bundle
@@ -1588,7 +1473,7 @@ public class MediaLinearLayout extends LinearLayout {
return null;
}
- final Activity activity = (Activity)getContext();
+ final Activity activity = (Activity) getContext();
return AlertDialogs.createAlert(activity,
FileUtils.getSimpleName(mediaItem.getFilename()),
0, mediaItem.isVideoClip() ?
@@ -1596,9 +1481,7 @@ public class MediaLinearLayout extends LinearLayout {
activity.getString(R.string.editor_remove_image_question),
activity.getString(R.string.yes),
new DialogInterface.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(DialogInterface dialog, int which) {
if (mMediaItemActionMode != null) {
mMediaItemActionMode.finish();
@@ -1612,16 +1495,12 @@ public class MediaLinearLayout extends LinearLayout {
mProject.getTheme());
}
}, activity.getString(R.string.no), new DialogInterface.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(DialogInterface dialog, int which) {
activity.removeDialog(VideoEditorActivity.DIALOG_REMOVE_MEDIA_ITEM_ID);
}
}, new DialogInterface.OnCancelListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onCancel(DialogInterface dialog) {
activity.removeDialog(VideoEditorActivity.DIALOG_REMOVE_MEDIA_ITEM_ID);
}
@@ -1665,9 +1544,7 @@ public class MediaLinearLayout extends LinearLayout {
builder.setSingleChoiceItems(renderingModeStrings, currentRenderingModeIndex,
new DialogInterface.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0: {
@@ -1703,9 +1580,7 @@ public class MediaLinearLayout extends LinearLayout {
});
builder.setCancelable(true);
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onCancel(DialogInterface dialog) {
activity.removeDialog(VideoEditorActivity.DIALOG_CHANGE_RENDERING_MODE_ID);
}
@@ -1720,15 +1595,13 @@ public class MediaLinearLayout extends LinearLayout {
return null;
}
- final Activity activity = (Activity)getContext();
+ final Activity activity = (Activity) getContext();
return AlertDialogs.createAlert(activity,
activity.getString(R.string.remove),
0, activity.getString(R.string.editor_remove_transition_question),
activity.getString(R.string.yes),
new DialogInterface.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(DialogInterface dialog, int which) {
if (mTransitionActionMode != null) {
mTransitionActionMode.finish();
@@ -1741,16 +1614,12 @@ public class MediaLinearLayout extends LinearLayout {
transition.getId());
}
}, activity.getString(R.string.no), new DialogInterface.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(DialogInterface dialog, int which) {
activity.removeDialog(VideoEditorActivity.DIALOG_REMOVE_TRANSITION_ID);
}
}, new DialogInterface.OnCancelListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onCancel(DialogInterface dialog) {
activity.removeDialog(VideoEditorActivity.DIALOG_REMOVE_TRANSITION_ID);
}
@@ -1764,15 +1633,13 @@ public class MediaLinearLayout extends LinearLayout {
return null;
}
- final Activity activity = (Activity)getContext();
+ final Activity activity = (Activity) getContext();
return AlertDialogs.createAlert(activity,
FileUtils.getSimpleName(mediaItem.getFilename()),
0, activity.getString(R.string.editor_remove_effect_question),
activity.getString(R.string.yes),
new DialogInterface.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(DialogInterface dialog, int which) {
activity.removeDialog(VideoEditorActivity.DIALOG_REMOVE_EFFECT_ID);
@@ -1784,16 +1651,12 @@ public class MediaLinearLayout extends LinearLayout {
}
}
}, activity.getString(R.string.no), new DialogInterface.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(DialogInterface dialog, int which) {
activity.removeDialog(VideoEditorActivity.DIALOG_REMOVE_EFFECT_ID);
}
}, new DialogInterface.OnCancelListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onCancel(DialogInterface dialog) {
activity.removeDialog(VideoEditorActivity.DIALOG_REMOVE_EFFECT_ID);
}
@@ -1806,9 +1669,6 @@ public class MediaLinearLayout extends LinearLayout {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public boolean onDragEvent(DragEvent event) {
boolean result = false;
@@ -2088,61 +1948,41 @@ public class MediaLinearLayout extends LinearLayout {
return timeMs;
}
- /**
- * Pick an overlay
- *
- * @param mediaItemId Media item id
- */
- private void pickOverlay(String mediaItemId) {
- final Intent intent = new Intent(getContext(), OverlaysActivity.class);
- intent.putExtra(OverlaysActivity.PARAM_MEDIA_ITEM_ID, mediaItemId);
- ((Activity)getContext()).startActivityForResult(intent,
- VideoEditorActivity.REQUEST_CODE_PICK_OVERLAY);
- }
/**
- * Pick an effect of the specified category
- *
- * @param category The category
- * @param mediaItem The media item
+ * Adds/edits title overlay of the specified media item.
*/
- private void pickEffect(int category, MovieMediaItem mediaItem) {
- final Intent intent = new Intent(getContext(), EffectsActivity.class);
- intent.putExtra(EffectsActivity.PARAM_CATEGORY, category);
- intent.putExtra(EffectsActivity.PARAM_MEDIA_ITEM_ID, mediaItem.getId());
- intent.putExtra(EffectsActivity.PARAM_FILENAME, mediaItem.getFilename());
- intent.putExtra(EffectsActivity.PARAM_WIDTH, mediaItem.getWidth());
- intent.putExtra(EffectsActivity.PARAM_HEIGHT, mediaItem.getHeight());
- ((Activity)getContext()).startActivityForResult(intent,
- VideoEditorActivity.REQUEST_CODE_PICK_EFFECT);
+ private void editOverlay(MovieMediaItem mediaItem) {
+ final Intent intent = new Intent(getContext(), OverlayTitleEditor.class);
+ intent.putExtra(OverlayTitleEditor.PARAM_MEDIA_ITEM_ID, mediaItem.getId());
+
+ // Determine if user wants to edit an existing title overlay or add a new one.
+ // Add overlay id and attributes bundle to the extra if the overlay already exists.
+ final MovieOverlay overlay = mediaItem.getOverlay();
+ if (overlay != null) {
+ final String overlayId = mediaItem.getOverlay().getId();
+ intent.putExtra(OverlayTitleEditor.PARAM_OVERLAY_ID, overlayId);
+ final Bundle attributes = MovieOverlay.buildUserAttributes(
+ overlay.getType(), overlay.getTitle(), overlay.getSubtitle());
+ intent.putExtra(OverlayTitleEditor.PARAM_OVERLAY_ATTRIBUTES,
+ attributes);
+ }
+ ((Activity) getContext()).startActivityForResult(intent,
+ VideoEditorActivity.REQUEST_CODE_PICK_OVERLAY);
}
/**
- * Edit an effect of the specified category
- *
- * @param category The category
- * @param mediaItem Media item
- * @param effect The effect
+ * Removes the overlay of the specified media item.
*/
- private void editEffect(int category, MovieMediaItem mediaItem, MovieEffect effect) {
- final Intent intent = new Intent(getContext(), EffectsActivity.class);
- intent.putExtra(EffectsActivity.PARAM_CATEGORY, category);
- intent.putExtra(EffectsActivity.PARAM_MEDIA_ITEM_ID, mediaItem.getId());
- intent.putExtra(EffectsActivity.PARAM_EFFECT_TYPE, effect.getType());
- intent.putExtra(EffectsActivity.PARAM_FILENAME, mediaItem.getFilename());
- intent.putExtra(EffectsActivity.PARAM_WIDTH, mediaItem.getWidth());
- intent.putExtra(EffectsActivity.PARAM_HEIGHT, mediaItem.getHeight());
- if (effect.getType() == EffectType.EFFECT_KEN_BURNS) {
- intent.putExtra(EffectsActivity.PARAM_START_RECT, effect.getStartRect());
- intent.putExtra(EffectsActivity.PARAM_END_RECT, effect.getEndRect());
- }
-
- ((Activity)getContext()).startActivityForResult(intent,
- VideoEditorActivity.REQUEST_CODE_EDIT_EFFECT);
+ private void removeOverlay(MovieMediaItem mediaItem) {
+ final Bundle bundle = new Bundle();
+ bundle.putString(PARAM_DIALOG_MEDIA_ITEM_ID, mediaItem.getId());
+ ((Activity) getContext()).showDialog(
+ VideoEditorActivity.DIALOG_REMOVE_OVERLAY_ID, bundle);
}
/**
- * Pick a transition
+ * Picks a transition.
*
* @param afterMediaItem After the media item
*
@@ -2165,13 +2005,13 @@ public class MediaLinearLayout extends LinearLayout {
intent.putExtra(TransitionsActivity.PARAM_DEFAULT_DURATION, transitionDurationMs);
intent.putExtra(TransitionsActivity.PARAM_MAXIMUM_DURATION,
getMaxTransitionDuration(afterMediaItem));
- ((Activity)getContext()).startActivityForResult(intent,
+ ((Activity) getContext()).startActivityForResult(intent,
VideoEditorActivity.REQUEST_CODE_PICK_TRANSITION);
return true;
}
/**
- * Edit a transition
+ * Edits a transition.
*
* @param transition The transition
*/
@@ -2353,9 +2193,6 @@ public class MediaLinearLayout extends LinearLayout {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public void setSelected(boolean selected) {
// Close the contextual action bar
@@ -2390,10 +2227,10 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Select a view and unselect any view that is selected.
+ * Selects a view and un-selects any view that is selected.
*
- * @param selectedView The view to select
- * @param selected true if selected
+ * @param selectedView the view to select
+ * @param selected {@code true} if the view must be selected
*/
private void selectView(View selectedView, boolean selected) {
// Check if the selection has changed
@@ -2456,9 +2293,7 @@ public class MediaLinearLayout extends LinearLayout {
private int mOriginalWidth;
private int mMovePosition;
- /*
- * {@inheritDoc}
- */
+ @Override
public void onMoveBegin(HandleView view) {
mMediaItem = (MovieMediaItem)mediaItemView.getTag();
mTransitionsDurationMs = (mMediaItem.getBeginTransition() != null ?
@@ -2484,9 +2319,7 @@ public class MediaLinearLayout extends LinearLayout {
scrollView.invalidate();
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onMove(HandleView view, int left, int delta) {
if (mMoveLayoutPending) {
return false;
@@ -2545,16 +2378,12 @@ public class MediaLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onMoveEnd(final HandleView view, final int left, final int delta) {
final int position = left + delta;
if (mMoveLayoutPending || (position != mMovePosition)) {
mHandler.post(new Runnable() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void run() {
if (mMoveLayoutPending) {
mHandler.post(this);
@@ -2632,9 +2461,7 @@ public class MediaLinearLayout extends LinearLayout {
private long mMinimumItemDurationMs;
private int mMovePosition;
- /*
- * {@inheritDoc}
- */
+ @Override
public void onMoveBegin(HandleView view) {
mMediaItem = (MovieMediaItem)mediaItemView.getTag();
mTransitionsDurationMs = (mMediaItem.getBeginTransition() != null ?
@@ -2648,7 +2475,7 @@ public class MediaLinearLayout extends LinearLayout {
mTrimmedView = mediaItemView;
mListener.onTrimMediaItemBegin(mMediaItem);
- if (videoClip) { // Video clip
+ if (videoClip) { // Video clip
mListener.onTrimMediaItem(mMediaItem, mMediaItem.getAppBoundaryEndTime());
} else {
mListener.onTrimMediaItem(mMediaItem, 0);
@@ -2659,9 +2486,7 @@ public class MediaLinearLayout extends LinearLayout {
scrollView.invalidate();
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onMove(HandleView view, int left, int delta) {
if (mMoveLayoutPending) {
return false;
@@ -2751,16 +2576,12 @@ public class MediaLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onMoveEnd(final HandleView view, final int left, final int delta) {
final int position = left + delta;
if (mMoveLayoutPending || (position != mMovePosition)) {
mHandler.post(new Runnable() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void run() {
if (mMoveLayoutPending) {
mHandler.post(this);
@@ -2823,7 +2644,7 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Set the trimming state for all media item views
+ * Sets the trimming state for all media item views.
*
* @param trimmingView The view which enters/exists the trimming state
* @param trimming true if trimming
@@ -2840,9 +2661,8 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Set the playback state for all media item views
+ * Sets the playback state for all media item views.
*
- * @param trimmingView The view which enters/exists the trimming state
* @param playback true if trimming
*/
private void setPlaybackState(boolean playback) {
@@ -2861,30 +2681,31 @@ public class MediaLinearLayout extends LinearLayout {
}
/**
- * Unselect all views
+ * Un-selects all views.
*/
private void unselectAllViews() {
((RelativeLayout)getParent()).setSelected(false);
}
/**
- * Invalidate all children
+ * Invalidates all children.
*/
private void invalidateAllChildren() {
final int childrenCount = getChildCount();
for (int i = 0; i < childrenCount; i++) {
final View childView = getChildAt(i);
- childView.invalidate();
+ childView.invalidate();
}
}
/**
- * Show/hide the media buttons
+ * Shows or hides "add media buttons".
*
- * @param show true to show the "Add media item" buttons
+ * @param show {@code true} to show the "Add media item" buttons, {@code false} to hide them
*/
private void showAddMediaItemButtons(boolean show) {
if (show) {
+ // Shows left add button iff there is at least one media item on the timeline.
if (mProject.getMediaItemCount() > 0) {
mLeftAddClipButton.setVisibility(View.VISIBLE);
}
diff --git a/src/com/android/videoeditor/widgets/MediaLinearLayoutListener.java b/src/com/android/videoeditor/widgets/MediaLinearLayoutListener.java
new file mode 100644
index 0000000..861dbf6
--- /dev/null
+++ b/src/com/android/videoeditor/widgets/MediaLinearLayoutListener.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2011 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.videoeditor.widgets;
+
+import com.android.videoeditor.service.MovieMediaItem;
+
+/**
+ * Listener that listens to state changes of {@link MediaLinearLayout}.
+ */
+public interface MediaLinearLayoutListener {
+ /**
+ * Request scrolling by an offset amount
+ *
+ * @param scrollBy The amount to scroll
+ * @param smooth true to scroll smoothly
+ */
+ void onRequestScrollBy(int scrollBy, boolean smooth);
+
+ /**
+ * Request scrolling to a specified time position
+ *
+ * @param scrollToTime The scroll position
+ * @param smooth true to scroll smoothly
+ */
+ void onRequestMovePlayhead(long scrollToTime, boolean smooth);
+
+ /**
+ * Add a new media item
+ *
+ * @param afterMediaItemId Add media item after this media item id
+ */
+ void onAddMediaItem(String afterMediaItemId);
+
+ /**
+ * A media item enters trimming mode
+ *
+ * @param mediaItem The media item
+ */
+ void onTrimMediaItemBegin(MovieMediaItem mediaItem);
+
+ /**
+ * A media item is being trimmed
+ *
+ * @param mediaItem The media item
+ * @param timeMs The time where the trim occurs
+ */
+ void onTrimMediaItem(MovieMediaItem mediaItem, long timeMs);
+
+ /**
+ * A media has been trimmed
+ *
+ * @param mediaItem The media item
+ * @param timeMs The time where the trim occurs
+ */
+ void onTrimMediaItemEnd(MovieMediaItem mediaItem, long timeMs);
+}
diff --git a/src/com/android/videoeditor/widgets/OverlayLinearLayout.java b/src/com/android/videoeditor/widgets/OverlayLinearLayout.java
index 44ca5aa..03f9852 100755
--- a/src/com/android/videoeditor/widgets/OverlayLinearLayout.java
+++ b/src/com/android/videoeditor/widgets/OverlayLinearLayout.java
@@ -37,8 +37,7 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.android.videoeditor.AlertDialogs;
-import com.android.videoeditor.OverlayTitleActivity;
-import com.android.videoeditor.OverlaysActivity;
+import com.android.videoeditor.OverlayTitleEditor;
import com.android.videoeditor.VideoEditorActivity;
import com.android.videoeditor.service.ApiService;
import com.android.videoeditor.service.MovieMediaItem;
@@ -49,7 +48,7 @@ import com.android.videoeditor.util.MediaItemUtils;
import com.android.videoeditor.R;
/**
- * The LinearLayout which displays overlays
+ * LinearLayout which displays overlays.
*/
public class OverlayLinearLayout extends LinearLayout {
// Logging
@@ -84,38 +83,28 @@ public class OverlayLinearLayout extends LinearLayout {
}
/**
- * The overlay action mode handler
+ * The overlay action mode handler.
*/
private class OverlayActionModeCallback implements ActionMode.Callback {
// Instance variables
private final MovieMediaItem mMediaItem;
- /**
- * Constructor
- *
- * @param mediaItem The media item
- */
public OverlayActionModeCallback(MovieMediaItem mediaItem) {
mMediaItem = mediaItem;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mOverlayActionMode = mode;
- final Activity activity = (Activity)getContext();
+ final Activity activity = (Activity) getContext();
activity.getMenuInflater().inflate(R.menu.overlay_mode_menu, menu);
- mode.setTitle(FileUtils.getSimpleName(mMediaItem.getFilename()));
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- final boolean enable = !ApiService.isProjectEdited(mProject.getPath()) &&
+ final boolean enable = !ApiService.isProjectBeingEdited(mProject.getPath()) &&
!mPlaybackInProgress;
final MenuItem eomi = menu.findItem(R.id.action_edit_overlay);
@@ -127,29 +116,27 @@ public class OverlayLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch (item.getItemId()) {
case R.id.action_edit_overlay: {
- final Activity activity = (Activity)getContext();
- final Intent intent = new Intent(activity, OverlaysActivity.class);
- intent.putExtra(OverlayTitleActivity.PARAM_MEDIA_ITEM_ID, mMediaItem.getId());
+ final Activity activity = (Activity) getContext();
+ final Intent intent = new Intent(activity, OverlayTitleEditor.class);
+ intent.putExtra(OverlayTitleEditor.PARAM_MEDIA_ITEM_ID, mMediaItem.getId());
final MovieOverlay overlay = mMediaItem.getOverlay();
- intent.putExtra(OverlaysActivity.PARAM_OVERLAY_ID, overlay.getId());
- intent.putExtra(OverlaysActivity.PARAM_OVERLAY_ATTRIBUTES,
+ intent.putExtra(OverlayTitleEditor.PARAM_OVERLAY_ID, overlay.getId());
+ intent.putExtra(OverlayTitleEditor.PARAM_OVERLAY_ATTRIBUTES,
overlay.buildUserAttributes());
activity.startActivityForResult(intent,
- VideoEditorActivity.REQUEST_CODE_EDIT_OVERLAY);
+ VideoEditorActivity.REQUEST_CODE_PICK_OVERLAY);
break;
}
case R.id.action_remove_overlay: {
final Bundle bundle = new Bundle();
bundle.putString(PARAM_DIALOG_MEDIA_ITEM_ID, mMediaItem.getId());
- ((Activity)getContext()).showDialog(
+ ((Activity) getContext()).showDialog(
VideoEditorActivity.DIALOG_REMOVE_OVERLAY_ID, bundle);
break;
}
@@ -162,9 +149,7 @@ public class OverlayLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onDestroyActionMode(ActionMode mode) {
final View overlayView = getOverlayView(mMediaItem.getId());
if (overlayView != null) {
@@ -175,9 +160,6 @@ public class OverlayLinearLayout extends LinearLayout {
}
}
- /*
- * {@inheritDoc}
- */
public OverlayLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
@@ -187,9 +169,7 @@ public class OverlayLinearLayout extends LinearLayout {
private long mScrollTotalDurationMs, mScrollMediaItemStartTime;
private boolean mScrolled;
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onSingleTapConfirmed(View view, int area, MotionEvent e) {
if (mPlaybackInProgress) {
return false;
@@ -204,9 +184,9 @@ public class OverlayLinearLayout extends LinearLayout {
case OverlayView.STATE_ADD_BUTTON: {
final MovieMediaItem mediaItem = (MovieMediaItem)view.getTag();
- final Intent intent = new Intent(getContext(), OverlaysActivity.class);
- intent.putExtra(OverlaysActivity.PARAM_MEDIA_ITEM_ID, mediaItem.getId());
- ((Activity)getContext()).startActivityForResult(intent,
+ final Intent intent = new Intent(getContext(), OverlayTitleEditor.class);
+ intent.putExtra(OverlayTitleEditor.PARAM_MEDIA_ITEM_ID, mediaItem.getId());
+ ((Activity) getContext()).startActivityForResult(intent,
VideoEditorActivity.REQUEST_CODE_PICK_OVERLAY);
break;
}
@@ -226,9 +206,7 @@ public class OverlayLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onLongPress(View view, MotionEvent e) {
if (mPlaybackInProgress) {
return;
@@ -261,9 +239,7 @@ public class OverlayLinearLayout extends LinearLayout {
}
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onMoveBegin(View view, MotionEvent e) {
if (mPlaybackInProgress) {
return false;
@@ -279,9 +255,7 @@ public class OverlayLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onMove(View view, MotionEvent e1, MotionEvent e2) {
final int beginPos = (int)(view.getLeft() - mHalfParentWidth - e1.getX() +
e2.getX());
@@ -302,9 +276,7 @@ public class OverlayLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onMoveEnd(View view) {
mRightHandle.setVisibility(View.VISIBLE);
if (mScrolled) {
@@ -325,9 +297,7 @@ public class OverlayLinearLayout extends LinearLayout {
// Add the beginning timeline item
final View beginView = inflate(getContext(), R.layout.empty_timeline_item, null);
beginView.setOnClickListener(new View.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(View view) {
unselectAllViews();
}
@@ -337,9 +307,7 @@ public class OverlayLinearLayout extends LinearLayout {
// Add the end timeline item
final View endView = inflate(getContext(), R.layout.empty_timeline_item, null);
endView.setOnClickListener(new View.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(View view) {
unselectAllViews();
}
@@ -363,16 +331,10 @@ public class OverlayLinearLayout extends LinearLayout {
setMotionEventSplittingEnabled(false);
}
- /*
- * {@inheritDoc}
- */
public OverlayLinearLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- /*
- * {@inheritDoc}
- */
public OverlayLinearLayout(Context context) {
this(context, null, 0);
}
@@ -631,9 +593,6 @@ public class OverlayLinearLayout extends LinearLayout {
}
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final long totalDurationMs = mProject.computeDuration();
@@ -740,15 +699,13 @@ public class OverlayLinearLayout extends LinearLayout {
return null;
}
- final Activity activity = (Activity)getContext();
+ final Activity activity = (Activity) getContext();
return AlertDialogs.createAlert(activity, FileUtils.getSimpleName(
mediaItem.getFilename()), 0,
activity.getString(R.string.editor_remove_overlay_question),
activity.getString(R.string.yes),
new DialogInterface.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(DialogInterface dialog, int which) {
if (mOverlayActionMode != null) {
mOverlayActionMode.finish();
@@ -760,16 +717,12 @@ public class OverlayLinearLayout extends LinearLayout {
mediaItem.getOverlay().getId());
}
}, activity.getString(R.string.no), new DialogInterface.OnClickListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onClick(DialogInterface dialog, int which) {
activity.removeDialog(VideoEditorActivity.DIALOG_REMOVE_OVERLAY_ID);
}
}, new DialogInterface.OnCancelListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onCancel(DialogInterface dialog) {
activity.removeDialog(VideoEditorActivity.DIALOG_REMOVE_OVERLAY_ID);
}
@@ -840,9 +793,6 @@ public class OverlayLinearLayout extends LinearLayout {
requestLayout();
}
- /*
- * {@inheritDoc}
- */
@Override
public void setSelected(boolean selected) {
if (selected == false) {
@@ -916,17 +866,13 @@ public class OverlayLinearLayout extends LinearLayout {
private int mMovePosition;
private long mMinimumDurationMs;
- /*
- * {@inheritDoc}
- */
+ @Override
public void onMoveBegin(HandleView view) {
mMediaItem = mediaItem;
mMinimumDurationMs = MediaItemUtils.getMinimumMediaItemDuration(mediaItem);
}
- /*
- * {@inheritDoc}
- */
+ @Override
public boolean onMove(HandleView view, int left, int delta) {
if (mMoveLayoutPending) {
return false;
@@ -960,16 +906,12 @@ public class OverlayLinearLayout extends LinearLayout {
return true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onMoveEnd(final HandleView view, final int left, final int delta) {
final int position = left + delta;
if (mMoveLayoutPending || (position != mMovePosition)) {
mHandler.post(new Runnable() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void run() {
if (mMoveLayoutPending) {
mHandler.post(this);
diff --git a/src/com/android/videoeditor/widgets/OverlayView.java b/src/com/android/videoeditor/widgets/OverlayView.java
index c15b8e8..250f689 100755
--- a/src/com/android/videoeditor/widgets/OverlayView.java
+++ b/src/com/android/videoeditor/widgets/OverlayView.java
@@ -51,17 +51,11 @@ public class OverlayView extends ImageView {
private boolean mLongPressMove;
private MotionEvent mStartScrollEvent;
- /*
- * {@inheritDoc}
- */
public OverlayView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mSimpleGestureDetector = new GestureDetector(context,
new GestureDetector.SimpleOnGestureListener() {
- /*
- * {@inheritDoc}
- */
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
if (mGestureListener != null) {
@@ -71,9 +65,6 @@ public class OverlayView extends ImageView {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public void onLongPress(MotionEvent e) {
if (mGestureListener == null) {
@@ -103,16 +94,10 @@ public class OverlayView extends ImageView {
mState = STATE_STUB;
}
- /*
- * {@inheritDoc}
- */
public OverlayView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- /*
- * {@inheritDoc}
- */
public OverlayView(Context context) {
this(context, null, 0);
}
@@ -162,9 +147,6 @@ public class OverlayView extends ImageView {
mGestureListener = listener;
}
- /*
- * {@inheritDoc}
- */
@Override
public void setSelected(boolean selected) {
super.setSelected(selected);
@@ -176,9 +158,6 @@ public class OverlayView extends ImageView {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public boolean onTouchEvent(MotionEvent ev) {
mSimpleGestureDetector.onTouchEvent(ev);
@@ -210,9 +189,6 @@ public class OverlayView extends ImageView {
return true;
}
- /*
- * {@inheritDoc}
- */
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
diff --git a/src/com/android/videoeditor/widgets/TimelineHorizontalScrollView.java b/src/com/android/videoeditor/widgets/TimelineHorizontalScrollView.java
index b63367e..779f9f5 100755
--- a/src/com/android/videoeditor/widgets/TimelineHorizontalScrollView.java
+++ b/src/com/android/videoeditor/widgets/TimelineHorizontalScrollView.java
@@ -61,9 +61,6 @@ public class TimelineHorizontalScrollView extends HorizontalScrollView {
// The runnable which executes when the scrolling ends
private Runnable mScrollEndedRunnable = new Runnable() {
- /*
- * {@inheritDoc}
- */
@Override
public void run() {
mIsScrolling = false;
@@ -77,9 +74,6 @@ public class TimelineHorizontalScrollView extends HorizontalScrollView {
}
};
- /*
- * {@inheritDoc}
- */
public TimelineHorizontalScrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
@@ -111,16 +105,10 @@ public class TimelineHorizontalScrollView extends HorizontalScrollView {
mMoveNotOkPlayheadDrawable = resources.getDrawable(R.drawable.playhead_move_not_ok);
}
- /*
- * {@inheritDoc}
- */
public TimelineHorizontalScrollView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- /*
- * {@inheritDoc}
- */
public TimelineHorizontalScrollView(Context context) {
this(context, null, 0);
}
@@ -133,18 +121,12 @@ public class TimelineHorizontalScrollView extends HorizontalScrollView {
mEnableUserScrolling = enable;
}
- /*
- * {@inheritDoc}
- */
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
mScaleDetector.onTouchEvent(ev);
return mScaleDetector.isInProgress() || super.onInterceptTouchEvent(ev);
}
- /*
- * {@inheritDoc}
- */
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (mEnableUserScrolling) {
@@ -230,9 +212,6 @@ public class TimelineHorizontalScrollView extends HorizontalScrollView {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public void computeScroll() {
super.computeScroll();
@@ -262,9 +241,6 @@ public class TimelineHorizontalScrollView extends HorizontalScrollView {
}
}
- /*
- * {@inheritDoc}
- */
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
diff --git a/src/com/android/videoeditor/widgets/TimelineRelativeLayout.java b/src/com/android/videoeditor/widgets/TimelineRelativeLayout.java
index 54e8e22..4f40ebf 100755
--- a/src/com/android/videoeditor/widgets/TimelineRelativeLayout.java
+++ b/src/com/android/videoeditor/widgets/TimelineRelativeLayout.java
@@ -40,25 +40,16 @@ public class TimelineRelativeLayout extends RelativeLayout {
public void onLayoutComplete();
}
- /*
- * {@inheritDoc}
- */
public TimelineRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setMotionEventSplittingEnabled(false);
}
- /*
- * {@inheritDoc}
- */
public TimelineRelativeLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- /*
- * {@inheritDoc}
- */
public TimelineRelativeLayout(Context context) {
this(context, null, 0);
}
@@ -74,9 +65,6 @@ public class TimelineRelativeLayout extends RelativeLayout {
requestLayout();
}
- /*
- * {@inheritDoc}
- */
@Override
public void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
@@ -87,9 +75,6 @@ public class TimelineRelativeLayout extends RelativeLayout {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public void setSelected(boolean selected) {
final int childrenCount = getChildCount();
diff --git a/src/com/android/videoeditor/widgets/TransitionView.java b/src/com/android/videoeditor/widgets/TransitionView.java
index 68a4750..e1f39bf 100755
--- a/src/com/android/videoeditor/widgets/TransitionView.java
+++ b/src/com/android/videoeditor/widgets/TransitionView.java
@@ -58,18 +58,12 @@ public class TransitionView extends ImageView {
private int mProgress;
private boolean mIsPlaying;
- /*
- * {@inheritDoc}
- */
public TransitionView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// Setup the gesture listener
mSimpleGestureDetector = new GestureDetector(context,
new GestureDetector.SimpleOnGestureListener() {
- /*
- * {@inheritDoc}
- */
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
if (mGestureListener != null) {
@@ -80,9 +74,6 @@ public class TransitionView extends ImageView {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public void onLongPress(MotionEvent e) {
if (mGestureListener != null) {
@@ -92,23 +83,17 @@ public class TransitionView extends ImageView {
});
mScrollListener = new ScrollViewListener() {
- /*
- * {@inheritDoc}
- */
+ @Override
public void onScrollBegin(View view, int scrollX, int scrollY, boolean appScroll) {
mIsScrolling = true;
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onScrollProgress(View view, int scrollX, int scrollY, boolean appScroll) {
invalidate();
}
- /*
- * {@inheritDoc}
- */
+ @Override
public void onScrollEnd(View view, int scrollX, int scrollY, boolean appScroll) {
mIsScrolling = false;
mScrollX = scrollX;
@@ -145,23 +130,14 @@ public class TransitionView extends ImageView {
mSeparatorPaint.setStrokeWidth(2);
}
- /*
- * {@inheritDoc}
- */
public TransitionView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- /*
- * {@inheritDoc}
- */
public TransitionView(Context context) {
this(context, null, 0);
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onAttachedToWindow() {
// Add the horizontal scroll view listener
@@ -171,9 +147,6 @@ public class TransitionView extends ImageView {
scrollView.addScrollListener(mScrollListener);
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onDetachedFromWindow() {
// Remove the horizontal scroll listener
@@ -263,9 +236,6 @@ public class TransitionView extends ImageView {
return true;
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
@@ -315,9 +285,6 @@ public class TransitionView extends ImageView {
}
}
- /*
- * {@inheritDoc}
- */
@Override
public boolean onTouchEvent(MotionEvent ev) {
// Let the gesture detector inspect all events.
diff --git a/src/com/android/videoeditor/widgets/ZoomControl.java b/src/com/android/videoeditor/widgets/ZoomControl.java
index bb101ef..da24a48 100755
--- a/src/com/android/videoeditor/widgets/ZoomControl.java
+++ b/src/com/android/videoeditor/widgets/ZoomControl.java
@@ -56,9 +56,6 @@ public class ZoomControl extends View {
public void onProgressChanged(int progress, boolean fromUser);
}
- /*
- * {@inheritDoc}
- */
public ZoomControl(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
@@ -70,9 +67,6 @@ public class ZoomControl extends View {
mThumb = context.getResources().getDrawable(R.drawable.zoom_thumb_selector);
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
@@ -81,23 +75,14 @@ public class ZoomControl extends View {
mInternalRadius = width * THUMB_INTERNAL_RADIUS_CONTAINER_SIZE_RATIO;
}
- /*
- * {@inheritDoc}
- */
public ZoomControl(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- /*
- * {@inheritDoc}
- */
public ZoomControl(Context context) {
this(context, null, 0);
}
- /*
- * {@inheritDoc}
- */
@Override
public void refreshDrawableState() {
mThumb.setState(isPressed() ? PRESSED_WINDOW_FOCUSED_STATE_SET : ENABLED_STATE_SET);
@@ -129,9 +114,6 @@ public class ZoomControl extends View {
mListener = listener;
}
- /*
- * {@inheritDoc}
- */
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
@@ -148,9 +130,6 @@ public class ZoomControl extends View {
mThumb.draw(canvas);
}
- /*
- * {@inheritDoc}
- */
@Override
public boolean onTouchEvent(MotionEvent ev) {
super.onTouchEvent(ev);