aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/ui/dialogs
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-11-03 21:09:36 +0100
committersteckbrief <steckbrief@chefmail.de>2015-11-03 21:09:36 +0100
commitb22d863c362bb6492240700c0f69f1a5d926f46b (patch)
treeacf185af5312a97f18819efd3927c46b12a797d1 /src/main/java/de/thedevstack/conversationsplus/ui/dialogs
parent11659eadb02b382804845d4e01a8536e02698468 (diff)
Implements FS#26: Introduction of dialog to choose whether to resize a picture or not
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/ui/dialogs')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java3
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java70
2 files changed, 72 insertions, 1 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
index 25d522f0..16939a1b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
@@ -43,6 +43,8 @@ public class MessageDetailsDialog extends AbstractAlertDialog {
displayMessageTypeInfo(view, message);
displayMessageStatusInfo(view, message);
displayFileInfo(view, message);
+
+ this.setView(view);
}
/**
@@ -61,7 +63,6 @@ public class MessageDetailsDialog extends AbstractAlertDialog {
TextView mimetype = (TextView) view.findViewById(R.id.dlgMsgDetFileMimeType);
mimetype.setText(message.getMimeType());
}
- this.setView(view);
}
/**
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java
new file mode 100644
index 00000000..ad920934
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java
@@ -0,0 +1,70 @@
+package de.thedevstack.conversationsplus.ui.dialogs;
+
+import android.app.Activity;
+import android.content.DialogInterface;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.TextView;
+
+import de.thedevstack.conversationsplus.R;
+import de.thedevstack.conversationsplus.enums.UserDecision;
+import de.thedevstack.conversationsplus.ui.listeners.UserDecisionListener;
+
+/**
+ * Created by tzur on 31.10.2015.
+ */
+public class UserDecisionDialog extends AbstractAlertDialog {
+ protected final UserDecisionListener listener;
+ protected final CheckBox rememberCheckBox;
+
+ public UserDecisionDialog(Activity context, int questionResourceId, UserDecisionListener userDecisionListener) {
+ super(context, "User Decision");
+ this.listener = userDecisionListener;
+
+ int viewId = R.layout.dialog_userdecision;
+ View view = context.getLayoutInflater().inflate(viewId, null);
+
+ ((TextView)view.findViewById(R.id.dlgUserDecQuestion)).setText(questionResourceId);
+ this.rememberCheckBox = (CheckBox) view.findViewById(R.id.dlgUserDecRemember);
+
+ this.setPositiveButton(R.string.cplus_yes, new PositiveOnClickListener());
+ this.setNegativeButton(R.string.cplus_no, new NegativeOnClickListener());
+ this.setView(view);
+ }
+
+ public void decide(UserDecision baseDecision) {
+ switch (baseDecision) {
+ case ALWAYS:
+ this.listener.onYes();
+ break;
+ case NEVER:
+ this.listener.onNo();
+ break;
+ case ASK:
+ this.show();
+ break;
+ }
+ }
+
+ class PositiveOnClickListener implements DialogInterface.OnClickListener {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ listener.onYes();
+ if (rememberCheckBox.isChecked()) {
+ listener.onRemember(UserDecision.ALWAYS);
+ }
+ }
+ }
+
+ class NegativeOnClickListener implements DialogInterface.OnClickListener {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ listener.onNo();
+ if (rememberCheckBox.isChecked()) {
+ listener.onRemember(UserDecision.NEVER);
+ }
+ }
+ }
+}