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.incallui;
18
19import android.app.AlertDialog;
20import android.app.Dialog;
21import android.app.DialogFragment;
22import android.content.DialogInterface;
23import android.os.Bundle;
24import 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 */
30public class PostCharDialogFragment extends DialogFragment {
31
32    private String mCallId;
33    private String mPostDialStr;
34
35    public PostCharDialogFragment(String callId, String postDialStr) {
36        mCallId = callId;
37        mPostDialStr = postDialStr;
38    }
39
40    @Override
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        dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
66        return dialog;
67    }
68
69    @Override
70    public void onCancel(DialogInterface dialog) {
71        super.onCancel(dialog);
72
73        TelecomAdapter.getInstance().postDialContinue(mCallId, false);
74    }
75}
76