summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/CountDownTimerPreference.java19
-rw-r--r--src/com/android/camera/PhotoMenu.java133
-rw-r--r--src/com/android/camera/PhotoUI.java16
-rw-r--r--src/com/android/camera/ui/CountdownTimerPopup.java (renamed from src/com/android/camera/ui/TimerSettingPopup.java)92
-rw-r--r--src/com/android/photos/data/SparseArrayBitmapPool.java2
5 files changed, 104 insertions, 158 deletions
diff --git a/src/com/android/camera/CountDownTimerPreference.java b/src/com/android/camera/CountDownTimerPreference.java
index 0bbf6bc9d..9c66dda8c 100644
--- a/src/com/android/camera/CountDownTimerPreference.java
+++ b/src/com/android/camera/CountDownTimerPreference.java
@@ -21,25 +21,20 @@ import android.util.AttributeSet;
import com.android.gallery3d.R;
-import java.util.List;
-
-/* CountDownTimerPreference generates entries (i.e. what users see in the UI),
- * and entry values (the actual value recorded in preference) in
- * initCountDownTimeChoices(Context context), rather than reading the entries
- * from a predefined list. When the entry values are a continuous list of numbers,
- * (e.g. 0-60), it is more efficient to auto generate the list than to predefine it.*/
public class CountDownTimerPreference extends ListPreference {
- private final static int MAX_DURATION = 60;
+ private static final int[] DURATIONS = {
+ 0, 1, 2, 3, 4, 5, 10, 15, 20, 30, 60
+ };
public CountDownTimerPreference(Context context, AttributeSet attrs) {
super(context, attrs);
initCountDownDurationChoices(context);
}
private void initCountDownDurationChoices(Context context) {
- CharSequence[] entryValues = new CharSequence[MAX_DURATION + 1];
- CharSequence[] entries = new CharSequence[MAX_DURATION + 1];
- for (int i = 0; i <= MAX_DURATION; i++) {
- entryValues[i] = Integer.toString(i);
+ CharSequence[] entryValues = new CharSequence[DURATIONS.length];
+ CharSequence[] entries = new CharSequence[DURATIONS.length];
+ for (int i = 0; i < DURATIONS.length; i++) {
+ entryValues[i] = Integer.toString(DURATIONS[i]);
if (i == 0) {
entries[0] = context.getString(R.string.setting_off); // Off
} else {
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java
index f29ed4a8b..d0f21ed68 100644
--- a/src/com/android/camera/PhotoMenu.java
+++ b/src/com/android/camera/PhotoMenu.java
@@ -16,34 +16,28 @@
package com.android.camera;
-import android.content.Context;
import android.content.res.Resources;
import android.hardware.Camera.Parameters;
-import android.view.LayoutInflater;
import com.android.camera.ui.AbstractSettingPopup;
+import com.android.camera.ui.CountdownTimerPopup;
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.TimerSettingPopup;
import com.android.gallery3d.R;
+import java.util.Locale;
+
public class PhotoMenu extends PieController
- implements MoreSettingPopup.Listener,
- TimerSettingPopup.Listener,
+ implements CountdownTimerPopup.Listener,
ListPrefSettingPopup.Listener {
private static String TAG = "CAM_photomenu";
private final String mSettingOff;
private PhotoUI mUI;
- private String[] mOtherKeys;
- // First level popup
- private MoreSettingPopup mPopup;
- // Second level popup
- private AbstractSettingPopup mSecondPopup;
+ private AbstractSettingPopup mPopup;
private CameraActivity mActivity;
public PhotoMenu(CameraActivity activity, PhotoUI ui, PieRenderer pie) {
@@ -56,9 +50,9 @@ public class PhotoMenu extends PieController
public void initialize(PreferenceGroup group) {
super.initialize(group);
mPopup = null;
- mSecondPopup = null;
PieItem item = null;
final Resources res = mActivity.getResources();
+ Locale locale = res.getConfiguration().locale;
// the order is from left to right in the menu
// hdr
@@ -108,22 +102,42 @@ public class PhotoMenu extends PieController
if (group.findPreference(CameraSettings.KEY_RECORD_LOCATION) != null) {
item = makeSwitchItem(CameraSettings.KEY_RECORD_LOCATION, true);
more.addItem(item);
+ if (mActivity.isSecureCamera()) {
+ // Prevent location preference from getting changed in secure camera mode
+ item.setEnabled(false);
+ }
}
- // settings popup
- mOtherKeys = new String[] {
- CameraSettings.KEY_PICTURE_SIZE,
- CameraSettings.KEY_FOCUS_MODE,
- CameraSettings.KEY_TIMER,
- CameraSettings.KEY_TIMER_SOUND_EFFECTS,
- };
- item = makeItem(R.drawable.ic_settings_holo_light);
- item.setLabel(res.getString(R.string.camera_menu_settings_label));
+ // countdown timer
+ final ListPreference ctpref = group.findPreference(CameraSettings.KEY_TIMER);
+ final ListPreference beeppref = group.findPreference(CameraSettings.KEY_TIMER_SOUND_EFFECTS);
+ item = makeItem(R.drawable.ic_timer);
+ item.setLabel(res.getString(R.string.pref_camera_timer_title).toUpperCase(locale));
item.setOnClickListener(new OnClickListener() {
@Override
public void onClick(PieItem item) {
- if (mPopup == null) {
- initializePopup();
- }
+ CountdownTimerPopup timerPopup = (CountdownTimerPopup) mActivity.getLayoutInflater().inflate(
+ R.layout.countdown_setting_popup, null, false);
+ timerPopup.initialize(ctpref, beeppref);
+ timerPopup.setSettingChangedListener(PhotoMenu.this);
+ mUI.dismissPopup();
+ mPopup = timerPopup;
+ mUI.showPopup(mPopup);
+ }
+ });
+ more.addItem(item);
+ // image size
+ item = makeItem(R.drawable.ic_imagesize);
+ final ListPreference sizePref = group.findPreference(CameraSettings.KEY_PICTURE_SIZE);
+ item.setLabel(res.getString(R.string.pref_camera_picturesize_title).toUpperCase(locale));
+ 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(PhotoMenu.this);
+ mUI.dismissPopup();
+ mPopup = popup;
mUI.showPopup(mPopup);
}
});
@@ -145,50 +159,18 @@ public class PhotoMenu extends PieController
}
@Override
- public void reloadPreferences() {
- super.reloadPreferences();
- if (mPopup != null) {
- mPopup.reloadPreference();
- }
- }
-
- @Override
- // Hit when an item in the second-level popup gets selected
+ // Hit when an item in a popup gets selected
public void onListPrefChanged(ListPreference pref) {
- if (mPopup != null && mSecondPopup != null) {
- mUI.dismissPopup(true);
- mPopup.reloadPreference();
+ if (mPopup != null) {
+ mUI.dismissPopup();
}
onSettingChanged(pref);
}
- @Override
- public void overrideSettings(final String ... keyvalues) {
- super.overrideSettings(keyvalues);
- if (mPopup == null) initializePopup();
- mPopup.overrideSettings(keyvalues);
- }
-
- 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 (mSecondPopup != null) {
- mSecondPopup = null;
- if (topPopupOnly) mUI.showPopup(mPopup);
+ public void popupDismissed() {
+ // the popup gets dismissed
+ if (mPopup != null) {
+ mPopup = null;
}
}
@@ -217,29 +199,4 @@ public class PhotoMenu extends PieController
super.onSettingChanged(pref);
}
- @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 (mSecondPopup != null) return;
-
- LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
- if (CameraSettings.KEY_TIMER.equals(pref.getKey())) {
- TimerSettingPopup timerPopup = (TimerSettingPopup) inflater.inflate(
- R.layout.timer_setting_popup, null, false);
- timerPopup.initialize(pref);
- timerPopup.setSettingChangedListener(this);
- mUI.dismissPopup(true);
- mSecondPopup = timerPopup;
- } else {
- ListPrefSettingPopup basic = (ListPrefSettingPopup) inflater.inflate(
- R.layout.list_pref_setting_popup, null, false);
- basic.initialize(pref);
- basic.setSettingChangedListener(this);
- mUI.dismissPopup(true);
- mSecondPopup = basic;
- }
- mUI.showPopup(mSecondPopup);
- }
}
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index 5475b98f6..5a7b5bfef 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -357,7 +357,7 @@ public class PhotoUI implements PieListener,
mFaceView.setBlockDraw(!full);
}
if (mPopup != null) {
- dismissPopup(false, full);
+ dismissPopup(full);
}
if (mGestures != null) {
mGestures.setEnabled(full);
@@ -389,7 +389,7 @@ public class PhotoUI implements PieListener,
public boolean removeTopLevelPopup() {
// Remove the top level popup or dialog box and return true if there's any
if (mPopup != null) {
- dismissPopup(true);
+ dismissPopup();
return true;
}
return false;
@@ -408,11 +408,11 @@ public class PhotoUI implements PieListener,
mGestures.addTouchReceiver(mPopup);
}
- public void dismissPopup(boolean topPopupOnly) {
- dismissPopup(topPopupOnly, true);
+ public void dismissPopup() {
+ dismissPopup(true);
}
- private void dismissPopup(boolean topOnly, boolean fullScreen) {
+ private void dismissPopup(boolean fullScreen) {
if (fullScreen) {
mActivity.showUI();
mBlocker.setVisibility(View.VISIBLE);
@@ -423,7 +423,7 @@ public class PhotoUI implements PieListener,
((FrameLayout) mRootView).removeView(mPopup);
mPopup = null;
}
- mMenu.popupDismissed(topOnly);
+ mMenu.popupDismissed();
}
public void onShowSwitcherPopup() {
@@ -445,7 +445,7 @@ public class PhotoUI implements PieListener,
// Remove all the popups/dialog boxes
boolean ret = false;
if (mPopup != null) {
- dismissPopup(false);
+ dismissPopup();
ret = true;
}
return ret;
@@ -508,7 +508,7 @@ public class PhotoUI implements PieListener,
@Override
public void onPieOpened(int centerX, int centerY) {
- dismissPopup(false);
+ dismissPopup();
mActivity.cancelActivityTouchHandling();
mActivity.setSwipingEnabled(false);
if (mFaceView != null) {
diff --git a/src/com/android/camera/ui/TimerSettingPopup.java b/src/com/android/camera/ui/CountdownTimerPopup.java
index 983c7f21b..7c3572b55 100644
--- a/src/com/android/camera/ui/TimerSettingPopup.java
+++ b/src/com/android/camera/ui/CountdownTimerPopup.java
@@ -16,37 +16,35 @@
package com.android.camera.ui;
-import java.util.Locale;
-
import android.content.Context;
-import android.content.res.Resources;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.Button;
-import android.widget.CompoundButton;
+import android.widget.CheckBox;
import android.widget.NumberPicker;
-import android.widget.Switch;
-import android.widget.TextView;
+import android.widget.NumberPicker.OnValueChangeListener;
import com.android.camera.ListPreference;
import com.android.gallery3d.R;
+import java.util.Locale;
+
/**
- * This is a popup window that allows users to turn on/off time lapse feature,
- * and to select a time interval for taking a time lapse video.
+ * This is a popup window that allows users to specify a countdown timer
*/
-public class TimerSettingPopup extends AbstractSettingPopup {
+public class CountdownTimerPopup extends AbstractSettingPopup {
private static final String TAG = "TimerSettingPopup";
private NumberPicker mNumberSpinner;
- private Switch mTimerSwitch;
private String[] mDurations;
- private ListPreference mPreference;
+ private ListPreference mTimer;
+ private ListPreference mBeep;
private Listener mListener;
private Button mConfirmButton;
- private TextView mHelpText;
- private View mTimePicker;
+ private View mPickerTitle;
+ private CheckBox mTimerSound;
+ private View mSoundTitle;
static public interface Listener {
public void onListPrefChanged(ListPreference pref);
@@ -56,65 +54,62 @@ public class TimerSettingPopup extends AbstractSettingPopup {
mListener = listener;
}
- public TimerSettingPopup(Context context, AttributeSet attrs) {
+ public CountdownTimerPopup(Context context, AttributeSet attrs) {
super(context, attrs);
}
- public void initialize(ListPreference preference) {
- mPreference = preference;
-
+ public void initialize(ListPreference timer, ListPreference beep) {
+ mTimer = timer;
+ mBeep = beep;
// Set title.
- mTitle.setText(mPreference.getTitle());
+ mTitle.setText(mTimer.getTitle());
// Duration
- CharSequence[] entries = mPreference.getEntryValues();
- mDurations = new String[entries.length - 1];
+ CharSequence[] entries = mTimer.getEntryValues();
+ mDurations = new String[entries.length];
Locale locale = getResources().getConfiguration().locale;
+ mDurations[0] = getResources().getString(R.string.setting_off); // Off
for (int i = 1; i < entries.length; i++)
- mDurations[i-1] = String.format(locale, "%d",
- Integer.parseInt(entries[i].toString()));
+ mDurations[i] = String.format(locale, "%d", Integer.parseInt(entries[i].toString()));
int durationCount = mDurations.length;
mNumberSpinner = (NumberPicker) findViewById(R.id.duration);
mNumberSpinner.setMinValue(0);
mNumberSpinner.setMaxValue(durationCount - 1);
mNumberSpinner.setDisplayedValues(mDurations);
mNumberSpinner.setWrapSelectorWheel(false);
-
- mTimerSwitch = (Switch) findViewById(R.id.timer_setting_switch);
- mHelpText = (TextView) findViewById(R.id.set_timer_help_text);
+ mNumberSpinner.setOnValueChangedListener(new OnValueChangeListener() {
+ @Override
+ public void onValueChange(NumberPicker picker, int oldValue, int newValue) {
+ setTimeSelectionEnabled(newValue != 0);
+ }
+ });
mConfirmButton = (Button) findViewById(R.id.timer_set_button);
- mTimePicker = findViewById(R.id.time_duration_picker);
+ mPickerTitle = findViewById(R.id.set_time_interval_title);
// Disable focus on the spinners to prevent keyboard from coming up
mNumberSpinner.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
- mTimerSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- setTimeSelectionEnabled(isChecked);
- }
- });
mConfirmButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
updateInputState();
}
});
+ mTimerSound = (CheckBox) findViewById(R.id.sound_check_box);
+ mSoundTitle = findViewById(R.id.beep_title);
}
private void restoreSetting() {
- int index = mPreference.findIndexOfValue(mPreference.getValue());
+ int index = mTimer.findIndexOfValue(mTimer.getValue());
if (index == -1) {
Log.e(TAG, "Invalid preference value.");
- mPreference.print();
+ mTimer.print();
throw new IllegalArgumentException();
- } else if (index == 0) {
- // default choice: time lapse off
- mTimerSwitch.setChecked(false);
- setTimeSelectionEnabled(false);
} else {
- mTimerSwitch.setChecked(true);
- setTimeSelectionEnabled(true);
- mNumberSpinner.setValue(index - 1);
+ setTimeSelectionEnabled(index != 0);
+ mNumberSpinner.setValue(index);
}
+ boolean checked = mBeep.findIndexOfValue(mBeep.getValue()) != 0;
+ mTimerSound.setChecked(checked);
}
@Override
@@ -130,8 +125,9 @@ public class TimerSettingPopup extends AbstractSettingPopup {
}
protected void setTimeSelectionEnabled(boolean enabled) {
- mHelpText.setVisibility(enabled ? GONE : VISIBLE);
- mTimePicker.setVisibility(enabled ? VISIBLE : GONE);
+ mPickerTitle.setVisibility(enabled ? VISIBLE : INVISIBLE);
+ mTimerSound.setEnabled(enabled);
+ mSoundTitle.setEnabled(enabled);
}
@Override
@@ -139,15 +135,11 @@ public class TimerSettingPopup extends AbstractSettingPopup {
}
private void updateInputState() {
- if (mTimerSwitch.isChecked()) {
- int newId = mNumberSpinner.getValue() + 1;
- mPreference.setValueIndex(newId);
- } else {
- mPreference.setValueIndex(0);
- }
-
+ mTimer.setValueIndex(mNumberSpinner.getValue());
+ mBeep.setValueIndex(mTimerSound.isChecked() ? 1 : 0);
if (mListener != null) {
- mListener.onListPrefChanged(mPreference);
+ mListener.onListPrefChanged(mTimer);
+ mListener.onListPrefChanged(mBeep);
}
}
}
diff --git a/src/com/android/photos/data/SparseArrayBitmapPool.java b/src/com/android/photos/data/SparseArrayBitmapPool.java
index 851259056..1ef9e9f48 100644
--- a/src/com/android/photos/data/SparseArrayBitmapPool.java
+++ b/src/com/android/photos/data/SparseArrayBitmapPool.java
@@ -135,6 +135,8 @@ public class SparseArrayBitmapPool {
mStore.put(key, newNode);
if (newNode.nextInPool == null) {
mPoolNodesTail = newNode;
+ } else {
+ newNode.nextInPool.prevInPool = newNode;
}
mSizeBytes += bytes;
return true;