summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2016-11-30 08:53:24 +0100
committerMichael Bestas <mikeioannina@gmail.com>2017-01-04 22:00:45 +0200
commit2bdd1d84429afd31c76c263c9623f2728a5eb4b0 (patch)
tree340f8cbfc3b671853fcc31af31e32f184ef487fc
parenta9d6965e55a5d22cce8f43b673fdb7ef3954e421 (diff)
downloadandroid_packages_apps_Snap-2bdd1d84429afd31c76c263c9623f2728a5eb4b0.tar.gz
android_packages_apps_Snap-2bdd1d84429afd31c76c263c9623f2728a5eb4b0.tar.bz2
android_packages_apps_Snap-2bdd1d84429afd31c76c263c9623f2728a5eb4b0.zip
Clean up module switcher.
- Get rid of Holo highlight color - Don't hardcode pixel sizes - Simplify code Change-Id: I3695b04e99308c266537eb9b837d0b65793a33f7
-rw-r--r--res/layout-land/switcher_popup.xml1
-rw-r--r--res/layout-port/switcher_popup.xml1
-rw-r--r--res/layout/switcher_popup_item.xml21
-rw-r--r--src/com/android/camera/ui/ModuleSwitcher.java82
4 files changed, 47 insertions, 58 deletions
diff --git a/res/layout-land/switcher_popup.xml b/res/layout-land/switcher_popup.xml
index 1c552c9e0..247df474f 100644
--- a/res/layout-land/switcher_popup.xml
+++ b/res/layout-land/switcher_popup.xml
@@ -25,4 +25,5 @@
android:paddingRight="8dip"
android:paddingTop="16dip"
android:paddingBottom="16dip"
+ android:elevation="4dp"
android:background="@color/black" />
diff --git a/res/layout-port/switcher_popup.xml b/res/layout-port/switcher_popup.xml
index 90a64aecc..15647624e 100644
--- a/res/layout-port/switcher_popup.xml
+++ b/res/layout-port/switcher_popup.xml
@@ -25,4 +25,5 @@
android:paddingRight="16dip"
android:paddingTop="8dip"
android:paddingBottom="8dip"
+ android:elevation="4dp"
android:background="@color/black" />
diff --git a/res/layout/switcher_popup_item.xml b/res/layout/switcher_popup_item.xml
new file mode 100644
index 000000000..afb83a11a
--- /dev/null
+++ b/res/layout/switcher_popup_item.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The CyanogenMod 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.
+-->
+<com.android.camera.ui.RotateImageView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="@dimen/switcher_size"
+ android:layout_height="@dimen/switcher_size"
+ android:scaleType="center"
+ android:background="?android:attr/selectableItemBackground" />
diff --git a/src/com/android/camera/ui/ModuleSwitcher.java b/src/com/android/camera/ui/ModuleSwitcher.java
index 90ba05484..c0b0e4348 100644
--- a/src/com/android/camera/ui/ModuleSwitcher.java
+++ b/src/com/android/camera/ui/ModuleSwitcher.java
@@ -28,7 +28,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
-import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
@@ -51,12 +50,12 @@ public class ModuleSwitcher extends RotateImageView {
public static final int GCAM_MODULE_INDEX = 4;
public static final int CAPTURE_MODULE_INDEX = 5;
- private static final int[] DRAW_IDS = {
- R.drawable.ic_switch_camera,
- R.drawable.ic_switch_video,
- R.drawable.ic_switch_pan,
- R.drawable.ic_switch_photosphere,
- R.drawable.ic_switch_gcam,
+ private static final int[][] DRAW_AND_DESC_IDS = {
+ { R.drawable.ic_switch_camera, R.string.accessibility_switch_to_camera },
+ { R.drawable.ic_switch_video, R.string.accessibility_switch_to_video },
+ { R.drawable.ic_switch_pan, R.string.accessibility_switch_to_panorama },
+ { R.drawable.ic_switch_photosphere, R.string.accessibility_switch_to_photo_sphere },
+ { R.drawable.ic_switch_gcam, R.string.accessibility_switch_to_gcam }
};
public interface ModuleSwitchListener {
@@ -68,8 +67,7 @@ public class ModuleSwitcher extends RotateImageView {
private ModuleSwitchListener mListener;
private int mCurrentIndex;
private int[] mModuleIds;
- private int[] mDrawIds;
- private int mItemSize;
+ private int[][] mDrawAndDescIds;
private PopupWindow mPopup;
private LinearLayout mContent;
@@ -87,13 +85,12 @@ public class ModuleSwitcher extends RotateImageView {
}
private void init(Context context) {
- mItemSize = context.getResources().getDimensionPixelSize(R.dimen.switcher_size);
initializeDrawables(context);
initPopup();
}
public void initializeDrawables(Context context) {
- int numDrawIds = DRAW_IDS.length;
+ int numDrawIds = DRAW_AND_DESC_IDS.length;
if (!PhotoSphereHelper.hasLightCycleCapture(context)) {
--numDrawIds;
@@ -102,25 +99,19 @@ public class ModuleSwitcher extends RotateImageView {
// Always decrement one because of GCam.
--numDrawIds;
- int[] drawids = new int[numDrawIds];
- int[] moduleids = new int[numDrawIds];
- int ix = 0;
- for (int i = 0; i < DRAW_IDS.length; i++) {
+ mDrawAndDescIds = new int[numDrawIds][2];
+ mModuleIds = new int[numDrawIds];
+ int index = 0;
+ for (int i = 0; i < DRAW_AND_DESC_IDS.length; i++) {
if (i == LIGHTCYCLE_MODULE_INDEX && !PhotoSphereHelper.hasLightCycleCapture(context)) {
continue; // not enabled, so don't add to UI
}
if (i == GCAM_MODULE_INDEX) {
continue; // don't add to UI
}
- moduleids[ix] = i;
- drawids[ix++] = DRAW_IDS[i];
+ mModuleIds[index] = i;
+ mDrawAndDescIds[index++] = DRAW_AND_DESC_IDS[i];
}
- setIds(moduleids, drawids);
- }
-
- public void setIds(int[] moduleids, int[] drawids) {
- mDrawIds = drawids;
- mModuleIds = moduleids;
}
public void setCurrentIndex(int i) {
@@ -128,7 +119,7 @@ public class ModuleSwitcher extends RotateImageView {
if (i == GCAM_MODULE_INDEX) {
setImageResource(R.drawable.ic_switch_camera);
} else {
- setImageResource(mDrawIds[i]);
+ setImageResource(mDrawAndDescIds[i][0]);
}
}
@@ -165,15 +156,14 @@ public class ModuleSwitcher extends RotateImageView {
}
private void initPopup() {
- mContent = (LinearLayout) LayoutInflater.from(getContext()).inflate(
- R.layout.switcher_popup, null);
- mContent.setElevation(6);
-
- for (int i = mDrawIds.length - 1; i >= 0; i--) {
- RotateImageView item = new RotateImageView(getContext());
- item.setImageResource(mDrawIds[i]);
- item.setScaleType(ImageView.ScaleType.CENTER);
- item.setBackgroundResource(R.drawable.bg_pressed);
+ final LayoutInflater inflater = LayoutInflater.from(getContext());
+ mContent = (LinearLayout) inflater.inflate(R.layout.switcher_popup, null);
+
+ for (int i = mDrawAndDescIds.length - 1; i >= 0; i--) {
+ RotateImageView item = (RotateImageView)
+ inflater.inflate(R.layout.switcher_popup_item, mContent, false);
+ item.setImageResource(mDrawAndDescIds[i][0]);
+ item.setContentDescription(getContext().getString(mDrawAndDescIds[i][1]));
final int index = i;
item.setOnClickListener(new OnClickListener() {
@Override
@@ -185,31 +175,7 @@ public class ModuleSwitcher extends RotateImageView {
}
}
});
- switch (mDrawIds[i]) {
- case R.drawable.ic_switch_camera:
- item.setContentDescription(getContext().getResources().getString(
- R.string.accessibility_switch_to_camera));
- break;
- case R.drawable.ic_switch_video:
- item.setContentDescription(getContext().getResources().getString(
- R.string.accessibility_switch_to_video));
- break;
- case R.drawable.ic_switch_pan:
- item.setContentDescription(getContext().getResources().getString(
- R.string.accessibility_switch_to_panorama));
- break;
- case R.drawable.ic_switch_photosphere:
- item.setContentDescription(getContext().getResources().getString(
- R.string.accessibility_switch_to_photo_sphere));
- break;
- case R.drawable.ic_switch_gcam:
- item.setContentDescription(getContext().getResources().getString(
- R.string.accessibility_switch_to_gcam));
- break;
- default:
- break;
- }
- mContent.addView(item, new LinearLayout.LayoutParams(mItemSize, mItemSize));
+ mContent.addView(item);
}
mContent.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
}