1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.camera;
18
19import android.content.Context;
20import android.util.AttributeSet;
21
22import com.android.camera2.R;
23
24public class CountDownTimerPreference extends ListPreference {
25    private static final int[] DURATIONS = {
26        0, 1, 2, 3, 4, 5, 10, 15, 20, 30, 60
27    };
28    public CountDownTimerPreference(Context context, AttributeSet attrs) {
29        super(context, attrs);
30        initCountDownDurationChoices(context);
31    }
32
33    private void initCountDownDurationChoices(Context context) {
34        CharSequence[] entryValues = new CharSequence[DURATIONS.length];
35        CharSequence[] entries = new CharSequence[DURATIONS.length];
36        for (int i = 0; i < DURATIONS.length; i++) {
37            entryValues[i] = Integer.toString(DURATIONS[i]);
38            if (i == 0) {
39                entries[0] = context.getString(R.string.setting_off); // Off
40            } else {
41                entries[i] = context.getResources()
42                        .getQuantityString(R.plurals.pref_camera_timer_entry, i, i);
43            }
44        }
45        setEntries(entries);
46        setEntryValues(entryValues);
47    }
48}
49