1 /* ownCloud Android client application
2 * Copyright (C) 2012-2014 ownCloud Inc.
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.
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.
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/>.
18 package com
.owncloud
.android
.ui
.dialog
;
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
;
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
;
43 * Dialog showing a list activities able to resolve a given Intent,
44 * filtering out the activities matching give package names.
46 * @author David A. Velasco
48 public class ActivityChooserDialog
extends SherlockDialogFragment
{
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";
54 private ListAdapter mAdapter
= null
; //new ArrayAdapter<Intent>();
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
);
65 public ActivityChooserDialog() {
67 Log_OC
.d(TAG
, "constructor");
71 public Dialog
onCreateDialog(Bundle savedInstanceState
) {
72 Intent intent
= getArguments().getParcelable(ARG_INTENT
);
73 String
[] packagesToExclude
= getArguments().getStringArray(ARG_PACKAGES_TO_EXCLUDE
);
77 return new AlertDialog
.Builder(getSherlockActivity())
78 .setIcon(DisplayUtils
.getSeasonalIconId())
79 .setTitle(R
.string
.activity_chooser_title
)
80 .setAdapter(mAdapter
, new DialogInterface
.OnClickListener() {
82 public void onClick(DialogInterface dialog
, int which
) {
83 // The 'which' argument contains the index position
84 // of the selected item