EventColorPickerDialog.java revision 318227abcb8fa14731907aefff6d65fa33dee6c6
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.calendar.event; 18 19import android.app.Activity; 20import android.content.DialogInterface; 21import android.os.Bundle; 22 23import com.android.calendar.R; 24import com.android.colorpicker.ColorPickerDialog; 25 26/** 27 * A dialog which displays event colors, with an additional button for the calendar color. 28 */ 29public class EventColorPickerDialog extends ColorPickerDialog { 30 31 private static final int NUM_COLUMNS = 4; 32 33 private int mCalendarColor; 34 35 public EventColorPickerDialog() { 36 // Empty constructor required for dialog fragment. 37 } 38 39 public EventColorPickerDialog(int[] colors, int selectedColor, int calendarColor, 40 boolean isTablet) { 41 super(R.string.event_color_picker_dialog_title, colors, selectedColor, NUM_COLUMNS, 42 isTablet ? SIZE_LARGE : SIZE_SMALL); 43 mCalendarColor = calendarColor; 44 } 45 46 public void setCalendarColor(int color) { 47 mCalendarColor = color; 48 } 49 50 @Override 51 public void onActivityCreated(Bundle savedInstanceState) { 52 super.onActivityCreated(savedInstanceState); 53 final Activity activity = getActivity(); 54 mAlertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, 55 activity.getString(R.string.event_color_set_to_default), 56 new DialogInterface.OnClickListener() { 57 58 @Override 59 public void onClick(DialogInterface dialog, int which) { 60 onColorSelected(mCalendarColor); 61 } 62 } 63 ); 64 } 65} 66