Merge "Custom settings ui with dialogs." into gb-ub-photos-denali
diff --git a/res/layout/settings_list_layout.xml b/res/layout/settings_list_layout.xml
new file mode 100644
index 0000000..fa0025a
--- /dev/null
+++ b/res/layout/settings_list_layout.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<com.android.camera.ui.SettingsView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/settings_list_layout"
+ android:fillViewport="true"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/mode_selector_background_light" >
+</com.android.camera.ui.SettingsView>
\ No newline at end of file
diff --git a/res/layout/settings_selector.xml b/res/layout/settings_selector.xml
new file mode 100644
index 0000000..2825188
--- /dev/null
+++ b/res/layout/settings_selector.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/setting_text"
+ android:layout_gravity="left"
+ android:paddingLeft="24dp"
+ android:paddingRight="24dp"
+ android:layout_width="match_parent"
+ android:layout_height="60dp"
+ android:gravity="center_vertical"
+ android:textSize="16sp"
+ android:textColor="@color/mode_selector_text_color"
+/>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c0e46ea..1dc112a 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -157,4 +157,5 @@
<!-- Mode selector icon width -->
<dimen name="mode_selector_icon_block_width">84dp</dimen>
<dimen name="mode_selector_icon_drawable_size">32dp</dimen>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1a10320..be94f84 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -423,6 +423,7 @@
<!-- Dialog "OK" button. Dismisses dialog. -->
<string name="dialog_ok">OK</string>
+ <string name="dialog_cancel">Cancel</string>
<!-- Low-memory dialog message [CHAR LIMIT=NONE] -->
<string name="spaceIsLow_content" product="default">Your SD card is running out of space. Change the quality setting or delete some images or other files.</string>
@@ -692,4 +693,9 @@
<!-- Text shown in the camera mode options list for putting camera in wide angle panorama mode [CHAR LIMIT = 25] -->
<string name="mode_wideangle">Wide Angle</string>
+ <string name="setting_location">Location</string>
+ <string name="setting_picture_size">Picture Size</string>
+ <string name="setting_video_resolution">Video Resolution</string>
+ <string name="setting_default_camera">Default Camera</string>
+
</resources>
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index b90ce37..a78dc6b 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -32,6 +32,7 @@
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
+import android.graphics.Color;
import android.graphics.SurfaceTexture;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
@@ -49,6 +50,7 @@
import android.provider.MediaStore;
import android.provider.Settings;
import android.util.Log;
+import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -60,7 +62,9 @@
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
+import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
+import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.ShareActionProvider;
@@ -97,6 +101,7 @@
import com.android.camera.ui.DetailsDialog;
import com.android.camera.ui.FilmstripView;
import com.android.camera.ui.ModeListView;
+import com.android.camera.ui.SettingsView;
import com.android.camera.util.ApiHelper;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.GcamHelper;
@@ -167,10 +172,11 @@
*/
private LocalDataAdapter mWrappedDataAdapter;
+ private SettingsManager mSettingsManager;
private PanoramaStitchingManager mPanoramaManager;
private PlaceholderManager mPlaceholderManager;
private ModeListView mModeListView;
- private int mCurrentModuleIndex;
+ private int mCurrentModeIndex;
private CameraModule mCurrentModule;
private ModuleController mCurrentModule2;
private ModuleManagerImpl mModuleManager;
@@ -216,6 +222,7 @@
private Intent mImageShareIntent;
private CameraController mCameraController;
+ private boolean mPaused;
private MediaSaver mMediaSaver;
private ServiceConnection mConnection = new ServiceConnection() {
@@ -247,7 +254,7 @@
@Override
public void onCameraOpened(CameraManager.CameraProxy camera) {
- if (!mModuleManager.getModuleAgent(mCurrentModuleIndex).requestAppForCamera()) {
+ if (!mModuleManager.getModuleAgent(mCurrentModeIndex).requestAppForCamera()) {
// We shouldn't be here. Just close the camera and leave.
camera.release(false);
throw new IllegalStateException("Camera opened but the module shouldn't be " +
@@ -1201,30 +1208,30 @@
// Set up the camera preview first so the preview shows up ASAP.
mFilmstripController.setListener(mFilmStripListener);
- int moduleIndex = -1;
+ int modeIndex = -1;
if (MediaStore.INTENT_ACTION_VIDEO_CAMERA.equals(getIntent().getAction())
|| MediaStore.ACTION_VIDEO_CAPTURE.equals(getIntent().getAction())) {
- moduleIndex = ModeListView.MODE_VIDEO;
+ modeIndex = ModeListView.MODE_VIDEO;
} else if (MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA.equals(getIntent().getAction())
|| MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(getIntent()
.getAction())) {
- moduleIndex = ModeListView.MODE_PHOTO;
+ modeIndex = ModeListView.MODE_PHOTO;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getInt(CameraSettings.KEY_STARTUP_MODULE_INDEX, -1)
== ModeListView.MODE_GCAM && GcamHelper.hasGcamCapture()) {
- moduleIndex = ModeListView.MODE_GCAM;
+ modeIndex = ModeListView.MODE_GCAM;
}
} else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(getIntent().getAction())
|| MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(getIntent().getAction())) {
- moduleIndex = ModeListView.MODE_PHOTO;
+ modeIndex = ModeListView.MODE_PHOTO;
} else {
// If the activity has not been started using an explicit intent,
// read the module index from the last time the user changed modes
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- moduleIndex = prefs.getInt(CameraSettings.KEY_STARTUP_MODULE_INDEX, -1);
- if ((moduleIndex == ModeListView.MODE_GCAM &&
- !GcamHelper.hasGcamCapture()) || moduleIndex < 0) {
- moduleIndex = ModeListView.MODE_PHOTO;
+ modeIndex = prefs.getInt(CameraSettings.KEY_STARTUP_MODULE_INDEX, -1);
+ if ((modeIndex == ModeListView.MODE_GCAM &&
+ !GcamHelper.hasGcamCapture()) || modeIndex < 0) {
+ modeIndex = ModeListView.MODE_PHOTO;
}
}
@@ -1242,7 +1249,9 @@
}
});
- setModuleFromIndex(moduleIndex);
+ mSettingsManager = new SettingsManager(this);
+
+ setModuleFromModeIndex(modeIndex);
mCurrentModule.init(this, mCameraModuleRootView);
if (!mSecureCamera) {
@@ -1326,6 +1335,8 @@
@Override
public void onPause() {
+ mPaused = true;
+
// Delete photos that are pending deletion
performDeletion();
// TODO: call mCurrentModule.pause() instead after all the modules
@@ -1352,6 +1363,8 @@
@Override
public void onResume() {
+ mPaused = false;
+
// TODO: Handle this in OrientationManager.
// Auto-rotate off
if (Settings.System.getInt(getContentResolver(),
@@ -1531,43 +1544,69 @@
}
@Override
- public void onModeSelected(int moduleIndex) {
- if (mCurrentModuleIndex == moduleIndex) {
+ public boolean isPaused() {
+ return mPaused;
+ }
+
+ @Override
+ public void onModeSelected(int modeIndex) {
+ if (mCurrentModeIndex == modeIndex) {
return;
}
+ CameraHolder.instance().keep();
closeModule(mCurrentModule);
- setModuleFromIndex(moduleIndex);
+ setModuleFromModeIndex(modeIndex);
openModule(mCurrentModule);
mCurrentModule.onOrientationChanged(mLastRawOrientation);
if (mMediaSaver != null) {
mCurrentModule.onMediaSaverAvailable(mMediaSaver);
}
-
// Store the module index so we can use it the next time the Camera
// starts up.
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- prefs.edit().putInt(CameraSettings.KEY_STARTUP_MODULE_INDEX, moduleIndex).apply();
+ prefs.edit().putInt(CameraSettings.KEY_STARTUP_MODULE_INDEX, modeIndex).apply();
+ }
+
+ @Override
+ public void onSettingsSelected(int modeIndex) {
+ // Temporary until we finalize the touch flow.
+ LayoutInflater inflater = getLayoutInflater();
+ SettingsView settingsView = (SettingsView) inflater.inflate(R.layout.settings_list_layout,
+ null, false);
+ settingsView.setSettingsListener(new SettingsController(this, mSettingsManager));
+
+ PopupWindow popup = new PopupWindow(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ popup.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ popup.setOutsideTouchable(true);
+ popup.setFocusable(true);
+ popup.setContentView(settingsView);
+ popup.showAtLocation(mModeListView.getRootView(), Gravity.CENTER, 0, 0);
}
/**
* Sets the mCurrentModuleIndex, creates a new module instance for the given
* index an sets it as mCurrentModule.
*/
- private void setModuleFromIndex(int moduleIndex) {
- ModuleManagerImpl.ModuleAgent agent = mModuleManager.getModuleAgent(moduleIndex);
+ private void setModuleFromModeIndex(int modeIndex) {
+ ModuleManagerImpl.ModuleAgent agent = mModuleManager.getModuleAgent(modeIndex);
if (agent == null) {
return;
}
if (!agent.requestAppForCamera()) {
mCameraController.closeCamera();
}
- mCurrentModuleIndex = agent.getModuleId();
+ mCurrentModeIndex = agent.getModuleId();
mCurrentModule2 = agent.createModule();
mCurrentModule = (CameraModule) mCurrentModule2;
}
+ @Override
+ public SettingsManager getSettingsManager() {
+ return mSettingsManager;
+ }
+
/**
* Launches an ACTION_EDIT intent for the given local data item.
*/
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index e8a8964..e2aa32e 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -200,6 +200,7 @@
private ContentResolver mContentResolver;
private LocationManager mLocationManager;
+ private SettingsManager mSettingsManager;
private final PostViewPictureCallback mPostViewPictureCallback =
new PostViewPictureCallback();
@@ -363,6 +364,7 @@
mCameraId = getPreferredCameraId(mPreferences);
mContentResolver = mActivity.getContentResolver();
+ mSettingsManager = mActivity.getSettingsManager();
// Surface texture is from camera screen nail and startPreview needs it.
// This must be done before startPreview.
@@ -880,7 +882,7 @@
}
mJpegRotation = CameraUtil.getJpegRotation(mActivity, mCameraId, orientation);
mParameters.setRotation(mJpegRotation);
- Location loc = mLocationManager.getCurrentLocation();
+ Location loc = mActivity.getLocationManager().getCurrentLocation();
CameraUtil.setGpsParameters(mParameters, loc);
mCameraDevice.setParameters(mParameters);
diff --git a/src/com/android/camera/SettingsController.java b/src/com/android/camera/SettingsController.java
new file mode 100644
index 0000000..ecf6bd5
--- /dev/null
+++ b/src/com/android/camera/SettingsController.java
@@ -0,0 +1,55 @@
+/*
+ * 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 com.android.camera.ui.SettingsView;
+import com.android.camera.SettingsManager.LocationSetting;
+
+public class SettingsController implements SettingsView.SettingsListener {
+ private static final String TAG = "CAM_SettingsController";
+
+ private CameraActivity mActivity;
+ private SettingsManager mSettingsManager;
+
+ SettingsController(CameraActivity activity, SettingsManager manager) {
+ mActivity = activity;
+ mSettingsManager = manager;
+ }
+
+ @Override
+ public void setLocation(boolean on) {
+ if (!mActivity.isPaused()) {
+ LocationSetting locationPreference = mSettingsManager.getLocationSetting();
+ locationPreference.set(on ? SettingsManager.VALUE_ON : SettingsManager.VALUE_OFF);
+
+ LocationManager locationManager = mActivity.getLocationManager();
+ locationManager.recordLocation(on);
+ }
+ }
+
+ @Override
+ public void setPictureSize(int size) {
+ }
+
+ @Override
+ public void setVideoResolution(int resolution) {
+ }
+
+ @Override
+ public void setDefaultCamera(int id) {
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
new file mode 100644
index 0000000..e76ce8f
--- /dev/null
+++ b/src/com/android/camera/SettingsManager.java
@@ -0,0 +1,80 @@
+/*
+ * 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.content.ContentResolver;
+import android.content.Context;
+import android.location.Location;
+import android.util.Log;
+
+public class SettingsManager {
+ private static final String TAG = "CAM_SettingsManager";
+
+ private Context mContext;
+ // TODO(edahlgren): plumb this into this class.
+ private ComboPreferences mPreferences;
+
+ // List settings here.
+ private LocationSetting mLocationSetting;
+
+ public SettingsManager(Context context) {
+ mContext = context;
+
+ mPreferences = new ComboPreferences(context);
+ // Local preferences must be non-null to edit preferences.
+ int cameraId = CameraSettings.readPreferredCameraId(mPreferences);
+ mPreferences.setLocalId(context, cameraId);
+ CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
+
+ init();
+ }
+
+ private void init() {
+ mLocationSetting = new LocationSetting();
+ // initialize other settings here.
+ }
+
+ // There's global and camera dependent preferences.
+ // We need to distinguish between the two.
+ public static final String VALUE_GLOBAL = "global";
+ public static final String VALUE_CAMERA = "camera";
+
+ public static final String VALUE_NONE = "none";
+ public static final String VALUE_ON = "on";
+ public static final String VALUE_OFF = "off";
+
+ public class LocationSetting {
+ public String isGlobal() {
+ return VALUE_GLOBAL;
+ }
+
+ public String get() {
+ return mPreferences.getString(CameraSettings.KEY_RECORD_LOCATION,
+ VALUE_NONE);
+ }
+
+ public void set(String value) {
+ mPreferences.edit()
+ .putString(CameraSettings.KEY_RECORD_LOCATION, value)
+ .apply();
+ }
+ }
+
+ public LocationSetting getLocationSetting() {
+ return mLocationSetting;
+ }
+}
diff --git a/src/com/android/camera/app/AppController.java b/src/com/android/camera/app/AppController.java
index 1b25397..efd73d4 100644
--- a/src/com/android/camera/app/AppController.java
+++ b/src/com/android/camera/app/AppController.java
@@ -23,6 +23,7 @@
import android.widget.FrameLayout;
import com.android.camera.LocationManager;
+import com.android.camera.SettingsManager;
/**
* The controller at app level.
@@ -59,6 +60,11 @@
*/
public Context getAndroidContext();
+ /**
+ * Returns whether the app is currently paused.
+ */
+ public boolean isPaused();
+
/********************** UI / Camera preview **********************/
/**
@@ -165,4 +171,11 @@
* @return {@code null} if not available yet.
*/
public LocationManager getLocationManager();
+
+ /**
+ * Returns the {@link com.android.camera.SettingsManager}.
+ *
+ * @return {@code null} if not available yet.
+ */
+ public SettingsManager getSettingsManager();
}
diff --git a/src/com/android/camera/ui/ModeListView.java b/src/com/android/camera/ui/ModeListView.java
index d172b25..e549455 100644
--- a/src/com/android/camera/ui/ModeListView.java
+++ b/src/com/android/camera/ui/ModeListView.java
@@ -109,6 +109,7 @@
public interface ModeSwitchListener {
public void onModeSelected(int modeIndex);
+ public void onSettingsSelected(int modeIndex);
}
/**
@@ -193,7 +194,11 @@
int index = getFocusItem(ev.getX(), ev.getY());
// Validate the selection
if (index != NO_ITEM_SELECTED) {
- onModeSelected(index);
+ if (index == MODE_SETTING) {
+ onSettingsSelected(index);
+ } else {
+ onModeSelected(index);
+ }
}
return true;
}
@@ -266,6 +271,13 @@
resetModeSelectors();
}
+ private void onSettingsSelected(int modeIndex) {
+ if (mListener != null) {
+ mListener.onSettingsSelected(modeIndex);
+ }
+ snapBack();
+ }
+
/** Notify ModeSwitchListener, if any, of the mode change. */
private void onModeSelected(int modeIndex) {
if (mListener != null) {
diff --git a/src/com/android/camera/ui/SettingsView.java b/src/com/android/camera/ui/SettingsView.java
new file mode 100644
index 0000000..724bbae
--- /dev/null
+++ b/src/com/android/camera/ui/SettingsView.java
@@ -0,0 +1,186 @@
+/*
+ * 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.ui;
+
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.ListView;
+import android.widget.ArrayAdapter;
+import android.widget.AdapterView;
+
+import com.android.camera.CameraActivity;
+import com.android.camera2.R;
+
+/**
+ * SettingsView class displays all global settings in the form
+ * of a list. Each setting launches a dialog or a toggle.
+ */
+public class SettingsView extends ListView {
+ private static final String TAG = "SettingsView";
+
+ private static final int LOCATION_SETTING = 0;
+ private static final int PICTURE_SIZE_SETTING = 1;
+ private static final int VIDEO_RES_SETTING = 2;
+ private static final int DEFAULT_CAMERA_SETTING = 3;
+
+ private static final int MODE_TOTAL = 4;
+ private static final float ROWS_TO_SHOW_IN_LANDSCAPE = 4.5f;
+
+ private final int mHeadingIconResId = R.drawable.settings;
+ private final int mHeadingTextResId = R.string.mode_settings;
+ private final int mHeadingIconBlockColor = R.color.settings_mode_color;
+
+ private final int[] mSettingsTextResId = {
+ R.string.setting_location, R.string.setting_picture_size,
+ R.string.setting_video_resolution, R.string.setting_default_camera,};
+
+ private Context mContext;
+ private SettingsListener mListener;
+ private AlertDialog.Builder mDialogBuilder;
+
+ private ArrayAdapter mAdapter;
+ private CharSequence[] mSettingsItems;
+
+ public SettingsView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mContext = context;
+ mSettingsItems = buildItems();
+ mAdapter = new ArrayAdapter(mContext, R.layout.settings_selector, mSettingsItems);
+ setAdapter(mAdapter);
+
+ setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int pos, long id) {
+ onSettingSelected(pos);
+ }
+ });
+ }
+
+ public interface SettingsListener {
+ public void setLocation(boolean on);
+ public void setPictureSize(int size);
+ public void setVideoResolution(int resolution);
+ public void setDefaultCamera(int id);
+ }
+
+ public void setSettingsListener(SettingsListener listener) {
+ mListener = listener;
+ }
+
+ private CharSequence[] buildItems() {
+ int total = mSettingsTextResId.length;
+ CharSequence[] items = new String[total];
+
+ for (int i = 0; i < total; i++) {
+ CharSequence text = getResources().getText(mSettingsTextResId[i]);
+ items[i] = text;
+ }
+ return items;
+ }
+
+ private void onSettingSelected(int settingIndex) {
+ switch (settingIndex) {
+ case LOCATION_SETTING:
+ mDialogBuilder = new LocationAlertBuilder();
+ break;
+ case PICTURE_SIZE_SETTING:
+ mDialogBuilder = new PictureSizeAlertBuilder();
+ break;
+ case VIDEO_RES_SETTING:
+ mDialogBuilder = new VideoResAlertBuilder();
+ break;
+ case DEFAULT_CAMERA_SETTING:
+ mDialogBuilder = new DefaultCameraAlertBuilder();
+ break;
+ default:
+ mDialogBuilder = null;
+ }
+ if (mDialogBuilder != null) {
+ AlertDialog alert = mDialogBuilder.create();
+ alert.show();
+ }
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ }
+
+ private class LocationAlertBuilder extends AlertDialog.Builder {
+ LocationAlertBuilder() {
+ super(mContext);
+ setTitle(R.string.remember_location_title);
+ setMessage(R.string.remember_location_prompt);
+ setPositiveButton(R.string.remember_location_yes,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int arg1) {
+ mListener.setLocation(true);
+ }
+ });
+ setNegativeButton(R.string.remember_location_no,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int arg1) {
+ dialog.cancel();
+ }
+ });
+ setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ mListener.setLocation(false);
+ }
+ });
+ }
+ }
+
+ private class PictureSizeAlertBuilder extends AlertDialog.Builder {
+ PictureSizeAlertBuilder() {
+ super(mContext);
+ setTitle(R.string.setting_picture_size);
+ }
+ //mListener.setPictureSize();
+ }
+
+ private class VideoResAlertBuilder extends AlertDialog.Builder {
+ VideoResAlertBuilder() {
+ super(mContext);
+ setTitle(R.string.setting_video_resolution);
+ }
+ //mListener.setVideoResolution();
+ }
+
+ private class DefaultCameraAlertBuilder extends AlertDialog.Builder {
+ DefaultCameraAlertBuilder() {
+ super(mContext);
+ setTitle(R.string.setting_default_camera);
+ }
+ //mListener.setDefaultCamera();
+ }
+
+
+}