diff options
author | Owen Lin <owenlin@google.com> | 2010-03-10 17:14:25 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2010-03-14 19:23:49 +0800 |
commit | 469a9ef839e38630e1e652d182f7e0ee5882e277 (patch) | |
tree | 1a45462513b9d3a457a5c2bcbd6495bed1c8a961 /src/com/android | |
parent | c24155c65b45f554ffc29c523d7ea8e63ea10d33 (diff) | |
download | LegacyCamera-469a9ef839e38630e1e652d182f7e0ee5882e277.zip LegacyCamera-469a9ef839e38630e1e652d182f7e0ee5882e277.tar.gz LegacyCamera-469a9ef839e38630e1e652d182f7e0ee5882e277.tar.bz2 |
New UI for camcorder.
Change-Id: Id35564836da7b4051662cccfd0920480421499b0
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/camera/Camera.java | 17 | ||||
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 59 | ||||
-rw-r--r-- | src/com/android/camera/Menu3DTest.java | 4 | ||||
-rw-r--r-- | src/com/android/camera/OnScreenSettings.java | 591 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 269 | ||||
-rw-r--r-- | src/com/android/camera/ui/BasicIndicator.java | 5 | ||||
-rw-r--r-- | src/com/android/camera/ui/CamcorderHeadUpDisplay.java | 46 | ||||
-rw-r--r-- | src/com/android/camera/ui/CameraHeadUpDisplay.java | 81 | ||||
-rw-r--r-- | src/com/android/camera/ui/HeadUpDisplay.java | 79 |
9 files changed, 286 insertions, 865 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 391ec0d..0536c1d 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -67,10 +67,9 @@ import android.view.WindowManager; import android.view.MenuItem.OnMenuItemClickListener; import android.widget.ImageView; -import com.android.camera.R; - import com.android.camera.gallery.IImage; import com.android.camera.gallery.IImageList; +import com.android.camera.ui.CameraHeadUpDisplay; import com.android.camera.ui.GLRootView; import com.android.camera.ui.HeadUpDisplay; import com.android.camera.ui.ZoomController; @@ -216,9 +215,8 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, private String mFocusMode; private final Handler mHandler = new MainHandler(); - private OnScreenSettings mSettings; private boolean mQuickCapture; - private HeadUpDisplay mHeadUpDisplay; + private CameraHeadUpDisplay mHeadUpDisplay; /** * This Handler is used to post message back onto the main thread of the @@ -334,7 +332,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, initializeFocusTone(); - mHeadUpDisplay = new HeadUpDisplay(this); + mHeadUpDisplay = new CameraHeadUpDisplay(this); CameraSettings settings = new CameraSettings(this, mInitialParams); mHeadUpDisplay.initialize(this, settings.getPreferenceGroup(R.xml.camera_preferences)); @@ -1266,10 +1264,6 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, closeCamera(); resetScreenOn(); - if (mSettings != null && mSettings.isVisible()) { - mSettings.setVisible(false); - } - if (mFirstTimeInitialized) { mOrientationListener.disable(); mHeadUpDisplay.setGpsHasSignal(false); @@ -1859,7 +1853,9 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, return; } else if (isCameraIdle()) { mHandler.removeMessages(SET_CAMERA_PARAMETERS_WHEN_IDLE); - setCameraParameters(); + synchronized (mPreferences) { + setCameraParameters(); + } } else { mHandler.sendEmptyMessageDelayed( SET_CAMERA_PARAMETERS_WHEN_IDLE, 1000); @@ -2017,6 +2013,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, if (onOff == SWITCH_VIDEO) { if (!isCameraIdle()) return false; MenuHelper.gotoVideoMode(this); + ((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView); finish(); } return true; diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index 56feb2a..774bc5a 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -39,8 +39,7 @@ public class CameraSettings { public static final String KEY_VERSION = "pref_version_key"; public static final String KEY_RECORD_LOCATION = RecordLocationPreference.KEY; - public static final String KEY_VIDEO_QUALITY = "pref_camera_videoquality_key"; - public static final String KEY_VIDEO_DURATION = "pref_camera_video_duration_key"; + public static final String KEY_VIDEO_QUALITY = "pref_video_quality_key"; public static final String KEY_PICTURE_SIZE = "pref_camera_picturesize_key"; public static final String KEY_JPEG_QUALITY = "pref_camera_jpegquality_key"; public static final String KEY_FOCUS_MODE = "pref_camera_focusmode_key"; @@ -55,12 +54,18 @@ public class CameraSettings { public static final String QUICK_CAPTURE_ON = "on"; public static final String QUICK_CAPTURE_OFF = "off"; - public static final int CURRENT_VERSION = 3; + private static final String VIDEO_QUALITY_HIGH = "high"; + private static final String VIDEO_QUALITY_MMS = "mms"; + private static final String VIDEO_QUALITY_YOUTUBE = "youtube"; - // max mms video duration in seconds. - public static final int MMS_VIDEO_DURATION = CamcorderProfile.getMmsRecordingDurationInSeconds(); + public static final int CURRENT_VERSION = 4; - public static final boolean DEFAULT_VIDEO_QUALITY_VALUE = true; + // max video duration in seconds for mms and youtube. + private static final int MMS_VIDEO_DURATION = CamcorderProfile.getMmsRecordingDurationInSeconds(); + private static final int YOUTUBE_VIDEO_DURATION = 10 * 60; // 10 mins + private static final int DEFAULT_VIDEO_DURATION = 30 * 60; // 10 mins + + public static final String DEFAULT_VIDEO_QUALITY_VALUE = "high"; // MMS video length public static final int DEFAULT_VIDEO_DURATION_VALUE = -1; @@ -125,7 +130,7 @@ public class CameraSettings { } private void initPreference(PreferenceGroup group) { - ListPreference videoDuration = group.findPreference(KEY_VIDEO_DURATION); + ListPreference videoQuality = group.findPreference(KEY_VIDEO_QUALITY); ListPreference pictureSize = group.findPreference(KEY_PICTURE_SIZE); ListPreference whiteBalance = group.findPreference(KEY_WHITE_BALANCE); ListPreference colorEffect = group.findPreference(KEY_COLOR_EFFECT); @@ -136,13 +141,19 @@ public class CameraSettings { // Since the screen could be loaded from different resources, we need // to check if the preference is available here - if (videoDuration != null) { + if (videoQuality != null) { // Modify video duration settings. // The first entry is for MMS video duration, and we need to fill // in the device-dependent value (in seconds). - CharSequence[] entries = videoDuration.getEntries(); - entries[0] = String.format( - entries[0].toString(), MMS_VIDEO_DURATION); + CharSequence[] entries = videoQuality.getEntries(); + CharSequence[] values = videoQuality.getEntryValues(); + for (int i = 0; i < entries.length; ++i) { + if (VIDEO_QUALITY_MMS.equals(values[i])) { + entries[i] = entries[i].toString().replace( + "30", Integer.toString(MMS_VIDEO_DURATION)); + break; + } + } } // Filter out unsupported settings / options @@ -281,10 +292,8 @@ public class CameraSettings { SharedPreferences.Editor editor = pref.edit(); if (version == 0) { - // For old version, change 1 to 10 for video duration preference. - if (pref.getString(KEY_VIDEO_DURATION, "1").equals("1")) { - editor.putString(KEY_VIDEO_DURATION, "10"); - } + // We won't use the preference which change in version 1. + // So, just upgrade to version 1 directly version = 1; } if (version == 1) { @@ -307,7 +316,27 @@ public class CameraSettings { : RecordLocationPreference.VALUE_NONE); version = 3; } + if (version == 3) { + // Just use video quality to replace it and + // ignore the current settings. + editor.remove("pref_camera_videoquality_key"); + editor.remove("pref_camera_video_duration_key"); + } editor.putInt(KEY_VERSION, CURRENT_VERSION); editor.commit(); } + + public static boolean getVideoQuality(String quality) { + return VIDEO_QUALITY_YOUTUBE.equals( + quality) || VIDEO_QUALITY_HIGH.equals(quality); + } + + public static int getVidoeDurationInMillis(String quality) { + if (VIDEO_QUALITY_MMS.equals(quality)) { + return MMS_VIDEO_DURATION * 1000; + } else if (VIDEO_QUALITY_YOUTUBE.equals(quality)) { + return YOUTUBE_VIDEO_DURATION * 1000; + } + return DEFAULT_VIDEO_DURATION * 1000; + } } diff --git a/src/com/android/camera/Menu3DTest.java b/src/com/android/camera/Menu3DTest.java index a16bf22..cb36d21 100644 --- a/src/com/android/camera/Menu3DTest.java +++ b/src/com/android/camera/Menu3DTest.java @@ -8,7 +8,7 @@ import android.widget.FrameLayout; import com.android.camera.R; import com.android.camera.ui.GLRootView; -import com.android.camera.ui.HeadUpDisplay; +import com.android.camera.ui.CameraHeadUpDisplay; public class Menu3DTest extends Activity { @@ -24,7 +24,7 @@ public class Menu3DTest extends Activity { // set background as 18% gray :D mRootView.setBackgroundColor(0xffb7b7b7); - final HeadUpDisplay hud = new HeadUpDisplay(this); + final CameraHeadUpDisplay hud = new CameraHeadUpDisplay(this); mRootView.setContentPane(hud); PreferenceInflater inflater = new PreferenceInflater(this); diff --git a/src/com/android/camera/OnScreenSettings.java b/src/com/android/camera/OnScreenSettings.java deleted file mode 100644 index 54d5d10..0000000 --- a/src/com/android/camera/OnScreenSettings.java +++ /dev/null @@ -1,591 +0,0 @@ -/* - * Copyright (C) 2009 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; - -import android.content.Context; -import android.content.SharedPreferences; -import android.graphics.PixelFormat; -import android.os.Handler; -import android.os.Message; -import android.preference.PreferenceManager; -import android.util.Log; -import android.view.Display; -import android.view.Gravity; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.view.WindowManager.LayoutParams; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.ListView; -import android.widget.RadioButton; -import android.widget.TextView; -import android.widget.AdapterView.OnItemClickListener; - -import com.android.camera.R; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.regex.Pattern; -import java.util.regex.Matcher; - -/** - * The on-screen setting menu. - * - * <p>Please reference to {@code android.widget.ZoomButtonsController} for - * detail information about adding window to WindowManager. - */ -public class OnScreenSettings { - @SuppressWarnings("unused") - private static final String TAG = "OnScreenSettings"; - private static final int MSG_POST_SET_VISIBLE = 1; - - private static final Pattern TITLE_PATTERN = - Pattern.compile("(.*)\\s*\\((.+)\\)"); - - /** - * A callback to be invoked when the on-screen menu's visibility changes. - */ - public interface OnVisibilityChangedListener { - public void onVisibilityChanged(boolean visibility); - } - - private LayoutParams mContainerLayoutParams; - private final Context mContext; - private final Container mContainer; - private final WindowManager mWindowManager; - private final View mOwnerView; - private ListView mMainMenu; - private ListView mSubMenu; - private boolean mIsVisible = false; - private OnVisibilityChangedListener mVisibilityListener; - private MainMenuAdapter mMainAdapter; - - private final LayoutInflater mInflater; - private Runnable mRestoreRunner; - private PreferenceGroup mPreferenceGroup; - - // We store the override values here. For a given preference, - // if the mapping value of the preference key is not null, we will - // use the value in this map instead of the value read from the preference - // - // This is design for the scene mode, for example, in the scene mode - // "Action", the focus mode will become "infinite" no matter what in the - // preference settings. So, we need to put a {pref_camera_focusmode_key, - // "infinite"} entry in this map. - private HashMap<String, String> mOverride = new HashMap<String, String>(); - - private final Handler mHandler = new Handler() { - @Override - public void handleMessage(Message msg) { - switch (msg.what) { - case MSG_POST_SET_VISIBLE: - setVisible(true); - break; - } - } - }; - - public OnScreenSettings(View ownerView) { - mContext = ownerView.getContext(); - mInflater = (LayoutInflater) - mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - - mWindowManager = (WindowManager) - mContext.getSystemService(Context.WINDOW_SERVICE); - mOwnerView = ownerView; - mContainer = createContainer(); - } - - public void clearSettings() { - SharedPreferences.Editor editor = PreferenceManager - .getDefaultSharedPreferences(mContext).edit(); - editor.clear(); - editor.commit(); - - mPreferenceGroup.reloadValue(); - if (mMainAdapter != null) { - mMainAdapter.notifyDataSetChanged(); - } - mOverride.clear(); - } - - public void setRestoreRunner(Runnable restorer) { - mRestoreRunner = restorer; - } - - public boolean isVisible() { - return mIsVisible; - } - - public void setOnVisibilityChangedListener( - OnVisibilityChangedListener listener) { - mVisibilityListener = listener; - } - - public void setVisible(boolean visible) { - mHandler.removeMessages(MSG_POST_SET_VISIBLE); - if (visible) { - if (mOwnerView.getWindowToken() == null) { - /* - * We need a window token to show ourselves, maybe the owner's - * window hasn't been created yet but it will have been by the - * time the looper is idle, so post the setVisible(true) call. - */ - mHandler.sendEmptyMessage(MSG_POST_SET_VISIBLE); - return; - } - } - - if (mIsVisible == visible) { - return; - } - mIsVisible = visible; - - if (visible) { - // Invalid the main adapter before show up, so it would be like - // a new created list - if (mMainAdapter != null) mMainAdapter.notifyDataSetInvalidated(); - if (mContainerLayoutParams.token == null) { - mContainerLayoutParams.token = mOwnerView.getWindowToken(); - } - mSubMenu.setVisibility(View.INVISIBLE); - mMainMenu.setVisibility(View.VISIBLE); - mWindowManager.addView(mContainer, mContainerLayoutParams); - updateLayout(); - } else { - // Reset the two menus - - mWindowManager.removeView(mContainer); - } - if (mVisibilityListener != null) { - mVisibilityListener.onVisibilityChanged(mIsVisible); - } - } - - // Override the preference settings, if value == null, then disable the - // override. - public void overrideSettings(String key, String value) { - if (value == null) { - if (mOverride.remove(key) != null && mMainAdapter != null) { - mMainAdapter.notifyDataSetChanged(); - } - } else { - if (mOverride.put(key, value) == null && mMainAdapter != null) { - mMainAdapter.notifyDataSetChanged(); - } - } - } - - public void updateLayout() { - // if the mOwnerView is detached from window then skip. - if (mOwnerView.getWindowToken() == null) return; - Display display = mWindowManager.getDefaultDisplay(); - - mContainerLayoutParams.x = 0; - mContainerLayoutParams.y = 0; - - mContainerLayoutParams.width = display.getWidth() / 2; - mContainerLayoutParams.height = display.getHeight(); - - if (mIsVisible) { - mWindowManager.updateViewLayout(mContainer, mContainerLayoutParams); - } - } - - private void showSubMenu() { - Util.slideOut(mMainMenu, Util.DIRECTION_LEFT); - Util.slideIn(mSubMenu, Util.DIRECTION_RIGHT); - mSubMenu.requestFocus(); - } - - private void closeSubMenu() { - Util.slideOut(mSubMenu, Util.DIRECTION_RIGHT); - Util.slideIn(mMainMenu, Util.DIRECTION_LEFT); - } - - private Container createContainer() { - LayoutParams lp = new LayoutParams( - LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); - lp.flags = LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; - lp.gravity = Gravity.TOP | Gravity.LEFT; - lp.height = LayoutParams.WRAP_CONTENT; - lp.width = LayoutParams.WRAP_CONTENT; - lp.type = LayoutParams.TYPE_APPLICATION_PANEL; - lp.format = PixelFormat.OPAQUE; - lp.windowAnimations = R.style.Animation_OnScreenMenu; - - mContainerLayoutParams = lp; - - Container container = new Container(mContext); - container.setLayoutParams(lp); - - mInflater.inflate(R.layout.on_screen_menu, container); - - mMainMenu = (ListView) container.findViewById(R.id.menu_view); - mSubMenu = (ListView) container.findViewById(R.id.sub_menu); - - container.findViewById(R.id.btn_gripper) - .setOnTouchListener(new GripperTouchListener()); - - return container; - } - - private class GripperTouchListener implements View.OnTouchListener { - public boolean onTouch(View view, MotionEvent event) { - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - return true; - case MotionEvent.ACTION_UP: - setVisible(false); - return true; - } - return false; - } - } - - private boolean onContainerKey(KeyEvent event) { - switch (event.getKeyCode()) { - case KeyEvent.KEYCODE_CAMERA: - case KeyEvent.KEYCODE_FOCUS: - case KeyEvent.KEYCODE_BACK: - case KeyEvent.KEYCODE_MENU: - if (event.getAction() == KeyEvent.ACTION_UP) { - setVisible(false); - return true; - } - } - return false; - } - - // Add the preference and it's children recursively to the given list. So - // that we can show the preference (and it's children) in the list view. - private static void addPreference( - CameraPreference preference, ArrayList<CameraPreference> list) { - list.add(preference); - if (preference instanceof PreferenceGroup) { - PreferenceGroup group = (PreferenceGroup) preference; - for (int i = 0, n = group.size(); i < n; ++i) { - CameraPreference child = group.get(i); - addPreference(child, list); - } - } - } - - public void setPreferenceGroup(PreferenceGroup group) { - this.mPreferenceGroup = group; - - ArrayList<CameraPreference> list = new ArrayList<CameraPreference>(); - - // We don't want the root group added to the list. So, we add the - // children of the root here - for (int i = 0, n = group.size(); i < n; ++i) { - addPreference(group.get(i), list); - } - mMainAdapter = new MainMenuAdapter(mContext, list); - mMainMenu.setAdapter(mMainAdapter); - mMainMenu.setOnItemClickListener(mMainAdapter); - } - - private View inflateIfNeed( - View view, int resource, ViewGroup root, boolean attachToRoot) { - if (view != null) return view; - return mInflater.inflate(resource, root, attachToRoot); - } - - private class MainMenuAdapter extends BaseAdapter - implements OnItemClickListener { - private final ArrayList<CameraPreference> mPreferences; - - public MainMenuAdapter( - Context context, ArrayList<CameraPreference> preferences) { - mPreferences = preferences; - } - - public void onItemClick( - AdapterView<?> parent, View view, int position, long id) { - // If not the last item (restore settings) - if (position < mPreferences.size()) { - CameraPreference preference = mPreferences.get(position); - SubMenuAdapter adapter = new SubMenuAdapter( - mContext, (ListPreference) preference); - mSubMenu.setAdapter(adapter); - mSubMenu.setOnItemClickListener(adapter); - showSubMenu(); - } else { - MenuHelper.confirmAction(mContext, - mContext.getString(R.string.confirm_restore_title), - mContext.getString(R.string.confirm_restore_message), - mRestoreRunner); - } - } - - public View getView(int position, View convertView, ViewGroup parent) { - // The last item in the view (i.e., restore settings) - if (position == mPreferences.size()) { - convertView = inflateIfNeed(convertView, - R.layout.on_screen_menu_list_item, parent, false); - - ((TextView) convertView.findViewById(R.id.title)).setText( - mContext.getString(R.string.pref_restore_title)); - ((TextView) convertView.findViewById(R.id.summary)).setText( - mContext.getString(R.string.pref_restore_detail)); - - // Make sure we didn't set focusable. Otherwise, it will - // consume all the events. See more detail in the comments - // below. - convertView.setFocusable(false); - return convertView; - } - - CameraPreference preference = mPreferences.get(position); - if (preference instanceof PreferenceGroup) { - convertView = inflateIfNeed(convertView, - R.layout.on_screen_menu_header, parent, false); - PreferenceGroup group = (PreferenceGroup) preference; - ((TextView) convertView.findViewById( - R.id.title)).setText(group.getTitle()); - } else { - convertView = inflateIfNeed(convertView, - R.layout.on_screen_menu_list_item, parent, false); - - String override = mOverride.get( - ((ListPreference) preference).getKey()); - TextView title = (TextView) - convertView.findViewById(R.id.title); - title.setText(preference.getTitle()); - title.setEnabled(override == null); - - TextView summary = (TextView) - convertView.findViewById(R.id.summary); - summary.setText(override == null - ? ((ListPreference) preference).getEntry() - : override); - summary.setEnabled(override == null); - - // A little trick here, making the view focusable will eat - // both touch/key events on the view and thus make it looks - // like disabled. - convertView.setFocusable(override != null); - } - return convertView; - } - - @Override - public boolean areAllItemsEnabled() { - return false; - } - - @Override - public boolean isEnabled(int position) { - // The last item (restore default) - if (position == mPreferences.size()) return true; - - CameraPreference preference = mPreferences.get(position); - return !(preference instanceof PreferenceGroup); - } - - public int getCount() { - // The last one is "restore default" - return mPreferences.size() + 1; - } - - public Object getItem(int position) { - return null; - } - - public long getItemId(int position) { - return position; - } - - @Override - public int getItemViewType(int position) { - if (position == mPreferences.size()) return 1; - CameraPreference pref = mPreferences.get(position); - if (pref instanceof PreferenceGroup) return 0; - if (pref instanceof ListPreference) return 1; - throw new IllegalStateException(); - } - - @Override - public int getViewTypeCount() { - // we have two types, see getItemViewType() - return 2; - } - - @Override - public boolean hasStableIds() { - return true; - } - - @Override - public boolean isEmpty() { - return mPreferences.isEmpty(); - } - } - - private class SubMenuAdapter extends BaseAdapter - implements OnItemClickListener { - private final ListPreference mPreference; - private final IconListPreference mIconPreference; - - public SubMenuAdapter(Context context, ListPreference preference) { - mPreference = preference; - mIconPreference = (preference instanceof IconListPreference) - ? (IconListPreference) preference - : null; - } - - public View getView(int position, View convertView, ViewGroup parent) { - CharSequence entry[] = mPreference.getEntries(); - if (position == 0) { - convertView = inflateIfNeed(convertView, - R.layout.on_screen_menu_header, parent, false); - ((TextView) convertView.findViewById( - R.id.title)).setText(mPreference.getTitle()); - } else { - int index = position - 1; - convertView = inflateIfNeed(convertView, - R.layout.on_screen_submenu_item, parent, false); - boolean checked = mPreference.getValue().equals( - mPreference.getEntryValues()[index]); - String title = entry[index].toString(); - String detail = null; - - // Handle the title of format "Title (details)". We extract the - // details from the title message for better UI layout. The - // detail will be shown in second line with a smaller font. - Matcher matcher = TITLE_PATTERN.matcher(title); - if (matcher.matches()) { - title = matcher.group(1); - detail = matcher.group(2); - } - - ((TextView) convertView - .findViewById(R.id.title)).setText(title); - TextView detailView = (TextView) - convertView.findViewById(R.id.summary); - if (detail == null) { - detailView.setVisibility(View.GONE); - } else { - detailView.setVisibility(View.VISIBLE); - detailView.setText(detail); - } - - ((RadioButton) convertView.findViewById( - R.id.radio_button)).setChecked(checked); - ImageView icon = (ImageView) - convertView.findViewById(R.id.icon); - if (mIconPreference != null) { - icon.setVisibility(View.VISIBLE); - icon.setImageDrawable( - mIconPreference.getIcons()[position - 1]); - } else { - icon.setVisibility(View.GONE); - } - } - return convertView; - } - - @Override - public boolean areAllItemsEnabled() { - return false; - } - - @Override - public boolean isEnabled(int position) { - return getItemViewType(position) != 0; - } - - public int getCount() { - // add one for the header - return mPreference.getEntries().length + 1; - } - - public Object getItem(int position) { - return null; - } - - public long getItemId(int position) { - return position; - } - - @Override - public int getItemViewType(int position) { - return position == 0 ? 0 : 1; - } - - @Override - public int getViewTypeCount() { - return 2; - } - - @Override - public boolean hasStableIds() { - return true; - } - - public void onItemClick( - AdapterView<?> parent, View view, int position, long id) { - CharSequence values[] = mPreference.getEntryValues(); - int idx = mPreference.findIndexOfValue(mPreference.getValue()); - if (idx != position - 1) { - mPreference.setValueIndex(position - 1); - notifyDataSetChanged(); - mMainAdapter.notifyDataSetChanged(); - return; - } - - // Close the sub menu when user presses the original option. - closeSubMenu(); - } - } - - private class Container extends FrameLayout { - public Container(Context context) { - super(context); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - if (super.onTouchEvent(event)) return true; - if (event.getAction() == MotionEvent.ACTION_DOWN) { - setVisible(false); - return true; - } - return false; - } - - /* - * Need to override this to intercept the key events. Otherwise, we - * would attach a key listener to the container but its superclass - * ViewGroup gives it to the focused View instead of calling the key - * listener, and so we wouldn't get the events. - */ - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - return onContainerKey(event) - ? true - : super.dispatchKeyEvent(event); - } - } -} diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 008f5c9..82e2ae0 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -24,15 +24,14 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; -import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.hardware.Camera.Parameters; import android.hardware.Camera.Size; +import android.media.CamcorderProfile; import android.media.MediaRecorder; import android.media.ThumbnailUtils; -import android.media.CamcorderProfile; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -43,14 +42,13 @@ import android.os.StatFs; import android.os.SystemClock; import android.preference.PreferenceManager; import android.provider.MediaStore; -import android.provider.MediaStore.Video; import android.provider.Settings; +import android.provider.MediaStore.Video; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; -import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; @@ -66,7 +64,10 @@ import android.widget.Toast; import com.android.camera.gallery.IImage; import com.android.camera.gallery.IImageList; -import com.android.camera.R; +import com.android.camera.ui.CamcorderHeadUpDisplay; +import com.android.camera.ui.GLRootView; +import com.android.camera.ui.GLView; +import com.android.camera.ui.HeadUpDisplay; import java.io.File; import java.io.FileDescriptor; @@ -83,9 +84,7 @@ public class VideoCamera extends NoSearchActivity implements View.OnClickListener, ShutterButton.OnShutterButtonListener, SurfaceHolder.Callback, MediaRecorder.OnErrorListener, MediaRecorder.OnInfoListener, - Switcher.OnSwitchListener, OnSharedPreferenceChangeListener, - OnScreenSettings.OnVisibilityChangedListener, - PreviewFrameLayout.OnSizeChangedListener { + Switcher.OnSwitchListener, PreviewFrameLayout.OnSizeChangedListener { private static final String TAG = "videocamera"; @@ -127,6 +126,8 @@ public class VideoCamera extends NoSearchActivity private SurfaceView mVideoPreview; private SurfaceHolder mSurfaceHolder = null; private ImageView mVideoFrame; + private GLRootView mGLRootView; + private CamcorderHeadUpDisplay mHeadUpDisplay; private boolean mIsVideoCaptureIntent; private boolean mQuickCapture; @@ -151,8 +152,6 @@ public class VideoCamera extends NoSearchActivity private String mCurrentVideoFilename; private Uri mCurrentVideoUri; private ContentValues mCurrentVideoValues; - private IconIndicator mWhitebalanceIndicator; - private IconIndicator mFlashIndicator; private CamcorderProfile mProfile; @@ -166,7 +165,6 @@ public class VideoCamera extends NoSearchActivity private ShutterButton mShutterButton; private TextView mRecordingTimeView; - private View mGripper; private Switcher mSwitcher; private boolean mRecordingTimeCountsDown = false; @@ -174,7 +172,6 @@ public class VideoCamera extends NoSearchActivity private final Handler mHandler = new MainHandler(); private Parameters mParameters; - private OnScreenSettings mSettings; // This Handler is used to post message back onto the main thread of the // application @@ -304,6 +301,7 @@ public class VideoCamera extends NoSearchActivity mVideoPreview = (SurfaceView) findViewById(R.id.camera_preview); mVideoFrame = (ImageView) findViewById(R.id.video_frame); + mGLRootView = (GLRootView) findViewById(R.id.settings_ui); // don't set mSurfaceHolder here. We have it set ONLY within // surfaceCreated / surfaceDestroyed, other parts of the code @@ -346,12 +344,6 @@ public class VideoCamera extends NoSearchActivity mShutterButton.setImageResource(R.drawable.btn_ic_video_record); mShutterButton.setOnShutterButtonListener(this); mShutterButton.requestFocus(); - mGripper = findViewById(R.id.btn_gripper); - mGripper.setOnTouchListener(new GripperTouchListener()); - - mWhitebalanceIndicator = - (IconIndicator) findViewById(R.id.whitebalance_icon); - mFlashIndicator = (IconIndicator) findViewById(R.id.flash_icon); // Make sure preview is started. try { @@ -363,16 +355,25 @@ public class VideoCamera extends NoSearchActivity } catch (InterruptedException ex) { // ignore } - removeUnsupportedIndicators(); + mHandler.post(new Runnable() { + public void run() { + initializeHeadUpDisplay(); + } + }); } - private void removeUnsupportedIndicators() { - if (mParameters.getSupportedWhiteBalance() == null) { - mWhitebalanceIndicator.setVisibility(View.GONE); - } - if (mParameters.getSupportedFlashModes() == null) { - mFlashIndicator.setVisibility(View.GONE); + private void initializeHeadUpDisplay() { + mHeadUpDisplay = new CamcorderHeadUpDisplay(this); + CameraSettings settings = new CameraSettings(this, mParameters); + + PreferenceGroup group = + settings.getPreferenceGroup(R.xml.video_preferences); + if (mIsVideoCaptureIntent) { + group = filterPreferenceScreenByIntent(group); } + mHeadUpDisplay.initialize(this, group); + mGLRootView.setContentPane(mHeadUpDisplay); + mHeadUpDisplay.setListener(new MyHeadUpDisplayListener()); } @Override @@ -493,10 +494,12 @@ public class VideoCamera extends NoSearchActivity } private void readVideoPreferences() { - boolean videoQualityHigh = - getBooleanPreference(CameraSettings.KEY_VIDEO_QUALITY, + String quality = mPreferences.getString( + CameraSettings.KEY_VIDEO_QUALITY, CameraSettings.DEFAULT_VIDEO_QUALITY_VALUE); + boolean videoQualityHigh = CameraSettings.getVideoQuality(quality); + // Set video quality. Intent intent = getIntent(); if (intent.hasExtra(MediaStore.EXTRA_VIDEO_QUALITY)) { @@ -512,21 +515,12 @@ public class VideoCamera extends NoSearchActivity intent.getIntExtra(MediaStore.EXTRA_DURATION_LIMIT, 0); mMaxVideoDurationInMs = 1000 * seconds; } else { - int minutes = getIntPreference(CameraSettings.KEY_VIDEO_DURATION, - CameraSettings.DEFAULT_VIDEO_DURATION_VALUE); - if (minutes == -1) { - // This is a special case: the value -1 means we want to use the - // device-dependent duration for MMS messages. The value is - // represented in seconds. - mMaxVideoDurationInMs = - 1000 * CameraSettings.MMS_VIDEO_DURATION; - } else { - // 1 minute = 60000ms - mMaxVideoDurationInMs = 60000 * minutes; - } + mMaxVideoDurationInMs = + CameraSettings.getVidoeDurationInMillis(quality); } - - mProfile = CamcorderProfile.get(videoQualityHigh? CamcorderProfile.Quality.HIGH: CamcorderProfile.Quality.LOW); + mProfile = CamcorderProfile.get(videoQualityHigh + ? CamcorderProfile.Quality.HIGH + : CamcorderProfile.Quality.LOW); } private void resizeForPreviewAspectRatio() { @@ -538,6 +532,7 @@ public class VideoCamera extends NoSearchActivity public void onResume() { super.onResume(); mPausing = false; + mGLRootView.onResume(); mVideoPreview.setVisibility(View.VISIBLE); readVideoPreferences(); @@ -633,17 +628,13 @@ public class VideoCamera extends NoSearchActivity @Override protected void onPause() { super.onPause(); - + mGLRootView.onPause(); mPausing = true; // Hide the preview now. Otherwise, the preview may be rotated during // onPause and it is annoying to users. mVideoPreview.setVisibility(View.INVISIBLE); - if (mSettings != null && mSettings.isVisible()) { - mSettings.setVisible(false); - } - // This is similar to what mShutterButton.performClick() does, // but not quite the same. if (mMediaRecorderRecording) { @@ -729,12 +720,6 @@ public class VideoCamera extends NoSearchActivity case KeyEvent.KEYCODE_CAMERA: mShutterButton.setPressed(false); return true; - case KeyEvent.KEYCODE_MENU: - if (this.mIsVideoCaptureIntent) { - showOnScreenSettings(); - return true; - } - break; } return super.onKeyUp(keyCode, event); } @@ -964,21 +949,6 @@ public class VideoCamera extends NoSearchActivity } } - private int getIntPreference(String key, int defaultValue) { - String s = mPreferences.getString(key, ""); - int result = defaultValue; - try { - result = Integer.parseInt(s); - } catch (NumberFormatException e) { - // Ignore, result is already the default value. - } - return result; - } - - private boolean getBooleanPreference(String key, boolean defaultValue) { - return getIntPreference(key, defaultValue ? 1 : 0) != 0; - } - private void createVideoPath() { long dateTaken = System.currentTimeMillis(); String title = createName(dateTaken); @@ -1051,52 +1021,6 @@ public class VideoCamera extends NoSearchActivity }); gallery.setIcon(android.R.drawable.ic_menu_gallery); mGalleryItems.add(gallery); - - MenuItem item = menu.add(Menu.NONE, Menu.NONE, - MenuHelper.POSITION_CAMERA_SETTING, R.string.settings) - .setOnMenuItemClickListener(new OnMenuItemClickListener() { - public boolean onMenuItemClick(MenuItem item) { - showOnScreenSettings(); - return true; - }}); - item.setIcon(android.R.drawable.ic_menu_preferences); - } - - private void restorePreferences() { - // Unregister the listener since "upgrade preference" will change - // a bunch of preferences. We can handle them with one - // setCameraParameters(). - mPreferences.unregisterOnSharedPreferenceChangeListener(this); - mSettings.clearSettings(); - CameraSettings.upgradePreferences(mPreferences); - readVideoPreferences(); - resetCameraParameters(); - - mPreferences.registerOnSharedPreferenceChangeListener(this); - } - - private void showOnScreenSettings() { - if (mSettings == null) { - mSettings = new OnScreenSettings( - findViewById(R.id.camera_preview)); - final Runnable resetPreferences = new Runnable() { - public void run() { - restorePreferences(); - } - }; - mSettings.setRestoreRunner(resetPreferences); - - CameraSettings helper = new CameraSettings(this, mParameters); - PreferenceGroup group = helper - .getPreferenceGroup(R.xml.video_preferences); - if (mIsVideoCaptureIntent) { - group = filterPreferenceScreenByIntent(group); - } - - mSettings.setPreferenceGroup(group); - mSettings.setOnVisibilityChangedListener(this); - } - mSettings.setVisible(true); } private PreferenceGroup filterPreferenceScreenByIntent( @@ -1109,38 +1033,11 @@ public class VideoCamera extends NoSearchActivity if (intent.hasExtra(MediaStore.EXTRA_DURATION_LIMIT)) { CameraSettings.removePreferenceFromScreen(screen, - CameraSettings.KEY_VIDEO_DURATION); + CameraSettings.KEY_VIDEO_QUALITY); } return screen; } - private class GripperTouchListener implements View.OnTouchListener { - public boolean onTouch(View view, MotionEvent event) { - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - return true; - case MotionEvent.ACTION_UP: - showOnScreenSettings(); - return true; - } - return false; - } - } - - public void onVisibilityChanged(boolean visible) { - // At this point, we are not recording. - mGripper.setVisibility(visible ? View.INVISIBLE : View.VISIBLE); - if (visible) { - releaseMediaRecorder(); - mPreferences.registerOnSharedPreferenceChangeListener(this); - } else { - // When mSetting is set to invisible in onPause, we should not - // initialize recorder. - if (!mPausing) initializeRecorder(); - mPreferences.unregisterOnSharedPreferenceChangeListener(this); - } - } - // from MediaRecorder.OnErrorListener public void onError(MediaRecorder mr, int what, int extra) { if (what == MediaRecorder.MEDIA_RECORDER_ERROR_UNKNOWN) { @@ -1209,7 +1106,6 @@ public class VideoCamera extends NoSearchActivity mRecordingTimeView.setVisibility(View.VISIBLE); updateRecordingTime(); keepScreenOn(); - mGripper.setVisibility(View.INVISIBLE); } } @@ -1314,7 +1210,6 @@ public class VideoCamera extends NoSearchActivity updateRecordingIndicator(true); mRecordingTimeView.setVisibility(View.GONE); keepScreenOnAwhile(); - mGripper.setVisibility(View.VISIBLE); } if (needToRegisterRecording && mStorageStatus == STORAGE_STATUS_OK) { registerVideo(); @@ -1481,45 +1376,18 @@ public class VideoCamera extends NoSearchActivity } mCameraDevice.setParameters(mParameters); - - final String finalWhiteBalance = whiteBalance; - final String finalFlashMode = flashMode; - - // It can be execute from the startPreview thread, so we post it - // to the main UI thread - mHandler.post(new Runnable() { - public void run() { - mWhitebalanceIndicator.setMode(finalWhiteBalance); - mFlashIndicator.setMode(finalFlashMode); - } - }); } public boolean onSwitchChanged(Switcher source, boolean onOff) { if (onOff == SWITCH_CAMERA) { if (mMediaRecorderRecording) return false; MenuHelper.gotoCameraMode(this); + ((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView); finish(); } return true; } - public void onSharedPreferenceChanged( - SharedPreferences preferences, String key) { - // ignore the events after "onPause()" or preview has not started yet - if (mPausing) return; - - if (CameraSettings.KEY_VIDEO_DURATION.equals(key) - || CameraSettings.KEY_VIDEO_QUALITY.equals(key)) { - readVideoPreferences(); - } - - // If mCameraDevice is not ready then we can set the parameter in - // startPreview(). - if (mCameraDevice == null) return; - resetCameraParameters(); - } - private void resetCameraParameters() { // We need to restart the preview if preview size is changed. Size size = mParameters.getPreviewSize(); @@ -1551,9 +1419,64 @@ public class VideoCamera extends NoSearchActivity } public void onSizeChanged() { - if (mSettings != null) { - mSettings.updateLayout(); + // TODO: update the content on GLRootView + } + + private class MyHeadUpDisplayListener implements HeadUpDisplay.Listener { + public void onSharedPreferencesChanged() { + mHandler.post(new Runnable() { + public void run() { + VideoCamera.this.onSharedPreferencesChanged(); + } + }); } + public void onRestorePreferencesClicked() { + mHandler.post(new Runnable() { + public void run() { + VideoCamera.this.onRestorePreferencesClicked(); + } + }); + } + + public void onPopupWindowVisibilityChanged(final int visibility) { + mHandler.post(new Runnable() { + public void run() { + VideoCamera.this.onPopupWindowVisibilityChanged(visibility); + } + }); + } + } + + private void onPopupWindowVisibilityChanged(int visibility) { + if (visibility == GLView.VISIBLE) { + releaseMediaRecorder(); + } else { + if (!mPausing) initializeRecorder(); + } + } + + private void onRestorePreferencesClicked() { + Runnable runnable = new Runnable() { + public void run() { + mHeadUpDisplay.restorePreferences(); + } + }; + MenuHelper.confirmAction(this, + getString(R.string.confirm_restore_title), + getString(R.string.confirm_restore_message), + runnable); + } + + private void onSharedPreferencesChanged() { + // ignore the events after "onPause()" or preview has not started yet + if (mPausing) return; + synchronized (mPreferences) { + readVideoPreferences(); + // If mCameraDevice is not ready then we can set the parameter in + // startPreview(). + if (mCameraDevice == null) return; + resetCameraParameters(); + } } } diff --git a/src/com/android/camera/ui/BasicIndicator.java b/src/com/android/camera/ui/BasicIndicator.java index f270efa..b56f0a9 100644 --- a/src/com/android/camera/ui/BasicIndicator.java +++ b/src/com/android/camera/ui/BasicIndicator.java @@ -2,10 +2,9 @@ package com.android.camera.ui; import android.content.Context; -import com.android.camera.R; - import com.android.camera.IconListPreference; import com.android.camera.PreferenceGroup; +import com.android.camera.R; import com.android.camera.Util; import com.android.camera.ui.GLListView.OnItemSelectedListener; @@ -22,7 +21,7 @@ public class BasicIndicator extends AbstractIndicator { PreferenceGroup group, IconListPreference preference) { super(context); mPreference = preference; - mIcon = new ResourceTexture[preference.getIconIds().length]; + mIcon = new ResourceTexture[preference.getLargeIconIds().length]; mIndex = preference.findIndexOfValue(preference.getValue()); } diff --git a/src/com/android/camera/ui/CamcorderHeadUpDisplay.java b/src/com/android/camera/ui/CamcorderHeadUpDisplay.java new file mode 100644 index 0000000..1d0b1c4 --- /dev/null +++ b/src/com/android/camera/ui/CamcorderHeadUpDisplay.java @@ -0,0 +1,46 @@ +package com.android.camera.ui; + +import android.content.Context; + +import com.android.camera.CameraSettings; +import com.android.camera.ListPreference; +import com.android.camera.PreferenceGroup; + +public class CamcorderHeadUpDisplay extends HeadUpDisplay { + + protected static final String TAG = "CamcorderHeadUpDisplay"; + + private OtherSettingsIndicator mOtherSettings; + + public CamcorderHeadUpDisplay(Context context) { + super(context); + } + + @Override + protected void initializeIndicatorBar( + Context context, PreferenceGroup group) { + super.initializeIndicatorBar(context, group); + + ListPreference[] prefs = getListPreferences(group, + CameraSettings.KEY_FOCUS_MODE, + CameraSettings.KEY_EXPOSURE, + CameraSettings.KEY_SCENE_MODE, + CameraSettings.KEY_PICTURE_SIZE, + CameraSettings.KEY_JPEG_QUALITY, + CameraSettings.KEY_COLOR_EFFECT); + + mOtherSettings = new OtherSettingsIndicator(context, prefs); + mOtherSettings.setOnRestorePreferencesClickedRunner(new Runnable() { + public void run() { + if (mListener != null) { + mListener.onRestorePreferencesClicked(); + } + } + }); + mIndicatorBar.addComponent(mOtherSettings); + + addIndicator(context, group, CameraSettings.KEY_WHITE_BALANCE); + addIndicator(context, group, CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE); + addIndicator(context, group, CameraSettings.KEY_VIDEO_QUALITY); + } +} diff --git a/src/com/android/camera/ui/CameraHeadUpDisplay.java b/src/com/android/camera/ui/CameraHeadUpDisplay.java new file mode 100644 index 0000000..bf9f249 --- /dev/null +++ b/src/com/android/camera/ui/CameraHeadUpDisplay.java @@ -0,0 +1,81 @@ +package com.android.camera.ui; + +import android.content.Context; + +import com.android.camera.CameraSettings; +import com.android.camera.IconListPreference; +import com.android.camera.ListPreference; +import com.android.camera.PreferenceGroup; + +public class CameraHeadUpDisplay extends HeadUpDisplay { + + protected static final String TAG = "CamcoderHeadUpDisplay"; + + private OtherSettingsIndicator mOtherSettings; + private GpsIndicator mGpsIndicator; + private ZoomIndicator mZoomIndicator; + + public CameraHeadUpDisplay(Context context) { + super(context); + } + + @Override + protected void initializeIndicatorBar( + Context context, PreferenceGroup group) { + super.initializeIndicatorBar(context, group); + + ListPreference prefs[] = getListPreferences(group, + CameraSettings.KEY_FOCUS_MODE, + CameraSettings.KEY_EXPOSURE, + CameraSettings.KEY_SCENE_MODE, + CameraSettings.KEY_PICTURE_SIZE, + CameraSettings.KEY_JPEG_QUALITY, + CameraSettings.KEY_COLOR_EFFECT); + + mOtherSettings = new OtherSettingsIndicator(context, prefs); + mOtherSettings.setOnRestorePreferencesClickedRunner(new Runnable() { + public void run() { + if (mListener != null) { + mListener.onRestorePreferencesClicked(); + } + } + }); + mIndicatorBar.addComponent(mOtherSettings); + + mGpsIndicator = new GpsIndicator( + context, group, (IconListPreference) + group.findPreference(CameraSettings.KEY_RECORD_LOCATION)); + mIndicatorBar.addComponent(mGpsIndicator); + + addIndicator(context, group, CameraSettings.KEY_WHITE_BALANCE); + addIndicator(context, group, CameraSettings.KEY_FLASH_MODE); + + mZoomIndicator = new ZoomIndicator(context); + mIndicatorBar.addComponent(mZoomIndicator); + } + + public void setZoomListener(ZoomController.ZoomListener listener) { + mZoomIndicator.setZoomListener(listener); + } + + public void setZoomIndex(int index) { + mZoomIndicator.setZoomIndex(index); + } + + public void setGpsHasSignal(final boolean hasSignal) { + GLRootView root = getGLRootView(); + if (root != null) { + root.queueEvent(new Runnable() { + public void run() { + mGpsIndicator.setHasSignal(hasSignal); + } + }); + } else { + mGpsIndicator.setHasSignal(hasSignal); + } + } + + public void setZoomRatios(float[] zoomRatios) { + mZoomIndicator.setZoomRatios(zoomRatios); + } +} diff --git a/src/com/android/camera/ui/HeadUpDisplay.java b/src/com/android/camera/ui/HeadUpDisplay.java index 4ad881d..fc2628e 100644 --- a/src/com/android/camera/ui/HeadUpDisplay.java +++ b/src/com/android/camera/ui/HeadUpDisplay.java @@ -51,13 +51,10 @@ public class HeadUpDisplay extends GLView { protected static final String TAG = "HeadUpDisplay"; - private IndicatorBar mIndicatorBar; - private OtherSettingsIndicator mOtherSettings; - private GpsIndicator mGpsIndicator; - private ZoomIndicator mZoomIndicator; + protected IndicatorBar mIndicatorBar; - private PreferenceGroup mPreferenceGroup; private SharedPreferences mSharedPrefs; + private PreferenceGroup mPreferenceGroup; private PopupWindow mPopupWindow; @@ -65,7 +62,7 @@ public class HeadUpDisplay extends GLView { private int mAnchorY; private int mOrientation = 0; - private Listener mListener; + protected Listener mListener; // TODO: move this part (handler) into GLSurfaceView private final HandlerThread mTimerThread = new HandlerThread("UI Timer"); @@ -298,7 +295,7 @@ public class HeadUpDisplay extends GLView { return true; } - private static ListPreference[] getListPreferences( + protected static ListPreference[] getListPreferences( PreferenceGroup group, String ... prefKeys) { ArrayList<ListPreference> list = new ArrayList<ListPreference>(); for (String key : prefKeys) { @@ -310,84 +307,28 @@ public class HeadUpDisplay extends GLView { return list.toArray(new ListPreference[list.size()]); } - private static BasicIndicator addIndicator(Context context, - IndicatorBar indicatorBar, PreferenceGroup group, String key) { + protected BasicIndicator addIndicator( + Context context, PreferenceGroup group, String key) { IconListPreference iconPref = (IconListPreference) group.findPreference(key); if (iconPref == null) return null; BasicIndicator indicator = new BasicIndicator(context, group, iconPref); - indicatorBar.addComponent(indicator); + mIndicatorBar.addComponent(indicator); return indicator; } - private void initializeIndicatorBar( + protected void initializeIndicatorBar( Context context, PreferenceGroup group) { - mIndicatorBar = new IndicatorBar(); mIndicatorBar.setBackground(new NinePatchTexture( context, R.drawable.ic_viewfinder_iconbar)); mIndicatorBar.setHighlight(new NinePatchTexture( context, R.drawable.ic_viewfinder_iconbar_highlight)); - - mOtherSettings = new OtherSettingsIndicator( - context, - getListPreferences(group, - CameraSettings.KEY_FOCUS_MODE, - CameraSettings.KEY_EXPOSURE, - CameraSettings.KEY_SCENE_MODE, - CameraSettings.KEY_PICTURE_SIZE, - CameraSettings.KEY_JPEG_QUALITY, - CameraSettings.KEY_COLOR_EFFECT)); - mOtherSettings.setOnRestorePreferencesClickedRunner(new Runnable() { - public void run() { - if (mListener != null) { - mListener.onRestorePreferencesClicked(); - } - } - }); - mIndicatorBar.addComponent(mOtherSettings); - - GpsIndicator gpsIndicator = new GpsIndicator( - context, group, (IconListPreference) - group.findPreference(CameraSettings.KEY_RECORD_LOCATION)); - - mGpsIndicator = gpsIndicator; - mIndicatorBar.addComponent(gpsIndicator); - - addIndicator(context, mIndicatorBar, group, - CameraSettings.KEY_WHITE_BALANCE); - addIndicator(context, mIndicatorBar, group, - CameraSettings.KEY_FLASH_MODE); - - mZoomIndicator = new ZoomIndicator(context); - mIndicatorBar.addComponent(mZoomIndicator); - addComponent(mIndicatorBar); mIndicatorBar.setOnItemSelectedListener(new IndicatorBarListener()); } - public void setZoomListener(ZoomController.ZoomListener listener) { - mZoomIndicator.setZoomListener(listener); - } - - public void setZoomIndex(int index) { - mZoomIndicator.setZoomIndex(index); - } - - public void setGpsHasSignal(final boolean hasSignal) { - GLRootView root = getGLRootView(); - if (root != null) { - root.queueEvent(new Runnable() { - public void run() { - mGpsIndicator.setHasSignal(hasSignal); - } - }); - } else { - mGpsIndicator.setHasSignal(hasSignal); - } - } - private class IndicatorBarListener implements IndicatorBar.OnItemSelectedListener { @@ -415,10 +356,6 @@ public class HeadUpDisplay extends GLView { } } - public void setZoomRatios(float[] zoomRatios) { - mZoomIndicator.setZoomRatios(zoomRatios); - } - public void collapse() { getGLRootView().queueEvent(new Runnable() { public void run() { |