diff options
author | Michael Kolb <kolby@google.com> | 2013-05-08 14:31:41 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-05-08 14:31:41 -0700 |
commit | 751aad308cb146dc03e018e19a756b3f99e8e06a (patch) | |
tree | f9d39e7e08043d009f6f73121ec2d53638728bbc /src/com/android/camera/ui | |
parent | 563643da89eba5d22239a0c87f81fb274c52ed17 (diff) | |
parent | 83bd9d3e7bb5402c335bad1370cef7f2351352ab (diff) | |
download | android_packages_apps_Snap-751aad308cb146dc03e018e19a756b3f99e8e06a.tar.gz android_packages_apps_Snap-751aad308cb146dc03e018e19a756b3f99e8e06a.tar.bz2 android_packages_apps_Snap-751aad308cb146dc03e018e19a756b3f99e8e06a.zip |
am c3fde4b4: Merge "Fix second level menu" into gb-ub-photos-bryce
* commit 'c3fde4b4032591fc34ce118860e53fe92c0b3706':
Fix second level menu
Diffstat (limited to 'src/com/android/camera/ui')
-rw-r--r-- | src/com/android/camera/ui/CountdownTimerPopup.java (renamed from src/com/android/camera/ui/TimerSettingPopup.java) | 92 |
1 files changed, 42 insertions, 50 deletions
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); } } } |