1 package com
.owncloud
.android
.ui
.dialog
;
3 import android
.app
.Dialog
;
4 import android
.app
.ProgressDialog
;
5 import android
.content
.DialogInterface
;
6 import android
.content
.DialogInterface
.OnKeyListener
;
7 import android
.os
.Bundle
;
8 import android
.view
.KeyEvent
;
10 import com
.actionbarsherlock
.app
.SherlockDialogFragment
;
11 import com
.owncloud
.android
.R
;
13 public class IndeterminateProgressDialog
extends SherlockDialogFragment
{
15 private static final String ARG_MESSAGE_ID
= IndeterminateProgressDialog
.class.getCanonicalName() + ".ARG_MESSAGE_ID";
16 private static final String ARG_CANCELABLE
= IndeterminateProgressDialog
.class.getCanonicalName() + ".ARG_CANCELABLE";
20 * Public factory method to get dialog instances.
22 * @param messageId Resource id for a message to show in the dialog.
23 * @param cancelable If 'true', the dialog can be cancelled by the user input (BACK button, touch outside...)
24 * @return New dialog instance, ready to show.
26 public static IndeterminateProgressDialog
newInstance(int messageId
, boolean cancelable
) {
27 IndeterminateProgressDialog fragment
= new IndeterminateProgressDialog();
28 Bundle args
= new Bundle();
29 args
.putInt(ARG_MESSAGE_ID
, messageId
);
30 args
.putBoolean(ARG_CANCELABLE
, cancelable
);
31 fragment
.setArguments(args
);
40 public Dialog
onCreateDialog(Bundle savedInstanceState
) {
41 /// create indeterminate progress dialog
42 final ProgressDialog dialog
= new ProgressDialog(getActivity());
43 dialog
.setIndeterminate(true
);
46 int messageId
= getArguments().getInt(ARG_MESSAGE_ID
, R
.string
.text_placeholder
);
47 dialog
.setMessage(getString(messageId
));
49 /// set cancellation behavior
50 boolean cancelable
= getArguments().getBoolean(ARG_CANCELABLE
, false
);
52 dialog
.setCancelable(false
);
53 // disable the back button
54 OnKeyListener keyListener
= new OnKeyListener() {
56 public boolean onKey(DialogInterface dialog
, int keyCode
,
59 if( keyCode
== KeyEvent
.KEYCODE_BACK
){
66 dialog
.setOnKeyListener(keyListener
);