/ime/latinime/src/com/googlecode/eyesfree/inputmethod/latin/tutorial/LatinTutorialDialog.java
Java | 68 lines | 40 code | 9 blank | 19 comment | 1 complexity | 1874443de7f3e80c8eb326066bae0634 MD5 | raw file
1/* 2 * Copyright (C) 2011 Google Inc. 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.googlecode.eyesfree.inputmethod.latin.tutorial; 18 19import android.app.Activity; 20import android.app.AlertDialog; 21import android.content.DialogInterface; 22import android.content.DialogInterface.OnCancelListener; 23import android.content.DialogInterface.OnClickListener; 24import android.content.Intent; 25import android.view.WindowManager; 26 27import com.googlecode.eyesfree.inputmethod.latin.R; 28 29/** 30 * Shows an alert dialog asking whether the user would like to run the tutorial. 31 * This activity is only necessary because a Service cannot show a dialog. 32 */ 33public class LatinTutorialDialog extends Activity { 34 @Override 35 protected void onResume() { 36 super.onResume(); 37 38 final AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.tutorial_name) 39 .setMessage(R.string.tutorial_first_time) 40 .setCancelable(true).setNegativeButton(android.R.string.no, dialogClickListener) 41 .setPositiveButton(android.R.string.ok, dialogClickListener) 42 .setOnCancelListener(dialogCancelListener) 43 .create(); 44 45 dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); 46 dialog.show(); 47 } 48 49 private final OnCancelListener dialogCancelListener = new OnCancelListener() { 50 @Override 51 public void onCancel(DialogInterface dialog) { 52 finish(); 53 } 54 }; 55 56 private final OnClickListener dialogClickListener = new OnClickListener() { 57 @Override 58 public void onClick(DialogInterface dialog, int which) { 59 switch (which) { 60 case DialogInterface.BUTTON_POSITIVE: 61 startActivity(new Intent(LatinIMETutorial.ACTION)); 62 break; 63 } 64 65 finish(); 66 } 67 }; 68}