diff options
Diffstat (limited to 'src/com/android/camera/ui')
-rw-r--r-- | src/com/android/camera/ui/CameraRootView.java | 5 | ||||
-rw-r--r-- | src/com/android/camera/ui/EffectSettingPopup.java | 213 | ||||
-rw-r--r-- | src/com/android/camera/ui/FaceView.java | 5 | ||||
-rw-r--r-- | src/com/android/camera/ui/ModuleSwitcher.java | 10 | ||||
-rw-r--r-- | src/com/android/camera/ui/RotateLayout.java | 119 | ||||
-rw-r--r-- | src/com/android/camera/ui/Switch.java | 10 |
6 files changed, 24 insertions, 338 deletions
diff --git a/src/com/android/camera/ui/CameraRootView.java b/src/com/android/camera/ui/CameraRootView.java index 49a157568..35a585e92 100644 --- a/src/com/android/camera/ui/CameraRootView.java +++ b/src/com/android/camera/ui/CameraRootView.java @@ -43,9 +43,6 @@ public class CameraRootView extends FrameLayout { private Object mDisplayListener; private MyDisplayListener mListener; - // Hideybars are available on K and up. - private static final boolean HIDEYBARS_ENABLED = CameraActivity.isKitKatOrHigher(); - public interface MyDisplayListener { public void onDisplayChanged(); } @@ -59,7 +56,7 @@ public class CameraRootView extends FrameLayout { @Override protected boolean fitSystemWindows(Rect insets) { - if (!HIDEYBARS_ENABLED) { + if (!ApiHelper.HAS_HIDEYBARS) { mCurrentInsets = insets; // insets include status bar, navigation bar, etc // In this case, we are only concerned with the size of nav bar diff --git a/src/com/android/camera/ui/EffectSettingPopup.java b/src/com/android/camera/ui/EffectSettingPopup.java deleted file mode 100644 index 1ee278d21..000000000 --- a/src/com/android/camera/ui/EffectSettingPopup.java +++ /dev/null @@ -1,213 +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.camera.ui; - -import java.util.ArrayList; -import java.util.HashMap; - -import android.annotation.TargetApi; -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 com.android.camera.IconListPreference; -import com.android.camera2.R; -import com.android.camera.util.ApiHelper; - -// 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 static final String TAG = "EffectSettingPopup"; - private String mNoEffect; - private IconListPreference mPreference; - private Listener mListener; - private View mClearEffects; - private GridView mSillyFacesGrid; - private GridView mBackgroundGrid; - - // Data for silly face items. (text, image, and preference value) - ArrayList<HashMap<String, Object>> mSillyFacesItem = - new ArrayList<HashMap<String, Object>>(); - - // Data for background replacer items. (text, image, and preference value) - ArrayList<HashMap<String, Object>> mBackgroundItem = - new ArrayList<HashMap<String, Object>>(); - - - static public interface Listener { - public void onSettingChanged(); - } - - public EffectSettingPopup(Context context, AttributeSet attrs) { - super(context, attrs); - mNoEffect = context.getString(R.string.pref_video_effect_default); - } - - @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(); - CharSequence[] entryValues = mPreference.getEntryValues(); - int[] iconIds = mPreference.getImageIds(); - if (iconIds == null) { - iconIds = mPreference.getLargeIconIds(); - } - - // Set title. - mTitle.setText(mPreference.getTitle()); - - for(int i = 0; i < entries.length; ++i) { - String value = entryValues[i].toString(); - if (value.equals(mNoEffect)) continue; // no effect, skip it. - HashMap<String, Object> map = new HashMap<String, Object>(); - map.put("value", value); - map.put("text", entries[i].toString()); - if (iconIds != null) map.put("image", iconIds[i]); - if (value.startsWith("goofy_face")) { - mSillyFacesItem.add(map); - } else if (value.startsWith("backdropper")) { - mBackgroundItem.add(map); - } - } - - boolean hasSillyFaces = mSillyFacesItem.size() > 0; - boolean hasBackground = mBackgroundItem.size() > 0; - - // Initialize goofy face if it is supported. - if (hasSillyFaces) { - findViewById(R.id.effect_silly_faces_title).setVisibility(View.VISIBLE); - findViewById(R.id.effect_silly_faces_title_separator).setVisibility(View.VISIBLE); - mSillyFacesGrid.setVisibility(View.VISIBLE); - SimpleAdapter sillyFacesItemAdapter = new SimpleAdapter(context, - mSillyFacesItem, R.layout.effect_setting_item, - new String[] {"text", "image"}, - new int[] {R.id.text, R.id.image}); - mSillyFacesGrid.setAdapter(sillyFacesItemAdapter); - mSillyFacesGrid.setOnItemClickListener(this); - } - - if (hasSillyFaces && hasBackground) { - findViewById(R.id.effect_background_separator).setVisibility(View.VISIBLE); - } - - // Initialize background replacer if it is supported. - if (hasBackground) { - findViewById(R.id.effect_background_title).setVisibility(View.VISIBLE); - findViewById(R.id.effect_background_title_separator).setVisibility(View.VISIBLE); - mBackgroundGrid.setVisibility(View.VISIBLE); - SimpleAdapter backgroundItemAdapter = new SimpleAdapter(context, - mBackgroundItem, 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. - boolean noEffect = mPreference.getValue().equals(mNoEffect); - mClearEffects.setVisibility(noEffect ? View.GONE : View.VISIBLE); - } - reloadPreference(); - } - super.setVisibility(visibility); - } - - // The value of the preference may have changed. Update the UI. - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) - @Override - public void reloadPreference() { - mBackgroundGrid.setItemChecked(mBackgroundGrid.getCheckedItemPosition(), false); - mSillyFacesGrid.setItemChecked(mSillyFacesGrid.getCheckedItemPosition(), false); - - String value = mPreference.getValue(); - if (value.equals(mNoEffect)) return; - - for (int i = 0; i < mSillyFacesItem.size(); i++) { - if (value.equals(mSillyFacesItem.get(i).get("value"))) { - mSillyFacesGrid.setItemChecked(i, true); - return; - } - } - - for (int i = 0; i < mBackgroundItem.size(); i++) { - if (value.equals(mBackgroundItem.get(i).get("value"))) { - mBackgroundGrid.setItemChecked(i, true); - return; - } - } - - Log.e(TAG, "Invalid preference value: " + value); - mPreference.print(); - } - - public void setSettingChangedListener(Listener listener) { - mListener = listener; - } - - @Override - public void onItemClick(AdapterView<?> parent, View view, - int index, long id) { - String value; - if (parent == mSillyFacesGrid) { - value = (String) mSillyFacesItem.get(index).get("value"); - } else if (parent == mBackgroundGrid) { - value = (String) mBackgroundItem.get(index).get("value"); - } else { - return; - } - - // Tapping the selected effect will deselect it (clear effects). - if (value.equals(mPreference.getValue())) { - mPreference.setValue(mNoEffect); - } else { - mPreference.setValue(value); - } - reloadPreference(); - if (mListener != null) mListener.onSettingChanged(); - } - - @Override - public void onClick(View v) { - // Clear the effect. - mPreference.setValue(mNoEffect); - reloadPreference(); - if (mListener != null) mListener.onSettingChanged(); - } -} diff --git a/src/com/android/camera/ui/FaceView.java b/src/com/android/camera/ui/FaceView.java index 7ec9b7e54..1b3a9c72e 100644 --- a/src/com/android/camera/ui/FaceView.java +++ b/src/com/android/camera/ui/FaceView.java @@ -16,7 +16,6 @@ package com.android.camera.ui; -import android.annotation.TargetApi; import android.content.Context; import android.content.res.Resources; import android.graphics.Canvas; @@ -31,12 +30,10 @@ import android.util.AttributeSet; import android.util.Log; import android.view.View; -import com.android.camera.util.CameraUtil; import com.android.camera.PhotoUI; +import com.android.camera.util.CameraUtil; import com.android.camera2.R; -import com.android.camera.util.ApiHelper; -@TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public class FaceView extends View implements FocusIndicator, Rotatable, PhotoUI.SurfaceTextureSizeChangedListener { diff --git a/src/com/android/camera/ui/ModuleSwitcher.java b/src/com/android/camera/ui/ModuleSwitcher.java index 5eb316c7f..69ae3b57e 100644 --- a/src/com/android/camera/ui/ModuleSwitcher.java +++ b/src/com/android/camera/ui/ModuleSwitcher.java @@ -34,7 +34,6 @@ import android.view.ViewGroup; import android.widget.FrameLayout.LayoutParams; import android.widget.LinearLayout; -import com.android.camera.util.ApiHelper; import com.android.camera.util.CameraUtil; import com.android.camera.util.PhotoSphereHelper; import com.android.camera.util.UsageStatistics; @@ -317,9 +316,6 @@ public class ModuleSwitcher extends RotateImageView } private void popupAnimationSetup() { - if (!ApiHelper.HAS_VIEW_PROPERTY_ANIMATOR) { - return; - } layoutPopup(); mPopup.setScaleX(0.3f); mPopup.setScaleY(0.3f); @@ -329,9 +325,6 @@ public class ModuleSwitcher extends RotateImageView } private boolean animateHidePopup() { - if (!ApiHelper.HAS_VIEW_PROPERTY_ANIMATOR) { - return false; - } if (mHideAnimationListener == null) { mHideAnimationListener = new AnimatorListenerAdapter() { @Override @@ -358,9 +351,6 @@ public class ModuleSwitcher extends RotateImageView } private boolean animateShowPopup() { - if (!ApiHelper.HAS_VIEW_PROPERTY_ANIMATOR) { - return false; - } if (mNeedsAnimationSetup) { popupAnimationSetup(); } diff --git a/src/com/android/camera/ui/RotateLayout.java b/src/com/android/camera/ui/RotateLayout.java index 044da1cee..8539eb64c 100644 --- a/src/com/android/camera/ui/RotateLayout.java +++ b/src/com/android/camera/ui/RotateLayout.java @@ -16,19 +16,11 @@ package com.android.camera.ui; -import android.annotation.TargetApi; import android.content.Context; -import android.graphics.Canvas; import android.graphics.Matrix; -import android.graphics.Rect; import android.util.AttributeSet; -import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.view.ViewParent; - -import com.android.camera.util.MotionEventHelper; -import com.android.camera.util.ApiHelper; // A RotateLayout is designed to display a single item and provides the // capabilities to rotate the item. @@ -48,14 +40,11 @@ public class RotateLayout extends ViewGroup implements Rotatable { setBackgroundResource(android.R.color.transparent); } - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) @Override protected void onFinishInflate() { mChild = getChildAt(0); - if (ApiHelper.HAS_VIEW_TRANSFORM_PROPERTIES) { - mChild.setPivotX(0); - mChild.setPivotY(0); - } + mChild.setPivotX(0); + mChild.setPivotY(0); } @Override @@ -76,60 +65,6 @@ public class RotateLayout extends ViewGroup implements Rotatable { } @Override - public boolean dispatchTouchEvent(MotionEvent event) { - if (!ApiHelper.HAS_VIEW_TRANSFORM_PROPERTIES) { - final int w = getMeasuredWidth(); - final int h = getMeasuredHeight(); - switch (mOrientation) { - case 0: - mMatrix.setTranslate(0, 0); - break; - case 90: - mMatrix.setTranslate(0, -h); - break; - case 180: - mMatrix.setTranslate(-w, -h); - break; - case 270: - mMatrix.setTranslate(-w, 0); - break; - } - mMatrix.postRotate(mOrientation); - event = MotionEventHelper.transformEvent(event, mMatrix); - } - return super.dispatchTouchEvent(event); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - if (ApiHelper.HAS_VIEW_TRANSFORM_PROPERTIES) { - super.dispatchDraw(canvas); - } else { - canvas.save(); - int w = getMeasuredWidth(); - int h = getMeasuredHeight(); - switch (mOrientation) { - case 0: - canvas.translate(0, 0); - break; - case 90: - canvas.translate(0, h); - break; - case 180: - canvas.translate(w, h); - break; - case 270: - canvas.translate(w, 0); - break; - } - canvas.rotate(-mOrientation, 0, 0); - super.dispatchDraw(canvas); - canvas.restore(); - } - } - - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) - @Override protected void onMeasure(int widthSpec, int heightSpec) { int w = 0, h = 0; switch(mOrientation) { @@ -148,27 +83,25 @@ public class RotateLayout extends ViewGroup implements Rotatable { } setMeasuredDimension(w, h); - if (ApiHelper.HAS_VIEW_TRANSFORM_PROPERTIES) { - switch (mOrientation) { - case 0: - mChild.setTranslationX(0); - mChild.setTranslationY(0); - break; - case 90: - mChild.setTranslationX(0); - mChild.setTranslationY(h); - break; - case 180: - mChild.setTranslationX(w); - mChild.setTranslationY(h); - break; - case 270: - mChild.setTranslationX(w); - mChild.setTranslationY(0); - break; - } - mChild.setRotation(-mOrientation); + switch (mOrientation) { + case 0: + mChild.setTranslationX(0); + mChild.setTranslationY(0); + break; + case 90: + mChild.setTranslationX(0); + mChild.setTranslationY(h); + break; + case 180: + mChild.setTranslationX(w); + mChild.setTranslationY(h); + break; + case 270: + mChild.setTranslationX(w); + mChild.setTranslationY(0); + break; } + mChild.setRotation(-mOrientation); } @Override @@ -188,16 +121,4 @@ public class RotateLayout extends ViewGroup implements Rotatable { public int getOrientation() { return mOrientation; } - - @Override - public ViewParent invalidateChildInParent(int[] location, Rect r) { - if (!ApiHelper.HAS_VIEW_TRANSFORM_PROPERTIES && mOrientation != 0) { - // The workaround invalidates the entire rotate layout. After - // rotation, the correct area to invalidate may be larger than the - // size of the child. Ex: ListView. There is no way to invalidate - // only the necessary area. - r.set(0, 0, getWidth(), getHeight()); - } - return super.invalidateChildInParent(location, r); - } } diff --git a/src/com/android/camera/ui/Switch.java b/src/com/android/camera/ui/Switch.java index 4518dedf4..6c3399775 100644 --- a/src/com/android/camera/ui/Switch.java +++ b/src/com/android/camera/ui/Switch.java @@ -24,6 +24,7 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.os.Build; import android.text.Layout; import android.text.StaticLayout; import android.text.TextPaint; @@ -39,7 +40,6 @@ import android.view.accessibility.AccessibilityNodeInfo; import android.widget.CompoundButton; import com.android.camera2.R; -import com.android.camera.util.ApiHelper; /** * A Switch is a two-state toggle switch widget that can select between two @@ -82,7 +82,6 @@ public class Switch extends CompoundButton { private Layout mOnLayout; private Layout mOffLayout; - @SuppressWarnings("hiding") private final Rect mTempRect = new Rect(); private static final int[] CHECKED_STATE_SET = { @@ -151,8 +150,6 @@ public class Switch extends CompoundButton { @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int widthMode = MeasureSpec.getMode(widthMeasureSpec); - int widthSize = MeasureSpec.getSize(widthMeasureSpec); if (mOnLayout == null) { mOnLayout = makeLayout(mTextOn, mSwitchTextMaxWidth); } @@ -180,7 +177,7 @@ public class Switch extends CompoundButton { } } - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) + @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { super.onPopulateAccessibilityEvent(event); @@ -464,7 +461,6 @@ public class Switch extends CompoundButton { return super.verifyDrawable(who) || who == mThumbDrawable || who == mTrackDrawable; } - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) @Override public void jumpDrawablesToCurrentState() { super.jumpDrawablesToCurrentState(); @@ -472,14 +468,12 @@ public class Switch extends CompoundButton { mTrackDrawable.jumpToCurrentState(); } - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setClassName(Switch.class.getName()); } - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); |