OSDN Git Service

Mode switcher refinements.
authorDoris Liu <tianliu@google.com>
Mon, 10 Feb 2014 22:42:08 +0000 (14:42 -0800)
committerDoris Liu <tianliu@google.com>
Mon, 10 Feb 2014 23:33:52 +0000 (15:33 -0800)
- Increase the mode switch icon size.
- Change mode cover color to 0x191919
- Change the font of mode text to roboto medium
- Change the highlight state of mode icon to fill

Bug: 12954273
Bug: 12954790
Bug: 12954370
Bug: 12953261
Change-Id: I23ef62ae4ce5589da20c7ee6bf805e5af70b62f2

assets/fonts/Roboto-Light.ttf [deleted file]
assets/fonts/Roboto-Medium.ttf [new file with mode: 0644]
res/values/colors.xml
res/values/dimens.xml
src/com/android/camera/app/CameraAppUI.java
src/com/android/camera/ui/ModeIconView.java
src/com/android/camera/ui/ModeListView.java
src/com/android/camera/ui/ModeSelectorItem.java
src/com/android/camera/util/ApiHelper.java

diff --git a/assets/fonts/Roboto-Light.ttf b/assets/fonts/Roboto-Light.ttf
deleted file mode 100644 (file)
index 13bf13a..0000000
Binary files a/assets/fonts/Roboto-Light.ttf and /dev/null differ
diff --git a/assets/fonts/Roboto-Medium.ttf b/assets/fonts/Roboto-Medium.ttf
new file mode 100644 (file)
index 0000000..d0f6e2b
Binary files /dev/null and b/assets/fonts/Roboto-Medium.ttf differ
index c8b2abe..efeab76 100644 (file)
@@ -85,6 +85,7 @@
     <color name="timelapse_mode_color">#88695e</color>
     <color name="panorama_mode_color">#f1c938</color>
     <color name="settings_mode_color">#58595b</color>
+    <color name="mode_cover_default_color">#191919</color>
 
     <color name="bottombar_unpressed">#191919</color>
     <color name="bottombar_pressed">#262626</color>
index 59b36cc..0a2a694 100644 (file)
     <dimen name="photoeditor_original_text_margin">4dp</dimen>
 
     <!-- Mode selector icon width -->
-    <dimen name="mode_selector_icon_block_width">48dp</dimen>
-    <dimen name="mode_selector_icon_drawable_size">32dp</dimen>
+    <dimen name="mode_selector_icon_block_width">56dp</dimen>
+    <dimen name="mode_selector_icon_drawable_size">48dp</dimen>
     <dimen name="mode_selector_item_height">60dp</dimen>
 
     <!-- Filmstrip bottom controls -->
index 65dc747..2fd497c 100644 (file)
@@ -673,8 +673,7 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
             if (currentModuleIndex != moduleToTransitionTo) {
                 mAppRootView.redirectTouchEventsTo(mModeTransitionView);
 
-                int shadeColorId = CameraUtil.getCameraThemeColorId(moduleToTransitionTo,
-                        mController.getAndroidContext());
+                int shadeColorId = R.color.mode_cover_default_color;
                 int iconRes = CameraUtil.getCameraModeIconResId(moduleToTransitionTo,
                         mController.getAndroidContext());
 
@@ -735,7 +734,7 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
      */
     private void showModeCoverUntilPreviewReady() {
         int modeId = mController.getCurrentModuleIndex();
-        int colorId = CameraUtil.getCameraThemeColorId(modeId, mController.getAndroidContext());
+        int colorId = R.color.mode_cover_default_color;;
         int iconId = CameraUtil.getCameraModeIconResId(modeId, mController.getAndroidContext());
         mModeTransitionView.setupModeCover(colorId, iconId);
         mHideCoverRunnable = new Runnable() {
index d70e095..b5271ab 100644 (file)
@@ -18,9 +18,11 @@ package com.android.camera.ui;
 
 import android.content.Context;
 import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
 import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.StateListDrawable;
 import android.util.AttributeSet;
-import android.widget.ImageView;
+import android.view.View;
 
 import com.android.camera2.R;
 
@@ -32,7 +34,7 @@ import com.android.camera2.R;
  * multiple states can be rendered using the same drawable with some color modification,
  * whereas a state list drawable would require a different drawable for each state.
  */
-public class ModeIconView extends ImageView {
+public class ModeIconView extends View {
 
     private boolean mHighlightIsOn = false;
     private final GradientDrawable mBackground;
@@ -40,6 +42,8 @@ public class ModeIconView extends ImageView {
     private final int mIconBackgroundSize;
     private int mHighlightColor;
     private final int mBackgroundDefaultColor;
+    private final int mIconDrawableSize;
+    private Drawable mIconDrawable = null;
 
     public ModeIconView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -52,15 +56,38 @@ public class ModeIconView extends ImageView {
         mHighlightDrawable = (GradientDrawable) getResources()
                 .getDrawable(R.drawable.mode_icon_highlight).mutate();
         mHighlightDrawable.setBounds(0, 0, mIconBackgroundSize, mIconBackgroundSize);
+        mIconDrawableSize = getResources().getDimensionPixelSize(
+                R.dimen.mode_selector_icon_drawable_size);
+    }
+
+    /**
+     * Sets the drawable that shows the icon of the mode.
+     *
+     * @param drawable drawable of the mode icon
+     */
+    public void setIconDrawable(Drawable drawable) {
+        mIconDrawable = drawable;
+        // Center icon in the background.
+        if (mIconDrawable != null) {
+            mIconDrawable.setBounds(mIconBackgroundSize / 2 - mIconDrawableSize / 2,
+                    mIconBackgroundSize / 2 - mIconDrawableSize / 2,
+                    mIconBackgroundSize / 2 + mIconDrawableSize / 2,
+                    mIconBackgroundSize / 2 + mIconDrawableSize / 2);
+            invalidate();
+        }
     }
 
     @Override
     public void draw(Canvas canvas) {
+        super.draw(canvas);
         mBackground.draw(canvas);
         if (mHighlightIsOn) {
             mHighlightDrawable.draw(canvas);
         }
-        super.draw(canvas);
+        if (mIconDrawable != null) {
+            mIconDrawable.draw(canvas);
+        }
+
     }
 
     /**
index 0fce66d..ea624e3 100644 (file)
@@ -280,12 +280,12 @@ public class ModeListView extends FrameLayout
             // Validate the selection
             if (index != NO_ITEM_SELECTED) {
                 final int modeId = getModeIndex(index);
-                // Select the focused item.
-                mModeSelectorItems[index].setSelected(true);
                 // Un-highlight all the modes.
                 for (int i = 0; i < mModeSelectorItems.length; i++) {
                     mModeSelectorItems[i].setHighlighted(false);
                 }
+                // Select the focused item.
+                mModeSelectorItems[index].setSelected(true);
                 mState = MODE_SELECTED;
                 PeepholeAnimationEffect effect = new PeepholeAnimationEffect();
                 effect.setSize(mWidth, mHeight);
index 836c3d9..0025e53 100644 (file)
@@ -71,12 +71,12 @@ class ModeSelectorItem extends FrameLayout {
         mIcon = (ModeIconView) findViewById(R.id.selector_icon);
         mText = (TextView) findViewById(R.id.selector_text);
         Typeface typeface;
-        if (ApiHelper.HAS_ROBOTO_LIGHT_FONT) {
-            typeface = Typeface.create("sans-serif-light", Typeface.NORMAL);
+        if (ApiHelper.HAS_ROBOTO_MEDIUM_FONT) {
+            typeface = Typeface.create("sans-serif-medium", Typeface.NORMAL);
         } else {
             // Load roboto_light typeface from assets.
             typeface = Typeface.createFromAsset(getResources().getAssets(),
-                    "Roboto-Light.ttf");
+                    "Roboto-Medium.ttf");
         }
         mText.setTypeface(typeface);
         mDefaultTextColor = mText.getCurrentTextColor();
@@ -88,7 +88,9 @@ class ModeSelectorItem extends FrameLayout {
     }
 
     public void setHighlighted(boolean highlighted) {
-        mIcon.setHighlighted(highlighted);
+        // TODO: Remove the highlight logic if UX design on selection doesn't change
+        // within a week.
+        mIcon.setSelected(highlighted);
     }
 
     public void setSelected(boolean selected) {
@@ -139,7 +141,7 @@ class ModeSelectorItem extends FrameLayout {
         if (drawableIcon != null) {
             drawableIcon = drawableIcon.mutate();
         }
-        mIcon.setImageDrawable(drawableIcon);
+        mIcon.setIconDrawable(drawableIcon);
     }
 
     /**
index 3b8cea6..daf3173 100644 (file)
@@ -38,7 +38,7 @@ public class ApiHelper {
             Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
     public static final boolean HAS_SURFACE_TEXTURE_RECORDING =
             Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
-    public static final boolean HAS_ROBOTO_LIGHT_FONT =
+    public static final boolean HAS_ROBOTO_MEDIUM_FONT =
             Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
 
     public static final boolean HAS_CAMERA_HDR_PLUS = isKitKatOrHigher();