diff options
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | res/layout/filtershow_activity.xml | 86 | ||||
-rw-r--r-- | res/menu/filtershow_activity_menu.xml | 34 | ||||
-rw-r--r-- | res/values/filtershow_strings.xml | 6 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/FilterShowActivity.java | 194 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/imageshow/ImageShow.java | 2 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java | 4 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java | 5 |
8 files changed, 169 insertions, 164 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 9c857b6a3..3a3ac92de 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -228,7 +228,7 @@ <activity android:name="com.android.gallery3d.filtershow.FilterShowActivity" android:label="@string/title_activity_filter_show" - android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" > + android:theme="@android:style/Theme.Holo" > <intent-filter> <action android:name="android.intent.action.EDIT" /> <category android:name="android.intent.category.DEFAULT" /> diff --git a/res/layout/filtershow_activity.xml b/res/layout/filtershow_activity.xml index 1521585ad..42aba0cb9 100644 --- a/res/layout/filtershow_activity.xml +++ b/res/layout/filtershow_activity.xml @@ -67,65 +67,43 @@ android:layerType="hardware" android:orientation="vertical" > - <LinearLayout - android:layout_width="fill_parent" - android:layout_height="48dip" > + <FrameLayout + android:layout_weight="1" + android:layout_width="match_parent" + android:layout_height="wrap_content" > - <Button - android:id="@+id/saveButton" - style="@style/FilterShowTopButton" - android:layout_weight="1" - android:gravity="center_vertical|left" - android:text="@string/done" /> + <com.android.gallery3d.filtershow.imageshow.ImageShow + android:id="@+id/imageShow" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> - <ImageButton - android:id="@+id/showOriginalButton" - style="@style/FilterShowTopButton" - android:src="@drawable/filtershow_button_show_original" /> + <com.android.gallery3d.filtershow.imageshow.ImageStraighten + android:id="@+id/imageStraighten" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone" /> - <ImageButton - android:id="@+id/undoButton" - style="@style/FilterShowTopButton" - android:src="@drawable/filtershow_button_undo" /> + <com.android.gallery3d.filtershow.ui.ImageCurves + android:id="@+id/imageCurves" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone" /> - <ImageButton - android:id="@+id/redoButton" - style="@style/FilterShowTopButton" - android:src="@drawable/filtershow_button_redo" /> + <com.android.gallery3d.filtershow.imageshow.ImageBorder + android:id="@+id/imageBorder" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone" /> <ImageButton - android:id="@+id/operationsButton" - style="@style/FilterShowTopButton" - android:src="@drawable/filtershow_button_operations" /> - - </LinearLayout> - - <com.android.gallery3d.filtershow.imageshow.ImageShow - android:id="@+id/imageShow" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1" /> - - <com.android.gallery3d.filtershow.imageshow.ImageStraighten - android:id="@+id/imageStraighten" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1" - android:visibility="gone" /> - - <com.android.gallery3d.filtershow.ui.ImageCurves - android:id="@+id/imageCurves" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1" - android:visibility="gone" /> - - <com.android.gallery3d.filtershow.imageshow.ImageBorder - android:id="@+id/imageBorder" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1" - android:visibility="gone" /> + android:id="@+id/showOriginalButton" + android:layout_height="64dip" + android:layout_width="64dip" + android:scaleType="centerInside" + android:layout_gravity="bottom" + android:src="@drawable/filtershow_button_show_original" /> + + </FrameLayout> <HorizontalScrollView android:id="@+id/fxList" @@ -320,4 +298,4 @@ </LinearLayout> </LinearLayout> -</AbsoluteLayout> +</AbsoluteLayout>
\ No newline at end of file diff --git a/res/menu/filtershow_activity_menu.xml b/res/menu/filtershow_activity_menu.xml index 44a11e7db..ba0a8bcf4 100644 --- a/res/menu/filtershow_activity_menu.xml +++ b/res/menu/filtershow_activity_menu.xml @@ -1,5 +1,29 @@ -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:id="@+id/menu_settings" - android:title="@string/menu_settings" - android:orderInCategory="100" /> -</menu> +<menu xmlns:android="http://schemas.android.com/apk/res/android" > + <item + android:id="@+id/menu_share" + android:actionProviderClass="android.widget.ShareActionProvider" + android:showAsAction="ifRoom" + android:enabled="false" + android:title="@string/share"/> + <item + android:id="@+id/undoButton" + android:icon="@drawable/filtershow_button_undo" + android:showAsAction="ifRoom" + android:title="@string/filtershow_undo"/> + <item + android:id="@+id/redoButton" + android:icon="@drawable/filtershow_button_redo" + android:showAsAction="ifRoom" + android:title="@string/filtershow_redo"/> + <item + android:id="@+id/operationsButton" + android:icon="@drawable/filtershow_button_operations" + android:showAsAction="ifRoom" + android:title="@string/show_history_panel"/> + <item + android:id="@+id/menu_settings" + android:enabled="false" + android:orderInCategory="100" + android:title="@string/menu_settings"/> + +</menu>
\ No newline at end of file diff --git a/res/values/filtershow_strings.xml b/res/values/filtershow_strings.xml index 3a0a3afba..dd27a288c 100644 --- a/res/values/filtershow_strings.xml +++ b/res/values/filtershow_strings.xml @@ -22,9 +22,11 @@ <string name="save">Save</string> <string name="done">Done</string> <string name="history">History</string> + <string name="show_history_panel">Show History</string> + <string name="hide_history_panel">Hide History</string> <string name="reset">Reset</string> - <string name="undo">Undo</string> - <string name="redo">Redo</string> + <string name="filtershow_undo">Undo</string> + <string name="filtershow_redo">Redo</string> <string name="straighten">Straighten</string> <string name="crop">Crop</string> <string name="rotate">Rotate</string> diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index b9c384c51..a64ece0cc 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -16,6 +16,7 @@ import com.android.gallery3d.R; import android.net.Uri; import android.os.Bundle; import android.annotation.TargetApi; +import android.app.ActionBar; import android.app.Activity; import android.content.Intent; import android.content.res.Resources; @@ -25,6 +26,7 @@ import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.Menu; +import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; @@ -80,6 +82,9 @@ public class FilterShowActivity extends Activity implements OnItemClickListener super.onCreate(savedInstanceState); setContentView(R.layout.filtershow_activity); + ActionBar actionBar = getActionBar(); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setTitle(R.string.done); mImageLoader = new ImageLoader(getApplicationContext()); @@ -132,9 +137,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener mCurvesButtonRGB.setSelected(true); - // TODO: instead of click listeners, make the activity the single listener and - // do a dispatch in the listener callback method. - findViewById(R.id.saveButton).setOnClickListener(createOnClickSaveButton()); + // TODO: instead of click listeners, make the activity the single + // listener and do a dispatch in the listener callback method. findViewById(R.id.showOriginalButton).setOnTouchListener(createOnTouchShowOriginalButton()); findViewById(R.id.straightenButton).setOnClickListener(createOnClickStraightenButton()); findViewById(R.id.cropButton).setOnClickListener(createOnClickCropButton()); @@ -149,15 +153,12 @@ public class FilterShowActivity extends Activity implements OnItemClickListener mSharpenButton.setOnClickListener(createOnClickSharpenButton()); mContrastButton.setOnClickListener(createOnClickContrastButton()); - findViewById(R.id.undoButton).setOnClickListener(createOnClickUndoButton()); - findViewById(R.id.redoButton).setOnClickListener(createOnClickRedoButton()); mFxButton.setOnClickListener(createOnClickFxButton()); mBorderButton.setOnClickListener(createOnClickBorderButton()); mGeometryButton.setOnClickListener(createOnClickGeometryButton()); mColorsButton.setOnClickListener(createOnClickColorsButton()); - findViewById(R.id.operationsButton).setOnClickListener(createOnClickOperationsButton()); findViewById(R.id.resetOperationsButton).setOnClickListener( createOnClickResetOperationsButton()); @@ -187,6 +188,50 @@ public class FilterShowActivity extends Activity implements OnItemClickListener } } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.filtershow_activity_menu, menu); + MenuItem item = menu.findItem(R.id.operationsButton); + if (mShowingHistoryPanel) { + item.setTitle(R.string.hide_history_panel); + } else { + item.setTitle(R.string.show_history_panel); + } + return true; + } + + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.undoButton: { + HistoryAdapter adapter = (HistoryAdapter) mImageShow + .getListAdapter(); + int position = adapter.undo(); + mImageShow.onItemClick(position); + mImageShow.showToast("Undo"); + invalidateViews(); + return true; + } + case R.id.redoButton: { + HistoryAdapter adapter = (HistoryAdapter) mImageShow + .getListAdapter(); + int position = adapter.redo(); + mImageShow.onItemClick(position); + mImageShow.showToast("Redo"); + invalidateViews(); + return true; + } + case R.id.operationsButton: { + toggleHistoryPanel(); + return true; + } + case android.R.id.home: { + saveImage(); + return true; + } + } + return false; + } + private void fillListImages(LinearLayout listFilters) { // TODO: use listview // TODO: load the filters straight from the filesystem @@ -289,14 +334,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener // ////////////////////////////////////////////////////////////////////////////// // Click handlers for the top row buttons - private OnClickListener createOnClickSaveButton() { - return new View.OnClickListener() { - public void onClick(View v) { - saveImage(); - } - }; - } - private OnTouchListener createOnTouchShowOriginalButton() { return new View.OnTouchListener() { @Override @@ -312,80 +349,56 @@ public class FilterShowActivity extends Activity implements OnItemClickListener }; } - private OnClickListener createOnClickUndoButton() { - return new View.OnClickListener() { - @Override - public void onClick(View v) { - HistoryAdapter adapter = (HistoryAdapter) mImageShow - .getListAdapter(); - int position = adapter.undo(); - mImageShow.onItemClick(position); - mImageShow.showToast("Undo"); - invalidateViews(); - } - }; - } - - private OnClickListener createOnClickRedoButton() { - return new View.OnClickListener() { - @Override - public void onClick(View v) { - HistoryAdapter adapter = (HistoryAdapter) mImageShow - .getListAdapter(); - int position = adapter.redo(); - mImageShow.onItemClick(position); - mImageShow.showToast("Redo"); - invalidateViews(); - } - }; - } - // ////////////////////////////////////////////////////////////////////////////// // history panel... - private OnClickListener createOnClickOperationsButton() { - return new View.OnClickListener() { - @Override - public void onClick(View v) { - final View view = findViewById(R.id.mainPanel); - final View viewList = findViewById(R.id.historyPanel); - View rootView = viewList.getRootView(); - - // TODO: use a custom layout instead of absolutelayout... - final AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) view - .getLayoutParams(); - final AbsoluteLayout.LayoutParams lph = (AbsoluteLayout.LayoutParams) viewList - .getLayoutParams(); - final int positionHistoryPanel = (int) (rootView.getWidth() - viewList - .getWidth()); - if (!mShowingHistoryPanel) { - mShowingHistoryPanel = true; - view.animate().setDuration(200).x(-viewList.getWidth()) - .withLayer().withEndAction(new Runnable() { - public void run() { - view.setLayoutParams(lp); - lph.x = positionHistoryPanel; - viewList.setLayoutParams(lph); - viewList.setAlpha(0); - viewList.setVisibility(View.VISIBLE); - viewList.animate().setDuration(100) - .alpha(1.0f).start(); - } - }).start(); - } else { - mShowingHistoryPanel = false; - viewList.setVisibility(View.INVISIBLE); - view.animate().setDuration(200).x(0).withLayer() - .withEndAction(new Runnable() { - public void run() { - lp.x = 0; - view.setLayoutParams(lp); - } - }).start(); + private void toggleHistoryPanel() { + final View view = findViewById(R.id.mainPanel); + final View viewList = findViewById(R.id.historyPanel); + View rootView = viewList.getRootView(); + + // TODO: use a custom layout instead of absolutelayout... + final AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) view + .getLayoutParams(); + final AbsoluteLayout.LayoutParams lph = (AbsoluteLayout.LayoutParams) viewList + .getLayoutParams(); + final int positionHistoryPanel = (int) (rootView.getWidth() - viewList + .getWidth()); + if (!mShowingHistoryPanel) { + mShowingHistoryPanel = true; + view.animate().setDuration(200).x(-viewList.getWidth()) + .withLayer().withEndAction(new Runnable() { + public void run() { + view.setLayoutParams(lp); + lph.x = positionHistoryPanel; + viewList.setLayoutParams(lph); + viewList.setAlpha(0); + viewList.setVisibility(View.VISIBLE); + viewList.animate().setDuration(100) + .alpha(1.0f).start(); + } + }).start(); + } else { + mShowingHistoryPanel = false; + viewList.setVisibility(View.INVISIBLE); + view.animate().setDuration(200).x(0).withLayer() + .withEndAction(new Runnable() { + public void run() { + lp.x = 0; + view.setLayoutParams(lp); + } + }).start(); + } + invalidateOptionsMenu(); + } - } - } - }; + private void resetHistory() { + HistoryAdapter adapter = (HistoryAdapter) mImageShow + .getListAdapter(); + adapter.reset(); + ImagePreset original = new ImagePreset(adapter.getItem(0)); + mImageShow.setImagePreset(original); + invalidateViews(); } // reset button in the history panel. @@ -393,12 +406,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener return new View.OnClickListener() { @Override public void onClick(View v) { - HistoryAdapter adapter = (HistoryAdapter) mImageShow - .getListAdapter(); - adapter.reset(); - ImagePreset original = new ImagePreset(adapter.getItem(0)); - mImageShow.setImagePreset(original); - invalidateViews(); + resetHistory(); } }; } @@ -649,12 +657,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener r.getDisplayMetrics()); } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.filtershow_activity_menu, menu); - return true; - } - public void useImagePreset(ImagePreset preset) { if (preset == null) { return; diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java index b301394ea..a22170378 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java @@ -237,7 +237,7 @@ public class ImageShow extends View implements SliderListener { } public boolean showTitle() { - return true; + return false; } public void setImagePreset(ImagePreset preset) { diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java b/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java index 78e40051d..f8794230c 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java @@ -66,6 +66,10 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener return mImageLoader.getOriginalBitmapSmall(); } + public boolean showTitle() { + return true; + } + public boolean showControls() { return false; } diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java b/src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java deleted file mode 100644 index 8c0e22711..000000000 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.android.gallery3d.filtershow.imageshow; - -public class ImageVignette { - -} |