aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-11-20 22:41:30 +0100
committersteckbrief <steckbrief@chefmail.de>2015-11-20 22:41:30 +0100
commit2531c88f2c8a992aa0c40c9f96e88099dc94139e (patch)
treee3815b7f1ef0bbd227df8c4452d4aa52b54830e4 /src/main/java/de
parent8838a5094812e0540ccfef3334e49e1a5c1a564b (diff)
Implements FS#67: Introduce central logging class to use log prefix, new activity to show logcat output and button to copy contents
Diffstat (limited to '')
-rw-r--r--src/main/java/de/thedevstack/android/logcat/adapters/LogCatArrayAdapter.java122
-rw-r--r--src/main/java/de/thedevstack/android/logcat/tasks/ReadLogCatAsyncTask.java67
-rw-r--r--src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputActivity.java27
-rw-r--r--src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java42
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/crypto/OtrService.java16
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java22
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java6
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java8
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/parser/IqParser.java6
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java8
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java8
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java8
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java8
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java90
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/StartConversationActivity.java8
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java6
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java2
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java6
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java31
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/DNSHelper.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/ExceptionHelper.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/ExifHelper.java12
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java6
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/Logging.java124
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/PRNGFixes.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xml/Element.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xml/XmlReader.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/XmppConnection.java84
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java70
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnectionManager.java6
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleInbandTransport.java14
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleSocks5Transport.java20
-rw-r--r--src/main/java/de/tzur/conversations/Settings.java6
36 files changed, 639 insertions, 226 deletions
diff --git a/src/main/java/de/thedevstack/android/logcat/adapters/LogCatArrayAdapter.java b/src/main/java/de/thedevstack/android/logcat/adapters/LogCatArrayAdapter.java
new file mode 100644
index 00000000..c8a96ea3
--- /dev/null
+++ b/src/main/java/de/thedevstack/android/logcat/adapters/LogCatArrayAdapter.java
@@ -0,0 +1,122 @@
+package de.thedevstack.android.logcat.adapters;
+
+import android.content.Context;
+import android.widget.ArrayAdapter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Created by tzur on 20.11.2015.
+ */
+public class LogCatArrayAdapter extends ArrayAdapter<String> {
+ private ArrayList<String> logcatItems = new ArrayList<>();
+
+ /**
+ * Constructor
+ *
+ * @param context The current context.
+ * @param resource The resource ID for a layout file containing a TextView to use when
+ */
+ public LogCatArrayAdapter(Context context, int resource) {
+ super(context, resource);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param context The current context.
+ * @param resource The resource ID for a layout file containing a layout to use when
+ * instantiating views.
+ * @param textViewResourceId The id of the TextView within the layout resource to be populated
+ */
+ public LogCatArrayAdapter(Context context, int resource, int textViewResourceId) {
+ super(context, resource, textViewResourceId);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param context The current context.
+ * @param resource The resource ID for a layout file containing a TextView to use when
+ * instantiating views.
+ * @param objects The objects to represent in the ListView.
+ */
+ public LogCatArrayAdapter(Context context, int resource, String[] objects) {
+ super(context, resource, objects);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param context The current context.
+ * @param resource The resource ID for a layout file containing a layout to use when
+ * instantiating views.
+ * @param textViewResourceId The id of the TextView within the layout resource to be populated
+ * @param objects The objects to represent in the ListView.
+ */
+ public LogCatArrayAdapter(Context context, int resource, int textViewResourceId, String[] objects) {
+ super(context, resource, textViewResourceId, objects);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param context The current context.
+ * @param resource The resource ID for a layout file containing a TextView to use when
+ * instantiating views.
+ * @param objects The objects to represent in the ListView.
+ */
+ public LogCatArrayAdapter(Context context, int resource, List<String> objects) {
+ super(context, resource, objects);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param context The current context.
+ * @param resource The resource ID for a layout file containing a layout to use when
+ * instantiating views.
+ * @param textViewResourceId The id of the TextView within the layout resource to be populated
+ * @param objects The objects to represent in the ListView.
+ */
+ public LogCatArrayAdapter(Context context, int resource, int textViewResourceId, List<String> objects) {
+ super(context, resource, textViewResourceId, objects);
+ }
+
+ @Override
+ public void add(String object) {
+ super.add(object);
+ logcatItems.add(object);
+ }
+
+ @Override
+ public void addAll(Collection<? extends String> collection) {
+ super.addAll(collection);
+ logcatItems.addAll(collection);
+ }
+
+ @Override
+ public void addAll(String... items) {
+ super.addAll(items);
+ Collections.addAll(logcatItems, items);
+ }
+
+ @Override
+ public void clear() {
+ super.clear();
+ logcatItems.clear();
+ }
+
+ @Override
+ public void remove(String object) {
+ super.remove(object);
+ logcatItems.remove(object);
+ }
+
+ public ArrayList<String> getItems() {
+ return this.logcatItems;
+ }
+}
diff --git a/src/main/java/de/thedevstack/android/logcat/tasks/ReadLogCatAsyncTask.java b/src/main/java/de/thedevstack/android/logcat/tasks/ReadLogCatAsyncTask.java
new file mode 100644
index 00000000..b9fa450b
--- /dev/null
+++ b/src/main/java/de/thedevstack/android/logcat/tasks/ReadLogCatAsyncTask.java
@@ -0,0 +1,67 @@
+package de.thedevstack.android.logcat.tasks;
+
+import android.os.AsyncTask;
+import de.thedevstack.conversationsplus.utils.Logging;
+import android.widget.ArrayAdapter;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+import de.thedevstack.conversationsplus.utils.StreamUtil;
+
+/**
+ * Created by tzur on 20.11.2015.
+ */
+public class ReadLogCatAsyncTask extends AsyncTask<Void, Void, String[]> {
+ private final ArrayAdapter<String> arrayAdapter;
+ private static final String[] LOG_CAT_CMD = { "logcat", "-d", "-v", "time"};
+ private static final String[] WHITE_LIST = { "thedevstack.", "E/", "W/" };
+ private static final String[] BLACK_LIST = { "D/TextLayoutCache" };
+
+ public ReadLogCatAsyncTask(ArrayAdapter<String> arrayAdapter) {
+ this.arrayAdapter = arrayAdapter;
+ }
+ @Override
+ protected String[] doInBackground(Void... params) {
+ ArrayList<String> logCatOutput = new ArrayList<>();
+ BufferedReader bufferedReader = null;
+ try {
+ Process process = Runtime.getRuntime().exec(ReadLogCatAsyncTask.LOG_CAT_CMD);
+ bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+ String line = "";
+ while ((line = bufferedReader.readLine()) != null) {
+ logCatOutput.add(line);
+ }
+ bufferedReader.close();
+ } catch (IOException e) {
+ Logging.e("ReadLogCat", "error while retrieving information from logcat: " + e.getMessage(), e);
+ } finally {
+ StreamUtil.close(bufferedReader);
+ }
+ logCatOutput.trimToSize();
+ return logCatOutput.toArray(new String[0]);
+ }
+
+ @Override
+ protected void onPostExecute(String[] items) {
+ this.arrayAdapter.clear();
+ if (null != items && items.length > 0) {
+ for (String item : items) {
+ if (!filter(item)) {
+ this.arrayAdapter.add(item);
+ }
+ }
+ }
+ }
+
+ protected boolean filter(String item) {
+ for (String whiteListed : ReadLogCatAsyncTask.WHITE_LIST) {
+ if (item.contains(whiteListed)) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputActivity.java b/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputActivity.java
new file mode 100644
index 00000000..bb49c54d
--- /dev/null
+++ b/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputActivity.java
@@ -0,0 +1,27 @@
+package de.thedevstack.android.logcat.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.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));
+ }
+}
diff --git a/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java b/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java
new file mode 100644
index 00000000..da82fc7f
--- /dev/null
+++ b/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java
@@ -0,0 +1,42 @@
+package de.thedevstack.android.logcat.ui;
+
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.view.View;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+
+import de.thedevstack.android.logcat.adapters.LogCatArrayAdapter;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
+import de.thedevstack.conversationsplus.R;
+
+/**
+ * Created by tzur on 20.11.2015.
+ */
+public class LogCatOutputCopyOnClickListener implements View.OnClickListener {
+ private final LogCatArrayAdapter logCatOutputAdapter;
+ private final Context context;
+
+ public LogCatOutputCopyOnClickListener(Context context, LogCatArrayAdapter logCatOutputAdapter) {
+ this.logCatOutputAdapter = logCatOutputAdapter;
+ this.context = context;
+ }
+
+ @Override
+ public void onClick(View v) {
+ ArrayList<String> items = this.logCatOutputAdapter.getItems();
+ if (null != items && !items.isEmpty()) {
+ StringBuilder sb = new StringBuilder();
+ for (String item : items) {
+ sb.append(item);
+ sb.append("\n");
+ }
+ ClipboardManager clipboard = (ClipboardManager) ConversationsPlusApplication.getInstance().getSystemService(Context.CLIPBOARD_SERVICE);
+ ClipData clip = ClipData.newPlainText("c+logcat", sb.toString());
+ clipboard.setPrimaryClip(clip);
+ Toast.makeText(this.context, R.string.cplus_copied_to_clipboard, Toast.LENGTH_LONG).show();
+ }
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/crypto/OtrService.java b/src/main/java/de/thedevstack/conversationsplus/crypto/OtrService.java
index c9ee53ae..11091c9f 100644
--- a/src/main/java/de/thedevstack/conversationsplus/crypto/OtrService.java
+++ b/src/main/java/de/thedevstack/conversationsplus/crypto/OtrService.java
@@ -14,7 +14,7 @@ import java.security.spec.InvalidKeySpecException;
import org.json.JSONException;
import org.json.JSONObject;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
@@ -111,7 +111,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
mXmppConnectionService.updateConversationUi();
}
} catch (InvalidJidException e) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": smp in invalid session "+id.toString());
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": smp in invalid session "+id.toString());
}
}
@@ -152,7 +152,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
this.saveKey();
mXmppConnectionService.databaseBackend.updateAccount(account);
} catch (NoSuchAlgorithmException e) {
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
"error generating key pair " + e.getMessage());
}
}
@@ -221,7 +221,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
@Override
public void showError(SessionID arg0, String arg1) throws OtrException {
- Log.d(Config.LOGTAG,"show error");
+ Logging.d(Config.LOGTAG,"show error");
}
@Override
@@ -256,7 +256,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
@Override
public void unreadableMessageReceived(SessionID session) throws OtrException {
- Log.d(Config.LOGTAG,"unreadable message received");
+ Logging.d(Config.LOGTAG,"unreadable message received");
sendOtrErrorMessage(session, "You sent me an unreadable OTR-encrypted message");
}
@@ -270,8 +270,8 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
.generateOtrError(jid, id, errorText);
packet.setFrom(account.getJid());
mXmppConnectionService.sendMessagePacket(account,packet);
- Log.d(Config.LOGTAG,packet.toString());
- Log.d(Config.LOGTAG,account.getJid().toBareJid().toString()
+ Logging.d(Config.LOGTAG,packet.toString());
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid().toString()
+": unreadable OTR message in "+conversation.getName());
}
} catch (InvalidJidException e) {
@@ -286,7 +286,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
@Override
public void verify(SessionID id, String fingerprint, boolean approved) {
- Log.d(Config.LOGTAG,"OtrService.verify("+id.toString()+","+fingerprint+","+String.valueOf(approved)+")");
+ Logging.d(Config.LOGTAG,"OtrService.verify("+id.toString()+","+fingerprint+","+String.valueOf(approved)+")");
try {
final Jid jid = Jid.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account,jid);
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java b/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java
index 9a677cd0..8d608ae7 100644
--- a/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java
+++ b/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java
@@ -22,7 +22,7 @@ import javax.crypto.spec.SecretKeySpec;
import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.utils.MimeUtils;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
public class DownloadableFile extends File {
@@ -114,19 +114,19 @@ public class DownloadableFile extends File {
IvParameterSpec ips = new IvParameterSpec(iv);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, this.getKey(), ips);
- Log.d(Config.LOGTAG, "opening encrypted input stream");
+ Logging.d(Config.LOGTAG, "opening encrypted input stream");
return new CipherInputStream(new FileInputStream(this), cipher);
} catch (NoSuchAlgorithmException e) {
- Log.d(Config.LOGTAG, "no such algo: " + e.getMessage());
+ Logging.d(Config.LOGTAG, "no such algo: " + e.getMessage());
return null;
} catch (NoSuchPaddingException e) {
- Log.d(Config.LOGTAG, "no such padding: " + e.getMessage());
+ Logging.d(Config.LOGTAG, "no such padding: " + e.getMessage());
return null;
} catch (InvalidKeyException e) {
- Log.d(Config.LOGTAG, "invalid key: " + e.getMessage());
+ Logging.d(Config.LOGTAG, "invalid key: " + e.getMessage());
return null;
} catch (InvalidAlgorithmParameterException e) {
- Log.d(Config.LOGTAG, "invavid iv:" + e.getMessage());
+ Logging.d(Config.LOGTAG, "invavid iv:" + e.getMessage());
return null;
} catch (FileNotFoundException e) {
return null;
@@ -146,20 +146,20 @@ public class DownloadableFile extends File {
IvParameterSpec ips = new IvParameterSpec(this.iv);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, this.getKey(), ips);
- Log.d(Config.LOGTAG, "opening encrypted output stream");
+ Logging.d(Config.LOGTAG, "opening encrypted output stream");
return new CipherOutputStream(new FileOutputStream(this),
cipher);
} catch (NoSuchAlgorithmException e) {
- Log.d(Config.LOGTAG, "no such algo: " + e.getMessage());
+ Logging.d(Config.LOGTAG, "no such algo: " + e.getMessage());
return null;
} catch (NoSuchPaddingException e) {
- Log.d(Config.LOGTAG, "no such padding: " + e.getMessage());
+ Logging.d(Config.LOGTAG, "no such padding: " + e.getMessage());
return null;
} catch (InvalidKeyException e) {
- Log.d(Config.LOGTAG, "invalid key: " + e.getMessage());
+ Logging.d(Config.LOGTAG, "invalid key: " + e.getMessage());
return null;
} catch (InvalidAlgorithmParameterException e) {
- Log.d(Config.LOGTAG, "invavid iv:" + e.getMessage());
+ Logging.d(Config.LOGTAG, "invavid iv:" + e.getMessage());
return null;
} catch (FileNotFoundException e) {
return null;
diff --git a/src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java b/src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java
index b958e57e..c0a169ee 100644
--- a/src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java
+++ b/src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java
@@ -3,7 +3,7 @@ package de.thedevstack.conversationsplus.http;
import android.content.Intent;
import android.net.Uri;
import android.os.SystemClock;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import java.io.BufferedInputStream;
import java.io.IOException;
@@ -144,7 +144,7 @@ public class HttpDownloadConnection implements Transferable {
HttpDownloadConnection.this.mXmppConnectionService.getNotificationService().push(message);
return;
} catch (IOException e) {
- Log.d(Config.LOGTAG, "io exception in http file size checker: " + e.getMessage());
+ Logging.d(Config.LOGTAG, "io exception in http file size checker: " + e.getMessage());
if (interactive) {
mXmppConnectionService.showErrorToastInUi(R.string.file_not_found_on_remote_host);
}
@@ -163,7 +163,7 @@ public class HttpDownloadConnection implements Transferable {
}
private long retrieveFileSize() throws IOException {
- Log.d(Config.LOGTAG,"retrieve file size. interactive:"+String.valueOf(interactive));
+ Logging.d(Config.LOGTAG,"retrieve file size. interactive:"+String.valueOf(interactive));
changeStatus(STATUS_CHECKING);
HttpURLConnection connection = (HttpURLConnection) mUrl.openConnection();
connection.setRequestMethod("HEAD");
diff --git a/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java b/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java
index 05d3a129..3d12681f 100644
--- a/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java
+++ b/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java
@@ -1,7 +1,7 @@
package de.thedevstack.conversationsplus.http;
import android.app.PendingIntent;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import java.io.IOException;
import java.io.InputStream;
@@ -134,7 +134,7 @@ public class HttpUploadConnection implements Transferable {
InputStream is = null;
HttpURLConnection connection = null;
try {
- Log.d(Config.LOGTAG, "uploading to " + mPutUrl.toString());
+ Logging.d(Config.LOGTAG, "uploading to " + mPutUrl.toString());
connection = (HttpURLConnection) mPutUrl.openConnection();
if (connection instanceof HttpsURLConnection) {
mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, true);
@@ -159,7 +159,7 @@ public class HttpUploadConnection implements Transferable {
is.close();
int code = connection.getResponseCode();
if (code == 200 || code == 201) {
- Log.d(Config.LOGTAG, "finished uploading file");
+ Logging.d(Config.LOGTAG, "finished uploading file");
Message.FileParams params = message.getFileParams();
if (key != null) {
mGetUrl = new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key));
@@ -191,7 +191,7 @@ public class HttpUploadConnection implements Transferable {
fail();
}
} catch (IOException e) {
- Log.d(Config.LOGTAG, e.getMessage());
+ Logging.d(Config.LOGTAG, e.getMessage());
fail();
} finally {
StreamUtil.close(is);
diff --git a/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java b/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java
index 87238f9e..c9efe3d7 100644
--- a/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java
+++ b/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java
@@ -61,10 +61,10 @@ public abstract class AbstractParser {
*/
public static Date parseTimestamp(String timestamp) throws ParseException {
/*try {
- Log.d("TIMESTAMP", timestamp);
+ Logging.d("TIMESTAMP", timestamp);
return DatatypeFactory.newInstance().newXMLGregorianCalendar(timestamp).toGregorianCalendar().getTime();
} catch (DatatypeConfigurationException e) {
- Log.d("TIMESTAMP", e.getMessage());
+ Logging.d("TIMESTAMP", e.getMessage());
return new Date();
}*/
timestamp = timestamp.replace("Z", "+0000");
diff --git a/src/main/java/de/thedevstack/conversationsplus/parser/IqParser.java b/src/main/java/de/thedevstack/conversationsplus/parser/IqParser.java
index f76dbf03..88091366 100644
--- a/src/main/java/de/thedevstack/conversationsplus/parser/IqParser.java
+++ b/src/main/java/de/thedevstack/conversationsplus/parser/IqParser.java
@@ -1,6 +1,6 @@
package de.thedevstack.conversationsplus.parser;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import java.util.ArrayList;
import java.util.Collection;
@@ -83,7 +83,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
} else if ((packet.hasChild("block", Xmlns.BLOCKING) || packet.hasChild("blocklist", Xmlns.BLOCKING)) &&
packet.fromServer(account)) {
// Block list or block push.
- Log.d(Config.LOGTAG, "Received blocklist update from server");
+ Logging.d(Config.LOGTAG, "Received blocklist update from server");
final Element blocklist = packet.findChild("blocklist", Xmlns.BLOCKING);
final Element block = packet.findChild("block", Xmlns.BLOCKING);
final Collection<Element> items = blocklist != null ? blocklist.getChildren() :
@@ -111,7 +111,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
mXmppConnectionService.updateBlocklistUi(OnUpdateBlocklist.Status.BLOCKED);
} else if (packet.hasChild("unblock", Xmlns.BLOCKING) &&
packet.fromServer(account) && packet.getType() == IqPacket.TYPE.SET) {
- Log.d(Config.LOGTAG, "Received unblock update from server");
+ Logging.d(Config.LOGTAG, "Received unblock update from server");
final Collection<Element> items = packet.findChild("unblock", Xmlns.BLOCKING).getChildren();
if (items.size() == 0) {
// No children to unblock == unblock all
diff --git a/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java b/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
index f346eafc..6f8ad2fe 100644
--- a/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
+++ b/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
@@ -1,6 +1,6 @@
package de.thedevstack.conversationsplus.parser;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import android.util.Pair;
import net.java.otr4j.session.Session;
@@ -219,7 +219,7 @@ public class MessageParser extends AbstractParser implements
serverMsgId = result.getAttribute("id");
query.incrementTotalCount();
} else if (query != null) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": received mam result from invalid sender");
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": received mam result from invalid sender");
return;
} else if (original.fromServer(account)) {
Pair<MessagePacket, Long> f;
@@ -249,7 +249,7 @@ public class MessageParser extends AbstractParser implements
final String remoteMsgId = packet.getId();
if (from == null || to == null) {
- Log.d(Config.LOGTAG,"no to or from in: "+packet.toString());
+ Logging.d(Config.LOGTAG,"no to or from in: "+packet.toString());
return;
}
@@ -323,7 +323,7 @@ public class MessageParser extends AbstractParser implements
|| (isTypeGroupChat && packet.hasChild("delay","urn:xmpp:delay"))
|| message.getType() == Message.TYPE_PRIVATE;
if (checkForDuplicates && conversation.hasDuplicateMessage(message)) {
- Log.d(Config.LOGTAG,"skipping duplicate message from "+message.getCounterpart().toString()+" "+message.getBody());
+ Logging.d(Config.LOGTAG,"skipping duplicate message from "+message.getCounterpart().toString()+" "+message.getBody());
return;
}
if (query != null) {
diff --git a/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java b/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java
index 21eaf476..cfd00b1b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java
+++ b/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java
@@ -18,7 +18,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteCantOpenDatabaseException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
public class DatabaseBackend extends SQLiteOpenHelper {
@@ -145,7 +145,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
cursor.getString(cursor.getColumnIndex(Conversation.CONTACTJID))
).toString();
} catch (InvalidJidException ignored) {
- Log.e(Config.LOGTAG, "Failed to migrate Conversation CONTACTJID "
+ Logging.e(Config.LOGTAG, "Failed to migrate Conversation CONTACTJID "
+cursor.getString(cursor.getColumnIndex(Conversation.CONTACTJID))
+": " + ignored +". Skipping...");
continue;
@@ -170,7 +170,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
cursor.getString(cursor.getColumnIndex(Contact.JID))
).toString();
} catch (InvalidJidException ignored) {
- Log.e(Config.LOGTAG, "Failed to migrate Contact JID "
+ Logging.e(Config.LOGTAG, "Failed to migrate Contact JID "
+cursor.getString(cursor.getColumnIndex(Contact.JID))
+": " + ignored +". Skipping...");
continue;
@@ -199,7 +199,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
"mobile"
).getDomainpart();
} catch (InvalidJidException ignored) {
- Log.e(Config.LOGTAG, "Failed to migrate Account SERVER "
+ Logging.e(Config.LOGTAG, "Failed to migrate Account SERVER "
+cursor.getString(cursor.getColumnIndex(Account.SERVER))
+": " + ignored +". Skipping...");
continue;
diff --git a/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java b/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java
index 7ee67a15..5cc63065 100644
--- a/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java
+++ b/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java
@@ -16,7 +16,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Environment;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import android.webkit.MimeTypeMap;
import de.thedevstack.conversationsplus.Config;
@@ -82,7 +82,7 @@ public final class FileBackend {
}
public static DownloadableFile copyFileToPrivateStorage(Message message, Uri uri) throws FileCopyException {
- Log.d(Config.LOGTAG, "copy " + uri.toString() + " to private storage");
+ Logging.d(Config.LOGTAG, "copy " + uri.toString() + " to private storage");
String mime = ConversationsPlusApplication.getInstance().getContentResolver().getType(uri);
String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mime);
message.setRelativeFilePath(message.getUuid() + "." + extension);
@@ -109,7 +109,7 @@ public final class FileBackend {
StreamUtil.close(os);
StreamUtil.close(is);
}
- Log.d(Config.LOGTAG, "output file name " + file);
+ Logging.d(Config.LOGTAG, "output file name " + file);
return file;
}
@@ -132,7 +132,7 @@ public final class FileBackend {
Bitmap originalBitmap;
BitmapFactory.Options options = new BitmapFactory.Options();
int inSampleSize = (int) Math.pow(2, sampleSize);
- Log.d(Config.LOGTAG, "reading bitmap with sample size " + inSampleSize);
+ Logging.d(Config.LOGTAG, "reading bitmap with sample size " + inSampleSize);
options.inSampleSize = inSampleSize;
originalBitmap = BitmapFactory.decodeStream(is, null, options);
is.close();
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java b/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java
index 2b8ed579..eee81b90 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java
@@ -1,6 +1,6 @@
package de.thedevstack.conversationsplus.services;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import java.math.BigInteger;
import java.util.ArrayList;
@@ -106,13 +106,13 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
private void execute(final Query query) {
final Account account= query.getAccount();
if (account.getStatus() == Account.State.ONLINE) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": running mam query " + query.toString());
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": running mam query " + query.toString());
IqPacket packet = this.mXmppConnectionService.getIqGenerator().queryMessageArchiveManagement(query);
this.mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.ERROR) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": error executing mam: " + packet.toString());
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": error executing mam: " + packet.toString());
finalizeQuery(query);
}
}
@@ -182,7 +182,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
boolean abort = (query.getStart() == 0 && query.getTotalCount() >= Config.PAGE_SIZE) || query.getTotalCount() >= Config.MAM_MAX_MESSAGES;
if (complete || relevant == null || abort) {
this.finalizeQuery(query);
- Log.d(Config.LOGTAG,query.getAccount().getJid().toBareJid().toString()+": finished mam after "+query.getTotalCount()+" messages");
+ Logging.d(Config.LOGTAG,query.getAccount().getJid().toBareJid().toString()+": finished mam after "+query.getTotalCount()+" messages");
} else {
final Query nextQuery;
if (query.getPagingOrder() == PagingOrder.NORMAL) {
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java b/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java
index 624914dd..30fae7cc 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java
@@ -21,7 +21,7 @@ import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.SystemClock;
import android.provider.ContactsContract;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import net.java.otr4j.OtrException;
import net.java.otr4j.session.Session;
@@ -223,7 +223,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
Element error = packet.findChild("error");
String text = error != null ? error.findChildContent("text") : null;
if (text != null) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": received iq error - "+text);
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": received iq error - "+text);
}
}
}
@@ -270,11 +270,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
if (connection != null && connection.getFeatures().csi()) {
if (checkListeners()) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()
+ " sending csi//inactive");
connection.sendInactive();
} else {
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()
+ " sending csi//active");
connection.sendActive();
}
@@ -294,7 +294,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
&& (account.getStatus() != Account.State.NO_INTERNET)) {
if (connection != null) {
int next = connection.getTimeToNextAttempt();
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": error connecting account. try again in "
+ next + "s for the "
+ (connection.getAttempt() + 1) + " time");
@@ -430,17 +430,17 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
message.setBody(Long.toString(imageSize) + '|' + imageWidth + '|' + imageHeight);
callback.success(message);
} catch (FileNotFoundException e) {
- Log.e("pictureresize", "File not found to send not resized. " + e.getMessage());
+ Logging.e("pictureresize", "File not found to send not resized. " + e.getMessage());
callback.error(R.string.error_file_not_found, message);
} catch (IOException e) {
- Log.e("pictureresize", "Error while sending not resized picture. " + e.getMessage());
+ Logging.e("pictureresize", "Error while sending not resized picture. " + e.getMessage());
callback.error(R.string.error_io_exception, message);
} finally {
if (null != is) {
try {
is.close();
} catch (IOException e) {
- Log.w("pictureresize", "Error while closing stream for sending not resized picture. " + e.getMessage());
+ Logging.w("pictureresize", "Error while closing stream for sending not resized picture. " + e.getMessage());
}
}
}
@@ -555,7 +555,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
long pingTimeoutIn = (lastSent + Config.PING_TIMEOUT * 1000) - SystemClock.elapsedRealtime();
if (lastSent > lastReceived) {
if (pingTimeoutIn < 0) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": ping timeout");
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid() + ": ping timeout");
this.reconnectAccount(account, true);
} else {
int secs = (int) (pingTimeoutIn / 1000);
@@ -563,7 +563,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
} else if (msToNextPing <= 0) {
account.getXmppConnection().sendPing();
- Log.d(Config.LOGTAG, account.getJid().toBareJid()+" send ping");
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()+" send ping");
this.scheduleWakeUpCall(Config.PING_TIMEOUT,account.getUuid().hashCode());
} else {
this.scheduleWakeUpCall((int) (msToNextPing / 1000), account.getUuid().hashCode());
@@ -573,7 +573,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
} else if (account.getStatus() == Account.State.CONNECTING) {
long timeout = Config.CONNECT_TIMEOUT - ((SystemClock.elapsedRealtime() - account.getXmppConnection().getLastConnect()) / 1000);
if (timeout < 0) {
- Log.d(Config.LOGTAG, account.getJid() + ": time out during connect reconnecting");
+ Logging.d(Config.LOGTAG, account.getJid() + ": time out during connect reconnecting");
reconnectAccount(account, true);
} else {
scheduleWakeUpCall((int) timeout,account.getUuid().hashCode());
@@ -604,7 +604,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
private void resetAllAttemptCounts(boolean reallyAll) {
- Log.d(Config.LOGTAG, "resetting all attepmt counts");
+ Logging.d(Config.LOGTAG, "resetting all attepmt counts");
for(Account account : accounts) {
if (account.hasErrorStatus() || reallyAll) {
final XmppConnection connection = account.getXmppConnection();
@@ -696,7 +696,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, EventReceiver.class);
alarmManager.cancel(PendingIntent.getBroadcast(context, 0, intent, 0));
- Log.d(Config.LOGTAG, "good bye");
+ Logging.d(Config.LOGTAG, "good bye");
stopSelf();
}
@@ -734,7 +734,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
private void sendFileMessage(final Message message) {
- Log.d(Config.LOGTAG, "send file message");
+ Logging.d(Config.LOGTAG, "send file message");
final Account account = message.getConversation().getAccount();
final XmppConnection connection = account.getXmppConnection();
if (connection != null && connection.getFeatures().httpUpload()) {
@@ -884,10 +884,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public void fetchRosterFromServer(final Account account) {
final IqPacket iqPacket = new IqPacket(IqPacket.TYPE.GET);
if (!"".equals(account.getRosterVersion())) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": fetching roster version " + account.getRosterVersion());
} else {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": fetching roster");
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid() + ": fetching roster");
}
iqPacket.query(Xmlns.ROSTER).setAttribute("ver", account.getRosterVersion());
sendIqPacket(account, iqPacket, mIqParser);
@@ -945,12 +945,12 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
mPhoneContactMergerThread = new Thread(new Runnable() {
@Override
public void run() {
- Log.d(Config.LOGTAG,"start merging phone contacts with roster");
+ Logging.d(Config.LOGTAG,"start merging phone contacts with roster");
for (Account account : accounts) {
List<Contact> withSystemAccounts = account.getRoster().getWithSystemAccounts();
for (Bundle phoneContact : phoneContacts) {
if (Thread.interrupted()) {
- Log.d(Config.LOGTAG,"interrupted merging phone contacts");
+ Logging.d(Config.LOGTAG,"interrupted merging phone contacts");
return;
}
Jid jid;
@@ -978,7 +978,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
}
}
- Log.d(Config.LOGTAG,"finished merging phone contacts");
+ Logging.d(Config.LOGTAG,"finished merging phone contacts");
updateAccountUi();
}
});
@@ -999,7 +999,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
Runnable runnable =new Runnable() {
@Override
public void run() {
- Log.d(Config.LOGTAG,"restoring roster");
+ Logging.d(Config.LOGTAG,"restoring roster");
for(Account account : accounts) {
databaseBackend.readRoster(account.getRoster());
}
@@ -1008,13 +1008,13 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
PhoneHelper.loadPhoneContacts(getApplicationContext(),
new CopyOnWriteArrayList<Bundle>(),
XmppConnectionService.this);
- Log.d(Config.LOGTAG,"restoring messages");
+ Logging.d(Config.LOGTAG,"restoring messages");
for (Conversation conversation : conversations) {
conversation.addAll(0, databaseBackend.getMessages(conversation, Config.PAGE_SIZE));
checkDeletedFiles(conversation);
}
mRestoredFromDatabase = true;
- Log.d(Config.LOGTAG,"restored all messages");
+ Logging.d(Config.LOGTAG,"restored all messages");
updateConversationUi();
}
};
@@ -1084,9 +1084,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
public void loadMoreMessages(final Conversation conversation, final long timestamp, final OnMoreMessagesLoaded callback) {
- Log.d(Config.LOGTAG, "load more messages for " + conversation.getName() + " prior to " + MessageGenerator.getTimestamp(timestamp));
+ Logging.d(Config.LOGTAG, "load more messages for " + conversation.getName() + " prior to " + MessageGenerator.getTimestamp(timestamp));
if (XmppConnectionService.this.getMessageArchiveService().queryInProgress(conversation,callback)) {
- Log.d("mam", "Query in progress");
+ Logging.d("mam", "Query in progress");
return;
}
//TODO Create a separate class for this runnable to store if messages are getting loaded or not. Not really a good idea to do this in the callback.
@@ -1099,23 +1099,23 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
final Account account = conversation.getAccount();
List<Message> messages = databaseBackend.getMessages(conversation, 50, timestamp);
- Log.d("mam", "runnable load more messages");
+ Logging.d("mam", "runnable load more messages");
if (messages.size() > 0) {
- Log.d("mam", "At least one message");
+ Logging.d("mam", "At least one message");
conversation.addAll(0, messages);
checkDeletedFiles(conversation);
callback.onMoreMessagesLoaded(messages.size(), conversation);
} else if (conversation.hasMessagesLeftOnServer()
&& account.isOnlineAndConnected()
&& account.getXmppConnection().getFeatures().mam()) {
- Log.d("mam", "mam activate, account online and connected and messages left on server");
+ Logging.d("mam", "mam activate, account online and connected and messages left on server");
MessageArchiveService.Query query = getMessageArchiveService().query(conversation, 0, timestamp - 1);
if (query != null) {
query.setCallback(callback);
}
callback.informUser(R.string.fetching_history_from_server);
} else {
- Log.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)");
+ 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);
callback.informUser(R.string.no_more_history_on_server);
}
@@ -1457,7 +1457,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
}
}
- Log.d(Config.LOGTAG, "app switched into foreground");
+ Logging.d(Config.LOGTAG, "app switched into foreground");
}
private void switchToBackground() {
@@ -1473,7 +1473,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
conversation.setIncomingChatState(ChatState.ACTIVE);
}
this.mNotificationService.setIsInForeground(false);
- Log.d(Config.LOGTAG, "app switched into background");
+ Logging.d(Config.LOGTAG, "app switched into background");
}
private void connectMultiModeConversations(Account account) {
@@ -1497,7 +1497,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (joinJid == null) {
return; //safety net
}
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": joining conversation " + joinJid.toString());
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": joining conversation " + joinJid.toString());
PresencePacket packet = new PresencePacket();
packet.setFrom(conversation.getAccount().getJid());
packet.setTo(joinJid);
@@ -1596,7 +1596,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
sendPresencePacket(conversation.getAccount(), packet);
conversation.getMucOptions().setOffline();
conversation.deregisterWithBookmark();
- Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid()
+ Logging.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid()
+ ": leaving muc " + conversation.getJid());
} else {
account.pendingConferenceLeaves.add(conversation);
@@ -1623,7 +1623,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
public void createAdhocConference(final Account account, final Iterable<Jid> jids, final UiCallback<Conversation> callback) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": creating adhoc conference with " + jids.toString());
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": creating adhoc conference with " + jids.toString());
if (account.getStatus() == Account.State.ONLINE) {
try {
String server = findConferenceServer(account);
@@ -1781,11 +1781,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public void changeRoleInConference(final Conversation conference, final String nick, MucOptions.Role role, final OnRoleChanged callback) {
IqPacket request = this.mIqGenerator.changeRole(conference, nick, role.toString());
- Log.d(Config.LOGTAG, request.toString());
+ Logging.d(Config.LOGTAG, request.toString());
sendIqPacket(conference.getAccount(), request, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
- Log.d(Config.LOGTAG, packet.toString());
+ Logging.d(Config.LOGTAG, packet.toString());
if (packet.getType() == IqPacket.TYPE.RESULT) {
callback.onRoleChangedSuccessful(nick);
} else {
@@ -1806,7 +1806,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
leaveMuc(conversation);
} else {
if (conversation.endOtrIfNeeded()) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": ended otr session with "
+ conversation.getJid());
}
@@ -1851,7 +1851,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public void onOtrSessionEstablished(Conversation conversation) {
final Account account = conversation.getAccount();
final Session otrSession = conversation.getOtrSession();
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
account.getJid().toBareJid() + " otr session established with "
+ conversation.getJid() + "/"
+ otrSession.getSessionID().getUserID());
@@ -2049,20 +2049,20 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (callback != null) {
callback.success(avatar);
}
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": succesfuly fetched pep avatar for " + avatar.owner);
return;
}
} else {
- Log.d(Config.LOGTAG, ERROR + "(parsing error)");
+ Logging.d(Config.LOGTAG, ERROR + "(parsing error)");
}
} else {
Element error = result.findChild("error");
if (error == null) {
- Log.d(Config.LOGTAG, ERROR + "(server error)");
+ Logging.d(Config.LOGTAG, ERROR + "(server error)");
} else {
- Log.d(Config.LOGTAG, ERROR + error.toString());
+ Logging.d(Config.LOGTAG, ERROR + error.toString());
}
}
if (callback != null) {
@@ -2088,7 +2088,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (image != null) {
avatar.image = image;
if (AvatarUtil.save(avatar)) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": successfully fetched vCard avatar for " + avatar.owner);
Contact contact = account.getRoster()
.getContact(avatar.owner);
@@ -2194,7 +2194,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
public void invite(Conversation conversation, Jid contact) {
- Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": inviting " + contact + " to " + conversation.getJid().toBareJid());
+ Logging.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": inviting " + contact + " to " + conversation.getJid().toBareJid());
MessagePacket packet = mMessageGenerator.invite(conversation, contact);
sendMessagePacket(conversation.getAccount(), packet);
}
@@ -2332,7 +2332,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public synchronized void updateUnreadCountBadge() {
int count = unreadCount();
if (unreadCount != count) {
- Log.d(Config.LOGTAG, "update unread count to " + count);
+ Logging.d(Config.LOGTAG, "update unread count to " + count);
if (count > 0) {
ShortcutBadger.with(getApplicationContext()).count(count);
} else {
@@ -2346,7 +2346,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
final Message markable = conversation.getLatestMarkableMessage();
this.markRead(conversation);
if (Settings.CONFIRM_MESSAGE_READ && markable != null && markable.getRemoteMsgId() != null) {
- Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": sending read marker to " + markable.getCounterpart().toString());
+ Logging.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": sending read marker to " + markable.getCounterpart().toString());
Account account = conversation.getAccount();
final Jid to = markable.getCounterpart();
MessagePacket packet = mMessageGenerator.confirm(account, to, markable.getRemoteMsgId());
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/StartConversationActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/StartConversationActivity.java
index 4cd24a4b..6a5d47c2 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/StartConversationActivity.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/StartConversationActivity.java
@@ -24,7 +24,7 @@ import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.Editable;
import android.text.TextWatcher;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
@@ -615,12 +615,12 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
switch (intent.getAction()) {
case Intent.ACTION_SENDTO:
case Intent.ACTION_VIEW:
- Log.d(Config.LOGTAG, "received uri=" + intent.getData());
+ Logging.d(Config.LOGTAG, "received uri=" + intent.getData());
return new Invite(intent.getData()).invite();
case NfcAdapter.ACTION_NDEF_DISCOVERED:
for (Parcelable message : getIntent().getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)) {
if (message instanceof NdefMessage) {
- Log.d(Config.LOGTAG, "received message=" + message);
+ Logging.d(Config.LOGTAG, "received message=" + message);
for (NdefRecord record : ((NdefMessage) message).getRecords()) {
switch (record.getTnf()) {
case NdefRecord.TNF_WELL_KNOWN:
@@ -652,7 +652,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
Contact contact = contacts.get(0);
if (invite.getFingerprint() != null) {
if (contact.addOtrFingerprint(invite.getFingerprint())) {
- Log.d(Config.LOGTAG,"added new fingerprint");
+ Logging.d(Config.LOGTAG,"added new fingerprint");
xmppConnectionService.syncRosterToDisk(contact.getAccount());
}
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java
index 97582fc7..15a614d4 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java
@@ -37,7 +37,7 @@ import android.os.IBinder;
import android.os.SystemClock;
import android.text.InputType;
import android.util.DisplayMetrics;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -797,7 +797,7 @@ public abstract class XmppActivity extends Activity {
}
protected Bitmap createQrCodeBitmap(String input, int size) {
- Log.d(Config.LOGTAG,"qr code requested size: "+size);
+ Logging.d(Config.LOGTAG,"qr code requested size: "+size);
try {
final QRCodeWriter QR_CODE_WRITER = new QRCodeWriter();
final Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
@@ -813,7 +813,7 @@ public abstract class XmppActivity extends Activity {
}
}
final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- Log.d(Config.LOGTAG,"output size: "+width+"x"+height);
+ Logging.d(Config.LOGTAG,"output size: "+width+"x"+height);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
} catch (final WriterException e) {
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 56e1baa4..abb77993 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,7 @@ import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
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 16939a1b..670fb9ee 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
@@ -2,7 +2,7 @@ package de.thedevstack.conversationsplus.ui.dialogs;
import android.app.Activity;
import android.text.format.DateFormat;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import android.view.View;
import android.widget.TextView;
@@ -145,7 +145,7 @@ public class MessageDetailsDialog extends AbstractAlertDialog {
String me = conversation.getAccount().getJid().getResourcepart();
// Get resource name of chat partner, if available
String other = (message.getCounterpart().isBareJid()) ? "" : message.getCounterpart().getResourcepart();
- Log.d("MesageDialog", "Me: " + me + ", other: " + other);
+ Logging.d("MesageDialog", "Me: " + me + ", other: " + other);
TextView sender = (TextView) view.findViewById(R.id.dlgMsgDetSender);
TextView receipient = (TextView) view.findViewById(R.id.dlgMsgDetReceipient);
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 05591b74..84203bf4 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java
@@ -1,7 +1,7 @@
package de.thedevstack.conversationsplus.ui.listeners;
import android.support.v4.widget.SwipeRefreshLayout;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import android.widget.ListView;
import java.util.List;
@@ -28,7 +28,7 @@ public class ConversationSwipeRefreshListener implements SwipeRefreshLayout.OnRe
@Override
public void onRefresh() {
- Log.d(Config.LOGTAG, "Refresh swipe container");
+ Logging.d(Config.LOGTAG, "Refresh swipe container");
synchronized (this.messageList) {
long timestamp;
if (messageList.isEmpty()) {
@@ -39,6 +39,6 @@ public class ConversationSwipeRefreshListener implements SwipeRefreshLayout.OnRe
ConversationActivity activity = (ConversationActivity) fragment.getActivity();
activity.xmppConnectionService.loadMoreMessages(activity.getSelectedConversation(), timestamp, this.listener);
}
- Log.d(Config.LOGTAG, "End Refresh swipe container");
+ Logging.d(Config.LOGTAG, "End Refresh swipe container");
}
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java b/src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java
new file mode 100644
index 00000000..65b3b1b3
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java
@@ -0,0 +1,31 @@
+package de.thedevstack.conversationsplus.ui.preferences;
+
+import android.content.Context;
+import android.content.Intent;
+import android.preference.Preference;
+import android.util.AttributeSet;
+
+import de.thedevstack.android.logcat.ui.LogCatOutputActivity;
+
+/**
+ * Created by tzur on 07.10.2015.
+ */
+public class LogInformationPreference extends Preference {
+ public LogInformationPreference(final Context context, final AttributeSet attrs, final int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ public LogInformationPreference(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ }
+ public LogInformationPreference(Context context) {
+ super(context);
+ }
+
+ @Override
+ protected void onClick() {
+ super.onClick();
+ final Intent intent = new Intent(getContext(), LogCatOutputActivity.class);
+ getContext().startActivity(intent);
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java
index 287f4b50..87b9eb32 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java
@@ -4,7 +4,7 @@ import android.graphics.Bitmap;
import android.net.Uri;
import android.util.Base64;
import android.util.Base64OutputStream;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -100,7 +100,7 @@ public final class AvatarUtil {
if (sha1sum.equals(avatar.sha1sum)) {
file.renameTo(new File(filename));
} else {
- Log.d(Config.LOGTAG, "sha1sum mismatch for " + avatar.owner);
+ Logging.d(Config.LOGTAG, "sha1sum mismatch for " + avatar.owner);
file.delete();
return false;
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/DNSHelper.java b/src/main/java/de/thedevstack/conversationsplus/utils/DNSHelper.java
index 8951426f..bd7a6623 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/DNSHelper.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/DNSHelper.java
@@ -23,7 +23,7 @@ import java.util.TreeMap;
import java.util.regex.Pattern;
import android.os.Bundle;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
public class DNSHelper {
@@ -55,7 +55,7 @@ public class DNSHelper {
Bundle bundle = new Bundle();
try {
String qname = "_xmpp-client._tcp." + host;
- Log.d(Config.LOGTAG, "using dns server: " + dnsServer.getHostAddress() + " to look up " + host);
+ Logging.d(Config.LOGTAG, "using dns server: " + dnsServer.getHostAddress() + " to look up " + host);
DNSMessage message = client.query(qname, TYPE.SRV, CLASS.IN, dnsServer.getHostAddress());
TreeMap<Integer, ArrayList<SRV>> priorities = new TreeMap<>();
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/ExceptionHelper.java b/src/main/java/de/thedevstack/conversationsplus/utils/ExceptionHelper.java
index d25e6d35..999d1027 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/ExceptionHelper.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/ExceptionHelper.java
@@ -26,7 +26,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.preference.PreferenceManager;
import android.text.format.DateUtils;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
public class ExceptionHelper {
public static void init(Context context) {
@@ -87,7 +87,7 @@ public class ExceptionHelper {
@Override
public void onClick(DialogInterface dialog, int which) {
- Log.d(Config.LOGTAG, "using account="
+ Logging.d(Config.LOGTAG, "using account="
+ finalAccount.getJid().toBareJid()
+ " to send in stack trace");
Conversation conversation = null;
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/ExifHelper.java b/src/main/java/de/thedevstack/conversationsplus/utils/ExifHelper.java
index 13aff60d..7aaf8b0b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/ExifHelper.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/ExifHelper.java
@@ -16,7 +16,7 @@
package de.thedevstack.conversationsplus.utils;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import java.io.IOException;
import java.io.InputStream;
@@ -56,7 +56,7 @@ public class ExifHelper {
}
length = pack(buf, 0, 2, false);
if (length < 2) {
- Log.e(TAG, "Invalid length");
+ Logging.e(TAG, "Invalid length");
return 0;
}
length -= 2;
@@ -91,7 +91,7 @@ public class ExifHelper {
// Identify the byte order.
int tag = pack(jpeg, offset, 4, false);
if (tag != 0x49492A00 && tag != 0x4D4D002A) {
- Log.e(TAG, "Invalid byte order");
+ Logging.e(TAG, "Invalid byte order");
return 0;
}
boolean littleEndian = (tag == 0x49492A00);
@@ -99,7 +99,7 @@ public class ExifHelper {
// Get the offset and check if it is reasonable.
int count = pack(jpeg, offset + 4, 4, littleEndian) + 2;
if (count < 10 || count > length) {
- Log.e(TAG, "Invalid offset");
+ Logging.e(TAG, "Invalid offset");
return 0;
}
offset += count;
@@ -123,7 +123,7 @@ public class ExifHelper {
case 8:
return 270;
}
- Log.i(TAG, "Unsupported orientation");
+ Logging.i(TAG, "Unsupported orientation");
return 0;
}
offset += 12;
@@ -131,7 +131,7 @@ public class ExifHelper {
}
}
- Log.i(TAG, "Orientation not found");
+ Logging.i(TAG, "Orientation not found");
return 0;
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java
index 3c3e1c99..1d126db5 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java
@@ -7,7 +7,7 @@ import android.graphics.Matrix;
import android.graphics.RectF;
import android.media.ExifInterface;
import android.net.Uri;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import android.util.LruCache;
import java.io.File;
@@ -66,7 +66,7 @@ public final class ImageUtil {
* @see LruCache#LruCache(int) for details
*/
public static void initBitmapCache() {
- Log.i("Conversations+ImageUtil", "Initializing BitmapCache");
+ Logging.i("Conversations+ImageUtil", "Initializing BitmapCache");
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
final int cacheSize = maxMemory / 8;
BITMAP_CACHE = new LruCache<String, Bitmap>(cacheSize) {
@@ -177,7 +177,7 @@ public final class ImageUtil {
return rotate(original, rotation);
}
} catch (IOException e) {
- Log.w("filebackend", "Error while rotating image, returning original (" + e.getMessage() + ")");
+ Logging.w("filebackend", "Error while rotating image, returning original (" + e.getMessage() + ")");
}
return original;
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/Logging.java b/src/main/java/de/thedevstack/conversationsplus/utils/Logging.java
new file mode 100644
index 00000000..40ec66a0
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/Logging.java
@@ -0,0 +1,124 @@
+package de.thedevstack.conversationsplus.utils;
+
+import android.util.Log;
+
+/**
+ * Created by tzur on 20.11.2015.
+ */
+public class Logging {
+ protected static final String LOG_TAG_PREFIX = "thedevstack.";
+ /**
+ * Send a {@link Log#VERBOSE} log message.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param msg The message you would like logged.
+ */
+ public static int v(String tag, String msg) {
+ return Log.v(Logging.LOG_TAG_PREFIX + tag, msg);
+ }
+
+ /**
+ * Send a {@link Log#VERBOSE} log message and log the exception.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param msg The message you would like logged.
+ * @param tr An exception to log
+ */
+ public static int v(String tag, String msg, Throwable tr) {
+ return Log.v(Logging.LOG_TAG_PREFIX + tag, msg + '\n' + Log.getStackTraceString(tr));
+ }
+
+ /**
+ * Send a {@link Log#DEBUG} log message.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param msg The message you would like logged.
+ */
+ public static int d(String tag, String msg) {
+ return Log.d(Logging.LOG_TAG_PREFIX + tag, msg);
+ }
+
+ /**
+ * Send a {@link Log#DEBUG} log message and log the exception.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param msg The message you would like logged.
+ * @param tr An exception to log
+ */
+ public static int d(String tag, String msg, Throwable tr) {
+ return Log.d(Logging.LOG_TAG_PREFIX + tag, msg + '\n' + Log.getStackTraceString(tr));
+ }
+
+ /**
+ * Send an {@link Log#INFO} log message.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param msg The message you would like logged.
+ */
+ public static int i(String tag, String msg) {
+ return Log.i(Logging.LOG_TAG_PREFIX + tag, msg);
+ }
+
+ /**
+ * Send a {@link Log#INFO} log message and log the exception.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param msg The message you would like logged.
+ * @param tr An exception to log
+ */
+ public static int i(String tag, String msg, Throwable tr) {
+ return Log.i(Logging.LOG_TAG_PREFIX + tag, msg + '\n' + Log.getStackTraceString(tr));
+ }
+
+ /**
+ * Send a {@link Log#WARN} log message.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param msg The message you would like logged.
+ */
+ public static int w(String tag, String msg) {
+ return Log.w(Logging.LOG_TAG_PREFIX + tag, msg);
+ }
+
+ /**
+ * Send a {@link Log#WARN} log message and log the exception.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param msg The message you would like logged.
+ * @param tr An exception to log
+ */
+ public static int w(String tag, String msg, Throwable tr) {
+ return Log.w(Logging.LOG_TAG_PREFIX + tag, msg + '\n' + Log.getStackTraceString(tr));
+ }
+
+ /*
+ * Send a {@link #WARN} log message and log the exception.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param tr An exception to log
+ */
+ public static int w(String tag, Throwable tr) {
+ return Log.w(Logging.LOG_TAG_PREFIX + tag, Log.getStackTraceString(tr));
+ }
+
+ /**
+ * Send an {@link Log#ERROR} log message.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param msg The message you would like logged.
+ */
+ public static int e(String tag, String msg) {
+ return Log.e(Logging.LOG_TAG_PREFIX + tag, msg);
+ }
+
+ /**
+ * Send a {@link Log#ERROR} log message and log the exception.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param msg The message you would like logged.
+ * @param tr An exception to log
+ */
+ public static int e(String tag, String msg, Throwable tr) {
+ return Log.e(Logging.LOG_TAG_PREFIX + tag, msg + '\n' + Log.getStackTraceString(tr));
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/PRNGFixes.java b/src/main/java/de/thedevstack/conversationsplus/utils/PRNGFixes.java
index 78776aeb..ca4d65ff 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/PRNGFixes.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/PRNGFixes.java
@@ -2,7 +2,7 @@ package de.thedevstack.conversationsplus.utils;
import android.os.Build;
import android.os.Process;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
@@ -209,7 +209,7 @@ public final class PRNGFixes {
} catch (IOException e) {
// On a small fraction of devices /dev/urandom is not writable.
// Log and ignore.
- Log.w(PRNGFixes.class.getSimpleName(),
+ Logging.w(PRNGFixes.class.getSimpleName(),
"Failed to mix seed into " + URANDOM_FILE);
} finally {
mSeeded = true;
diff --git a/src/main/java/de/thedevstack/conversationsplus/xml/Element.java b/src/main/java/de/thedevstack/conversationsplus/xml/Element.java
index ca5d70cb..88b20e14 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xml/Element.java
+++ b/src/main/java/de/thedevstack/conversationsplus/xml/Element.java
@@ -1,6 +1,6 @@
package de.thedevstack.conversationsplus.xml;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import java.util.ArrayList;
import java.util.Hashtable;
@@ -124,7 +124,7 @@ public class Element {
try {
return Jid.fromString(jid);
} catch (final InvalidJidException e) {
- Log.e(Config.LOGTAG, "could not parse jid " + jid);
+ Logging.e(Config.LOGTAG, "could not parse jid " + jid);
return null;
}
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xml/XmlReader.java b/src/main/java/de/thedevstack/conversationsplus/xml/XmlReader.java
index d7f6edf5..2eea0571 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xml/XmlReader.java
+++ b/src/main/java/de/thedevstack/conversationsplus/xml/XmlReader.java
@@ -11,7 +11,7 @@ import de.thedevstack.conversationsplus.Config;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import android.util.Xml;
public class XmlReader {
@@ -25,7 +25,7 @@ public class XmlReader {
this.parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES,
true);
} catch (XmlPullParserException e) {
- Log.d(Config.LOGTAG, "error setting namespace feature on parser");
+ Logging.d(Config.LOGTAG, "error setting namespace feature on parser");
}
this.wakeLock = wakeLock;
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/XmppConnection.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/XmppConnection.java
index 79556a0a..2b084d4b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xmpp/XmppConnection.java
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/XmppConnection.java
@@ -6,7 +6,7 @@ import android.os.Parcelable;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.SystemClock;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import android.util.Pair;
import android.util.SparseArray;
@@ -142,7 +142,7 @@ public class XmppConnection implements Runnable {
}
protected void connect() {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": connecting");
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": connecting");
features.encryptionEnabled = false;
lastConnect = SystemClock.elapsedRealtime();
lastPingSent = SystemClock.elapsedRealtime();
@@ -183,12 +183,12 @@ public class XmppConnection implements Runnable {
final InetSocketAddress addr;
if (srvIpServer != null) {
addr = new InetSocketAddress(srvIpServer, srvRecordPort);
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": using values from dns " + srvRecordServer
+ "[" + srvIpServer + "]:" + srvRecordPort);
} else {
addr = new InetSocketAddress(srvRecordServer, srvRecordPort);
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": using values from dns "
+ srvRecordServer + ":" + srvRecordPort);
}
@@ -196,10 +196,10 @@ public class XmppConnection implements Runnable {
socket.connect(addr, Config.SOCKET_TIMEOUT * 1000);
socketError = false;
} catch (final UnknownHostException e) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
i++;
} catch (final IOException e) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
i++;
}
}
@@ -237,7 +237,7 @@ public class XmppConnection implements Runnable {
} catch (final UnknownHostException | ConnectException e) {
this.changeStatus(Account.State.SERVER_NOT_FOUND);
} catch (final IOException | XmlPullParserException | NoSuchAlgorithmException e) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
this.changeStatus(Account.State.OFFLINE);
this.attempt--; //don't count attempt when reconnecting instantly anyway
} finally {
@@ -286,9 +286,9 @@ public class XmppConnection implements Runnable {
saslMechanism.getResponse(challenge);
} catch (final SaslMechanism.AuthenticationException e) {
disconnect(true);
- Log.e(Config.LOGTAG, String.valueOf(e));
+ Logging.e(Config.LOGTAG, String.valueOf(e));
}
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": logged in");
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": logged in");
account.setKey(Account.PINNED_MECHANISM_KEY,
String.valueOf(saslMechanism.getPriority()));
tagReader.reset();
@@ -306,18 +306,18 @@ public class XmppConnection implements Runnable {
response.setContent(saslMechanism.getResponse(challenge));
} catch (final SaslMechanism.AuthenticationException e) {
// TODO: Send auth abort tag.
- Log.e(Config.LOGTAG, e.toString());
+ Logging.e(Config.LOGTAG, e.toString());
}
tagWriter.writeElement(response);
} else if (nextTag.isStart("enabled")) {
final Element enabled = tagReader.readElement(nextTag);
if ("true".equals(enabled.getAttribute("resume"))) {
this.streamId = enabled.getAttribute("id");
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": stream managment(" + smVersion
+ ") enabled (resumable)");
} else {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": stream managment(" + smVersion + ") enabled");
}
this.lastSessionStarted = SystemClock.elapsedRealtime();
@@ -331,11 +331,11 @@ public class XmppConnection implements Runnable {
try {
final int serverCount = Integer.parseInt(h);
if (serverCount != stanzasSent) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": session resumed with lost packages");
stanzasSent = serverCount;
} else {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": session resumed");
}
if (acknowledgedListener != null) {
@@ -356,7 +356,7 @@ public class XmppConnection implements Runnable {
} else if (nextTag.isStart("r")) {
tagReader.readElement(nextTag);
if (Config.EXTENDED_SM_LOGGING) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": acknowledging stanza #" + this.stanzasReceived);
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid() + ": acknowledging stanza #" + this.stanzasReceived);
}
final AckPacket ack = new AckPacket(this.stanzasReceived, smVersion);
tagWriter.writeStanzaAsync(ack);
@@ -366,7 +366,7 @@ public class XmppConnection implements Runnable {
try {
final int serverSequence = Integer.parseInt(ack.getAttribute("h"));
if (Config.EXTENDED_SM_LOGGING) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": server acknowledged stanza #" + serverSequence);
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid() + ": server acknowledged stanza #" + serverSequence);
}
final String msgId = this.messageReceipts.get(serverSequence);
if (msgId != null) {
@@ -377,11 +377,11 @@ public class XmppConnection implements Runnable {
this.messageReceipts.remove(serverSequence);
}
} catch (NumberFormatException e) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": server send ack without sequence number");
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": server send ack without sequence number");
}
} else if (nextTag.isStart("failed")) {
tagReader.readElement(nextTag);
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": resumption failed");
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": resumption failed");
streamId = null;
if (account.getStatus() != Account.State.ONLINE) {
sendBindRequest();
@@ -404,14 +404,14 @@ public class XmppConnection implements Runnable {
}
private void sendInitialPing() {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": sending intial ping");
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": sending intial ping");
final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
iq.setFrom(account.getJid());
iq.addChild("ping", "urn:xmpp:ping");
this.sendIqPacket(iq, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(final Account account, final IqPacket packet) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": online with resource " + account.getResource());
changeStatus(Account.State.ONLINE);
}
@@ -486,14 +486,14 @@ public class XmppConnection implements Runnable {
packetCallbackDuple.second.onIqPacketReceived(account, packet);
packetCallbacks.remove(packet.getId());
} else {
- Log.e(Config.LOGTAG,account.getJid().toBareJid().toString()+": ignoring spoofed iq packet");
+ Logging.e(Config.LOGTAG,account.getJid().toBareJid().toString()+": ignoring spoofed iq packet");
}
} else {
if (packet.getFrom().equals(packetCallbackDuple.first.getTo())) {
packetCallbackDuple.second.onIqPacketReceived(account, packet);
packetCallbacks.remove(packet.getId());
} else {
- Log.e(Config.LOGTAG,account.getJid().toBareJid().toString()+": ignoring spoofed iq packet");
+ Logging.e(Config.LOGTAG,account.getJid().toBareJid().toString()+": ignoring spoofed iq packet");
}
}
} else if (packet.getType() == IqPacket.TYPE.GET|| packet.getType() == IqPacket.TYPE.SET) {
@@ -547,24 +547,24 @@ public class XmppConnection implements Runnable {
final String[] cipherSuites = CryptoHelper.getOrderedCipherSuites(
sslSocket.getSupportedCipherSuites());
- //Log.d(Config.LOGTAG, "Using ciphers: " + Arrays.toString(cipherSuites));
+ //Logging.d(Config.LOGTAG, "Using ciphers: " + Arrays.toString(cipherSuites));
if (cipherSuites.length > 0) {
sslSocket.setEnabledCipherSuites(cipherSuites);
}
if (!verifier.verify(account.getServer().getDomainpart(),sslSocket.getSession())) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": TLS certificate verification failed");
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": TLS certificate verification failed");
throw new SecurityException();
}
tagReader.setInputStream(sslSocket.getInputStream());
tagWriter.setOutputStream(sslSocket.getOutputStream());
sendStartStream();
- Log.d(Config.LOGTAG, account.getJid().toBareJid()+ ": TLS connection established");
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()+ ": TLS connection established");
features.encryptionEnabled = true;
processStream(tagReader.readTag());
sslSocket.close();
} catch (final NoSuchAlgorithmException | KeyManagementException e1) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": TLS certificate verification failed");
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": TLS certificate verification failed");
throw new SecurityException();
}
}
@@ -600,16 +600,16 @@ public class XmppConnection implements Runnable {
try {
if (keys.has(Account.PINNED_MECHANISM_KEY) &&
keys.getInt(Account.PINNED_MECHANISM_KEY) > saslMechanism.getPriority()) {
- Log.e(Config.LOGTAG, "Auth failed. Authentication mechanism " + saslMechanism.getMechanism() +
+ Logging.e(Config.LOGTAG, "Auth failed. Authentication mechanism " + saslMechanism.getMechanism() +
" has lower priority (" + String.valueOf(saslMechanism.getPriority()) +
") than pinned priority (" + keys.getInt(Account.PINNED_MECHANISM_KEY) +
"). Possible downgrade attack?");
throw new SecurityException();
}
} catch (final JSONException e) {
- Log.d(Config.LOGTAG, "Parse error while checking pinned auth mechanism");
+ Logging.d(Config.LOGTAG, "Parse error while checking pinned auth mechanism");
}
- Log.d(Config.LOGTAG, account.getJid().toString() + ": Authenticating with " + saslMechanism.getMechanism());
+ Logging.d(Config.LOGTAG, account.getJid().toString() + ": Authenticating with " + saslMechanism.getMechanism());
auth.setAttribute("mechanism", saslMechanism.getMechanism());
if (!saslMechanism.getClientFirstMessage().isEmpty()) {
auth.setContent(saslMechanism.getClientFirstMessage());
@@ -622,7 +622,7 @@ public class XmppConnection implements Runnable {
+ smVersion)
&& streamId != null) {
if (Config.EXTENDED_SM_LOGGING) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": resuming after stanza #"+stanzasReceived);
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": resuming after stanza #"+stanzasReceived);
}
final ResumePacket resume = new ResumePacket(this.streamId, stanzasReceived, smVersion);
this.tagWriter.writeStanzaAsync(resume);
@@ -673,7 +673,7 @@ public class XmppConnection implements Runnable {
changeStatus(Account.State.REGISTRATION_CONFLICT);
} else {
changeStatus(Account.State.REGISTRATION_FAILED);
- Log.d(Config.LOGTAG, packet.toString());
+ Logging.d(Config.LOGTAG, packet.toString());
}
disconnect(true);
}
@@ -681,7 +681,7 @@ public class XmppConnection implements Runnable {
} else {
changeStatus(Account.State.REGISTRATION_FAILED);
disconnect(true);
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": could not register. instructions are"
+ (instructions != null ? instructions.getContent() : ""));
}
@@ -810,7 +810,7 @@ public class XmppConnection implements Runnable {
sendEnableCarbons();
}
if (getFeatures().blocking() && !features.blockListRequested) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": Requesting block list");
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": Requesting block list");
this.sendIqPacket(getIqGenerator().generateGetBlockList(), mXmppConnectionService.getIqParser());
}
}
@@ -844,11 +844,11 @@ public class XmppConnection implements Runnable {
@Override
public void onIqPacketReceived(final Account account, final IqPacket packet) {
if (!packet.hasChild("error")) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": successfully enabled carbons");
features.carbonsEnabled = true;
} else {
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": error enableing carbons " + packet.toString());
}
}
@@ -861,7 +861,7 @@ public class XmppConnection implements Runnable {
if (streamError != null && streamError.hasChild("conflict")) {
final String resource = account.getResource().split("\\.")[0];
account.setResource(resource + "." + nextRandomId());
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
account.getJid().toBareJid() + ": switching resource due to conflict ("
+ account.getResource() + ")");
}
@@ -923,7 +923,7 @@ public class XmppConnection implements Runnable {
tagWriter.writeStanzaAsync(packet);
if (packet instanceof MessagePacket && packet.getId() != null && getFeatures().sm()) {
if (Config.EXTENDED_SM_LOGGING) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": requesting ack for message stanza #" + stanzasSent);
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid() + ": requesting ack for message stanza #" + stanzasSent);
}
this.messageReceipts.put(stanzasSent, packet.getId());
tagWriter.writeStanzaAsync(new RequestPacket(this.smVersion));
@@ -981,7 +981,7 @@ public class XmppConnection implements Runnable {
}
public void disconnect(final boolean force) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": disconnecting");
+ Logging.d(Config.LOGTAG, account.getJid().toBareJid() + ": disconnecting");
try {
if (force) {
socket.close();
@@ -995,22 +995,22 @@ public class XmppConnection implements Runnable {
tagWriter.finish();
try {
while (!tagWriter.finished()) {
- Log.d(Config.LOGTAG, "not yet finished");
+ Logging.d(Config.LOGTAG, "not yet finished");
Thread.sleep(100);
}
tagWriter.writeTag(Tag.end("stream:stream"));
socket.close();
} catch (final IOException e) {
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
"io exception during disconnect");
} catch (final InterruptedException e) {
- Log.d(Config.LOGTAG, "interrupted");
+ Logging.d(Config.LOGTAG, "interrupted");
}
}
}
}).start();
} catch (final IOException e) {
- Log.d(Config.LOGTAG, "io exception during disconnect");
+ Logging.d(Config.LOGTAG, "io exception during disconnect");
}
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java
index 94a0d2d7..e3a599d7 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java
@@ -11,7 +11,7 @@ import java.util.concurrent.ConcurrentHashMap;
import android.content.Intent;
import android.net.Uri;
import android.os.SystemClock;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
import de.thedevstack.conversationsplus.entities.Account;
@@ -100,7 +100,7 @@ public class JingleConnection implements Transferable {
file.delete();
}
}
- Log.d(Config.LOGTAG,"successfully transmitted file:" + file.getAbsolutePath()+" ("+file.getSha1Sum()+")");
+ Logging.d(Config.LOGTAG,"successfully transmitted file:" + file.getAbsolutePath()+" ("+file.getSha1Sum()+")");
if (message.getEncryption() != Message.ENCRYPTION_PGP) {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(file));
@@ -120,17 +120,17 @@ public class JingleConnection implements Transferable {
@Override
public void success() {
if (initiator.equals(account.getJid())) {
- Log.d(Config.LOGTAG, "we were initiating. sending file");
+ Logging.d(Config.LOGTAG, "we were initiating. sending file");
transport.send(file, onFileTransmissionSatusChanged);
} else {
transport.receive(file, onFileTransmissionSatusChanged);
- Log.d(Config.LOGTAG, "we were responding. receiving file");
+ Logging.d(Config.LOGTAG, "we were responding. receiving file");
}
}
@Override
public void failed() {
- Log.d(Config.LOGTAG, "proxy activation failed");
+ Logging.d(Config.LOGTAG, "proxy activation failed");
}
};
@@ -176,13 +176,13 @@ public class JingleConnection implements Transferable {
returnResult = this.receiveFallbackToIbb(packet);
} else {
returnResult = false;
- Log.d(Config.LOGTAG, "trying to fallback to something unknown"
+ Logging.d(Config.LOGTAG, "trying to fallback to something unknown"
+ packet.toString());
}
} else if (packet.isAction("transport-accept")) {
returnResult = this.receiveTransportAccept(packet);
} else {
- Log.d(Config.LOGTAG, "packet arrived in connection. action was "
+ Logging.d(Config.LOGTAG, "packet arrived in connection. action was "
+ packet.getAction());
returnResult = false;
}
@@ -225,14 +225,14 @@ public class JingleConnection implements Transferable {
@Override
public void failed() {
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
"connection to our own primary candidete failed");
sendInitRequest();
}
@Override
public void established() {
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
"succesfully connected to our own primary candidate");
mergeCandidate(candidate);
sendInitRequest();
@@ -240,7 +240,7 @@ public class JingleConnection implements Transferable {
});
mergeCandidate(candidate);
} else {
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
"no primary candidate of our own was found");
sendInitRequest();
}
@@ -323,13 +323,13 @@ public class JingleConnection implements Transferable {
mXmppConnectionService.updateConversationUi();
if (size <= ConversationsPlusPreferences.autoAcceptFileSize()
&& mXmppConnectionService.isDownloadAllowedInConnection()) {
- Log.d(Config.LOGTAG, "auto accepting file from "
+ Logging.d(Config.LOGTAG, "auto accepting file from "
+ packet.getFrom());
this.acceptedAutomatically = true;
this.sendAccept();
} else {
message.markUnread();
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
"not auto accepting new file offer with size: "
+ size
+ " allowed size:"
@@ -368,7 +368,7 @@ public class JingleConnection implements Transferable {
if (message.getEncryption() == Message.ENCRYPTION_OTR) {
Conversation conversation = this.message.getConversation();
if (!this.mXmppConnectionService.renewSymmetricKey(conversation)) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not set symmetric key");
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": could not set symmetric key");
cancel();
}
content.setFileOffer(this.file, true);
@@ -385,7 +385,7 @@ public class JingleConnection implements Transferable {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() != IqPacket.TYPE.ERROR) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": other party received offer");
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": other party received offer");
mJingleStatus = JINGLE_STATUS_INITIATED;
mXmppConnectionService.markMessage(message, Message.STATUS_OFFERED);
} else {
@@ -427,7 +427,7 @@ public class JingleConnection implements Transferable {
@Override
public void failed() {
- Log.d(Config.LOGTAG,"connection to our own primary candidate failed");
+ Logging.d(Config.LOGTAG,"connection to our own primary candidate failed");
content.socks5transport().setChildren(getCandidatesAsElements());
packet.setContent(content);
sendJinglePacket(packet);
@@ -436,7 +436,7 @@ public class JingleConnection implements Transferable {
@Override
public void established() {
- Log.d(Config.LOGTAG, "connected to primary candidate");
+ Logging.d(Config.LOGTAG, "connected to primary candidate");
mergeCandidate(candidate);
content.socks5transport().setChildren(getCandidatesAsElements());
packet.setContent(content);
@@ -445,7 +445,7 @@ public class JingleConnection implements Transferable {
}
});
} else {
- Log.d(Config.LOGTAG,"did not find a primary candidate for ourself");
+ Logging.d(Config.LOGTAG,"did not find a primary candidate for ourself");
content.socks5transport().setChildren(getCandidatesAsElements());
packet.setContent(content);
sendJinglePacket(packet);
@@ -491,13 +491,13 @@ public class JingleConnection implements Transferable {
onProxyActivated.success();
} else {
String cid = content.socks5transport().findChild("activated").getAttribute("cid");
- Log.d(Config.LOGTAG, "received proxy activated (" + cid
+ Logging.d(Config.LOGTAG, "received proxy activated (" + cid
+ ")prior to choosing our own transport");
JingleSocks5Transport connection = this.connections.get(cid);
if (connection != null) {
connection.setActivated(true);
} else {
- Log.d(Config.LOGTAG, "activated connection not found");
+ Logging.d(Config.LOGTAG, "activated connection not found");
this.sendCancel();
this.fail();
}
@@ -507,7 +507,7 @@ public class JingleConnection implements Transferable {
onProxyActivated.failed();
return true;
} else if (content.socks5transport().hasChild("candidate-error")) {
- Log.d(Config.LOGTAG, "received candidate error");
+ Logging.d(Config.LOGTAG, "received candidate error");
this.receivedCandidate = true;
if ((mJingleStatus == JINGLE_STATUS_ACCEPTED)
&& (this.sentCandidate)) {
@@ -518,7 +518,7 @@ public class JingleConnection implements Transferable {
String cid = content.socks5transport()
.findChild("candidate-used").getAttribute("cid");
if (cid != null) {
- Log.d(Config.LOGTAG, "candidate used by counterpart:" + cid);
+ Logging.d(Config.LOGTAG, "candidate used by counterpart:" + cid);
JingleCandidate candidate = getCandidate(cid);
candidate.flagAsUsedByCounterpart();
this.receivedCandidate = true;
@@ -526,7 +526,7 @@ public class JingleConnection implements Transferable {
&& (this.sentCandidate)) {
this.connect();
} else {
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
"ignoring because file is already in transmission or we havent sent our candidate yet");
}
return true;
@@ -545,7 +545,7 @@ public class JingleConnection implements Transferable {
final JingleSocks5Transport connection = chooseConnection();
this.transport = connection;
if (connection == null) {
- Log.d(Config.LOGTAG, "could not find suitable candidate");
+ Logging.d(Config.LOGTAG, "could not find suitable candidate");
this.disconnectSocks5Connections();
if (this.initiator.equals(account.getJid())) {
this.sendFallbackToIbb();
@@ -554,7 +554,7 @@ public class JingleConnection implements Transferable {
this.mJingleStatus = JINGLE_STATUS_TRANSMITTING;
if (connection.needsActivation()) {
if (connection.getCandidate().isOurs()) {
- Log.d(Config.LOGTAG, "candidate "
+ Logging.d(Config.LOGTAG, "candidate "
+ connection.getCandidate().getCid()
+ " was our proxy. going to activate");
IqPacket activation = new IqPacket(IqPacket.TYPE.SET);
@@ -579,17 +579,17 @@ public class JingleConnection implements Transferable {
}
});
} else {
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
"candidate "
+ connection.getCandidate().getCid()
+ " was a proxy. waiting for other party to activate");
}
} else {
if (initiator.equals(account.getJid())) {
- Log.d(Config.LOGTAG, "we were initiating. sending file");
+ Logging.d(Config.LOGTAG, "we were initiating. sending file");
connection.send(file, onFileTransmissionSatusChanged);
} else {
- Log.d(Config.LOGTAG, "we were responding. receiving file");
+ Logging.d(Config.LOGTAG, "we were responding. receiving file");
connection.receive(file, onFileTransmissionSatusChanged);
}
}
@@ -601,11 +601,11 @@ public class JingleConnection implements Transferable {
for (Entry<String, JingleSocks5Transport> cursor : connections
.entrySet()) {
JingleSocks5Transport currentConnection = cursor.getValue();
- // Log.d(Config.LOGTAG,"comparing candidate: "+currentConnection.getCandidate().toString());
+ // Logging.d(Config.LOGTAG,"comparing candidate: "+currentConnection.getCandidate().toString());
if (currentConnection.isEstablished()
&& (currentConnection.getCandidate().isUsedByCounterpart() || (!currentConnection
.getCandidate().isOurs()))) {
- // Log.d(Config.LOGTAG,"is usable");
+ // Logging.d(Config.LOGTAG,"is usable");
if (connection == null) {
connection = currentConnection;
} else {
@@ -614,7 +614,7 @@ public class JingleConnection implements Transferable {
connection = currentConnection;
} else if (connection.getCandidate().getPriority() == currentConnection
.getCandidate().getPriority()) {
- // Log.d(Config.LOGTAG,"found two candidates with same priority");
+ // Logging.d(Config.LOGTAG,"found two candidates with same priority");
if (initiator.equals(account.getJid())) {
if (currentConnection.getCandidate().isOurs()) {
connection = currentConnection;
@@ -646,7 +646,7 @@ public class JingleConnection implements Transferable {
}
private void sendFallbackToIbb() {
- Log.d(Config.LOGTAG, "sending fallback to ibb");
+ Logging.d(Config.LOGTAG, "sending fallback to ibb");
JinglePacket packet = this.bootstrapPacket("transport-replace");
Content content = new Content(this.contentCreator, this.contentName);
this.transportId = this.mJingleConnectionManager.nextRandomId();
@@ -658,7 +658,7 @@ public class JingleConnection implements Transferable {
}
private boolean receiveFallbackToIbb(JinglePacket packet) {
- Log.d(Config.LOGTAG, "receiving fallack to ibb");
+ Logging.d(Config.LOGTAG, "receiving fallack to ibb");
String receivedBlockSize = packet.getJingleContent().ibbTransport()
.getAttribute("block-size");
if (receivedBlockSize != null) {
@@ -695,7 +695,7 @@ public class JingleConnection implements Transferable {
@Override
public void failed() {
- Log.d(Config.LOGTAG, "ibb open failed");
+ Logging.d(Config.LOGTAG, "ibb open failed");
}
@Override
@@ -790,7 +790,7 @@ public class JingleConnection implements Transferable {
@Override
public void failed() {
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
"connection failed with " + candidate.getHost() + ":"
+ candidate.getPort());
connectNextCandidate();
@@ -798,7 +798,7 @@ public class JingleConnection implements Transferable {
@Override
public void established() {
- Log.d(Config.LOGTAG,
+ Logging.d(Config.LOGTAG,
"established connection with " + candidate.getHost()
+ ":" + candidate.getPort());
sendCandidateUsed(candidate.getCid());
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnectionManager.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnectionManager.java
index 8c2a9216..f10d7c7e 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnectionManager.java
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnectionManager.java
@@ -6,7 +6,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import android.annotation.SuppressLint;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.entities.Account;
import de.thedevstack.conversationsplus.entities.Transferable;
@@ -154,9 +154,9 @@ public class JingleConnectionManager extends AbstractConnectionManager {
}
}
}
- Log.d(Config.LOGTAG,"couldn't deliver payload: " + payload.toString());
+ Logging.d(Config.LOGTAG,"couldn't deliver payload: " + payload.toString());
} else {
- Log.d(Config.LOGTAG, "no sid found in incoming ibb packet");
+ Logging.d(Config.LOGTAG, "no sid found in incoming ibb packet");
}
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleInbandTransport.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleInbandTransport.java
index 94cce09f..db22f8c3 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleInbandTransport.java
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleInbandTransport.java
@@ -8,7 +8,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import android.util.Base64;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.entities.Account;
@@ -96,13 +96,13 @@ public class JingleInbandTransport extends JingleTransport {
file.createNewFile();
this.fileOutputStream = file.createOutputStream();
if (this.fileOutputStream == null) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not create output stream");
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": could not create output stream");
callback.onFileTransferAborted();
return;
}
this.remainingSize = this.fileSize = file.getExpectedSize();
} catch (final NoSuchAlgorithmException | IOException e) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+" "+e.getMessage());
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+" "+e.getMessage());
callback.onFileTransferAborted();
}
}
@@ -123,7 +123,7 @@ public class JingleInbandTransport extends JingleTransport {
this.digest.reset();
fileInputStream = this.file.createInputStream();
if (fileInputStream == null) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could no create input stream");
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": could no create input stream");
callback.onFileTransferAborted();
return;
}
@@ -132,7 +132,7 @@ public class JingleInbandTransport extends JingleTransport {
}
} catch (NoSuchAlgorithmException e) {
callback.onFileTransferAborted();
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": "+e.getMessage());
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": "+e.getMessage());
}
}
@@ -190,7 +190,7 @@ public class JingleInbandTransport extends JingleTransport {
fileInputStream.close();
}
} catch (IOException e) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": "+e.getMessage());
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": "+e.getMessage());
StreamUtil.close(fileInputStream);
this.onFileTransmissionStatusChanged.onFileTransferAborted();
}
@@ -214,7 +214,7 @@ public class JingleInbandTransport extends JingleTransport {
connection.updateProgress((int) ((((double) (this.fileSize - this.remainingSize)) / this.fileSize) * 100));
}
} catch (IOException e) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": "+e.getMessage());
+ Logging.d(Config.LOGTAG,account.getJid().toBareJid()+": "+e.getMessage());
StreamUtil.close(fileOutputStream);
this.onFileTransmissionStatusChanged.onFileTransferAborted();
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleSocks5Transport.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleSocks5Transport.java
index 72a5d7cb..20f2b45a 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleSocks5Transport.java
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleSocks5Transport.java
@@ -1,6 +1,6 @@
package de.thedevstack.conversationsplus.xmpp.jingle;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -109,7 +109,7 @@ public class JingleSocks5Transport extends JingleTransport {
digest.reset();
fileInputStream = file.createInputStream();
if (fileInputStream == null) {
- Log.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": could not create input stream");
+ Logging.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": could not create input stream");
callback.onFileTransferAborted();
return;
}
@@ -129,13 +129,13 @@ public class JingleSocks5Transport extends JingleTransport {
callback.onFileTransmitted(file);
}
} catch (FileNotFoundException e) {
- Log.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
+ Logging.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
callback.onFileTransferAborted();
} catch (IOException e) {
- Log.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
+ Logging.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
callback.onFileTransferAborted();
} catch (NoSuchAlgorithmException e) {
- Log.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
+ Logging.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
callback.onFileTransferAborted();
} finally {
StreamUtil.close(fileInputStream);
@@ -161,7 +161,7 @@ public class JingleSocks5Transport extends JingleTransport {
fileOutputStream = file.createOutputStream();
if (fileOutputStream == null) {
callback.onFileTransferAborted();
- Log.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": could not create output stream");
+ Logging.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": could not create output stream");
return;
}
double size = file.getExpectedSize();
@@ -172,7 +172,7 @@ public class JingleSocks5Transport extends JingleTransport {
count = inputStream.read(buffer);
if (count == -1) {
callback.onFileTransferAborted();
- Log.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": file ended prematurely with "+remainingSize+" bytes remaining");
+ Logging.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": file ended prematurely with "+remainingSize+" bytes remaining");
return;
} else {
fileOutputStream.write(buffer, 0, count);
@@ -186,13 +186,13 @@ public class JingleSocks5Transport extends JingleTransport {
file.setSha1Sum(CryptoHelper.bytesToHex(digest.digest()));
callback.onFileTransmitted(file);
} catch (FileNotFoundException e) {
- Log.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
+ Logging.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
callback.onFileTransferAborted();
} catch (IOException e) {
- Log.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
+ Logging.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
callback.onFileTransferAborted();
} catch (NoSuchAlgorithmException e) {
- Log.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
+ Logging.d(Config.LOGTAG, connection.getAccount().getJid().toBareJid() + ": "+e.getMessage());
callback.onFileTransferAborted();
} finally {
StreamUtil.close(fileOutputStream);
diff --git a/src/main/java/de/tzur/conversations/Settings.java b/src/main/java/de/tzur/conversations/Settings.java
index ffdce86d..b8922f0a 100644
--- a/src/main/java/de/tzur/conversations/Settings.java
+++ b/src/main/java/de/tzur/conversations/Settings.java
@@ -1,7 +1,7 @@
package de.tzur.conversations;
import android.content.SharedPreferences;
-import android.util.Log;
+import de.thedevstack.conversationsplus.utils.Logging;
import de.thedevstack.conversationsplus.ConversationsPlusApplication;
@@ -16,7 +16,7 @@ public abstract class Settings {
* @param preferences the shared preferences of the app.
*/
public static void initSettingsClassWithPreferences(SharedPreferences preferences) {
- Log.d("SETTING", "Initializing settings");
+ Logging.d("SETTING", "Initializing settings");
String[] preferenceNames = { "parse_emoticons", "send_button_status", "led_notification_color", "auto_download_file_wlan", "auto_download_file_link", "confirm_messages_list" };
for (String name : preferenceNames) {
Settings.synchronizeSettingsClassWithPreferences(preferences, name);
@@ -29,7 +29,7 @@ public abstract class Settings {
* @param name the name of the setting to synchronize.
*/
public static void synchronizeSettingsClassWithPreferences(SharedPreferences preferences, String name) {
- Log.d("SETTING", "Synchronizing settings");
+ Logging.d("SETTING", "Synchronizing settings");
switch (name) {
case "parse_emoticons":
Settings.PARSE_EMOTICONS = preferences.getBoolean(name, Settings.PARSE_EMOTICONS);