summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2012-10-29 13:11:10 -0700
committerDoris Liu <tianliu@google.com>2012-10-29 13:39:06 -0700
commitbf1677a434760fcb7389a30c18e05cc3e7926d40 (patch)
treeeec90d549d07081d9567e3f5651ea5a48bd807a0
parentbe8f8878f7941bcb6b86523ed3c0ecc21761c104 (diff)
downloadandroid_packages_apps_Gallery2-bf1677a434760fcb7389a30c18e05cc3e7926d40.tar.gz
android_packages_apps_Gallery2-bf1677a434760fcb7389a30c18e05cc3e7926d40.tar.bz2
android_packages_apps_Gallery2-bf1677a434760fcb7389a30c18e05cc3e7926d40.zip
Disable save button when there's no modification
Bug: 7353884 Change-Id: I1b88e8b8ab3a92aad1226c60062a17a2f4badfb9
-rwxr-xr-xres/drawable-hdpi/ic_menu_savephoto_disabled.pngbin0 -> 1434 bytes
-rwxr-xr-xres/drawable-mdpi/ic_menu_savephoto_disabled.pngbin0 -> 1033 bytes
-rwxr-xr-xres/drawable-xhdpi/ic_menu_savephoto_disabled.pngbin0 -> 1912 bytes
-rw-r--r--res/drawable/menu_save_photo.xml20
-rw-r--r--res/layout/filtershow_actionbar.xml2
-rw-r--r--res/layout/trim_menu.xml2
-rw-r--r--src/com/android/gallery3d/app/TrimVideo.java25
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java9
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java3
9 files changed, 46 insertions, 15 deletions
diff --git a/res/drawable-hdpi/ic_menu_savephoto_disabled.png b/res/drawable-hdpi/ic_menu_savephoto_disabled.png
new file mode 100755
index 000000000..afb34ec7a
--- /dev/null
+++ b/res/drawable-hdpi/ic_menu_savephoto_disabled.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_savephoto_disabled.png b/res/drawable-mdpi/ic_menu_savephoto_disabled.png
new file mode 100755
index 000000000..dc9b406b6
--- /dev/null
+++ b/res/drawable-mdpi/ic_menu_savephoto_disabled.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_savephoto_disabled.png b/res/drawable-xhdpi/ic_menu_savephoto_disabled.png
new file mode 100755
index 000000000..fab1c5582
--- /dev/null
+++ b/res/drawable-xhdpi/ic_menu_savephoto_disabled.png
Binary files differ
diff --git a/res/drawable/menu_save_photo.xml b/res/drawable/menu_save_photo.xml
new file mode 100644
index 000000000..0b92ac968
--- /dev/null
+++ b/res/drawable/menu_save_photo.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_enabled="true" android:drawable="@drawable/ic_menu_savephoto" />
+ <item android:state_enabled="false" android:drawable="@drawable/ic_menu_savephoto_disabled" />
+</selector>
diff --git a/res/layout/filtershow_actionbar.xml b/res/layout/filtershow_actionbar.xml
index 93c8c595d..5f0aa3ff6 100644
--- a/res/layout/filtershow_actionbar.xml
+++ b/res/layout/filtershow_actionbar.xml
@@ -23,5 +23,5 @@
android:text="@string/save"
android:gravity="center_vertical"
android:textSize="14sp"
- android:drawableLeft="@drawable/ic_menu_savephoto"
+ android:drawableLeft="@drawable/menu_save_photo"
android:drawablePadding="8dip" /> \ No newline at end of file
diff --git a/res/layout/trim_menu.xml b/res/layout/trim_menu.xml
index b61922083..e2333921a 100644
--- a/res/layout/trim_menu.xml
+++ b/res/layout/trim_menu.xml
@@ -27,6 +27,6 @@
android:textAllCaps="true"
android:textSize="14sp"
android:gravity="left|center_vertical"
- android:drawableLeft="@drawable/ic_menu_savephoto"
+ android:drawableLeft="@drawable/menu_save_photo"
android:drawablePadding="8dp" />
</FrameLayout>
diff --git a/src/com/android/gallery3d/app/TrimVideo.java b/src/com/android/gallery3d/app/TrimVideo.java
index 38b403b10..f246ff6c7 100644
--- a/src/com/android/gallery3d/app/TrimVideo.java
+++ b/src/com/android/gallery3d/app/TrimVideo.java
@@ -53,6 +53,7 @@ public class TrimVideo extends Activity implements
ControllerOverlay.Listener {
private VideoView mVideoView;
+ private TextView mSaveVideoTextView;
private TrimControllerOverlay mController;
private Context mContext;
private Uri mUri;
@@ -93,13 +94,14 @@ public class TrimVideo extends Activity implements
actionBar.setDisplayOptions(displayOptions, displayOptions);
actionBar.setCustomView(R.layout.trim_menu);
- TextView mSaveVideoTextView = (TextView) findViewById(R.id.start_trim);
+ mSaveVideoTextView = (TextView) findViewById(R.id.start_trim);
mSaveVideoTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
trimVideo();
}
});
+ mSaveVideoTextView.setEnabled(false);
Intent intent = getIntent();
mUri = intent.getData();
@@ -257,21 +259,18 @@ public class TrimVideo extends Activity implements
return dir[0];
}
- private void trimVideo() {
+ private boolean isModified() {
int delta = mTrimEndTime - mTrimStartTime;
+
// Considering that we only trim at sync frame, we don't want to trim
// when the time interval is too short or too close to the origin.
- if (delta < 100 ) {
- Toast.makeText(getApplicationContext(),
- getString(R.string.trim_too_short),
- Toast.LENGTH_SHORT).show();
- return;
- }
- if (Math.abs(mVideoView.getDuration() - delta) < 100) {
- // If no change has been made, go back
- onBackPressed();
- return;
+ if (delta < 100 || Math.abs(mVideoView.getDuration() - delta) < 100) {
+ return false;
+ } else {
+ return true;
}
+ }
+ private void trimVideo() {
// Use the default save directory if the source directory cannot be
// saved.
mSaveDirectory = getSaveDirectory();
@@ -410,6 +409,8 @@ public class TrimVideo extends Activity implements
mTrimStartTime = start;
mTrimEndTime = end;
setProgress();
+ // Enable save if there's modifications
+ mSaveVideoTextView.setEnabled(isModified());
}
@Override
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index ef0415f94..94d318558 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -117,6 +117,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
private View mListGeometry = null;
private View mListColors = null;
private View mListFilterButtons = null;
+ private View mSaveButton = null;
private ImageButton mFxButton = null;
private ImageButton mBorderButton = null;
@@ -178,7 +179,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.filtershow_actionbar);
- actionBar.getCustomView().setOnClickListener(new OnClickListener() {
+ mSaveButton = actionBar.getCustomView();
+ mSaveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
saveImage();
@@ -633,6 +635,11 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
return false;
}
+ public void enableSave(boolean enable) {
+ if (mSaveButton != null)
+ mSaveButton.setEnabled(enable);
+ }
+
private void fillListImages(LinearLayout listFilters) {
// TODO: use listview
// TODO: load the filters straight from the filesystem
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index 0145c24dc..358d5b795 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -230,6 +230,7 @@ public class ImageShow extends View implements OnGestureListener,
}
updateSeekBar(parameter, minp, maxp);
invalidate();
+ mActivity.enableSave(hasModifications());
}
@Override
@@ -396,6 +397,7 @@ public class ImageShow extends View implements OnGestureListener,
public void updateImagePresets(boolean force) {
ImagePreset preset = getImagePreset();
if (preset == null) {
+ mActivity.enableSave(false);
return;
}
if (force) {
@@ -419,6 +421,7 @@ public class ImageShow extends View implements OnGestureListener,
mFiltersOnlyImage = null;
}
}
+ mActivity.enableSave(hasModifications());
}
public void requestFilteredImages() {