/remindme/src/com/google/marvin/remindme/ConfirmationView.java
Java | 90 lines | 56 code | 14 blank | 20 comment | 1 complexity | 34ee0a670fde7bef504054f18e3e717b MD5 | raw file
1/* 2 * Copyright (C) 2008 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * 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, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17package com.google.marvin.remindme; 18 19 20import android.content.Context; 21import android.graphics.Canvas; 22import android.graphics.Color; 23import android.graphics.Paint; 24import android.graphics.Typeface; 25import android.os.Vibrator; 26import android.view.KeyEvent; 27import android.widget.TextView; 28 29/** 30 * Implements the user interface for doing slide dialing. 31 * 32 * @author clchen@google.com (Charles L. Chen) Created 8-2-2008 33 */ 34public class ConfirmationView extends TextView { 35 public RemindMe parent; 36 private Vibrator vibe; 37 38 public ConfirmationView(Context context) { 39 super(context); 40 parent = (RemindMe) context; 41 vibe = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); 42 setClickable(true); 43 setFocusable(true); 44 setFocusableInTouchMode(true); 45 requestFocus(); 46 } 47 48 49 50 @Override 51 public void onDraw(Canvas canvas) { 52 Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 53 paint.setColor(Color.WHITE); 54 paint.setTextAlign(Paint.Align.CENTER); 55 paint.setTypeface(Typeface.DEFAULT_BOLD); 56 57 int x = 5; 58 int y = getHeight() - 40; 59 paint.setTextSize(20); 60 paint.setTextAlign(Paint.Align.LEFT); 61 y -= paint.ascent() / 2; 62 canvas.drawText("Press CALL to confirm", x, y, paint); 63 x = 5; 64 y = getHeight() - 20; 65 paint.setTextSize(20); 66 paint.setTextAlign(Paint.Align.LEFT); 67 y -= paint.ascent() / 2; 68 canvas.drawText("Press BACK to try again", x, y, paint); 69 } 70 71 72 73 @Override 74 public boolean onKeyDown(int keyCode, KeyEvent event) { 75 switch (keyCode) { 76 case KeyEvent.KEYCODE_CALL: 77 parent.tts.playEarcon("[tock]", 0, null); 78 long[] pattern = {0, 1, 40, 41}; 79 vibe.vibrate(pattern, -1); 80 parent.confirmAlarm(); 81 return true; 82 case KeyEvent.KEYCODE_BACK: 83 parent.showNumberEntryView(); 84 return true; 85 86 } 87 return false; 88 } 89 90}