summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2013-03-09 11:18:43 -0800
committernicolasroard <nicolasroard@google.com>2013-03-11 10:33:31 -0700
commit6019ad95f1c85786488d2d4cae1cbb665d33bd30 (patch)
treea8b16ee6e60e7b9368392a57b4629209a6f56532
parent402dd963ad8fb1dfed81cca63cbaf82e93533a94 (diff)
downloadandroid_packages_apps_Gallery2-6019ad95f1c85786488d2d4cae1cbb665d33bd30.tar.gz
android_packages_apps_Gallery2-6019ad95f1c85786488d2d4cae1cbb665d33bd30.tar.bz2
android_packages_apps_Gallery2-6019ad95f1c85786488d2d4cae1cbb665d33bd30.zip
Add tiled background
Change-Id: I52292f6cae4f1121795829663dc4738cb38a953b
-rw-r--r--res/drawable/filtershow_background.pngbin653905 -> 1863 bytes
-rw-r--r--res/drawable/filtershow_tiled_background.xml21
-rw-r--r--res/layout-land/filtershow_activity.xml89
-rw-r--r--res/layout/filtershow_activity.xml89
-rw-r--r--res/layout/filtershow_history_operation_row.xml23
-rw-r--r--res/layout/filtershow_history_panel.xml64
-rw-r--r--res/layout/filtershow_state_panel.xml45
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java30
-rw-r--r--src/com/android/gallery3d/filtershow/HistoryAdapter.java2
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java23
10 files changed, 210 insertions, 176 deletions
diff --git a/res/drawable/filtershow_background.png b/res/drawable/filtershow_background.png
index e7646c33a..22e1641dd 100644
--- a/res/drawable/filtershow_background.png
+++ b/res/drawable/filtershow_background.png
Binary files differ
diff --git a/res/drawable/filtershow_tiled_background.xml b/res/drawable/filtershow_tiled_background.xml
new file mode 100644
index 000000000..055fbcd63
--- /dev/null
+++ b/res/drawable/filtershow_tiled_background.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2013 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.
+-->
+<bitmap
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/filtershow_background"
+ android:tileMode="repeat"
+ android:dither="false" /> \ No newline at end of file
diff --git a/res/layout-land/filtershow_activity.xml b/res/layout-land/filtershow_activity.xml
index 8cef0cef8..957a36592 100644
--- a/res/layout-land/filtershow_activity.xml
+++ b/res/layout-land/filtershow_activity.xml
@@ -19,7 +19,8 @@
xmlns:iconbutton="http://schemas.android.com/apk/res/com.android.gallery3d"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:id="@+id/mainView">
+ android:id="@+id/mainView"
+ android:background="@drawable/filtershow_tiled_background">
<LinearLayout
android:layout_width="match_parent"
@@ -58,79 +59,19 @@
android:layout_weight="1"
android:orientation="vertical" >
- <LinearLayout
- android:id="@+id/imageStatePanel"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_weight="1"
- android:visibility="visible" >
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@android:color/transparent"
- android:gravity="center"
- android:padding="2dip"
- android:text="@string/imageState"
- android:textColor="@android:color/white"
- android:textSize="24sp"
- android:textStyle="bold" />
-
- <ListView
- android:id="@+id/imageStateList"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1" >
- </ListView>
-
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/historyPanel"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:layout_weight="1"
- android:visibility="gone" >
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@android:color/transparent"
- android:gravity="center"
- android:padding="2dip"
- android:text="@string/history"
- android:textColor="@android:color/white"
- android:textSize="24sp"
- android:textStyle="bold" />
-
- <ListView
- android:id="@+id/operationsList"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1" >
- </ListView>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
-
- <Button
- android:id="@+id/resetOperationsButton"
- style="@style/FilterShowHistoryButton"
- android:gravity="center"
- android:text="@string/reset" />
-
- <Button
- android:id="@+id/saveOperationsButton"
- style="@style/FilterShowHistoryButton"
- android:text="@string/save"
- android:visibility="gone" />
- </LinearLayout>
- </LinearLayout>
-
+ <ViewStub android:id="@+id/statePanelStub"
+ android:inflatedId="@+id/imageStatePanel"
+ android:layout="@layout/filtershow_state_panel"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="visible" />
+
+ <ViewStub android:id="@+id/historyPanelStub"
+ android:inflatedId="@+id/historyPanel"
+ android:layout="@layout/filtershow_history_panel"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone" />
<FrameLayout
android:layout_gravity="bottom"
diff --git a/res/layout/filtershow_activity.xml b/res/layout/filtershow_activity.xml
index 6bdd48710..c723aaba5 100644
--- a/res/layout/filtershow_activity.xml
+++ b/res/layout/filtershow_activity.xml
@@ -19,7 +19,8 @@
xmlns:iconbutton="http://schemas.android.com/apk/res/com.android.gallery3d"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:id="@+id/mainView">
+ android:id="@+id/mainView"
+ android:background="@drawable/filtershow_tiled_background">
<LinearLayout
android:layout_width="match_parent"
@@ -247,80 +248,22 @@
</LinearLayout>
- <LinearLayout
- android:id="@+id/imageStatePanel"
- android:layout_width="400dip"
- android:layout_height="match_parent"
- android:layout_gravity="right"
- android:orientation="vertical"
- android:layout_weight="1"
- android:visibility="gone" >
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@android:color/transparent"
- android:gravity="center"
- android:padding="2dip"
- android:text="@string/imageState"
- android:textColor="@android:color/white"
- android:textSize="24sp"
- android:textStyle="bold" />
-
- <ListView
- android:id="@+id/imageStateList"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1" >
- </ListView>
-
- </LinearLayout>
+ <ViewStub android:id="@+id/statePanelStub"
+ android:inflatedId="@+id/imageStatePanel"
+ android:layout="@layout/filtershow_state_panel"
+ android:layout_width="200dip"
+ android:layout_height="match_parent"
+ android:layout_gravity="right"
+ android:visibility="visible" />
</LinearLayout>
- <LinearLayout
- android:id="@+id/historyPanel"
- android:layout_width="200dip"
- android:layout_height="match_parent"
- android:layout_gravity="right"
- android:orientation="vertical"
- android:visibility="invisible" >
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@android:color/transparent"
- android:gravity="center"
- android:padding="2dip"
- android:text="@string/history"
- android:textColor="@android:color/white"
- android:textSize="24sp"
- android:textStyle="bold" />
-
- <ListView
- android:id="@+id/operationsList"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1" >
- </ListView>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
-
- <Button
- android:id="@+id/resetOperationsButton"
- style="@style/FilterShowHistoryButton"
- android:gravity="center"
- android:text="@string/reset" />
-
- <Button
- android:id="@+id/saveOperationsButton"
- style="@style/FilterShowHistoryButton"
- android:text="@string/save"
- android:visibility="gone" />
- </LinearLayout>
- </LinearLayout>
+ <ViewStub android:id="@+id/historyPanelStub"
+ android:inflatedId="@+id/historyPanel"
+ android:layout="@layout/filtershow_history_panel"
+ android:layout_width="200dip"
+ android:layout_height="match_parent"
+ android:layout_gravity="right"
+ android:visibility="invisible" />
</FrameLayout>
diff --git a/res/layout/filtershow_history_operation_row.xml b/res/layout/filtershow_history_operation_row.xml
index 4042f71db..25a0d26f6 100644
--- a/res/layout/filtershow_history_operation_row.xml
+++ b/res/layout/filtershow_history_operation_row.xml
@@ -17,20 +17,18 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="120dip"
android:gravity="center_horizontal"
- android:orientation="vertical"
- android:padding="10dip"
- android:background="@drawable/filtershow_button_background">
+ android:orientation="horizontal"
+ android:padding="0dip"
+ android:background="@color/background_main_toolbar">
<ImageView
android:id="@+id/preview"
- android:background="@android:color/transparent"
- android:layout_width="match_parent"
- android:layout_height="128dip"
+ android:layout_width="180dip"
+ android:layout_height="120dip"
android:scaleType="centerCrop"
android:cropToPadding="true"
- android:paddingTop="10dip"
android:visibility="visible"
/>
@@ -38,11 +36,12 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowTextView"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:layout_weight="1"
- android:gravity="center_horizontal"
- android:padding="5dip"
- android:textSize="16dip">
+ android:gravity="bottom|right"
+ android:padding="10dip"
+ android:textSize="16dip"
+ android:textStyle="bold">
</TextView>
</LinearLayout> \ No newline at end of file
diff --git a/res/layout/filtershow_history_panel.xml b/res/layout/filtershow_history_panel.xml
new file mode 100644
index 000000000..392e39cbe
--- /dev/null
+++ b/res/layout/filtershow_history_panel.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2013 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:id="@+id/historyPanel"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_weight="1"
+ android:visibility="gone" >
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@android:color/transparent"
+ android:gravity="center"
+ android:padding="2dip"
+ android:text="@string/history"
+ android:textColor="@android:color/white"
+ android:textSize="24sp"
+ android:textStyle="bold" />
+
+ <ListView
+ android:id="@+id/operationsList"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:padding="10dip"
+ android:divider="@android:color/transparent"
+ android:dividerHeight="10dip" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/resetOperationsButton"
+ style="@style/FilterShowHistoryButton"
+ android:gravity="center"
+ android:text="@string/reset" />
+
+ <Button
+ android:id="@+id/saveOperationsButton"
+ style="@style/FilterShowHistoryButton"
+ android:text="@string/save"
+ android:visibility="gone" />
+ </LinearLayout>
+</LinearLayout>
diff --git a/res/layout/filtershow_state_panel.xml b/res/layout/filtershow_state_panel.xml
new file mode 100644
index 000000000..1f9f970b9
--- /dev/null
+++ b/res/layout/filtershow_state_panel.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2013 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:id="@+id/imageStatePanel"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_weight="1"
+ android:visibility="visible" >
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@android:color/transparent"
+ android:gravity="center"
+ android:padding="2dip"
+ android:text="@string/imageState"
+ android:textColor="@android:color/white"
+ android:textSize="24sp"
+ android:textStyle="bold" />
+
+ <ListView
+ android:id="@+id/imageStateList"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" >
+ </ListView>
+
+</LinearLayout> \ No newline at end of file
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index e36a3841e..1c7c0642a 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -37,13 +37,8 @@ import android.provider.MediaStore;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
-import android.view.Display;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
+import android.view.*;
import android.view.View.OnClickListener;
-import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.FrameLayout;
@@ -208,23 +203,32 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mPanelController.addView(findViewById(R.id.applyEffect));
+ ((ViewStub) findViewById(R.id.historyPanelStub)).inflate();
+ ((ViewStub) findViewById(R.id.statePanelStub)).inflate();
+ setupHistoryPanel();
+ setupStatePanel();
+
+ mPanelController.setRowPanel(findViewById(R.id.secondRowPanel));
+ mPanelController.setUtilityPanel(this, findViewById(R.id.filterButtonsList),
+ findViewById(R.id.panelAccessoryViewList),
+ findViewById(R.id.applyEffect));
+
+ mPanelController.setCurrentPanel(R.id.fxButton);
+ }
+
+ public void setupHistoryPanel() {
findViewById(R.id.resetOperationsButton).setOnClickListener(
createOnClickResetOperationsButton());
ListView operationsList = (ListView) findViewById(R.id.operationsList);
operationsList.setAdapter(mMasterImage.getHistory());
operationsList.setOnItemClickListener(this);
+ }
+ public void setupStatePanel() {
ListView imageStateList = (ListView) findViewById(R.id.imageStateList);
imageStateList.setAdapter(mMasterImage.getState());
mImageLoader.setAdapter(mMasterImage.getHistory());
-
- mPanelController.setRowPanel(findViewById(R.id.secondRowPanel));
- mPanelController.setUtilityPanel(this, findViewById(R.id.filterButtonsList),
- findViewById(R.id.panelAccessoryViewList),
- findViewById(R.id.applyEffect));
-
- mPanelController.setCurrentPanel(R.id.fxButton);
}
private void fillPanel(Vector<FilterRepresentation> representations, int layoutId, int buttonId) {
diff --git a/src/com/android/gallery3d/filtershow/HistoryAdapter.java b/src/com/android/gallery3d/filtershow/HistoryAdapter.java
index a10e66ba4..dc42f4027 100644
--- a/src/com/android/gallery3d/filtershow/HistoryAdapter.java
+++ b/src/com/android/gallery3d/filtershow/HistoryAdapter.java
@@ -205,7 +205,7 @@ public class HistoryAdapter extends ArrayAdapter<ImagePreset> {
if (position == mCurrentPresetPosition) {
view.setBackgroundColor(Color.WHITE);
} else {
- view.setBackgroundResource(R.drawable.filtershow_button_background);
+ view.setBackgroundResource(R.color.background_main_toolbar);
}
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index f44e6f5a7..92d6c7435 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -28,6 +28,7 @@ import android.graphics.RectF;
import android.net.Uri;
import android.os.Handler;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.OnDoubleTapListener;
import android.view.GestureDetector.OnGestureListener;
@@ -249,7 +250,7 @@ public class ImageShow extends View implements OnGestureListener,
Point translate = MasterImage.getImage().getTranslation();
float scaleFactor = MasterImage.getImage().getScaleFactor();
m.postTranslate(translate.x, translate.y);
- m.postScale(scaleFactor, scaleFactor, getWidth()/2.0f, getHeight()/2.0f);
+ m.postScale(scaleFactor, scaleFactor, getWidth() / 2.0f, getHeight() / 2.0f);
return m;
}
@@ -301,12 +302,26 @@ public class ImageShow extends View implements OnGestureListener,
@Override
public void onDraw(Canvas canvas) {
MasterImage.getImage().setImageShowSize(getWidth(), getHeight());
- canvas.save();
- // TODO: center scale on gesture
+
float cx = canvas.getWidth()/2.0f;
float cy = canvas.getHeight()/2.0f;
float scaleFactor = MasterImage.getImage().getScaleFactor();
Point translation = MasterImage.getImage().getTranslation();
+
+ Matrix scalingMatrix = new Matrix();
+ scalingMatrix.postScale(scaleFactor, scaleFactor, cx, cy);
+ scalingMatrix.preTranslate(translation.x, translation.y);
+
+ RectF unscaledClipRect = new RectF(mImageBounds);
+ scalingMatrix.mapRect(unscaledClipRect, unscaledClipRect);
+
+ canvas.save();
+ if (!unscaledClipRect.isEmpty()) {
+ canvas.clipRect(unscaledClipRect);
+ }
+
+ canvas.save();
+ // TODO: center scale on gesture
canvas.scale(scaleFactor, scaleFactor, cx, cy);
canvas.translate(translation.x, translation.y);
drawBackground(canvas);
@@ -337,6 +352,8 @@ public class ImageShow extends View implements OnGestureListener,
drawPartialImage(canvas, getGeometryOnlyImage());
canvas.restore();
+ canvas.restore();
+
drawToast(canvas);
}