diff options
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/ui')
7 files changed, 67 insertions, 19 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/LogCatOutputActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/LogCatOutputActivity.java new file mode 100644 index 00000000..e75c1f63 --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/ui/LogCatOutputActivity.java @@ -0,0 +1,28 @@ +package de.thedevstack.conversationsplus.ui; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.Button; +import android.widget.ListView; + +import de.thedevstack.android.logcat.adapters.LogCatArrayAdapter; +import de.thedevstack.android.logcat.tasks.ReadLogCatAsyncTask; +import de.thedevstack.android.logcat.ui.LogCatOutputCopyOnClickListener; +import de.thedevstack.conversationsplus.R; + +/** + * Created by tzur on 07.10.2015. + */ +public class LogCatOutputActivity extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_logcatoutput); + ListView lv = (ListView)findViewById(R.id.actLogInfoOutput); + LogCatArrayAdapter logCatOutputAdapter = new LogCatArrayAdapter(this, R.layout.list_item_logcatoutput); + lv.setAdapter(logCatOutputAdapter); + new ReadLogCatAsyncTask(logCatOutputAdapter).execute(); + Button copyButton = (Button) findViewById(R.id.actLogOutputCopyButton); + copyButton.setOnClickListener(new LogCatOutputCopyOnClickListener(this, logCatOutputAdapter, R.string.cplus_copied_to_clipboard)); + } +} diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/StartConversationActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/StartConversationActivity.java index 6a5d47c2..8ad23e6e 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/StartConversationActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/StartConversationActivity.java @@ -24,7 +24,6 @@ import android.support.v13.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.text.Editable; import android.text.TextWatcher; -import de.thedevstack.conversationsplus.utils.Logging; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.KeyEvent; @@ -52,6 +51,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import de.thedevstack.android.logcat.Logging; import de.thedevstack.conversationsplus.Config; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; import de.thedevstack.conversationsplus.R; diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java index 312c4223..23278bfb 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java @@ -37,7 +37,6 @@ import android.os.IBinder; import android.os.SystemClock; import android.text.InputType; import android.util.DisplayMetrics; -import de.thedevstack.conversationsplus.utils.Logging; import android.view.MenuItem; import android.view.View; import android.view.inputmethod.InputMethodManager; @@ -62,6 +61,7 @@ import java.util.Hashtable; import java.util.List; import java.util.concurrent.RejectedExecutionException; +import de.thedevstack.android.logcat.Logging; import de.thedevstack.conversationsplus.Config; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; import de.thedevstack.conversationsplus.R; diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java index abb77993..4e361c67 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java @@ -8,7 +8,6 @@ import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import de.thedevstack.conversationsplus.utils.Logging; import android.util.Pair; import android.view.LayoutInflater; import android.view.View; @@ -21,6 +20,7 @@ import java.lang.ref.WeakReference; import java.util.List; import java.util.concurrent.RejectedExecutionException; +import de.thedevstack.android.logcat.Logging; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; import de.thedevstack.conversationsplus.ui.listeners.ShowResourcesListDialogListener; import de.tzur.conversations.Settings; 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 a6ee21e6..56297f6c 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java @@ -2,12 +2,12 @@ package de.thedevstack.conversationsplus.ui.dialogs; import android.app.Activity; import android.text.format.DateFormat; -import de.thedevstack.conversationsplus.utils.Logging; import android.view.View; import android.widget.TextView; import java.util.Date; +import de.thedevstack.android.logcat.Logging; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.entities.Conversation; import de.thedevstack.conversationsplus.entities.Message; diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java index bd616691..30b7bf73 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java @@ -1,8 +1,5 @@ package de.thedevstack.conversationsplus.ui.listeners; -import de.thedevstack.conversationsplus.R; -import de.thedevstack.conversationsplus.services.MessageArchiveService; -import de.thedevstack.conversationsplus.utils.Logging; import android.widget.ListView; import com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout; @@ -10,6 +7,10 @@ import com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayoutD import java.util.List; +import de.thedevstack.android.logcat.Logging; +import de.thedevstack.conversationsplus.R; +import de.thedevstack.conversationsplus.entities.Conversation; +import de.thedevstack.conversationsplus.services.MessageArchiveService; import de.thedevstack.conversationsplus.Config; import de.thedevstack.conversationsplus.entities.Message; import de.thedevstack.conversationsplus.ui.ConversationActivity; @@ -36,7 +37,7 @@ public class ConversationSwipeRefreshListener implements SwipyRefreshLayout.OnRe Logging.d(Config.LOGTAG, "Refresh direction " + direction); synchronized (this.messageList) { long timestamp; - if (SwipyRefreshLayoutDirection.TOP == direction) { + if (SwipyRefreshLayoutDirection.TOP == direction) { // Load history -> messages sent/received before first message in database if (messageList.isEmpty()) { timestamp = System.currentTimeMillis(); } else { @@ -45,28 +46,47 @@ public class ConversationSwipeRefreshListener implements SwipyRefreshLayout.OnRe ConversationActivity activity = (ConversationActivity) fragment.getActivity(); this.listener.setLoadHistory(true); activity.xmppConnectionService.loadMoreMessages(activity.getSelectedConversation(), timestamp, this.listener); - } else if (SwipyRefreshLayoutDirection.BOTTOM == direction) { + } else if (SwipyRefreshLayoutDirection.BOTTOM == direction) { // load messages sent/received between last received or last session establishment and now Logging.d("mam", "loading missing messages from mam (last session establishing or last received message)"); final ConversationActivity activity = (ConversationActivity) fragment.getActivity(); - long lastSessionEstablished = activity.getSelectedConversation().getAccount().getXmppConnection().getLastSessionEstablished(); - int lastMessageIndex = this.messageList.size() - 1; - long lastReceivedMessage = (0 <= lastMessageIndex) ? this.messageList.get(lastMessageIndex).getTimeSent() : Long.MAX_VALUE; + 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()); if (query != null) { this.listener.setLoadHistory(false); query.setCallback(this.listener); } else { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - listener.onMoreMessagesLoaded(0, activity.getSelectedConversation()); - } - }); + Logging.d("mam", "no query built - no messages loaded"); + this.listener.onMoreMessagesLoaded(0, activity.getSelectedConversation()); + this.listener.informUser(R.string.no_more_history_on_server); } this.listener.informUser(R.string.fetching_history_from_server); } } Logging.d(Config.LOGTAG, "End Refresh swipe container"); } + + private long getTimestampOfLastReceivedOrTransmittedMessage() { + long lastReceivedOrTransmittedMessage = Long.MAX_VALUE; + if (null != this.messageList + && !this.messageList.isEmpty()) { + int lastMessageIndex = this.messageList.size() - 1; + if (0 <= lastMessageIndex && this.messageList.size() > lastMessageIndex) { + lastReceivedOrTransmittedMessage = this.messageList.get(lastMessageIndex).getTimeSent(); + } + } + + return lastReceivedOrTransmittedMessage; + } + + private long getTimestampOfLastSessionEstablished(Conversation conversation) { + long lastSessionEstablished = Long.MAX_VALUE; + if (null != conversation + && null != conversation.getAccount() + && null != conversation.getAccount().getXmppConnection()) { + lastSessionEstablished = conversation.getAccount().getXmppConnection().getLastSessionEstablished(); + } + return lastSessionEstablished; + } } diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java b/src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java index 65b3b1b3..5dcfc607 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java @@ -5,7 +5,7 @@ import android.content.Intent; import android.preference.Preference; import android.util.AttributeSet; -import de.thedevstack.android.logcat.ui.LogCatOutputActivity; +import de.thedevstack.conversationsplus.ui.LogCatOutputActivity; /** * Created by tzur on 07.10.2015. |