OC-3261: Fix a problem when trying to detect the kind of authentication. Add new...
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / dialog / AlertMessageDialog.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.app.AlertDialog;
21 import android.app.Dialog;
22 import android.content.DialogInterface;
23 import android.os.Bundle;
24
25 import com.actionbarsherlock.app.SherlockDialogFragment;
26 import com.owncloud.android.R;
27
28 public class AlertMessageDialog extends SherlockDialogFragment {
29
30 private static final String ARG_TITLE_ID = AlertMessageDialog.class.getCanonicalName() + ".ARG_TITLE_ID";
31 private static final String ARG_MESSAGE_ID = AlertMessageDialog.class.getCanonicalName() + ".ARG_MESSAGE_ID";
32
33
34 public static AlertMessageDialog newInstance(int title, int message) {
35 AlertMessageDialog frag = new AlertMessageDialog();
36 Bundle args = new Bundle();
37 args.putInt(ARG_TITLE_ID, title);
38 args.putInt(ARG_MESSAGE_ID, message);
39 frag.setArguments(args);
40 return frag;
41 }
42
43 @Override
44 public Dialog onCreateDialog(Bundle savedInstanceState) {
45 AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getSherlockActivity());
46
47 int title = getArguments().getInt(ARG_TITLE_ID);
48 int message = getArguments().getInt(ARG_MESSAGE_ID);
49
50 dialogBuilder.setIcon(R.drawable.common_error)
51 .setTitle(title)
52 .setMessage(message)
53 .setCancelable(true)
54 .setPositiveButton(R.string.common_ok,
55 new DialogInterface.OnClickListener() {
56 public void onClick(DialogInterface dialog, int whichButton) {
57 dialog.dismiss();
58 }
59 });
60 return dialogBuilder.create();
61 }
62
63 }