aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-12-10 20:37:34 +0100
committersteckbrief <steckbrief@chefmail.de>2015-12-10 20:37:34 +0100
commit3b1723dcf19dc6e3390df63a71df903d9cb7dd94 (patch)
treea912db2e2204645fc3138cce62bb75a8d1a9b7d3 /src/main/java/de/thedevstack
parentaa6a2e1c182858e7bcc077f5220546e08df12ec1 (diff)
parenta7454223008c78dcf5e0ff727bca64241f99daa1 (diff)
Merge remote-tracking branch 'remotes/origin/trz/rename' into trz/rebase
Diffstat (limited to 'src/main/java/de/thedevstack')
-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/LogCatOutputCopyOnClickListener.java43
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/LogCatOutputActivity.java (renamed from src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputActivity.java)5
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java3
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java2
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java2
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java3
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/Logging.java124
9 files changed, 9 insertions, 362 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
deleted file mode 100644
index c8a96ea3..00000000
--- a/src/main/java/de/thedevstack/android/logcat/adapters/LogCatArrayAdapter.java
+++ /dev/null
@@ -1,122 +0,0 @@
-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
deleted file mode 100644
index b9fa450b..00000000
--- a/src/main/java/de/thedevstack/android/logcat/tasks/ReadLogCatAsyncTask.java
+++ /dev/null
@@ -1,67 +0,0 @@
-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/LogCatOutputCopyOnClickListener.java b/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java
deleted file mode 100644
index 1a37555a..00000000
--- a/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-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 eu.siacs.conversations.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/android/logcat/ui/LogCatOutputActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/LogCatOutputActivity.java
index 477cfc48..733da0cc 100644
--- a/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputActivity.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/LogCatOutputActivity.java
@@ -1,4 +1,4 @@
-package de.thedevstack.android.logcat.ui;
+package de.thedevstack.conversationsplus.ui;
import android.app.Activity;
import android.os.Bundle;
@@ -7,6 +7,7 @@ import android.widget.ListView;
import de.thedevstack.android.logcat.adapters.LogCatArrayAdapter;
import de.thedevstack.android.logcat.tasks.ReadLogCatAsyncTask;
+import de.thedevstack.android.logcat.ui.LogCatOutputCopyOnClickListener;
import eu.siacs.conversations.R;
@@ -23,6 +24,6 @@ public class LogCatOutputActivity extends Activity {
lv.setAdapter(logCatOutputAdapter);
new ReadLogCatAsyncTask(logCatOutputAdapter).execute();
Button copyButton = (Button) findViewById(R.id.actLogOutputCopyButton);
- copyButton.setOnClickListener(new LogCatOutputCopyOnClickListener(this, logCatOutputAdapter));
+ copyButton.setOnClickListener(new LogCatOutputCopyOnClickListener(this, logCatOutputAdapter, R.string.cplus_copied_to_clipboard));
}
}
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 7d82223c..b1b2298b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
@@ -2,12 +2,13 @@ package de.thedevstack.conversationsplus.ui.dialogs;
import android.app.Activity;
import android.text.format.DateFormat;
-import de.thedevstack.conversationsplus.utils.Logging;
import android.view.View;
import android.widget.TextView;
import java.util.Date;
+import de.thedevstack.android.logcat.Logging;
+
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java b/src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java
index 65b3b1b3..5dcfc607 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/preferences/LogInformationPreference.java
@@ -5,7 +5,7 @@ import android.content.Intent;
import android.preference.Preference;
import android.util.AttributeSet;
-import de.thedevstack.android.logcat.ui.LogCatOutputActivity;
+import de.thedevstack.conversationsplus.ui.LogCatOutputActivity;
/**
* Created by tzur on 07.10.2015.
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java
index 6b080202..401c77fc 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java
@@ -4,7 +4,6 @@ import android.graphics.Bitmap;
import android.net.Uri;
import android.util.Base64;
import android.util.Base64OutputStream;
-import de.thedevstack.conversationsplus.utils.Logging;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -16,6 +15,7 @@ import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import eu.siacs.conversations.Config;
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java
index 802c7ffb..204f56c4 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java
@@ -7,7 +7,6 @@ import android.graphics.Matrix;
import android.graphics.RectF;
import android.media.ExifInterface;
import android.net.Uri;
-import de.thedevstack.conversationsplus.utils.Logging;
import android.util.LruCache;
import java.io.File;
@@ -15,6 +14,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import de.thedevstack.android.logcat.Logging;
+
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.persistance.FileBackend;
import eu.siacs.conversations.utils.ExifHelper;
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/Logging.java b/src/main/java/de/thedevstack/conversationsplus/utils/Logging.java
deleted file mode 100644
index 40ec66a0..00000000
--- a/src/main/java/de/thedevstack/conversationsplus/utils/Logging.java
+++ /dev/null
@@ -1,124 +0,0 @@
-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));
- }
-}