aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/ui/dialogs
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-08-23 11:23:40 +0200
committersteckbrief <steckbrief@chefmail.de>2016-08-23 11:23:40 +0200
commitad096f4bfd220a106aab670105275397bfcbfd0e (patch)
tree0a4d3b171f3d7fc9de7aeca8c37dcaa72ce16f0c /src/main/java/de/thedevstack/conversationsplus/ui/dialogs
parente91e8a30b1f4a806d77d74871df5af6cdb87ca0e (diff)
Confirmation dialog added before sending delete command for remote file
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/ui/dialogs')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/SimpleConfirmDialog.java36
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java18
2 files changed, 44 insertions, 10 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/SimpleConfirmDialog.java b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/SimpleConfirmDialog.java
new file mode 100644
index 00000000..04e60caa
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/SimpleConfirmDialog.java
@@ -0,0 +1,36 @@
+package de.thedevstack.conversationsplus.ui.dialogs;
+
+import android.content.Context;
+import android.content.DialogInterface;
+
+import de.thedevstack.conversationsplus.R;
+import de.thedevstack.conversationsplus.ui.listeners.SimpleUserDecisionCallback;
+
+/**
+ * A dialog to give the user the choice to decide whether to do something or not.
+ * A UserDecisionListener is used to provide the functionality to be performed by clicking on yes, or no.
+ */
+public class SimpleConfirmDialog extends AbstractAlertDialog {
+ protected final SimpleUserDecisionCallback callback;
+
+ public SimpleConfirmDialog(Context context, String title, SimpleUserDecisionCallback userDecisionCallback) {
+ super(context, title);
+ this.callback = userDecisionCallback;
+ this.setPositiveButton(R.string.cplus_ok, new ConfirmOnClickListener());
+ this.setNegativeButton(R.string.cancel, null);
+ }
+
+ public SimpleConfirmDialog(Context context, int titleTextId, SimpleUserDecisionCallback userDecisionCallback) {
+ super(context, titleTextId);
+ this.callback = userDecisionCallback;
+ this.setPositiveButton(R.string.cplus_ok, new ConfirmOnClickListener());
+ this.setNegativeButton(R.string.cancel, null);
+ }
+
+ private class ConfirmOnClickListener implements DialogInterface.OnClickListener {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ callback.onYes();
+ }
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java
index 25349b2d..e0834390 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java
@@ -15,13 +15,11 @@ import de.thedevstack.conversationsplus.R;
* The user also has the choice to save his answer for the future.
* A UserDecisionListener is used to provide the functionality to be performed by clicking on yes, or no.
*/
-public class UserDecisionDialog extends AbstractAlertDialog {
- protected final UserDecisionListener listener;
+public class UserDecisionDialog extends SimpleConfirmDialog {
protected final CheckBox rememberCheckBox;
public UserDecisionDialog(Activity context, int questionResourceId, UserDecisionListener userDecisionListener) {
- super(context, questionResourceId);
- this.listener = userDecisionListener;
+ super(context, questionResourceId, userDecisionListener);
int viewId = R.layout.dialog_userdecision;
View view = context.getLayoutInflater().inflate(viewId, null);
@@ -36,10 +34,10 @@ public class UserDecisionDialog extends AbstractAlertDialog {
public void decide(UserDecision baseDecision) {
switch (baseDecision) {
case ALWAYS:
- this.listener.onYes();
+ this.callback.onYes();
break;
case NEVER:
- this.listener.onNo();
+ this.callback.onNo();
break;
case ASK:
this.show();
@@ -51,9 +49,9 @@ public class UserDecisionDialog extends AbstractAlertDialog {
@Override
public void onClick(DialogInterface dialog, int which) {
- listener.onYes();
+ callback.onYes();
if (rememberCheckBox.isChecked()) {
- listener.onRemember(UserDecision.ALWAYS);
+ ((UserDecisionListener)callback).onRemember(UserDecision.ALWAYS);
}
}
}
@@ -62,9 +60,9 @@ public class UserDecisionDialog extends AbstractAlertDialog {
@Override
public void onClick(DialogInterface dialog, int which) {
- listener.onNo();
+ callback.onNo();
if (rememberCheckBox.isChecked()) {
- listener.onRemember(UserDecision.NEVER);
+ ((UserDecisionListener)callback).onRemember(UserDecision.NEVER);
}
}
}