Merge branch 'share_link__new_share' into share_link__new_share_menu
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / dialog / ActivityChooserDialog.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012-2014 ownCloud Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18 package com.owncloud.android.ui.dialog;
19
20 import android.annotation.SuppressLint;
21 import android.app.Activity;
22 import android.app.AlertDialog;
23 import android.app.Dialog;
24 import android.content.DialogInterface;
25 import android.content.Intent;
26 import android.os.Bundle;
27 import android.view.LayoutInflater;
28 import android.view.View;
29 import android.view.ViewGroup;
30 import android.view.WindowManager.LayoutParams;
31 import android.widget.ArrayAdapter;
32 import android.widget.EditText;
33 import android.widget.ListAdapter;
34
35 import com.actionbarsherlock.app.SherlockDialogFragment;
36 import com.owncloud.android.R;
37 import com.owncloud.android.ui.dialog.ConflictsResolveDialog.Decision;
38 import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionMadeListener;
39 import com.owncloud.android.utils.DisplayUtils;
40 import com.owncloud.android.utils.Log_OC;
41
42 /**
43 * Dialog showing a list activities able to resolve a given Intent,
44 * filtering out the activities matching give package names.
45 *
46 * @author David A. Velasco
47 */
48 public class ActivityChooserDialog extends SherlockDialogFragment {
49
50 private final static String TAG = ActivityChooserDialog.class.getSimpleName();
51 private final static String ARG_INTENT = ActivityChooserDialog.class.getSimpleName() + ".ARG_INTENT";
52 private final static String ARG_PACKAGES_TO_EXCLUDE = ActivityChooserDialog.class.getSimpleName() + ".ARG_PACKAGES_TO_EXCLUDE";
53
54 private ListAdapter mAdapter = null; //new ArrayAdapter<Intent>();
55
56 public static ActivityChooserDialog newInstance(Intent intent, String[] packagesToExclude/*OnConflictDecisionMadeListener listener*/) {
57 ActivityChooserDialog f = new ActivityChooserDialog();
58 Bundle args = new Bundle();
59 args.putParcelable(ARG_INTENT, intent);
60 args.putStringArray(ARG_PACKAGES_TO_EXCLUDE, packagesToExclude);
61 f.setArguments(args);
62 return f;
63 }
64
65 public ActivityChooserDialog() {
66 super();
67 Log_OC.d(TAG, "constructor");
68 }
69
70 @Override
71 public Dialog onCreateDialog(Bundle savedInstanceState) {
72 Intent intent = getArguments().getParcelable(ARG_INTENT);
73 String [] packagesToExclude = getArguments().getStringArray(ARG_PACKAGES_TO_EXCLUDE);
74
75 // TODO init mAdapter
76
77 return new AlertDialog.Builder(getSherlockActivity())
78 .setIcon(DisplayUtils.getSeasonalIconId())
79 .setTitle(R.string.activity_chooser_title)
80 .setAdapter(mAdapter, new DialogInterface.OnClickListener() {
81 @Override
82 public void onClick(DialogInterface dialog, int which) {
83 // The 'which' argument contains the index position
84 // of the selected item
85 }
86 })
87 .create();
88 }
89
90 }