aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/ConversationActivity.java')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java98
1 files changed, 77 insertions, 21 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index e6c2aad1a..706a2cbd3 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -7,10 +7,12 @@ import android.app.AlertDialog;
import android.app.FragmentTransaction;
import android.app.PendingIntent;
import android.content.ClipData;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
+import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
@@ -52,13 +54,16 @@ import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Transferable;
+import eu.siacs.conversations.entities.Presences;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate;
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
import eu.siacs.conversations.ui.adapter.ConversationAdapter;
import eu.siacs.conversations.utils.ExceptionHelper;
+import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
+import eu.siacs.conversations.xmpp.chatstate.ChatState;
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
import org.openintents.openpgp.util.OpenPgpApi;
@@ -180,6 +185,8 @@ public class ConversationActivity extends XmppActivity
}
}
+ AppUpdate();
+
setContentView(R.layout.fragment_conversations_overview);
this.mConversationFragment = new ConversationFragment();
@@ -277,8 +284,9 @@ public class ConversationActivity extends XmppActivity
listView.enableSwipeToDismiss();
listView.setSwipingLayout(R.id.swipeable_item);
listView.setUndoStyle(EnhancedListView.UndoStyle.SINGLE_POPUP);
- listView.setUndoHideDelay(5000);
+ listView.setUndoHideDelay(10000);
listView.setRequireTouchBeforeDismiss(false);
+ listView.setSwipeDirection(EnhancedListView.SwipeDirection.START); // swipe to left to close conversation
mContentView = findViewById(R.id.content_view_spl);
if (mContentView == null) {
@@ -319,6 +327,32 @@ public class ConversationActivity extends XmppActivity
}
}
+ protected void AppUpdate() {
+ String PREFS_NAME = "UpdateTimeStamp";
+ SharedPreferences UpdateTimeStamp = getApplicationContext().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
+ long lastUpdateTime = UpdateTimeStamp.getLong("lastUpdateTime", 0);
+
+ Log.d(Config.LOGTAG, "AppUpdater - LastUpdateTime: " + lastUpdateTime);
+
+ if ((lastUpdateTime + (Config.UPDATE_CHECK_TIMER * 1000)) < System.currentTimeMillis()) {
+ lastUpdateTime = System.currentTimeMillis();
+ SharedPreferences.Editor editor = UpdateTimeStamp.edit();
+ editor.putLong("lastUpdateTime", lastUpdateTime);
+ editor.commit();
+
+ // run AppUpdater
+ Log.d(Config.LOGTAG, "AppUpdater - CurrentTime: " + lastUpdateTime);
+ Intent AppUpdater = new Intent(this, UpdaterActivity.class);
+ startActivity(AppUpdater);
+ Log.d(Config.LOGTAG, "AppUpdater started");
+
+ } else {
+
+ Log.d(Config.LOGTAG, "AppUpdater stopped");
+ return;
+ }
+ }
+
@Override
public void switchToConversation(Conversation conversation) {
setSelectedConversation(conversation);
@@ -336,24 +370,42 @@ public class ConversationActivity extends XmppActivity
}
private void updateActionBarTitle(boolean titleShouldBeName) {
- final ActionBar ab = getActionBar();
- final Conversation conversation = getSelectedConversation();
- if (ab != null) {
- if (titleShouldBeName && conversation != null) {
- ab.setDisplayHomeAsUpEnabled(true);
- ab.setHomeButtonEnabled(true);
- if (conversation.getMode() == Conversation.MODE_SINGLE || useSubjectToIdentifyConference()) {
- ab.setTitle(conversation.getName());
- } else {
- ab.setTitle(conversation.getJid().toBareJid().toString());
- }
- } else {
- ab.setDisplayHomeAsUpEnabled(false);
- ab.setHomeButtonEnabled(false);
- ab.setTitle(R.string.app_name);
- }
- }
- }
+ final ActionBar ab = getActionBar();
+ final Conversation conversation = getSelectedConversation();
+ if (ab != null) {
+ if (titleShouldBeName && conversation != null) {
+ ab.setDisplayHomeAsUpEnabled(true);
+ ab.setHomeButtonEnabled(true);
+ if (conversation.getMode() == Conversation.MODE_SINGLE || useSubjectToIdentifyConference()) {
+ ab.setTitle(conversation.getName());
+ if (conversation.getMode() == Conversation.MODE_SINGLE) {
+ if (conversation.getContact().getPresences().getMostAvailableStatus() == Presences.OFFLINE) {
+ ab.setSubtitle(getString(R.string.account_status_offline));
+ } else {
+ ChatState state = conversation.getIncomingChatState();
+ if (state == ChatState.COMPOSING) {
+ ab.setSubtitle(getString(R.string.is_typing));
+ } else if (state == ChatState.PAUSED) {
+ ab.setSubtitle(UIHelper.lastseen(getApplicationContext(), conversation.getContact().lastseen.time));
+ } else {
+ ab.setSubtitle(UIHelper.lastseen(getApplicationContext(), conversation.getContact().lastseen.time));
+ }
+ }
+ } else if (useSubjectToIdentifyConference()) {
+ ab.setSubtitle(conversation.getParticipants());
+ }
+ } else {
+ ab.setTitle(conversation.getJid().toBareJid().toString());
+ ab.setSubtitle(null);
+ }
+ } else {
+ ab.setDisplayHomeAsUpEnabled(false);
+ ab.setHomeButtonEnabled(false);
+ ab.setTitle(R.string.app_name);
+ ab.setSubtitle(null);
+ }
+ }
+ }
private void openConversation() {
this.updateActionBarTitle();
@@ -403,6 +455,7 @@ public class ConversationActivity extends XmppActivity
} else {
menuAdd.setVisible(!isConversationsOverviewHideable());
if (this.getSelectedConversation() != null) {
+ menuSecure.setVisible(!Config.HIDE_ENCRYPTION_IN_UI);
if (this.getSelectedConversation().getNextEncryption() != Message.ENCRYPTION_NONE) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
menuSecure.setIcon(R.drawable.ic_lock_white_24dp);
@@ -414,6 +467,7 @@ public class ConversationActivity extends XmppActivity
menuContactDetails.setVisible(false);
menuAttach.setVisible(getSelectedConversation().getAccount().httpUploadAvailable() && getSelectedConversation().getMucOptions().participating());
menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite());
+ menuSecure.setVisible(!Config.HIDE_ENCRYPTION_IN_UI);
menuSecure.setVisible(!Config.HIDE_PGP_IN_UI && !Config.X509_VERIFICATION); //if pgp is hidden conferences have no choice of encryption
} else {
menuMucDetails.setVisible(false);
@@ -969,7 +1023,7 @@ public class ConversationActivity extends XmppActivity
return true;
} else if (modifier && key == downKey) {
if (isConversationsOverviewHideable() && !isConversationsOverviewVisable()) {
- showConversationsOverview();;
+ showConversationsOverview();
}
return selectDownConversation();
} else if (modifier && key == upKey) {
@@ -1099,6 +1153,8 @@ public class ConversationActivity extends XmppActivity
sendReadMarkerIfNecessary(getSelectedConversation());
}
+ AppUpdate();
+
}
@Override
@@ -1568,4 +1624,4 @@ public class ConversationActivity extends XmppActivity
public boolean highlightSelectedConversations() {
return !isConversationsOverviewHideable() || this.conversationWasSelectedByKeyboard;
}
-}
+} \ No newline at end of file