aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/ui/dialogs
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-10-20 19:45:26 +0200
committersteckbrief <steckbrief@chefmail.de>2016-10-20 19:45:26 +0200
commit59e861ee6904296cbe8dd43c4a29513c2e928981 (patch)
treea3bf768814ece1c377caefca35bc535c758a47c5 /src/main/java/de/thedevstack/conversationsplus/ui/dialogs
parent2860088f0ea1cd5753756861c71cc7c118094f32 (diff)
parent9ec29bb1dcf664fea606105b7e700641a4b44ae4 (diff)
Merge remote-tracking branch 'remotes/origin/trz/rename' into trz/rebase
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/ui/dialogs')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java7
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/SimpleConfirmDialog.java37
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java18
3 files changed, 49 insertions, 13 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 4f6cffb4..1b44d09b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
@@ -9,6 +9,7 @@ import java.util.Date;
import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.ConversationsPlusColors;
+import de.thedevstack.conversationsplus.entities.FileParams;
import de.thedevstack.conversationsplus.utils.ui.TextViewUtil;
import eu.siacs.conversations.R;
@@ -60,10 +61,10 @@ public class MessageDetailsDialog extends AbstractAlertDialog {
Logging.d("messagedetailsfile", "File is stored in path: " + message.getRelativeFilePath());
view.findViewById(R.id.dlgMsgDetFileTable).setVisibility(View.VISIBLE);
if (null != message.getFileParams()) {
- Message.FileParams params = message.getFileParams();
- TextViewUtil.setText(view, R.id.dlgMsgDetFileSize, UIHelper.getHumanReadableFileSize(params.size));
+ FileParams params = message.getFileParams();
+ TextViewUtil.setText(view, R.id.dlgMsgDetFileSize, UIHelper.getHumanReadableFileSize(params.getSize()));
+ TextViewUtil.setText(view, R.id.dlgMsgDetFileMimeType, params.getMimeType());
}
- TextViewUtil.setText(view, R.id.dlgMsgDetFileMimeType, message.getMimeType());
TextViewUtil.setText(view, R.id.dlgMsgDetFileHttpUploaded, message.isHttpUploaded() ? R.string.cplus_yes : R.string.cplus_no);
}
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..6bf9c563
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/SimpleConfirmDialog.java
@@ -0,0 +1,37 @@
+package de.thedevstack.conversationsplus.ui.dialogs;
+
+import android.content.Context;
+import android.content.DialogInterface;
+
+import de.thedevstack.conversationsplus.ui.listeners.SimpleUserDecisionCallback;
+
+import eu.siacs.conversations.R;
+
+/**
+ * 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 c29832a5..3305e8e1 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 eu.siacs.conversations.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);
}
}
}