diff options
| author | Ethan Chen <intervigil@gmail.com> | 2013-12-09 16:54:14 -0800 |
|---|---|---|
| committer | Ethan Chen <intervigil@gmail.com> | 2013-12-10 12:52:24 -0800 |
| commit | f0a488142b8ffaeda720eef23a98bcc6fd942ebd (patch) | |
| tree | ac686a2390799f676f312bc207e0d064d07495a8 | |
| parent | a547ad1a08a2a7bc4466457a1d00eb9722404bf3 (diff) | |
| download | android_packages_apps_CMFileManager-f0a488142b8ffaeda720eef23a98bcc6fd942ebd.tar.gz android_packages_apps_CMFileManager-f0a488142b8ffaeda720eef23a98bcc6fd942ebd.tar.bz2 android_packages_apps_CMFileManager-f0a488142b8ffaeda720eef23a98bcc6fd942ebd.zip | |
CMFM: Don't show the cancel button if action is non-cancellable
Change-Id: Ic8078d75aa8c5e77f37f3110cdd8cbf5e65fe790
| -rw-r--r-- | src/com/cyanogenmod/filemanager/ui/dialogs/MessageProgressDialog.java | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/com/cyanogenmod/filemanager/ui/dialogs/MessageProgressDialog.java b/src/com/cyanogenmod/filemanager/ui/dialogs/MessageProgressDialog.java index 3b64a897..ab4f8ec9 100644 --- a/src/com/cyanogenmod/filemanager/ui/dialogs/MessageProgressDialog.java +++ b/src/com/cyanogenmod/filemanager/ui/dialogs/MessageProgressDialog.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.DialogInterface; import android.text.Spanned; import android.view.LayoutInflater; +import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; @@ -117,36 +118,27 @@ public class MessageProgressDialog implements DialogInterface.OnClickListener { iconResourceId, titleResourceId, layout); - this.mDialog.setButton( - DialogInterface.BUTTON_NEUTRAL, context.getString(android.R.string.cancel), this); - this.mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - // Disable cancel button - MessageProgressDialog.this.mDialog.getButton( + this.mDialog.setCancelable(cancellable); + if (cancellable) { + this.mDialog.setButton( + DialogInterface.BUTTON_NEUTRAL, context.getString(android.R.string.cancel), this); + this.mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialog) { + // Disable cancel button + MessageProgressDialog.this.mDialog.getButton( DialogInterface.BUTTON_NEUTRAL).setEnabled(false); - // Wait for cancellation - if (MessageProgressDialog.this.mOnCancelListener != null) { - if (!MessageProgressDialog.this.mOnCancelListener.onCancel()) { - //The operation couldn't be cancelled - DialogHelper.showToast( + // Wait for cancellation + if (MessageProgressDialog.this.mOnCancelListener != null) { + if (!MessageProgressDialog.this.mOnCancelListener.onCancel()) { + //The operation couldn't be cancelled + DialogHelper.showToast( MessageProgressDialog.this.mContext, R.string.msgs_operation_can_not_be_cancelled, Toast.LENGTH_SHORT); + } } } - } - }); - - // Is cancellable - this.mDialog.setCancelable(cancellable); - if (!cancellable) { - this.mProgress.post(new Runnable() { - @Override - public void run() { - MessageProgressDialog.this.mDialog.getButton( - DialogInterface.BUTTON_NEUTRAL).setEnabled(false); - } }); } |
