blob: 3ee617ed2e55400603a48f51e904a0ba5cfc23ef [file] [log] [blame]
Alexandre Lisionf02190d2013-12-12 17:26:12 -05001/*
2 * Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
3 *
4 * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * Additional permission under GNU GPL version 3 section 7:
21 *
22 * If you modify this program, or any covered work, by linking or
23 * combining it with the OpenSSL project's OpenSSL library (or a
24 * modified version of that library), containing parts covered by the
25 * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
26 * grants you additional permission to convey the resulting work.
27 * Corresponding Source for a non-source form of such a combination
28 * shall include the source code for the parts of OpenSSL used as well
29 * as that of the covered work.
30 */
31
32package org.sflphone.fragments;
33
34import org.sflphone.R;
35
36import android.app.AlertDialog;
37import android.app.Dialog;
Alexandre Lisionf02190d2013-12-12 17:26:12 -050038import android.content.DialogInterface;
39import android.content.Intent;
40import android.os.Bundle;
Alexandre Lisiona8b78722013-12-13 10:18:33 -050041import android.support.v4.app.DialogFragment;
Alexandre Lisionf02190d2013-12-12 17:26:12 -050042import android.view.View;
43import android.widget.AdapterView;
44import android.widget.AdapterView.OnItemClickListener;
45import android.widget.ArrayAdapter;
46import android.widget.ListAdapter;
47import android.widget.ListView;
48
49public class DropActionsChoice extends DialogFragment {
50
51 ListAdapter mAdapter;
52 private Bundle args;
53 public static final int REQUEST_TRANSFER = 10;
54 public static final int REQUEST_CONF = 20;
55
56 /**
57 * Create a new instance of CallActionsDFragment
58 */
59 public static DropActionsChoice newInstance() {
60 DropActionsChoice f = new DropActionsChoice();
61 return f;
62 }
63
64 @Override
65 public void onCreate(Bundle savedInstanceState) {
66 super.onCreate(savedInstanceState);
67
68 // Pick a style based on the num.
69 int style = DialogFragment.STYLE_NORMAL, theme = 0;
70 setStyle(style, theme);
71 }
72
73 @Override
74 public Dialog onCreateDialog(Bundle savedInstanceState) {
75 ListView rootView = new ListView(getActivity());
76
77 args = getArguments();
78 mAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.drop_actions));
79
80 // ListView list = (ListView) rootView.findViewById(R.id.concurrent_calls);
81 rootView.setAdapter(mAdapter);
82 rootView.setOnItemClickListener(new OnItemClickListener() {
83
84 @Override
85 public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
86 Intent in = new Intent();
87
88 in.putExtra("transfer", args.getParcelable("call_initial"));
89 in.putExtra("target", args.getParcelable("call_targeted"));
90
91 switch (pos) {
92 case 0: // Transfer
93 getTargetFragment().onActivityResult(REQUEST_TRANSFER, 0, in);
94 break;
95 case 1: // Conference
96 getTargetFragment().onActivityResult(REQUEST_CONF, 0, in);
97 break;
98 }
99 dismiss();
100
101 }
102 });
103
104 final AlertDialog a = new AlertDialog.Builder(getActivity()).setView(rootView).setTitle("Choose Action")
105 .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
106 public void onClick(DialogInterface dialog, int whichButton) {
107 dismiss();
108 }
109 }).create();
110
111 return a;
112 }
113
114}