diff options
Diffstat (limited to 'src/com/android/camera/VideoMenu.java')
-rw-r--r-- | src/com/android/camera/VideoMenu.java | 131 |
1 files changed, 76 insertions, 55 deletions
diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java index 3ed6b5875..cedb199dd 100644 --- a/src/com/android/camera/VideoMenu.java +++ b/src/com/android/camera/VideoMenu.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2012 The Android Open Source Project - * Copyright (C) 2013 The CyanogenMod Project + * Copyright (C) 2013-2014 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. @@ -40,13 +40,15 @@ public class VideoMenu extends PieController private static String TAG = "CAM_VideoMenu"; private VideoUI mUI; - private String[] mOtherKeys; + private String[] mSettingsKeys; private AbstractSettingPopup mPopup; + private MoreSettingPopup mSettingsPopup; 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 CameraActivity mActivity; public VideoMenu(CameraActivity activity, VideoUI ui, PieRenderer pie) { @@ -58,6 +60,7 @@ public class VideoMenu extends PieController public void initialize(PreferenceGroup group) { super.initialize(group); mPopup = null; + mSettingsPopup = null; mPopupStatus = POPUP_NONE; PieItem item = null; final Resources res = mActivity.getResources(); @@ -88,21 +91,11 @@ public class VideoMenu extends PieController final ListPreference colorPref = group.findPreference(CameraSettings.KEY_VIDEOCAMERA_COLOR_EFFECT); if (colorPref != null) { - item = makeItem(R.drawable.ic_tint); - item.setLabel(res.getString( - R.string.pref_camera_coloreffect_title).toUpperCase(locale)); + item = makeListItem(CameraSettings.KEY_VIDEOCAMERA_COLOR_EFFECT); item.setOnClickListener(new OnClickListener() { @Override public void onClick(PieItem item) { - ListPrefSettingPopup popup = - (ListPrefSettingPopup) mActivity.getLayoutInflater().inflate( - R.layout.list_pref_setting_popup, null, false); - popup.initialize(colorPref); - popup.setSettingChangedListener(VideoMenu.this); - mUI.dismissPopup(); - mPopup = popup; - mPopupStatus = POPUP_SECOND_LEVEL; - mUI.showPopup(mPopup); + showListPopup(colorPref); } }); enhance.addItem(item); @@ -156,7 +149,6 @@ public class VideoMenu extends PieController timeInterval.setSettingChangedListener(VideoMenu.this); mUI.dismissPopup(); mPopup = timeInterval; - mPopupStatus = POPUP_SECOND_LEVEL; mUI.showPopup(mPopup); } }); @@ -164,21 +156,11 @@ public class VideoMenu extends PieController // video size final ListPreference sizePref = group.findPreference(CameraSettings.KEY_VIDEO_QUALITY); if (sizePref != null) { - item = makeItem(R.drawable.ic_imagesize); - item.setLabel(res.getString( - R.string.pref_video_quality_title).toUpperCase(locale)); + item = makeListItem(CameraSettings.KEY_VIDEO_QUALITY); item.setOnClickListener(new OnClickListener() { @Override public void onClick(PieItem item) { - ListPrefSettingPopup popup = - (ListPrefSettingPopup) mActivity.getLayoutInflater().inflate( - R.layout.list_pref_setting_popup, null, false); - popup.initialize(sizePref); - popup.setSettingChangedListener(VideoMenu.this); - mUI.dismissPopup(); - mPopup = popup; - mPopupStatus = POPUP_SECOND_LEVEL; - mUI.showPopup(mPopup); + showListPopup(sizePref); } }); more.addItem(item); @@ -190,7 +172,7 @@ public class VideoMenu extends PieController more.addItem(item); } // extra settings popup - mOtherKeys = new String[] { + mSettingsKeys = new String[] { CameraSettings.KEY_STORAGE, CameraSettings.KEY_POWER_SHUTTER, CameraSettings.KEY_DIS, @@ -200,44 +182,61 @@ public class VideoMenu extends PieController CameraSettings.KEY_JPEG_QUALITY, CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE, }; - item = makeItem(R.drawable.ic_settings_holo_light); - item.setLabel(res.getString(R.string.camera_menu_more_label).toUpperCase(locale)); - item.setOnClickListener(new OnClickListener() { + PieItem settings = makeItem(R.drawable.ic_settings_holo_light); + settings.setLabel(res.getString(R.string.camera_menu_more_label).toUpperCase(locale)); + settings.setOnClickListener(new OnClickListener() { @Override public void onClick(PieItem item) { - if (mPopup == null || mPopupStatus != POPUP_FIRST_LEVEL) { - LayoutInflater inflater = mActivity.getLayoutInflater(); - MoreSettingPopup popup = (MoreSettingPopup) inflater.inflate( - R.layout.more_setting_popup, null, false); - popup.initialize(mPreferenceGroup, mOtherKeys); - popup.setSettingChangedListener(VideoMenu.this); - mPopup = popup; + if (mSettingsPopup == null || mPopupStatus != POPUP_FIRST_LEVEL) { + initializeSettingsPopup(); mPopupStatus = POPUP_FIRST_LEVEL; } - mUI.showPopup(mPopup); + mUI.showPopup(mSettingsPopup); } }); - more.addItem(item); + more.addItem(settings); } - @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(); + public void popupDismissed() { + if (mPopupStatus == POPUP_SECOND_LEVEL) { + initializeSettingsPopup(); + mPopupStatus = POPUP_FIRST_LEVEL; + mUI.showPopup(mSettingsPopup); + if (mSettingsPopup != null) { + mSettingsPopup = null; + } + } else { + initializeSettingsPopup(); + if (mPopup != null) { + mPopup = null; } } - onSettingChanged(pref); } - public void popupDismissed() { - // if the 2nd level popup gets dismissed - if (mPopup != null) { - if (mPopupStatus == POPUP_SECOND_LEVEL) { - mPopup = null; - } + @Override + public void reloadPreferences() { + super.reloadPreferences(); + if (mSettingsPopup != null) { + mSettingsPopup.reloadPreference(); + } + } + + @Override + public void overrideSettings(final String ... keyvalues) { + super.overrideSettings(keyvalues); + if (mSettingsPopup == null) { + initializeSettingsPopup(); + } + mSettingsPopup.overrideSettings(keyvalues); + } + + @Override + // Hit when an item in a popup gets selected + public void onListPrefChanged(ListPreference pref) { + if (mPopup != null && mSettingsPopup != null) { + mUI.dismissPopup(); } + onSettingChanged(pref); } @Override @@ -246,8 +245,8 @@ public class VideoMenu extends PieController public void onPreferenceClicked(ListPreference pref) { if (mPopupStatus != POPUP_FIRST_LEVEL) return; - LayoutInflater inflater = mActivity.getLayoutInflater(); - ListPrefSettingPopup basic = (ListPrefSettingPopup) inflater.inflate( + ListPrefSettingPopup basic = + (ListPrefSettingPopup) mActivity.getLayoutInflater().inflate( R.layout.list_pref_setting_popup, null, false); basic.initialize(pref); basic.setSettingChangedListener(this); @@ -257,4 +256,26 @@ public class VideoMenu extends PieController mPopupStatus = POPUP_SECOND_LEVEL; } + // Initialize the second-level settings popup + protected void initializeSettingsPopup() { + MoreSettingPopup popup = + (MoreSettingPopup) mActivity.getLayoutInflater().inflate( + R.layout.more_setting_popup, null, false); + popup.initialize(mPreferenceGroup, mSettingsKeys); + popup.setSettingChangedListener(VideoMenu.this); + mSettingsPopup = popup; + } + + // Show a popup options list + protected void showListPopup(ListPreference pref) { + ListPrefSettingPopup popup = + (ListPrefSettingPopup) mActivity.getLayoutInflater().inflate( + R.layout.list_pref_setting_popup, null, false); + popup.initialize(pref); + popup.setSettingChangedListener(VideoMenu.this); + mUI.dismissPopup(); + mPopup = popup; + mUI.showPopup(mPopup); + } + } |