aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-03-10 23:03:19 +0100
committersteckbrief <steckbrief@chefmail.de>2016-03-10 23:03:19 +0100
commit8585231be2844ab794cfa63454b1013bae8502f6 (patch)
tree65126dbebd698c0358b2d499be9e16c3ae8d8f5f
parent07c2aba59b0ec0fd492621406d08ce33e23ad7ad (diff)
parent27c9c0aa21e3ec1a5801f6c3279caf0cd4fe9248 (diff)
Merge remote-tracking branch 'remotes/origin/trz/rename' into trz/rebase
Conflicts: src/main/java/de/thedevstack/conversationsplus/ui/listeners/ResizePictureUserDecisionListener.java
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java7
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/listeners/ResizePictureUserDecisionListener.java4
-rw-r--r--src/main/java/eu/siacs/conversations/services/MessageArchiveService.java39
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java40
-rw-r--r--src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java3
-rw-r--r--src/main/res/layout/dialog_userdecision.xml8
6 files changed, 52 insertions, 49 deletions
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 2d919528..c29832a5 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/UserDecisionDialog.java
@@ -11,20 +11,21 @@ import de.thedevstack.conversationsplus.ui.listeners.UserDecisionListener;
import eu.siacs.conversations.R;
/**
- * Created by tzur on 31.10.2015.
+ * A dialog to give the user the choice to decide whether to do something or not.
+ * 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;
protected final CheckBox rememberCheckBox;
public UserDecisionDialog(Activity context, int questionResourceId, UserDecisionListener userDecisionListener) {
- super(context, "User Decision");
+ super(context, questionResourceId);
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());
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ResizePictureUserDecisionListener.java b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ResizePictureUserDecisionListener.java
index 3436d322..bc74f39b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ResizePictureUserDecisionListener.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ResizePictureUserDecisionListener.java
@@ -18,6 +18,8 @@ import de.thedevstack.conversationsplus.exceptions.UiException;
import de.thedevstack.conversationsplus.utils.FileHelper;
import de.thedevstack.conversationsplus.utils.ImageUtil;
import de.thedevstack.conversationsplus.utils.MessageUtil;
+import de.thedevstack.conversationsplus.utils.StreamUtil;
+
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.DownloadableFile;
@@ -146,7 +148,7 @@ public class ResizePictureUserDecisionListener implements UserDecisionListener {
public void run() {
InputStream is = null;
try {
- is = ConversationsPlusApplication.getInstance().getContentResolver().openInputStream(uri);
+ is = StreamUtil.openInputStreamFromContentResolver(uri);
long imageSize = is.available();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
diff --git a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java
index f3a1a7f9..40dbf1f5 100644
--- a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java
+++ b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java
@@ -96,18 +96,25 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
return this.query(conversation,conversation.getLastMessageTransmitted(),end);
}
- public Query query(Conversation conversation, long start, long end) {
- synchronized (this.queries) {
- if (start > end) {
- return null;
- }
- final Query query = new Query(conversation, start, end,PagingOrder.REVERSE);
- query.reference = conversation.getFirstMamReference();
- this.queries.add(query);
- this.execute(query);
- return query;
- }
- }
+ public Query query(Conversation conversation, long start, long end) {
+ return this.query(conversation, start, end, null);
+ }
+
+ public Query query(Conversation conversation, long start, long end, XmppConnectionService.OnMoreMessagesLoaded callback) {
+ synchronized (this.queries) {
+ if (start > end) {
+ return null;
+ }
+ final Query query = new Query(conversation, start, end,PagingOrder.REVERSE);
+ query.reference = conversation.getFirstMamReference();
+ this.queries.add(query);
+ if (null != callback) {
+ query.setCallback(callback);
+ }
+ this.execute(query);
+ return query;
+ }
+ }
public void executePendingQueries(final Account account) {
List<Query> pending = new ArrayList<>();
@@ -137,7 +144,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
synchronized (MessageArchiveService.this.queries) {
MessageArchiveService.this.queries.remove(query);
if (query.hasCallback()) {
- query.callback(false);
+ query.callback();
}
}
} else if (packet.getType() != IqPacket.TYPE.RESULT) {
@@ -169,7 +176,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
}
}
if (query.hasCallback()) {
- query.callback(done);
+ query.callback();
} else {
if (null != conversation) {
conversation.setHasMessagesLeftOnServer(query.getMessageCount() > 0);
@@ -335,10 +342,10 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
this.callback = callback;
}
- public void callback(boolean done) {
+ public void callback() {
if (this.callback != null) {
this.callback.onMoreMessagesLoaded(messageCount,conversation);
- if (done) {
+ if (messageCount <= 0) {
this.callback.informUser(R.string.no_more_history_on_server);
}
}
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index c814e454..fb587817 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -1218,19 +1218,19 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
}
Collections.sort(list, new Comparator<Conversation>() {
- @Override
- public int compare(Conversation lhs, Conversation rhs) {
- Message left = lhs.getLatestMessage();
- Message right = rhs.getLatestMessage();
- if (left.getTimeSent() > right.getTimeSent()) {
- return -1;
- } else if (left.getTimeSent() < right.getTimeSent()) {
- return 1;
- } else {
- return 0;
- }
- }
- });
+ @Override
+ public int compare(Conversation lhs, Conversation rhs) {
+ Message left = lhs.getLatestMessage();
+ Message right = rhs.getLatestMessage();
+ if (left.getTimeSent() > right.getTimeSent()) {
+ return -1;
+ } else if (left.getTimeSent() < right.getTimeSent()) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ });
}
public void loadMoreMessages(final Conversation conversation, final long timestamp, final OnMoreMessagesLoaded callback) {
@@ -1260,15 +1260,17 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
callback.onMoreMessagesLoaded(messages.size(), conversation);
} else if (conversation.hasMessagesLeftOnServer()
&& account.isOnlineAndConnected()) {
- Logging.d("mam", "mam activate, account online and connected and messages left on server");
+ Logging.d("mam", "account online and connected and messages left on server");
+ //TODO Check if this needs to be checked before trying anything with regards to MAM
if ((conversation.getMode() == Conversation.MODE_SINGLE && account.getXmppConnection().getFeatures().mam())
|| (conversation.getMode() == Conversation.MODE_MULTI && conversation.getMucOptions().mamSupport())) {
- MessageArchiveService.Query query = getMessageArchiveService().query(conversation, 0, timestamp - 1);
- if (query != null) {
- query.setCallback(callback);
- }
+ Logging.d("mam", "mam active");
+ getMessageArchiveService().query(conversation, 0, timestamp - 1, callback);
callback.informUser(R.string.fetching_history_from_server);
- }
+ } else {
+ Logging.d("mam", "mam inactive");
+ callback.onMoreMessagesLoaded(0, conversation);
+ }
} else {
Logging.d("mam", ((!conversation.hasMessagesLeftOnServer()) ? "no" : "") + " more messages left on server, mam " + ((account.getXmppConnection().getFeatures().mam()) ? "" : "not") + " activated, account is " + ((account.isOnlineAndConnected()) ? "" : "not") + " online or connected)");
callback.onMoreMessagesLoaded(0, conversation);
diff --git a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java b/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java
index 9d508357..5ef2eea7 100644
--- a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java
+++ b/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java
@@ -52,10 +52,9 @@ public class ConversationSwipeRefreshListener implements SwipyRefreshLayout.OnRe
long lastSessionEstablished = this.getTimestampOfLastSessionEstablished(activity.getSelectedConversation());
long lastReceivedMessage = this.getTimestampOfLastReceivedOrTransmittedMessage();
long startTimestamp = Math.min(lastSessionEstablished, lastReceivedMessage);
- MessageArchiveService.Query query = activity.xmppConnectionService.getMessageArchiveService().query(activity.getSelectedConversation(), startTimestamp, System.currentTimeMillis());
+ MessageArchiveService.Query query = activity.xmppConnectionService.getMessageArchiveService().query(activity.getSelectedConversation(), startTimestamp, System.currentTimeMillis(), this.listener);
if (query != null) {
this.listener.setLoadHistory(false);
- query.setCallback(this.listener);
} else {
Logging.d("mam", "no query built - no messages loaded");
this.listener.onMoreMessagesLoaded(0, activity.getSelectedConversation());
diff --git a/src/main/res/layout/dialog_userdecision.xml b/src/main/res/layout/dialog_userdecision.xml
index 4c5a53cc..55f28a0b 100644
--- a/src/main/res/layout/dialog_userdecision.xml
+++ b/src/main/res/layout/dialog_userdecision.xml
@@ -4,14 +4,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="32dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="Medium Text"
- android:id="@+id/dlgUserDecQuestion"
- android:layout_marginLeft="8dp" />
-
<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"