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