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 17 package com.android.incallui; 18 19 import android.app.AlertDialog; 20 import android.app.Dialog; 21 import android.app.DialogFragment; 22 import android.content.DialogInterface; 23 import android.os.Bundle; 24 import android.view.WindowManager; 25 26 /** 27 * Pop up an alert dialog with OK and Cancel buttons to allow user to Accept or Reject the WAIT 28 * inserted as part of the Dial string. 29 */ 30 public class PostCharDialogFragment extends DialogFragment { 31 32 private String mCallId; 33 private String mPostDialStr; 34 PostCharDialogFragment(String callId, String postDialStr)35 public PostCharDialogFragment(String callId, String postDialStr) { 36 mCallId = callId; 37 mPostDialStr = postDialStr; 38 } 39 40 @Override onCreateDialog(Bundle savedInstanceState)41 public Dialog onCreateDialog(Bundle savedInstanceState) { 42 super.onCreateDialog(savedInstanceState); 43 44 final StringBuilder buf = new StringBuilder(); 45 buf.append(getResources().getText(R.string.wait_prompt_str)); 46 buf.append(mPostDialStr); 47 48 final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 49 builder.setMessage(buf.toString()); 50 51 builder.setPositiveButton(R.string.pause_prompt_yes, new DialogInterface.OnClickListener() { 52 @Override 53 public void onClick(DialogInterface dialog, int whichButton) { 54 TelecomAdapter.getInstance().postDialContinue(mCallId, true); 55 } 56 }); 57 builder.setNegativeButton(R.string.pause_prompt_no, new DialogInterface.OnClickListener() { 58 @Override 59 public void onClick(DialogInterface dialog, int whichButton) { 60 dialog.cancel(); 61 } 62 }); 63 64 final AlertDialog dialog = builder.create(); 65 return dialog; 66 } 67 68 @Override onCancel(DialogInterface dialog)69 public void onCancel(DialogInterface dialog) { 70 super.onCancel(dialog); 71 72 TelecomAdapter.getInstance().postDialContinue(mCallId, false); 73 } 74 } 75