summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable/bg_pressed.xml (renamed from res/drawable/bg_review_control.xml)0
-rw-r--r--res/layout/effect_setting_popup.xml40
-rw-r--r--res/values-w1024dp/dimens.xml5
-rw-r--r--res/values-w1024dp/styles.xml2
-rw-r--r--res/values/dimens.xml5
-rw-r--r--res/values/strings.xml9
-rw-r--r--res/values/styles.xml21
-rw-r--r--src/com/android/camera/EffectsRecorder.java1
-rw-r--r--src/com/android/camera/ui/BasicSettingPopup.java4
-rw-r--r--src/com/android/camera/ui/EffectSettingPopup.java173
-rw-r--r--src/com/android/camera/ui/ExpandedGridView.java36
-rw-r--r--src/com/android/camera/ui/IndicatorButton.java21
12 files changed, 294 insertions, 23 deletions
diff --git a/res/drawable/bg_review_control.xml b/res/drawable/bg_pressed.xml
index 979cc86..979cc86 100644
--- a/res/drawable/bg_review_control.xml
+++ b/res/drawable/bg_pressed.xml
diff --git a/res/layout/effect_setting_popup.xml b/res/layout/effect_setting_popup.xml
index ad22d9f..5fa4ad2 100644
--- a/res/layout/effect_setting_popup.xml
+++ b/res/layout/effect_setting_popup.xml
@@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<com.android.camera.ui.BasicSettingPopup xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.camera.ui.EffectSettingPopup xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/SettingPopupWindow">
<LinearLayout android:orientation="vertical"
@@ -30,12 +30,36 @@
</FrameLayout>
<View style="@style/PopupTitleSeperator" />
-
- <FrameLayout android:layout_width="match_parent"
+ <ScrollView
+ android:layout_width="match_parent"
android:layout_height="wrap_content">
- <GridView android:id="@+id/settingList"
- style="@style/EffectSettingGrid"
- android:choiceMode="singleChoice" />
- </FrameLayout>
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <TextView android:id="@+id/clear_effects"
+ android:text="@string/clear_effects"
+ style="@style/EffectSettingTypeTitle"
+ android:textSize="@dimen/effect_setting_clear_text_size"
+ android:minHeight="@dimen/effect_setting_clear_text_min_height"
+ android:background="@drawable/bg_pressed"/>
+ <View style="@style/EffectTitleSeparator"/>
+ <TextView
+ android:text="@string/effect_silly_faces"
+ style="@style/EffectSettingTypeTitle"/>
+ <com.android.camera.ui.ExpandedGridView android:id="@+id/effect_silly_faces"
+ style="@style/EffectSettingGrid"/>
+ <View android:id="@+id/effect_background_separator"
+ android:visibility="gone"
+ style="@style/EffectTitleSeparator"/>
+ <TextView android:id="@+id/effect_background_title"
+ android:text="@string/effect_background"
+ android:visibility="gone"
+ style="@style/EffectSettingTypeTitle"/>
+ <com.android.camera.ui.ExpandedGridView android:id="@+id/effect_background"
+ android:visibility="gone"
+ style="@style/EffectSettingGrid"/>
+ </LinearLayout>
+ </ScrollView>
</LinearLayout>
-</com.android.camera.ui.BasicSettingPopup>
+</com.android.camera.ui.EffectSettingPopup>
diff --git a/res/values-w1024dp/dimens.xml b/res/values-w1024dp/dimens.xml
index 4859607..a52bafa 100644
--- a/res/values-w1024dp/dimens.xml
+++ b/res/values-w1024dp/dimens.xml
@@ -47,4 +47,9 @@
<dimen name="setting_item_icon_width">35dp</dimen>
<dimen name="effect_setting_item_icon_width">54dp</dimen>
<dimen name="effect_setting_item_text_size">21dp</dimen>
+ <dimen name="effect_setting_type_text_size">21dp</dimen>
+ <dimen name="effect_setting_type_text_min_height">34dp</dimen>
+ <dimen name="effect_setting_clear_text_size">23dp</dimen>
+ <dimen name="effect_setting_clear_text_min_height">44dp</dimen>
+ <dimen name="effect_setting_type_text_left_padding">26dp</dimen>
</resources>
diff --git a/res/values-w1024dp/styles.xml b/res/values-w1024dp/styles.xml
index a0fd9bd..cda7e86 100644
--- a/res/values-w1024dp/styles.xml
+++ b/res/values-w1024dp/styles.xml
@@ -28,7 +28,7 @@
<item name="android:visibility">gone</item>
<item name="android:clickable">true</item>
<item name="android:focusable">true</item>
- <item name="android:background">@drawable/bg_review_control</item>
+ <item name="android:background">@drawable/bg_pressed</item>
</style>
<style name="ReviewControlIcon">
<item name="android:layout_height">60dp</item>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 74842b2..f34b2e5 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -45,4 +45,9 @@
<dimen name="setting_item_icon_width">28dp</dimen>
<dimen name="effect_setting_item_icon_width">40dp</dimen>
<dimen name="effect_setting_item_text_size">12dp</dimen>
+ <dimen name="effect_setting_type_text_size">18dp</dimen>
+ <dimen name="effect_setting_type_text_min_height">36dp</dimen>
+ <dimen name="effect_setting_clear_text_size">20dp</dimen>
+ <dimen name="effect_setting_clear_text_min_height">36dp</dimen>
+ <dimen name="effect_setting_type_text_left_padding">16dp</dimen>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4db1938..396a645 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -317,4 +317,13 @@
<!-- Toast telling users tapping on the viewfinder will take a picture [CHAR LIMIT=65] -->
<string name="video_snapshot_hint">Take a photo during video recording by tapping on the preview screen.</string>
+
+ <!-- A button in effect setting popup to clear the effect. [CHAR LIMIT=26] -->
+ <string name="clear_effects">Clear effects</string>
+
+ <!-- Title of category for silly face effects. [CHAR LIMIT=26] -->
+ <string name="effect_silly_faces">Silly faces</string>
+
+ <!-- Title of category for background replacement effects. [CHAR LIMIT=26] -->
+ <string name="effect_background">Background</string>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 7a5db3f..8a01313 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -44,7 +44,7 @@
<item name="android:layout_centerHorizontal">true</item>
<item name="android:clickable">true</item>
<item name="android:focusable">true</item>
- <item name="android:background">@drawable/bg_review_control</item>
+ <item name="android:background">@drawable/bg_pressed</item>
</style>
<style name="ReviewPlayIcon">
<item name="android:layout_height">wrap_content</item>
@@ -85,8 +85,6 @@
<style name="PopupTitleSeperator">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">2dp</item>
- <item name="android:layout_marginLeft">@dimen/setting_item_list_margin</item>
- <item name="android:layout_marginRight">@dimen/setting_item_list_margin</item>
<item name="android:background">@color/popup_title_color</item>
</style>
<style name="SettingItemList">
@@ -187,6 +185,7 @@
<item name="android:numColumns">3</item>
<item name="android:verticalSpacing">3dp</item>
<item name="android:horizontalSpacing">3dp</item>
+ <item name="android:choiceMode">singleChoice</item>
</style>
<style name="EffectSettingItem">
<item name="android:orientation">vertical</item>
@@ -207,4 +206,20 @@
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingTop">1dp</item>
</style>
+ <style name="EffectSettingTypeTitle">
+ <item name="android:textSize">@dimen/effect_setting_type_text_size</item>
+ <item name="android:gravity">left|center_vertical</item>
+ <item name="android:textColor">@android:color/white</item>
+ <item name="android:singleLine">true</item>
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:minHeight">@dimen/effect_setting_type_text_min_height</item>
+ <item name="android:paddingLeft">@dimen/effect_setting_type_text_left_padding</item>
+ </style>
+ <style name="EffectTitleSeparator">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">2dp</item>
+ <item name="android:paddingBottom">4dp</item>
+ <item name="android:background">@android:drawable/divider_horizontal_dark</item>
+ </style>
</resources>
diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java
index 6d4faf4..19d9106 100644
--- a/src/com/android/camera/EffectsRecorder.java
+++ b/src/com/android/camera/EffectsRecorder.java
@@ -56,6 +56,7 @@ public class EffectsRecorder {
public static final int EFFECT_GF_SMALL_MOUTH = 3;
public static final int EFFECT_GF_BIG_NOSE = 4;
public static final int EFFECT_GF_SMALL_EYES = 5;
+ public static final int NUM_OF_GF_EFFECTS = EFFECT_GF_SMALL_EYES + 1;
public static final int EFFECT_MSG_STARTED_LEARNING = 0;
public static final int EFFECT_MSG_DONE_LEARNING = 1;
diff --git a/src/com/android/camera/ui/BasicSettingPopup.java b/src/com/android/camera/ui/BasicSettingPopup.java
index 9220c3b..dd50912 100644
--- a/src/com/android/camera/ui/BasicSettingPopup.java
+++ b/src/com/android/camera/ui/BasicSettingPopup.java
@@ -47,7 +47,7 @@ public class BasicSettingPopup extends AbstractSettingPopup implements
super(context, attrs);
}
- public void initialize(IconListPreference preference, int settingItemLayoutId) {
+ public void initialize(IconListPreference preference) {
mPreference = preference;
Context context = getContext();
CharSequence[] entries = mPreference.getEntries();
@@ -69,7 +69,7 @@ public class BasicSettingPopup extends AbstractSettingPopup implements
listItem.add(map);
}
SimpleAdapter listItemAdapter = new SimpleAdapter(context, listItem,
- settingItemLayoutId,
+ R.layout.setting_item,
new String[] {"text", "image"},
new int[] {R.id.text, R.id.image});
((AbsListView) mSettingList).setAdapter(listItemAdapter);
diff --git a/src/com/android/camera/ui/EffectSettingPopup.java b/src/com/android/camera/ui/EffectSettingPopup.java
new file mode 100644
index 0000000..6005c8d
--- /dev/null
+++ b/src/com/android/camera/ui/EffectSettingPopup.java
@@ -0,0 +1,173 @@
+/*
+ * 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.camera.ui;
+
+import com.android.camera.EffectsRecorder;
+import com.android.camera.IconListPreference;
+import com.android.camera.R;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.GridView;
+import android.widget.SimpleAdapter;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+// A popup window that shows video effect setting. It has two grid view.
+// One shows the goofy face effects. The other shows the background replacer
+// effects.
+public class EffectSettingPopup extends AbstractSettingPopup implements
+ AdapterView.OnItemClickListener, View.OnClickListener {
+ private final String TAG = "EffectSettingPopup";
+ private IconListPreference mPreference;
+ private Listener mListener;
+ private View mClearEffects;
+ private GridView mSillyFacesGrid;
+ private GridView mBackgroundGrid;
+
+ static public interface Listener {
+ public void onSettingChanged();
+ }
+
+ public EffectSettingPopup(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mClearEffects = findViewById(R.id.clear_effects);
+ mClearEffects.setOnClickListener(this);
+ mSillyFacesGrid = (GridView) findViewById(R.id.effect_silly_faces);
+ mBackgroundGrid = (GridView) findViewById(R.id.effect_background);
+ }
+
+ public void initialize(IconListPreference preference) {
+ mPreference = preference;
+ Context context = getContext();
+ CharSequence[] entries = mPreference.getEntries();
+ int[] iconIds = mPreference.getImageIds();
+ if (iconIds == null) {
+ iconIds = mPreference.getLargeIconIds();
+ }
+
+ // Set title.
+ mTitle.setText(mPreference.getTitle());
+
+ // Prepare goofy face GridView.
+ ArrayList<HashMap<String, Object>> sillyFacesItem =
+ new ArrayList<HashMap<String, Object>>();
+ // The first is clear effect. Skip it.
+ for(int i = 1; i < EffectsRecorder.NUM_OF_GF_EFFECTS + 1; ++i) {
+ HashMap<String, Object> map = new HashMap<String, Object>();
+ map.put("text", entries[i].toString());
+ if (iconIds != null) map.put("image", iconIds[i]);
+ sillyFacesItem.add(map);
+ }
+ SimpleAdapter sillyFacesItemAdapter = new SimpleAdapter(context,
+ sillyFacesItem, R.layout.effect_setting_item,
+ new String[] {"text", "image"},
+ new int[] {R.id.text, R.id.image});
+ mSillyFacesGrid.setAdapter(sillyFacesItemAdapter);
+ mSillyFacesGrid.setOnItemClickListener(this);
+
+ // Prepare background replacer GridView.
+ ArrayList<HashMap<String, Object>> backgroundItem =
+ new ArrayList<HashMap<String, Object>>();
+ for(int i = EffectsRecorder.NUM_OF_GF_EFFECTS + 1; i < entries.length; ++i) {
+ HashMap<String, Object> map = new HashMap<String, Object>();
+ map.put("text", entries[i].toString());
+ if (iconIds != null) map.put("image", iconIds[i]);
+ backgroundItem.add(map);
+ }
+ // Initialize background replacer if it is supported.
+ if (backgroundItem.size() > 0) {
+ findViewById(R.id.effect_background_separator).setVisibility(View.VISIBLE);
+ findViewById(R.id.effect_background_title).setVisibility(View.VISIBLE);
+ mBackgroundGrid.setVisibility(View.VISIBLE);
+ SimpleAdapter backgroundItemAdapter = new SimpleAdapter(context,
+ backgroundItem, R.layout.effect_setting_item,
+ new String[] {"text", "image"},
+ new int[] {R.id.text, R.id.image});
+ mBackgroundGrid.setAdapter(backgroundItemAdapter);
+ mBackgroundGrid.setOnItemClickListener(this);
+ }
+
+ reloadPreference();
+ }
+
+ @Override
+ public void setVisibility(int visibility) {
+ if (visibility == View.VISIBLE) {
+ if (getVisibility() != View.VISIBLE) {
+ // Do not show or hide "Clear effects" button when the popup
+ // is already visible. Otherwise it looks strange.
+ int index = mPreference.findIndexOfValue(mPreference.getValue());
+ mClearEffects.setVisibility((index <= 0) ? View.GONE : View.VISIBLE);
+ }
+ reloadPreference();
+ }
+ super.setVisibility(visibility);
+ }
+
+ // The value of the preference may have changed. Update the UI.
+ @Override
+ public void reloadPreference() {
+ int index = mPreference.findIndexOfValue(mPreference.getValue());
+ if (index >= 0) {
+ mBackgroundGrid.clearChoices();
+ mSillyFacesGrid.clearChoices();
+ if (index >= 1 && index < EffectsRecorder.NUM_OF_GF_EFFECTS + 1) {
+ mSillyFacesGrid.setItemChecked(index - 1, true);
+ } else if (index >= EffectsRecorder.NUM_OF_GF_EFFECTS + 1) {
+ mBackgroundGrid.setItemChecked(index - EffectsRecorder.NUM_OF_GF_EFFECTS - 1, true);
+ }
+ } else {
+ Log.e(TAG, "Invalid preference value.");
+ mPreference.print();
+ }
+ }
+
+ public void setSettingChangedListener(Listener listener) {
+ mListener = listener;
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int index, long id) {
+ if (parent == mSillyFacesGrid) {
+ // The first one is clear effect.
+ mPreference.setValueIndex(index + 1);
+ } else { // Background replace grid.
+ mPreference.setValueIndex(index + EffectsRecorder.NUM_OF_GF_EFFECTS + 1);
+ }
+ reloadPreference();
+ if (mListener != null) mListener.onSettingChanged();
+ }
+
+ @Override
+ public void onClick(View v) {
+ // Clear the effect.
+ mPreference.setValueIndex(0);
+ reloadPreference();
+ if (mListener != null) mListener.onSettingChanged();
+ }
+}
diff --git a/src/com/android/camera/ui/ExpandedGridView.java b/src/com/android/camera/ui/ExpandedGridView.java
new file mode 100644
index 0000000..13cf58f
--- /dev/null
+++ b/src/com/android/camera/ui/ExpandedGridView.java
@@ -0,0 +1,36 @@
+/*
+ * 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.camera.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.GridView;
+
+public class ExpandedGridView extends GridView {
+ public ExpandedGridView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ // If UNSPECIFIED is passed to GridView, it will show only one row.
+ // Here GridView is put in a ScrollView, so pass it a very big size with
+ // AT_MOST to show all the rows.
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(65536, MeasureSpec.AT_MOST);
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+}
diff --git a/src/com/android/camera/ui/IndicatorButton.java b/src/com/android/camera/ui/IndicatorButton.java
index 7948f7c..9f1cfd5 100644
--- a/src/com/android/camera/ui/IndicatorButton.java
+++ b/src/com/android/camera/ui/IndicatorButton.java
@@ -27,7 +27,8 @@ import android.view.ViewGroup;
// An indicator button that represents one camera setting. Ex: flash. Pressing it opens a popup
// window.
-public class IndicatorButton extends AbstractIndicatorButton implements BasicSettingPopup.Listener {
+public class IndicatorButton extends AbstractIndicatorButton implements BasicSettingPopup.Listener,
+ EffectSettingPopup.Listener{
private final String TAG = "IndicatorButton";
private IconListPreference mPreference;
// Scene mode can override the original preference value.
@@ -103,19 +104,21 @@ public class IndicatorButton extends AbstractIndicatorButton implements BasicSet
Context.LAYOUT_INFLATER_SERVICE);
ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.frame_layout);
- BasicSettingPopup popup;
+ AbstractSettingPopup popup;
if (CameraSettings.KEY_VIDEO_EFFECT.equals(getKey())) {
- popup = (BasicSettingPopup) inflater.inflate(
+ EffectSettingPopup effect = (EffectSettingPopup) inflater.inflate(
R.layout.effect_setting_popup, root, false);
- popup.initialize(mPreference, R.layout.effect_setting_item);
+ effect.initialize(mPreference);
+ effect.setSettingChangedListener(this);
+ mPopup = effect;
} else {
- popup = (BasicSettingPopup) inflater.inflate(
+ BasicSettingPopup basic = (BasicSettingPopup) inflater.inflate(
R.layout.basic_setting_popup, root, false);
- popup.initialize(mPreference, R.layout.setting_item);
+ basic.initialize(mPreference);
+ basic.setSettingChangedListener(this);
+ mPopup = basic;
}
- popup.setSettingChangedListener(this);
- root.addView(popup);
- mPopup = popup;
+ root.addView(mPopup);
}
@Override