diff options
author | Doris Liu <tianliu@google.com> | 2013-03-14 21:01:35 -0700 |
---|---|---|
committer | Doris Liu <tianliu@google.com> | 2013-04-09 10:35:50 -0700 |
commit | 753bb8aa56fff425fe16b93be368b9b236e4751f (patch) | |
tree | 92182a98004dba4fb131e9fcb020796625659276 /src/com/android/camera/NewVideoMenu.java | |
parent | 15f4efb50b40fbdf108121e367bfd6f50d5b2c41 (diff) | |
download | android_packages_apps_Snap-753bb8aa56fff425fe16b93be368b9b236e4751f.tar.gz android_packages_apps_Snap-753bb8aa56fff425fe16b93be368b9b236e4751f.tar.bz2 android_packages_apps_Snap-753bb8aa56fff425fe16b93be368b9b236e4751f.zip |
Work in progress - Put preview in TextureView
Fixed gesture recognizing and pie menu.
Fixed camera picker. Exposure setting got fixed with rebasing.
Rebased for new pie menu
Fixed camera mode switch listener
Ongoing: secure album, aspect ratio for video recording on ICS
Change-Id: Iedae80815faf81cb49c791885810c8427034a6d1
Diffstat (limited to 'src/com/android/camera/NewVideoMenu.java')
-rw-r--r-- | src/com/android/camera/NewVideoMenu.java | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/src/com/android/camera/NewVideoMenu.java b/src/com/android/camera/NewVideoMenu.java new file mode 100644 index 000000000..1dec27a47 --- /dev/null +++ b/src/com/android/camera/NewVideoMenu.java @@ -0,0 +1,190 @@ +/* + * Copyright (C) 2013 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.app.Activity; +import android.content.Context; +import android.view.LayoutInflater; + +import com.android.camera.ui.AbstractSettingPopup; +import com.android.camera.ui.ListPrefSettingPopup; +import com.android.camera.ui.MoreSettingPopup; +import com.android.camera.ui.PieItem; +import com.android.camera.ui.PieItem.OnClickListener; +import com.android.camera.ui.PieRenderer; +import com.android.camera.ui.TimeIntervalPopup; +import com.android.gallery3d.R; + +public class NewVideoMenu extends PieController + implements MoreSettingPopup.Listener, + ListPrefSettingPopup.Listener, + TimeIntervalPopup.Listener { + + private static String TAG = "CAM_VideoMenu"; + private static final int POS_WB = 1; + private static final int POS_SET = 2; + private static final int POS_FLASH = 3; + private static final int POS_SWITCH = 4; + + private NewVideoUI mUI; + private String[] mOtherKeys; + private AbstractSettingPopup mPopup; + + private static final int POPUP_NONE = 0; + private static final int POPUP_FIRST_LEVEL = 1; + private static final int POPUP_SECOND_LEVEL = 2; + private int mPopupStatus; + private NewCameraActivity mActivity; + + public NewVideoMenu(NewCameraActivity activity, NewVideoUI ui, PieRenderer pie) { + super(activity, pie); + mUI = ui; + mActivity = activity; + } + + public void initialize(PreferenceGroup group) { + super.initialize(group); + mPopup = null; + mPopupStatus = POPUP_NONE; + + PieItem item = makeItem(CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE, POS_FLASH, 5); + mRenderer.addItem(item); + item = makeItem(CameraSettings.KEY_WHITE_BALANCE, POS_WB, 5); + mRenderer.addItem(item); + // camera switcher + item = makeItem(R.drawable.ic_switch_video_facing_holo_light); + item.setPosition(POS_SWITCH, 5); + item.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(PieItem item) { + // Find the index of next camera. + ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_CAMERA_ID); + if (pref != null) { + int index = pref.findIndexOfValue(pref.getValue()); + CharSequence[] values = pref.getEntryValues(); + index = (index + 1) % values.length; + int newCameraId = Integer.parseInt((String) values[index]); + mListener.onCameraPickerClicked(newCameraId); + } + } + }); + mRenderer.addItem(item); + // settings popup + mOtherKeys = new String[] { + CameraSettings.KEY_VIDEO_EFFECT, + CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL, + CameraSettings.KEY_VIDEO_QUALITY, + CameraSettings.KEY_RECORD_LOCATION + }; + item = makeItem(R.drawable.ic_settings_holo_light); + item.setPosition(POS_SET, 5); + item.setOnClickListener(new OnClickListener() { + @Override + public void onClick(PieItem item) { + if (mPopup == null || mPopupStatus != POPUP_FIRST_LEVEL) { + initializePopup(); + mPopupStatus = POPUP_FIRST_LEVEL; + } + mUI.showPopup(mPopup); + } + }); + mRenderer.addItem(item); + } + + @Override + public void reloadPreferences() { + super.reloadPreferences(); + if (mPopup != null) { + mPopup.reloadPreference(); + } + } + + @Override + public void overrideSettings(final String ... keyvalues) { + super.overrideSettings(keyvalues); + if (mPopup == null || mPopupStatus != POPUP_FIRST_LEVEL) { + mPopupStatus = POPUP_FIRST_LEVEL; + initializePopup(); + } + ((MoreSettingPopup) mPopup).overrideSettings(keyvalues); + } + + @Override + // Hit when an item in the second-level popup gets selected + public void onListPrefChanged(ListPreference pref) { + if (mPopup != null) { + if (mPopupStatus == POPUP_SECOND_LEVEL) { + mUI.dismissPopup(true); + } + } + super.onSettingChanged(pref); + } + + protected void initializePopup() { + LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + + MoreSettingPopup popup = (MoreSettingPopup) inflater.inflate( + R.layout.more_setting_popup, null, false); + popup.setSettingChangedListener(this); + popup.initialize(mPreferenceGroup, mOtherKeys); + if (mActivity.isSecureCamera()) { + // Prevent location preference from getting changed in secure camera mode + popup.setPreferenceEnabled(CameraSettings.KEY_RECORD_LOCATION, false); + } + mPopup = popup; + } + + public void popupDismissed(boolean topPopupOnly) { + // if the 2nd level popup gets dismissed + if (mPopupStatus == POPUP_SECOND_LEVEL) { + initializePopup(); + mPopupStatus = POPUP_FIRST_LEVEL; + if (topPopupOnly) mUI.showPopup(mPopup); + } + } + + @Override + // Hit when an item in the first-level popup gets selected, then bring up + // the second-level popup + public void onPreferenceClicked(ListPreference pref) { + if (mPopupStatus != POPUP_FIRST_LEVEL) return; + + LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + + if (CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL.equals(pref.getKey())) { + TimeIntervalPopup timeInterval = (TimeIntervalPopup) inflater.inflate( + R.layout.time_interval_popup, null, false); + timeInterval.initialize((IconListPreference) pref); + timeInterval.setSettingChangedListener(this); + mUI.dismissPopup(true); + mPopup = timeInterval; + } else { + ListPrefSettingPopup basic = (ListPrefSettingPopup) inflater.inflate( + R.layout.list_pref_setting_popup, null, false); + basic.initialize(pref); + basic.setSettingChangedListener(this); + mUI.dismissPopup(true); + mPopup = basic; + } + mUI.showPopup(mPopup); + mPopupStatus = POPUP_SECOND_LEVEL; + } + +} |