diff --git a/.classpath b/.classpath deleted file mode 100644 index b611bd1..0000000 --- a/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/.project b/.project deleted file mode 100644 index a13bc3f..0000000 --- a/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - alogcat - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/AndroidManifest.xml b/AndroidManifest.xml deleted file mode 100644 index 464a7b1..0000000 --- a/AndroidManifest.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Intents.md b/Intents.md new file mode 100644 index 0000000..5f79027 --- /dev/null +++ b/Intents.md @@ -0,0 +1,44 @@ +aLogcat accepts the following intents, + +## org.jtb.alogcat.intent.START ## + +This starts the application. Intent must be broadcast with the "single top" for it to effect an already running copy of aLogcat. + +The following extras are supported, + +### FILTER ### + +Sets aLogcat's filter value. Value is interpreted as a string if substring filter mode is in effect, or as a regular expression otherwise. Again, the regular expression string value must be Java conforming (it needs to be properly escaped). + +Note in all cases, extras that effect aLogcat's preferences are persistent. That is, if you start aLogcat with intent START and pass a filter extra, the filter value lives beyond the life cycle of this particular application invocation. I.e., it acts as if you had changed the filter value from aLogcat's preferences. + +### LEVEL ### + +Sets aLogcat's level. Value can be one of: V, D, I, W, or E. + +## org.jtb.alogcat.intent.SAVE ## + +Triggers aLogcat to immediately write a log snapshot to /sdcard/alogcat. This intent accepts the same extras a the START intent, with the same semantics. + +## org.jtb.alogcat.intent.SHARE ## + +Triggers aLogcat to share the state of the current log, as if menu > share was selected from the application. This intent accepts the same extras a the START intent, with the same semantics. + + +## org.jtb.alogcat.intent.SAVE\_START ## + +Triggers aLogcat to begin periodically saving log snapshots to /sdcard/alogcat. In addition to the extras allows by the START intent, this intent allows, + +### FREQUENCY ### + +The frequency to save log snapshots. Value must be one of, + +``` +FIFTEEN_MINUTES +HALF_HOUR +HOUR +``` + +## org.jtb.alogcat.intent.SAVE\_STOP ## + +Triggers aLogcat to stop periodically saving log snapshots to /sdcard/alogcat. \ No newline at end of file diff --git a/ProjectHome.md b/ProjectHome.md new file mode 100644 index 0000000..e278352 --- /dev/null +++ b/ProjectHome.md @@ -0,0 +1,11 @@ +aLogcat is the well-known developer tool logcat, in the form of an Android application. + +View color-coded, scrolling (tailed) Android device (logcat) logs directly from your phone. No USB, adb, or emailing necessary. + +Set log format / level / buffer, filter logs by regex, clear log file, save to SD. + +Share logs via any application that handles plain text or HTML sharing, including Gmail, Email, Pastedroid, Bluetooth, and others. + +Install application Pastedroid to share logs via pastebin. Ensure HTML output is disabled in preferences as this only supports plain text logs. + +Optionally save log files at specified intervals in the background. \ No newline at end of file diff --git a/ant.properties b/ant.properties deleted file mode 100755 index 9e8efe3..0000000 --- a/ant.properties +++ /dev/null @@ -1,4 +0,0 @@ -key.store=release.keystore -key.alias=alogcat -key.store.password=1ap3tu$ -key.alias.password=1ap3tu$ diff --git a/build.xml b/build.xml deleted file mode 100755 index c37b580..0000000 --- a/build.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/graphics/device-1.png b/graphics/device-1.png deleted file mode 100644 index 26e1e0f..0000000 Binary files a/graphics/device-1.png and /dev/null differ diff --git a/graphics/device-2.png b/graphics/device-2.png deleted file mode 100644 index d8e1d31..0000000 Binary files a/graphics/device-2.png and /dev/null differ diff --git a/graphics/icon_512.png b/graphics/icon_512.png deleted file mode 100644 index b25e536..0000000 Binary files a/graphics/icon_512.png and /dev/null differ diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar deleted file mode 100644 index 99e063b..0000000 Binary files a/libs/android-support-v4.jar and /dev/null differ diff --git a/local.properties b/local.properties deleted file mode 100755 index ab8f3ad..0000000 --- a/local.properties +++ /dev/null @@ -1,10 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. - -# location of the SDK. This is only used by Ant -# For customization when using a Version Control System, please read the -# header note. -sdk.dir=C:\\Program Files (x86)\\Android\\android-sdk diff --git a/proguard-project.txt b/proguard-project.txt deleted file mode 100755 index b60ae7e..0000000 --- a/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/project.properties b/project.properties deleted file mode 100644 index ddd0fc4..0000000 --- a/project.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Indicates whether an apk should be generated for each density. -split.density=false -# Project target. -target=android-10 diff --git a/release.keystore b/release.keystore deleted file mode 100644 index 7694df4..0000000 Binary files a/release.keystore and /dev/null differ diff --git a/release/alogcat-1.0.apk b/release/alogcat-1.0.apk deleted file mode 100644 index cc11018..0000000 Binary files a/release/alogcat-1.0.apk and /dev/null differ diff --git a/release/alogcat-1.1.1.apk b/release/alogcat-1.1.1.apk deleted file mode 100644 index 5232420..0000000 Binary files a/release/alogcat-1.1.1.apk and /dev/null differ diff --git a/release/alogcat-1.1.2.apk b/release/alogcat-1.1.2.apk deleted file mode 100644 index e941e09..0000000 Binary files a/release/alogcat-1.1.2.apk and /dev/null differ diff --git a/release/alogcat-1.1.3.apk b/release/alogcat-1.1.3.apk deleted file mode 100644 index a4914ac..0000000 Binary files a/release/alogcat-1.1.3.apk and /dev/null differ diff --git a/release/alogcat-1.1.4.apk b/release/alogcat-1.1.4.apk deleted file mode 100644 index fd6f29e..0000000 Binary files a/release/alogcat-1.1.4.apk and /dev/null differ diff --git a/release/alogcat-1.1.apk b/release/alogcat-1.1.apk deleted file mode 100644 index 5c85e52..0000000 Binary files a/release/alogcat-1.1.apk and /dev/null differ diff --git a/release/alogcat-1.2.apk b/release/alogcat-1.2.apk deleted file mode 100644 index 626265c..0000000 Binary files a/release/alogcat-1.2.apk and /dev/null differ diff --git a/release/alogcat-1.3.1.apk b/release/alogcat-1.3.1.apk deleted file mode 100644 index 36e85bf..0000000 Binary files a/release/alogcat-1.3.1.apk and /dev/null differ diff --git a/release/alogcat-1.3.2.apk b/release/alogcat-1.3.2.apk deleted file mode 100644 index a3caf7e..0000000 Binary files a/release/alogcat-1.3.2.apk and /dev/null differ diff --git a/release/alogcat-1.3.3.apk b/release/alogcat-1.3.3.apk deleted file mode 100644 index 819e572..0000000 Binary files a/release/alogcat-1.3.3.apk and /dev/null differ diff --git a/release/alogcat-1.3.4.apk b/release/alogcat-1.3.4.apk deleted file mode 100644 index d58a2a2..0000000 Binary files a/release/alogcat-1.3.4.apk and /dev/null differ diff --git a/release/alogcat-1.3.5.apk b/release/alogcat-1.3.5.apk deleted file mode 100644 index 731194f..0000000 Binary files a/release/alogcat-1.3.5.apk and /dev/null differ diff --git a/release/alogcat-1.3.6.apk b/release/alogcat-1.3.6.apk deleted file mode 100644 index b7537da..0000000 Binary files a/release/alogcat-1.3.6.apk and /dev/null differ diff --git a/release/alogcat-1.3.apk b/release/alogcat-1.3.apk deleted file mode 100644 index 4263469..0000000 Binary files a/release/alogcat-1.3.apk and /dev/null differ diff --git a/release/alogcat-1.4.apk b/release/alogcat-1.4.apk deleted file mode 100644 index 02a7e4f..0000000 Binary files a/release/alogcat-1.4.apk and /dev/null differ diff --git a/release/alogcat-1.5.1.apk b/release/alogcat-1.5.1.apk deleted file mode 100644 index 34a0a4b..0000000 Binary files a/release/alogcat-1.5.1.apk and /dev/null differ diff --git a/release/alogcat-1.5.2.apk b/release/alogcat-1.5.2.apk deleted file mode 100644 index c990625..0000000 Binary files a/release/alogcat-1.5.2.apk and /dev/null differ diff --git a/release/alogcat-1.5.apk b/release/alogcat-1.5.apk deleted file mode 100644 index 9939660..0000000 Binary files a/release/alogcat-1.5.apk and /dev/null differ diff --git a/release/alogcat-1.6.apk b/release/alogcat-1.6.apk deleted file mode 100644 index 816263e..0000000 Binary files a/release/alogcat-1.6.apk and /dev/null differ diff --git a/release/alogcat-2.0.1.apk b/release/alogcat-2.0.1.apk deleted file mode 100644 index 500652e..0000000 Binary files a/release/alogcat-2.0.1.apk and /dev/null differ diff --git a/release/alogcat-2.0.2.apk b/release/alogcat-2.0.2.apk deleted file mode 100644 index 624593a..0000000 Binary files a/release/alogcat-2.0.2.apk and /dev/null differ diff --git a/release/alogcat-2.0.3.apk b/release/alogcat-2.0.3.apk deleted file mode 100644 index e28c8fe..0000000 Binary files a/release/alogcat-2.0.3.apk and /dev/null differ diff --git a/release/alogcat-2.0.4.apk b/release/alogcat-2.0.4.apk deleted file mode 100644 index 180ea26..0000000 Binary files a/release/alogcat-2.0.4.apk and /dev/null differ diff --git a/release/alogcat-2.0.apk b/release/alogcat-2.0.apk deleted file mode 100644 index f633923..0000000 Binary files a/release/alogcat-2.0.apk and /dev/null differ diff --git a/release/alogcat-2.1.1.apk b/release/alogcat-2.1.1.apk deleted file mode 100644 index a4d9a65..0000000 Binary files a/release/alogcat-2.1.1.apk and /dev/null differ diff --git a/release/alogcat-2.1.2.apk b/release/alogcat-2.1.2.apk deleted file mode 100644 index c0987b2..0000000 Binary files a/release/alogcat-2.1.2.apk and /dev/null differ diff --git a/release/alogcat-2.1.3.apk b/release/alogcat-2.1.3.apk deleted file mode 100644 index c058482..0000000 Binary files a/release/alogcat-2.1.3.apk and /dev/null differ diff --git a/release/alogcat-2.1.4.1.apk b/release/alogcat-2.1.4.1.apk deleted file mode 100644 index f586f92..0000000 Binary files a/release/alogcat-2.1.4.1.apk and /dev/null differ diff --git a/release/alogcat-2.1.4.2.apk b/release/alogcat-2.1.4.2.apk deleted file mode 100644 index 5a04b67..0000000 Binary files a/release/alogcat-2.1.4.2.apk and /dev/null differ diff --git a/release/alogcat-2.1.4.apk b/release/alogcat-2.1.4.apk deleted file mode 100644 index b098bfa..0000000 Binary files a/release/alogcat-2.1.4.apk and /dev/null differ diff --git a/release/alogcat-2.1.5.apk b/release/alogcat-2.1.5.apk deleted file mode 100644 index 384fbfc..0000000 Binary files a/release/alogcat-2.1.5.apk and /dev/null differ diff --git a/release/alogcat-2.1.6.apk b/release/alogcat-2.1.6.apk deleted file mode 100644 index 920554c..0000000 Binary files a/release/alogcat-2.1.6.apk and /dev/null differ diff --git a/release/alogcat-2.1.apk b/release/alogcat-2.1.apk deleted file mode 100644 index 088ed16..0000000 Binary files a/release/alogcat-2.1.apk and /dev/null differ diff --git a/release/alogcat-2.2.apk b/release/alogcat-2.2.apk deleted file mode 100755 index ac0c1cd..0000000 Binary files a/release/alogcat-2.2.apk and /dev/null differ diff --git a/release/alogcat-2.3.2.apk b/release/alogcat-2.3.2.apk deleted file mode 100755 index f943a69..0000000 Binary files a/release/alogcat-2.3.2.apk and /dev/null differ diff --git a/release/alogcat-2.3.apk b/release/alogcat-2.3.apk deleted file mode 100755 index 14892eb..0000000 Binary files a/release/alogcat-2.3.apk and /dev/null differ diff --git a/release/alogcat-2.4.apk b/release/alogcat-2.4.apk deleted file mode 100644 index bd57e9a..0000000 Binary files a/release/alogcat-2.4.apk and /dev/null differ diff --git a/release/alogcat-2.5.1.apk b/release/alogcat-2.5.1.apk deleted file mode 100755 index 28dc62e..0000000 Binary files a/release/alogcat-2.5.1.apk and /dev/null differ diff --git a/release/alogcat-2.5.apk b/release/alogcat-2.5.apk deleted file mode 100755 index a396a10..0000000 Binary files a/release/alogcat-2.5.apk and /dev/null differ diff --git a/release/alogcat-2.6.1.apk b/release/alogcat-2.6.1.apk deleted file mode 100644 index 7101c56..0000000 Binary files a/release/alogcat-2.6.1.apk and /dev/null differ diff --git a/release/alogcat-2.6.apk b/release/alogcat-2.6.apk deleted file mode 100644 index 3d93198..0000000 Binary files a/release/alogcat-2.6.apk and /dev/null differ diff --git a/release/alogcat-donate-2.2.apk b/release/alogcat-donate-2.2.apk deleted file mode 100755 index 1c2aba9..0000000 Binary files a/release/alogcat-donate-2.2.apk and /dev/null differ diff --git a/release/alogcat-donate-2.3.2.apk b/release/alogcat-donate-2.3.2.apk deleted file mode 100755 index bef1d55..0000000 Binary files a/release/alogcat-donate-2.3.2.apk and /dev/null differ diff --git a/release/alogcat-donate-2.3.apk b/release/alogcat-donate-2.3.apk deleted file mode 100755 index 6f52e5f..0000000 Binary files a/release/alogcat-donate-2.3.apk and /dev/null differ diff --git a/release/alogcat-donate-2.4.apk b/release/alogcat-donate-2.4.apk deleted file mode 100644 index 2bacee3..0000000 Binary files a/release/alogcat-donate-2.4.apk and /dev/null differ diff --git a/release/alogcat-donate-2.5.1.apk b/release/alogcat-donate-2.5.1.apk deleted file mode 100755 index 43a5a80..0000000 Binary files a/release/alogcat-donate-2.5.1.apk and /dev/null differ diff --git a/release/alogcat-donate-2.5.apk b/release/alogcat-donate-2.5.apk deleted file mode 100755 index be13a84..0000000 Binary files a/release/alogcat-donate-2.5.apk and /dev/null differ diff --git a/release/alogcat-donate-2.6.1.apk b/release/alogcat-donate-2.6.1.apk deleted file mode 100644 index 94c2a73..0000000 Binary files a/release/alogcat-donate-2.6.1.apk and /dev/null differ diff --git a/release/alogcat-donate-2.6.apk b/release/alogcat-donate-2.6.apk deleted file mode 100644 index 9fc0c79..0000000 Binary files a/release/alogcat-donate-2.6.apk and /dev/null differ diff --git a/res/drawable/icon.png b/res/drawable/icon.png deleted file mode 100644 index 2368dc9..0000000 Binary files a/res/drawable/icon.png and /dev/null differ diff --git a/res/layout/entry.xml b/res/layout/entry.xml deleted file mode 100644 index d61ecb8..0000000 --- a/res/layout/entry.xml +++ /dev/null @@ -1,8 +0,0 @@ - - diff --git a/res/layout/filter_dialog.xml b/res/layout/filter_dialog.xml deleted file mode 100644 index 52ffc00..0000000 --- a/res/layout/filter_dialog.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - diff --git a/res/layout/log.xml b/res/layout/log.xml deleted file mode 100644 index 9342889..0000000 --- a/res/layout/log.xml +++ /dev/null @@ -1,5 +0,0 @@ - - \ No newline at end of file diff --git a/res/layout/prefs.xml b/res/layout/prefs.xml deleted file mode 100644 index 0ceb925..0000000 --- a/res/layout/prefs.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/values/arrays.xml b/res/values/arrays.xml deleted file mode 100644 index 3389380..0000000 --- a/res/values/arrays.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - Verbose - Debug - Information - Warning - Error - Fatal - - - V - D - I - W - E - F - - - Brief - Process - Tag - Thread - Thread Time - Time - Long - Raw - - - BRIEF - PROCESS - TAG - THREAD - THREADTIME - TIME - LONG - RAW - - - Main - Events - Radio - - - MAIN - EVENTS - RADIO - - - Small - Medium (default) - Large - - - SMALL - MEDIUM - LARGE - - - White - Gray - Black - - - WHITE - GRAY - BLACK - - - diff --git a/res/values/strings.xml b/res/values/strings.xml deleted file mode 100644 index 6e3d2d2..0000000 --- a/res/values/strings.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - aLogcat - aLogcat (paused) - aLogcat - Preferences - Cancel - Okay - Fatal - Error - Warning - Information - Verbose - Debug - Filter (%s) - Log Filter - Filter - A log filter can be a simple substring or a Java-conforming regular expression. - Invalid regular expression - Clear - Brief - Process - Tag - Thread - Raw - Time - Long - Reading logs, please wait. - Share - Play - Pause - Top - Bottom - Main - Events - Radio - Small - Medium - Large - Clear - Save - Preferences - Saving log to: %s, please wait - Thread Time - Black - White - Gray - Apply as regular expression? - \ No newline at end of file diff --git a/set-donate.sh b/set-donate.sh deleted file mode 100644 index f329a7f..0000000 --- a/set-donate.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -if [ $1 == 'true' ]; then - search='^import org\.jtb\.alogcat\.R;$' - replace='import org.jtb.alogcat.donate.R;' -else - search='^import org\.jtb\.alogcat\.donate\.R;$' - replace='import org.jtb.alogcat.R;' -fi - - -find src -type f -name \*.java -print0 | xargs -0 sed -i ".tmp" "s!$search!$replace!g" diff --git a/src/org/jtb/alogcat/ALogcatApplication.java b/src/org/jtb/alogcat/ALogcatApplication.java deleted file mode 100755 index 6f932c9..0000000 --- a/src/org/jtb/alogcat/ALogcatApplication.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.jtb.alogcat; - -import android.app.Application; -import android.os.StrictMode; - -public class ALogcatApplication extends Application { - private static final boolean DEBUG = false; - - @Override - public void onCreate() { - super.onCreate(); - if (DEBUG) { - StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() - .detectAll().penaltyLog().build()); - StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() - .detectAll().penaltyLog().penaltyDeath().build()); - } - } -} diff --git a/src/org/jtb/alogcat/BackgroundColor.java b/src/org/jtb/alogcat/BackgroundColor.java deleted file mode 100644 index efa566d..0000000 --- a/src/org/jtb/alogcat/BackgroundColor.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.jtb.alogcat; - -import java.util.HashMap; -import java.util.Map; - -import org.jtb.alogcat.R; - -import android.content.Context; -import android.graphics.Color; - -public enum BackgroundColor { - BLACK(R.string.black_title, "#000000"), WHITE(R.string.white_title, - "#ffffff"), GRAY(R.string.gray_title, "#bbbbbb"); - - private static final Map byHexColor; - - static { - byHexColor = new HashMap() { - { - put("#000000", BLACK); - put("#ffffff", WHITE); - put("#bbbbbb", GRAY); - } - }; - } - - private String mHexColor; - private int mId; - - private BackgroundColor(int id, String hexColor) { - mId = id; - mHexColor = hexColor; - } - - public static BackgroundColor valueOfHexColor(String hexColor) { - return byHexColor.get(hexColor); - } - - public int getColor() { - return Color.parseColor(mHexColor); - } - - public String getTitle(Context context) { - return context.getResources().getString(mId); - } -} diff --git a/src/org/jtb/alogcat/Buffer.java b/src/org/jtb/alogcat/Buffer.java deleted file mode 100644 index 7e7a1cb..0000000 --- a/src/org/jtb/alogcat/Buffer.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.jtb.alogcat; - -import java.util.HashMap; - -import org.jtb.alogcat.R; - -import android.content.Context; - -public enum Buffer { - MAIN("main", R.string.main_title), - EVENTS("events", R.string.events_title), - RADIO("radio", R.string.radio_title); - - private static Buffer[] byOrder = new Buffer[3]; - - static { - byOrder[0] = MAIN; - byOrder[1] = EVENTS; - byOrder[2] = RADIO; - } - - private static final HashMap VALUE_MAP = new HashMap(); - - static { - VALUE_MAP.put(MAIN.mValue, MAIN); - VALUE_MAP.put(EVENTS.mValue, EVENTS); - VALUE_MAP.put(RADIO.mValue, RADIO); - } - - private String mValue; - private int mTitleId; - - private Buffer(String value, int titleId) { - mValue = value; - mTitleId = titleId; - } - - public String getTitle(Context context) { - return context.getResources().getString(mTitleId); - } - - public static final Buffer byValue(String value) { - return VALUE_MAP.get(value); - } - - public static Buffer getByOrder(int order) { - return byOrder[order]; - } - - public String getValue() { - return mValue; - } -} diff --git a/src/org/jtb/alogcat/FilterDialog.java b/src/org/jtb/alogcat/FilterDialog.java deleted file mode 100644 index 732aedb..0000000 --- a/src/org/jtb/alogcat/FilterDialog.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.jtb.alogcat; - -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; - -import org.jtb.alogcat.R; - -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.EditText; -import android.widget.TextView; - -public class FilterDialog extends AlertDialog { - private boolean mError = false; - private Prefs mPrefs; - private LogActivity mLogActivity; - - @Override - public void dismiss() { - if (!mError) { - super.dismiss(); - } - } - - public FilterDialog(LogActivity logActivity) { - super(logActivity); - - mLogActivity = logActivity; - mPrefs = new Prefs(mLogActivity); - - LayoutInflater factory = LayoutInflater.from(mLogActivity); - final View view = factory.inflate(R.layout.filter_dialog, null); - - final EditText filterEdit = (EditText) view - .findViewById(R.id.filter_edit); - filterEdit.setText(mPrefs.getFilter()); - - final TextView patternErrorText = (TextView) view.findViewById(R.id.pattern_error_text); - patternErrorText.setVisibility(View.GONE); - - final CheckBox patternCheckBox = (CheckBox) view - .findViewById(R.id.pattern_checkbox); - patternCheckBox.setChecked(mPrefs.isFilterPattern()); - CompoundButton.OnCheckedChangeListener occl = new CompoundButton.OnCheckedChangeListener() { - - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - if (!isChecked) { - patternErrorText.setVisibility(View.GONE); - mError = false; - } - } - - }; - patternCheckBox.setOnCheckedChangeListener(occl); - - setView(view); - setTitle(R.string.filter_dialog_title); - - setButton(BUTTON_POSITIVE, mLogActivity.getResources().getString(R.string.ok), - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - FilterDialog fd = (FilterDialog)dialog; - String f = filterEdit.getText().toString(); - if (patternCheckBox.isChecked()) { - try { - Pattern.compile(f); - } catch (PatternSyntaxException e) { - patternErrorText.setVisibility(View.VISIBLE); - fd.mError = true; - return; - } - } - - fd.mError = false; - patternErrorText.setVisibility(View.GONE); - - mPrefs.setFilter(filterEdit.getText().toString()); - mPrefs.setFilterPattern(patternCheckBox.isChecked()); - - mLogActivity.setFilterMenu(); - mLogActivity.dismissDialog(LogActivity.FILTER_DIALOG); - mLogActivity.reset(); - } - }); - setButton(BUTTON_NEUTRAL, mLogActivity.getResources().getString(R.string.clear), - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - FilterDialog fd = (FilterDialog)dialog; - - mPrefs.setFilter(null); - filterEdit.setText(null); - - mPrefs.setFilterPattern(false); - patternCheckBox.setChecked(false); - - fd.mError = false; - - mLogActivity.setFilterMenu(); - mLogActivity.dismissDialog(LogActivity.FILTER_DIALOG); - mLogActivity.reset(); - } - }); - setButton(BUTTON_NEGATIVE, mLogActivity.getResources().getString(R.string.cancel), - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - FilterDialog fd = (FilterDialog)dialog; - - filterEdit.setText(mPrefs.getFilter()); - patternCheckBox.setChecked(mPrefs.isFilterPattern()); - - fd.mError = false; - mLogActivity.dismissDialog(LogActivity.FILTER_DIALOG); - } - }); - - } -} diff --git a/src/org/jtb/alogcat/Format.java b/src/org/jtb/alogcat/Format.java deleted file mode 100644 index 96df4d2..0000000 --- a/src/org/jtb/alogcat/Format.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.jtb.alogcat; - -import java.util.HashMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.jtb.alogcat.R; - -import android.content.Context; - -public enum Format { - BRIEF("brief", R.string.brief_title, Pattern.compile("^([VDIWEF])/")), - PROCESS("process", R.string.process_title, Pattern.compile("^([VDIWEF])\\(")), - TAG("tag", R.string.tag_title, Pattern.compile("^([VDIWEF])/")), - THREAD("thread", R.string.thread_title, Pattern.compile("^([VDIWEF])\\(")), - TIME("time", R.string.time_title, Pattern.compile(" ([VDIWEF])/")), - THREADTIME("threadtime", R.string.threadtime_title, Pattern.compile(" ([VDIWEF]) ")), - LONG("long", R.string.long_title, Pattern.compile("([VDIWEF])/")), - RAW("raw", R.string.raw_title, null); - - private static Format[] byOrder = new Format[8]; - - static { - byOrder[0] = BRIEF; - byOrder[1] = PROCESS; - byOrder[2] = TAG; - byOrder[3] = THREAD; - byOrder[4] = TIME; - byOrder[5] = THREADTIME; - byOrder[6] = LONG; - byOrder[7] = RAW; - } - - private static final HashMap VALUE_MAP = new HashMap(); - - static { - VALUE_MAP.put(BRIEF.mValue, BRIEF); - VALUE_MAP.put(PROCESS.mValue, PROCESS); - VALUE_MAP.put(TAG.mValue, TAG); - VALUE_MAP.put(THREAD.mValue, THREAD); - VALUE_MAP.put(THREADTIME.mValue, THREAD); - VALUE_MAP.put(TIME.mValue, TIME); - VALUE_MAP.put(RAW.mValue, RAW); - VALUE_MAP.put(LONG.mValue, LONG); - } - - private String mValue; - private int mTitleId; - private Pattern mLevelPattern; - - private Format(String value, int titleId, Pattern levelPattern) { - mValue = value; - mTitleId = titleId; - mLevelPattern = levelPattern; - } - - public String getTitle(Context context) { - return context.getResources().getString(mTitleId); - } - - public static final Format byValue(String value) { - return VALUE_MAP.get(value); - } - - public Level getLevel(String line) { - if (mLevelPattern == null) { - return null; - } - Matcher m = mLevelPattern.matcher(line); - if (m.find()) { - return Level.valueOf(m.group(1)); - } - return null; - } - - public static Format getByOrder(int order) { - return byOrder[order]; - } - - public String getValue() { - return mValue; - } -} diff --git a/src/org/jtb/alogcat/Intent.java b/src/org/jtb/alogcat/Intent.java deleted file mode 100644 index ccda35d..0000000 --- a/src/org/jtb/alogcat/Intent.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.jtb.alogcat; - -import android.content.Context; - -public class Intent { - static final String START_INTENT = "org.jtb.alogcat.intent.START"; - static final String SAVE_INTENT = "org.jtb.alogcat.intent.SAVE"; - static final String SHARE_INTENT = "org.jtb.alogcat.intent.SHARE"; - - static final String EXTRA_FILTER = "FILTER"; - static final String EXTRA_LEVEL = "LEVEL"; - static final String EXTRA_FREQUENCY = "FREQUENCY"; - static final String EXTRA_START_RECORD = "START_WRITE"; - static final String EXTRA_STOP_RECORD = "STOP_WRITE"; - - static void handleExtras(Context context, android.content.Intent intent) { - Prefs prefs = new Prefs(context); - String filter = intent.getStringExtra(EXTRA_FILTER); - if (filter != null) { - prefs.setFilter(filter); - } - String l = intent.getStringExtra(EXTRA_LEVEL); - if (l != null) { - Level level = Level.valueOf(l); - prefs.setLevel(level); - } - } -} diff --git a/src/org/jtb/alogcat/Level.java b/src/org/jtb/alogcat/Level.java deleted file mode 100644 index fb6324e..0000000 --- a/src/org/jtb/alogcat/Level.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.jtb.alogcat; - -import android.content.Context; -import android.graphics.Color; -import org.jtb.alogcat.R; - -public enum Level { - V(0, "#121212", R.string.verbose_title), D(1, "#00006C", - R.string.debug_title), I(2, "#20831B", R.string.info_title), W(3, - "#FD7916", R.string.warn_title), E(4, "#FD0010", - R.string.error_title), F(5, "#ff0066", R.string.fatal_title); - - private static Level[] byOrder = new Level[6]; - - static { - byOrder[0] = V; - byOrder[1] = D; - byOrder[2] = I; - byOrder[3] = W; - byOrder[4] = E; - byOrder[5] = F; - } - - private String mHexColor; - private int mColor; - private int mValue; - private int mTitleId; - - private Level(int value, String hexColor, int titleId) { - mValue = value; - mHexColor = hexColor; - mColor = Color.parseColor(hexColor); - mTitleId = titleId; - } - - public String getHexColor() { - return mHexColor; - } - - public int getColor() { - return mColor; - } - - public int getValue() { - return mValue; - } - - public static Level getByOrder(int value) { - return byOrder[value]; - } - - public String getTitle(Context context) { - return context.getResources().getString(mTitleId); - } -} diff --git a/src/org/jtb/alogcat/Lock.java b/src/org/jtb/alogcat/Lock.java deleted file mode 100644 index e23e97c..0000000 --- a/src/org/jtb/alogcat/Lock.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.jtb.alogcat; - -import android.content.Context; -import android.os.PowerManager; -import android.os.PowerManager.WakeLock; -import android.util.Log; - -public class Lock { - private static PowerManager.WakeLock lock; - - private static PowerManager.WakeLock getLock(Context context) { - if (lock == null) { - PowerManager mgr = (PowerManager) context - .getSystemService(Context.POWER_SERVICE); - - lock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "org.jtb.alogcat.lock"); - lock.setReferenceCounted(true); - } - return lock; - } - - public static synchronized void acquire(Context context) { - WakeLock wakeLock = getLock(context); - if (!wakeLock.isHeld()) { - wakeLock.acquire(); - //Log.d("alogcat", "wake lock acquired"); - } - } - - public static synchronized void release() { - if (lock == null) { - Log - .w(Lock.class.getSimpleName(), - "release attempted, but wake lock was null"); - } else { - if (lock.isHeld()) { - lock.release(); - //Log.d("alogcat", "wake lock released"); - } else { - Log.w("alogcat", - "release attempted, but wake lock was not held"); - } - } - } -} diff --git a/src/org/jtb/alogcat/LogActivity.java b/src/org/jtb/alogcat/LogActivity.java deleted file mode 100644 index d703666..0000000 --- a/src/org/jtb/alogcat/LogActivity.java +++ /dev/null @@ -1,553 +0,0 @@ -package org.jtb.alogcat; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; - -import android.app.AlertDialog; -import android.app.Dialog; -import android.app.ListActivity; -import android.content.Intent; -import android.os.Bundle; -import android.os.Debug; -import android.os.Environment; -import android.os.Handler; -import android.os.Message; -import android.support.v4.view.MenuItemCompat; -import android.text.Html; -import android.text.TextUtils; -import android.util.Log; -import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.WindowManager; -import android.widget.AbsListView; -import android.widget.AbsListView.OnScrollListener; -import android.widget.ListView; -import android.widget.Toast; -import org.jtb.alogcat.R; - -public class LogActivity extends ListActivity { - static final SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat( - "MMM d, yyyy HH:mm:ss ZZZZ"); - private static final Executor EX = Executors.newCachedThreadPool(); - - static final int FILTER_DIALOG = 1; - - private static final int PREFS_REQUEST = 1; - - private static final int MENU_FILTER = 1; - private static final int MENU_SHARE = 5; - private static final int MENU_PLAY = 6; - private static final int MENU_CLEAR = 8; - private static final int MENU_SAVE = 9; - private static final int MENU_PREFS = 10; - private static final int MENU_JUMP_TOP = 11; - private static final int MENU_JUMP_BOTTOM = 12; - - static final int WINDOW_SIZE = 1000; - - static final int CAT_WHAT = 0; - static final int CLEAR_WHAT = 2; - - private AlertDialog mFilterDialog; - - private ListView mLogList; - private LogEntryAdapter mLogEntryAdapter; - private MenuItem mPlayItem; - private MenuItem mFilterItem; - - private Level mLastLevel = Level.V; - private Logcat mLogcat; - private Prefs mPrefs; - private LogActivity mThis; - private boolean mPlay = true; - - private Handler mHandler = new Handler() { - @Override - public void handleMessage(Message msg) { - switch (msg.what) { - case CAT_WHAT: - final List lines = (List) msg.obj; - cat(lines); - break; - case CLEAR_WHAT: - mLogEntryAdapter.clear(); - break; - } - } - }; - - private void jumpTop() { - pauseLog(); - mLogList.post(new Runnable() { - public void run() { - mLogList.setSelection(0); - } - }); - } - - private void jumpBottom() { - playLog(); - mLogList.setSelection(mLogEntryAdapter.getCount() - 1); - } - - private void cat(final String s) { - if (mLogEntryAdapter.getCount() > WINDOW_SIZE) { - mLogEntryAdapter.remove(0); - } - - Format format = mLogcat.mFormat; - Level level = format.getLevel(s); - if (level == null) { - level = mLastLevel; - } else { - mLastLevel = level; - } - - final LogEntry entry = new LogEntry(s, level); - mLogEntryAdapter.add(entry); - } - - private void cat(List lines) { - for (String line : lines) { - cat(line); - } - jumpBottom(); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.log); - getWindow().setTitle(getResources().getString(R.string.app_name)); - - mThis = this; - mPrefs = new Prefs(this); - - mLogList = (ListView) findViewById(android.R.id.list); - mLogList.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { - - @Override - public void onCreateContextMenu(ContextMenu menu, View v, - ContextMenuInfo menuInfo) { - MenuItem jumpTopItem = menu.add(0, MENU_JUMP_TOP, 0, - R.string.jump_start_menu); - jumpTopItem.setIcon(android.R.drawable.ic_media_previous); - - MenuItem jumpBottomItem = menu.add(0, MENU_JUMP_BOTTOM, 0, - R.string.jump_end_menu); - jumpBottomItem.setIcon(android.R.drawable.ic_media_next); - } - }); - mLogList.setOnScrollListener(new AbsListView.OnScrollListener() { - - @Override - public void onScrollStateChanged(AbsListView view, int scrollState) { - pauseLog(); - } - - @Override - public void onScroll(AbsListView view, int firstVisibleItem, - int visibleItemCount, int totalItemCount) { - } - }); - - // Log.v("alogcat", "created"); - } - - @Override - protected void onNewIntent(Intent intent) { - // Log.i("alogcat", "new intent: " + intent); - if (intent == null) { - return; - } - if (intent.getAction() == null) { - return; - } - setIntent(intent); - if (intent.getAction().equals(org.jtb.alogcat.Intent.START_INTENT)) { - org.jtb.alogcat.Intent.handleExtras(this, intent); - } - } - - @Override - public void onStart() { - super.onStart(); - // Log.v("alogcat", "started"); - } - - private void init() { - BackgroundColor bc = mPrefs.getBackgroundColor(); - int color = bc.getColor(); - mLogList.setBackgroundColor(color); - mLogList.setCacheColorHint(color); - - mLogEntryAdapter = new LogEntryAdapter(this, R.layout.entry, - new ArrayList(WINDOW_SIZE)); - setListAdapter(mLogEntryAdapter); - reset(); - setKeepScreenOn(); - } - - @Override - public void onResume() { - //Debug.startMethodTracing("alogcat"); - super.onResume(); - onNewIntent(getIntent()); - init(); - // Log.v("alogcat", "resumed"); - } - - @Override - public void onPause() { - super.onPause(); - // Log.v("alogcat", "paused"); - - //Debug.stopMethodTracing(); - } - - @Override - public void onStop() { - super.onStop(); - if (mLogcat != null) { - mLogcat.stop(); - } - } - - @Override - public void onDestroy() { - super.onDestroy(); - // Log.v("alogcat", "destroyed"); - } - - @Override - protected void onSaveInstanceState(Bundle b) { - // Log.v("alogcat", "save instance"); - } - - @Override - protected void onRestoreInstanceState(Bundle b) { - // Log.v("alogcat", "restore instance"); - } - - public void reset() { - Toast.makeText(this, R.string.reading_logs, Toast.LENGTH_SHORT).show(); - mLastLevel = Level.V; - - if (mLogcat != null) { - mLogcat.stop(); - } - - mPlay = true; - - EX.execute(new Runnable() { - public void run() { - mLogcat = new Logcat(mThis, mHandler); - mLogcat.start(); - } - }); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - - // TODO: maybe this should be in a menu.xml file. ;) - mPlayItem = menu.add(0, MENU_PLAY, 0, R.string.pause_menu); - mPlayItem.setIcon(android.R.drawable.ic_media_pause); - MenuItemCompat.setShowAsAction(mPlayItem, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); - setPlayMenu(); - - mFilterItem = menu.add( - 0, - MENU_FILTER, - 0, - getResources().getString(R.string.filter_menu, - mPrefs.getFilter())); - mFilterItem.setIcon(android.R.drawable.ic_menu_search); - MenuItemCompat.setShowAsAction(mFilterItem, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM - | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); - setFilterMenu(); - - MenuItem clearItem = menu.add(0, MENU_CLEAR, 0, R.string.clear_menu); - clearItem.setIcon(android.R.drawable.ic_menu_close_clear_cancel); - MenuItemCompat.setShowAsAction(clearItem, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); - - MenuItem shareItem = menu.add(0, MENU_SHARE, 0, R.string.share_menu); - shareItem.setIcon(android.R.drawable.ic_menu_share); - MenuItemCompat.setShowAsAction(shareItem, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); - - MenuItem saveItem = menu.add(0, MENU_SAVE, 0, R.string.save_menu); - saveItem.setIcon(android.R.drawable.ic_menu_save); - MenuItemCompat.setShowAsAction(saveItem, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); - - MenuItem prefsItem = menu.add(0, MENU_PREFS, 0, getResources() - .getString(R.string.prefs_menu)); - prefsItem.setIcon(android.R.drawable.ic_menu_preferences); - MenuItemCompat.setShowAsAction(prefsItem, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); - - return true; - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - return true; - } - - public void setPlayMenu() { - if (mPlayItem == null) { - return; - } - if (mPlay) { - mPlayItem.setTitle(R.string.pause_menu); - mPlayItem.setIcon(android.R.drawable.ic_media_pause); - } else { - mPlayItem.setTitle(R.string.play_menu); - mPlayItem.setIcon(android.R.drawable.ic_media_play); - } - } - - void setFilterMenu() { - if (mFilterItem == null) { - return; - } - int filterMenuId; - String filter = mPrefs.getFilter(); - if (filter == null || filter.length() == 0) { - filterMenuId = R.string.filter_menu_empty; - } else { - filterMenuId = R.string.filter_menu; - } - mFilterItem.setTitle(getResources().getString(filterMenuId, filter)); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case MENU_FILTER: - showDialog(FILTER_DIALOG); - return true; - case MENU_SHARE: - share(); - return true; - case MENU_SAVE: - File f = save(); - String msg = getResources().getString(R.string.saving_log, - f.toString()); - Toast.makeText(this, msg, Toast.LENGTH_LONG).show(); - return true; - case MENU_PLAY: - if (mPlay) { - pauseLog(); - } else { - jumpBottom(); - } - return true; - case MENU_CLEAR: - clear(); - reset(); - return true; - case MENU_PREFS: - Intent intent = new Intent(this, PrefsActivity.class); - startActivityForResult(intent, PREFS_REQUEST); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - switch (requestCode) { - case PREFS_REQUEST: - setKeepScreenOn(); - break; - } - } - - private void setKeepScreenOn() { - if (mPrefs.isKeepScreenOn()) { - getWindow() - .addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - } else { - getWindow().clearFlags( - WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - } - - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - switch (item.getItemId()) { - case MENU_JUMP_TOP: - Toast.makeText(this, "Jumping to top of log ...", - Toast.LENGTH_SHORT).show(); - jumpTop(); - return true; - case MENU_JUMP_BOTTOM: - Toast.makeText(this, "Jumping to bottom of log ...", - Toast.LENGTH_SHORT).show(); - jumpBottom(); - return true; - default: - return super.onContextItemSelected(item); - } - } - - private void clear() { - try { - Runtime.getRuntime().exec(new String[] { "logcat", "-c" }); - } catch (IOException e) { - Log.e("alogcat", "error clearing log", e); - } finally { - } - } - - private String dump(boolean html) { - StringBuilder sb = new StringBuilder(); - Level lastLevel = Level.V; - - // make copy to avoid CME - List entries = new ArrayList( - mLogEntryAdapter.getEntries()); - - for (LogEntry le : entries) { - if (!html) { - sb.append(le.getText()); - sb.append('\n'); - } else { - Level level = le.getLevel(); - if (level == null) { - level = lastLevel; - } else { - lastLevel = level; - } - sb.append(""); - sb.append(TextUtils.htmlEncode(le.getText())); - sb.append("
\n"); - } - } - - return sb.toString(); - } - - private void share() { - EX.execute(new Runnable() { - public void run() { - boolean html = mPrefs.isShareHtml(); - String content = dump(html); - - Intent shareIntent = new Intent( - android.content.Intent.ACTION_SEND); - - // emailIntent.setType("message/rfc822"); - if (html) { - shareIntent.setType("text/html"); - } else { - shareIntent.setType("text/plain"); - } - - shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, - "Android Log: " + LOG_DATE_FORMAT.format(new Date())); - shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, - html ? Html.fromHtml(content) : content); - startActivity(Intent.createChooser(shareIntent, - "Share Android Log ...")); - } - }); - - } - - private File save() { - final File path = new File(Environment.getExternalStorageDirectory(), - "alogcat"); - final File file = new File(path + File.separator + "alogcat." - + LogSaver.LOG_FILE_FORMAT.format(new Date()) + ".txt"); - - // String msg = "saving log to: " + file.toString(); - // Log.d("alogcat", msg); - - EX.execute(new Runnable() { - public void run() { - String content = dump(false); - - if (!path.exists()) { - path.mkdir(); - } - - BufferedWriter bw = null; - try { - file.createNewFile(); - bw = new BufferedWriter(new FileWriter(file), 1024); - bw.write(content); - } catch (IOException e) { - Log.e("alogcat", "error saving log", e); - } finally { - if (bw != null) { - try { - bw.close(); - } catch (IOException e) { - Log.e("alogcat", "error closing log", e); - } - } - } - } - }); - - return file; - } - - protected Dialog onCreateDialog(int id) { - switch (id) { - case FILTER_DIALOG: - mFilterDialog = new FilterDialog(this); - return mFilterDialog; - } - return null; - } - - private void pauseLog() { - if (!mPlay) { - return; - } - getWindow() - .setTitle(getResources().getString(R.string.app_name_paused)); - if (mLogcat != null) { - mLogcat.setPlay(false); - mPlay = false; - } - setPlayMenu(); - } - - private void playLog() { - if (mPlay) { - return; - } - getWindow().setTitle(getResources().getString(R.string.app_name)); - if (mLogcat != null) { - mLogcat.setPlay(true); - mPlay = true; - } else { - reset(); - } - setPlayMenu(); - } -} diff --git a/src/org/jtb/alogcat/LogDumper.java b/src/org/jtb/alogcat/LogDumper.java deleted file mode 100644 index 81e4957..0000000 --- a/src/org/jtb/alogcat/LogDumper.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.jtb.alogcat; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.regex.Pattern; - -import android.content.Context; -import android.text.TextUtils; -import android.util.Log; - -public class LogDumper { - private Prefs mPrefs; - - public LogDumper(Context context) { - mPrefs = new Prefs(context); - } - - public String dump(boolean html) { - StringBuilder sb = new StringBuilder(); - BufferedReader br = null; - Process p = null; - - try { - p = Runtime.getRuntime().exec( - new String[] { "logcat", "-d", "-v", - mPrefs.getFormat().getValue(), "-b", - mPrefs.getBuffer().getValue(), - "*:" + mPrefs.getLevel() }); - - br = new BufferedReader(new InputStreamReader(p.getInputStream()), - 1024); - - String line; - Pattern filterPattern = mPrefs.getFilterPattern(); - Format format = mPrefs.getFormat(); - - Level lastLevel = Level.V; - - while ((line = br.readLine()) != null) { - if (filterPattern != null - && !filterPattern.matcher(line).find()) { - continue; - } - - if (!html) { - sb.append(line); - sb.append('\n'); - } else { - Level level = format.getLevel(line); - if (level == null) { - level = lastLevel; - } else { - lastLevel = level; - } - sb.append(""); - sb.append(TextUtils.htmlEncode(line)); - sb.append("
\n"); - - } - } - String s = sb.toString(); - return s; - } catch (IOException e) { - Log.e("alogcat", "error reading log", e); - return null; - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException e) { - Log.e("alogcat", "error closing stream", e); - } - } - if (p != null) { - p.destroy(); - } - } - } -} diff --git a/src/org/jtb/alogcat/LogEntry.java b/src/org/jtb/alogcat/LogEntry.java deleted file mode 100644 index 237118e..0000000 --- a/src/org/jtb/alogcat/LogEntry.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.jtb.alogcat; - -public class LogEntry { - private Level level = Level.V; - private String text = null; - private Integer hash = null; - - public LogEntry(String text, Level level) { - this.text = text; - this.level = level; - } - - public Level getLevel() { - return level; - } - - public String getText() { - return text; - } - - @Override - public int hashCode() { - if (hash == null) { - final int prime = 31; - int result = 1; - result = prime * result + ((level == null) ? 0 : level.hashCode()); - result = prime * result + ((text == null) ? 0 : text.hashCode()); - hash = result; - } - - return hash; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - LogEntry other = (LogEntry) obj; - if (level != other.level) - return false; - if (text == null) { - if (other.text != null) - return false; - } else if (!text.equals(other.text)) - return false; - return true; - } -} diff --git a/src/org/jtb/alogcat/LogEntryAdapter.java b/src/org/jtb/alogcat/LogEntryAdapter.java deleted file mode 100644 index ca8945e..0000000 --- a/src/org/jtb/alogcat/LogEntryAdapter.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.jtb.alogcat; - -import java.util.Collections; -import java.util.List; - -import android.app.Activity; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.TextView; -import org.jtb.alogcat.R; - -public class LogEntryAdapter extends ArrayAdapter { - private Activity mActivity; - private List entries; - private Prefs mPrefs; - - public LogEntryAdapter(Activity activity, int resourceId, - List entries) { - super(activity, resourceId, entries); - this.mActivity = activity; - this.entries = entries; - this.mPrefs = new Prefs(activity); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - LogEntry entry = entries.get(position); - TextView tv; - if (convertView == null) { - LayoutInflater inflater = mActivity.getLayoutInflater(); - tv = (TextView) inflater.inflate(R.layout.entry, null); - } else { - tv = (TextView) convertView; - } - - tv.setText(entry.getText()); - tv.setTextColor(entry.getLevel().getColor()); - tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mPrefs.getTextsize() - .getValue()); - - return tv; - } - - public void remove(int position) { - LogEntry entry = entries.get(position); - remove(entry); - } - - public boolean areAllItemsEnabled() { - return false; - } - - public boolean isEnabled(int position) { - return false; - } - - public LogEntry get(int position) { - return entries.get(position); - } - - public List getEntries() { - return Collections.unmodifiableList(entries); - } -} - diff --git a/src/org/jtb/alogcat/LogSaver.java b/src/org/jtb/alogcat/LogSaver.java deleted file mode 100644 index c8f2eba..0000000 --- a/src/org/jtb/alogcat/LogSaver.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.jtb.alogcat; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; - -import android.content.Context; -import android.os.Environment; -import android.util.Log; - -public class LogSaver { - static final SimpleDateFormat LOG_FILE_FORMAT = new SimpleDateFormat( - "yyyy-MM-dd-HH-mm-ssZ"); - private static final Executor EX = Executors.newSingleThreadExecutor(); - - private Context mContext; - private Prefs mPrefs; - private LogDumper mLogDumper; - - public LogSaver(Context context) { - mContext = context; - mPrefs = new Prefs(mContext); - - mLogDumper = new LogDumper(mContext); - } - - public File save() { - final File path = new File(Environment.getExternalStorageDirectory(), - "alogcat"); - final File file = new File(path + "/alogcat." - + LOG_FILE_FORMAT.format(new Date()) + ".txt"); - - String msg = "saving log to: " + file.toString(); - //Log.d("alogcat", msg); - - EX.execute(new Runnable() { - public void run() { - String dump = mLogDumper.dump(false); - - if (!path.exists()) { - path.mkdir(); - } - - BufferedWriter bw = null; - try { - file.createNewFile(); - bw = new BufferedWriter(new FileWriter(file), 1024); - bw.write(dump); - } catch (IOException e) { - Log.e("alogcat", "error saving log", e); - } finally { - if (bw != null) { - try { - bw.close(); - } catch (IOException e) { - Log.e("alogcat", "error closing log", e); - } - } - } - } - }); - - return file; - } - -} diff --git a/src/org/jtb/alogcat/Logcat.java b/src/org/jtb/alogcat/Logcat.java deleted file mode 100644 index 261cca3..0000000 --- a/src/org/jtb/alogcat/Logcat.java +++ /dev/null @@ -1,182 +0,0 @@ -package org.jtb.alogcat; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.regex.Pattern; - -import android.content.Context; -import android.os.Handler; -import android.os.Message; -import android.util.Log; - -public class Logcat { - private static final long CAT_DELAY = 1; - - private Level mLevel = null; - private String mFilter = null; - private Pattern mFilterPattern = null; - private boolean mRunning = false; - private BufferedReader mReader = null; - private boolean mIsFilterPattern; - private Handler mHandler; - private Buffer mBuffer; - private Process logcatProc; - private Context mContext; - private ArrayList mLogCache = new ArrayList(); - private boolean mPlay = true; - private long lastCat = -1; - private Runnable catRunner = new Runnable() { - - @Override - public void run() { - if (!mPlay) { - return; - } - long now = System.currentTimeMillis(); - if (now < lastCat + CAT_DELAY) { - return; - } - lastCat = now; - cat(); - } - }; - private ScheduledExecutorService EX; - - Format mFormat; - - public Logcat(Context context, Handler handler) { - mContext = context; - mHandler = handler; - - Prefs prefs = new Prefs(mContext); - - mLevel = prefs.getLevel(); - mIsFilterPattern = prefs.isFilterPattern(); - mFilter = prefs.getFilter(); - mFilterPattern = prefs.getFilterPattern(); - mFormat = prefs.getFormat(); - mBuffer = prefs.getBuffer(); - } - - public void start() { - // Log.d("alogcat", "starting ..."); - stop(); - - mRunning = true; - - EX = Executors.newScheduledThreadPool(1); - EX.scheduleAtFixedRate(catRunner, CAT_DELAY, CAT_DELAY, - TimeUnit.SECONDS); - - try { - Message m = Message.obtain(mHandler, LogActivity.CLEAR_WHAT); - mHandler.sendMessage(m); - - List progs = new ArrayList(); - - progs.add("logcat"); - progs.add("-v"); - progs.add(mFormat.getValue()); - if (mBuffer != Buffer.MAIN) { - progs.add("-b"); - progs.add(mBuffer.getValue()); - } - progs.add("*:" + mLevel); - - logcatProc = Runtime.getRuntime() - .exec(progs.toArray(new String[0])); - - mReader = new BufferedReader(new InputStreamReader( - logcatProc.getInputStream()), 1024); - - String line; - while (mRunning && (line = mReader.readLine()) != null) { - if (!mRunning) { - break; - } - if (line.length() == 0) { - continue; - } - if (mIsFilterPattern) { - if (mFilterPattern != null - && !mFilterPattern.matcher(line).find()) { - continue; - } - } else { - if (mFilter != null - && !line.toLowerCase().contains( - mFilter.toLowerCase())) { - continue; - } - } - synchronized (mLogCache) { - mLogCache.add(line); - } - } - } catch (IOException e) { - Log.e("alogcat", "error reading log", e); - return; - } finally { - // Log.d("alogcat", "stopped"); - - if (logcatProc != null) { - logcatProc.destroy(); - logcatProc = null; - } - if (mReader != null) { - try { - mReader.close(); - mReader = null; - } catch (IOException e) { - Log.e("alogcat", "error closing stream", e); - } - } - } - } - - private void cat() { - Message m; - - if (mLogCache.size() > 0) { - synchronized (mLogCache) { - if (mLogCache.size() > 0) { - m = Message.obtain(mHandler, LogActivity.CAT_WHAT); - m.obj = mLogCache.clone(); - mLogCache.clear(); - mHandler.sendMessage(m); - } - } - } - } - - public void stop() { - // Log.d("alogcat", "stopping ..."); - mRunning = false; - - if (EX != null && !EX.isShutdown()) { - EX.shutdown(); - EX = null; - } - } - - public boolean isRunning() { - return mRunning; - } - - public boolean isPlay() { - return mPlay; - } - - public void setPlay(boolean play) { - mPlay = play; - } - -} diff --git a/src/org/jtb/alogcat/Prefs.java b/src/org/jtb/alogcat/Prefs.java deleted file mode 100644 index 5dc95a8..0000000 --- a/src/org/jtb/alogcat/Prefs.java +++ /dev/null @@ -1,156 +0,0 @@ -package org.jtb.alogcat; - -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; - -import android.content.Context; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.preference.PreferenceManager; -import android.util.Log; -import org.jtb.alogcat.R; - -public class Prefs { - public static final String LEVEL_KEY = "level"; - public static final String FORMAT_KEY = "format"; - public static final String BUFFER_KEY = "buffer"; - public static final String TEXTSIZE_KEY = "textsize"; - public static final String BACKGROUND_COLOR_KEY = "backgroundColor"; - public static final String FILTER_PATTERN_KEY = "filterPattern"; - public static final String SHARE_HTML_KEY = "shareHtml"; - public static final String KEEP_SCREEN_ON_KEY = "keepScreenOn"; - - private SharedPreferences sharedPrefs = null; - - public Prefs(Context context) { - sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); - } - - private String getString(String key, String def) { - String s = sharedPrefs.getString(key, def); - return s; - } - - private void setString(String key, String val) { - Editor e = sharedPrefs.edit(); - e.putString(key, val); - e.commit(); - } - - private boolean getBoolean(String key, boolean def) { - boolean b = sharedPrefs.getBoolean(key, def); - return b; - } - - private void setBoolean(String key, boolean val) { - Editor e = sharedPrefs.edit(); - e.putBoolean(key, val); - e.commit(); - } - - public Level getLevel() { - return Level.valueOf(getString(LEVEL_KEY, "V")); - } - - public void setLevel(Level level) { - setString(LEVEL_KEY, level.toString()); - } - - public Format getFormat() { - String f = getString(FORMAT_KEY, "BRIEF"); - - // UPGRADE - // can remove at some point - - if (!f.equals(f.toUpperCase())) { - f = f.toUpperCase(); - setString(FORMAT_KEY, f); - } - - return Format.valueOf(f); - } - - public void setFormat(Format format) { - setString(FORMAT_KEY, format.toString()); - } - - public Buffer getBuffer() { - return Buffer.valueOf(getString(BUFFER_KEY, "MAIN")); - } - - public void setBuffer(Buffer buffer) { - setString(BUFFER_KEY, buffer.toString()); - } - - public Textsize getTextsize() { - return Textsize.valueOf(getString(TEXTSIZE_KEY, "MEDIUM")); - } - - public void setTextsize(Textsize textsize) { - setString(TEXTSIZE_KEY, textsize.toString()); - } - - public String getFilter() { - return getString("filter", null); - } - - public Pattern getFilterPattern() { - if (!isFilterPattern()) { - return null; - } - - String p = getString("filter", null); - if (p == null) { - return null; - } - try { - return Pattern.compile(p, Pattern.CASE_INSENSITIVE); - } catch (PatternSyntaxException e) { - setString("filter", null); - Log.w("alogcat", "invalid filter pattern found, cleared"); - return null; - } - } - - public void setFilter(String filter) { - setString("filter", filter); - } - - public BackgroundColor getBackgroundColor() { - String c = getString(BACKGROUND_COLOR_KEY, "WHITE"); - BackgroundColor bc; - - try { - bc = BackgroundColor.valueOf(c); - } catch (IllegalArgumentException iae) { - bc = BackgroundColor.valueOfHexColor(c); - } - if (bc == null) { - return BackgroundColor.WHITE; - } - - return bc; - } - - public boolean isShareHtml() { - boolean b = getBoolean(SHARE_HTML_KEY, false); - return b; - } - - public boolean isKeepScreenOn() { - boolean b = getBoolean(KEEP_SCREEN_ON_KEY, false); - return b; - } - - public void setKeepScreenOn(boolean keep) { - setBoolean(KEEP_SCREEN_ON_KEY, keep); - } - - public boolean isFilterPattern() { - return getBoolean(FILTER_PATTERN_KEY, false); - } - - public void setFilterPattern(boolean filterPattern) { - setBoolean(FILTER_PATTERN_KEY, filterPattern); - } -} diff --git a/src/org/jtb/alogcat/PrefsActivity.java b/src/org/jtb/alogcat/PrefsActivity.java deleted file mode 100644 index e4b7eb3..0000000 --- a/src/org/jtb/alogcat/PrefsActivity.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.jtb.alogcat; - -import android.app.Activity; -import android.content.SharedPreferences; -import android.content.SharedPreferences.OnSharedPreferenceChangeListener; -import android.os.Bundle; -import android.preference.ListPreference; -import android.preference.PreferenceActivity; -import org.jtb.alogcat.R; - -public class PrefsActivity extends PreferenceActivity implements - OnSharedPreferenceChangeListener { - private ListPreference mLevelPreference; - private ListPreference mFormatPreference; - private ListPreference mBufferPreference; - private ListPreference mTextsizePreference; - private ListPreference mBackgroundColorPreference; - - private Prefs mPrefs; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.layout.prefs); - - mPrefs = new Prefs(this); - - mLevelPreference = (ListPreference) getPreferenceScreen() - .findPreference(Prefs.LEVEL_KEY); - mFormatPreference = (ListPreference) getPreferenceScreen() - .findPreference(Prefs.FORMAT_KEY); - mBufferPreference = (ListPreference) getPreferenceScreen() - .findPreference(Prefs.BUFFER_KEY); - mTextsizePreference = (ListPreference) getPreferenceScreen() - .findPreference(Prefs.TEXTSIZE_KEY); - mBackgroundColorPreference = (ListPreference) getPreferenceScreen() - .findPreference(Prefs.BACKGROUND_COLOR_KEY); - - setResult(Activity.RESULT_OK); - } - - private void setLevelTitle() { - mLevelPreference.setTitle("Level? (" + mPrefs.getLevel().getTitle(this) + ")"); - } - - private void setFormatTitle() { - mFormatPreference.setTitle("Format? (" + mPrefs.getFormat().getTitle(this) + ")"); - } - - private void setBufferTitle() { - mBufferPreference.setTitle("Buffer? (" + mPrefs.getBuffer().getTitle(this) + ")"); - } - - private void setTextsizeTitle() { - mTextsizePreference.setTitle("Text Size? (" + mPrefs.getTextsize().getTitle(this) + ")"); - } - - private void setBackgroundColorTitle() { - mBackgroundColorPreference.setTitle("Background Color? (" + mPrefs.getBackgroundColor().getTitle(this) + ")"); - } - - @Override - protected void onResume() { - super.onResume(); - - setLevelTitle(); - setFormatTitle(); - setBufferTitle(); - setTextsizeTitle(); - setBackgroundColorTitle(); - - getPreferenceScreen().getSharedPreferences() - .registerOnSharedPreferenceChangeListener(this); - } - - @Override - protected void onPause() { - super.onPause(); - getPreferenceScreen().getSharedPreferences() - .unregisterOnSharedPreferenceChangeListener(this); - } - - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, - String key) { - if (key.equals(Prefs.LEVEL_KEY)) { - setLevelTitle(); - } else if (key.equals(Prefs.FORMAT_KEY)) { - setFormatTitle(); - } else if (key.equals(Prefs.BUFFER_KEY)) { - setBufferTitle(); - } else if (key.equals(Prefs.TEXTSIZE_KEY)) { - setTextsizeTitle(); - } else if (key.equals(Prefs.BACKGROUND_COLOR_KEY)) { - setBackgroundColorTitle(); - } - } -} diff --git a/src/org/jtb/alogcat/SaveReceiver.java b/src/org/jtb/alogcat/SaveReceiver.java deleted file mode 100644 index 929ad95..0000000 --- a/src/org/jtb/alogcat/SaveReceiver.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.jtb.alogcat; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.util.Log; - -public class SaveReceiver extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - //Log.d("alogcat", "received intent for save"); - - org.jtb.alogcat.Intent.handleExtras(context, intent); - - Lock.acquire(context); - - Intent svcIntent = new Intent(context, SaveService.class); - context.startService(svcIntent); - } -} diff --git a/src/org/jtb/alogcat/SaveService.java b/src/org/jtb/alogcat/SaveService.java deleted file mode 100644 index 094f246..0000000 --- a/src/org/jtb/alogcat/SaveService.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.jtb.alogcat; - -import android.app.IntentService; -import android.content.Intent; -import android.util.Log; - -public class SaveService extends IntentService { - public SaveService() { - super("saveService"); - } - - @Override - protected void onHandleIntent(Intent intent) { - //Log.d("alogcat", "handling intent"); - - LogSaver saver = new LogSaver(this); - saver.save(); - - Lock.release(); - } -} diff --git a/src/org/jtb/alogcat/ShareReceiver.java b/src/org/jtb/alogcat/ShareReceiver.java deleted file mode 100644 index 147a265..0000000 --- a/src/org/jtb/alogcat/ShareReceiver.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.jtb.alogcat; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.util.Log; - -public class ShareReceiver extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - //Log.d("alogcat", "received intent for share"); - - org.jtb.alogcat.Intent.handleExtras(context, intent); - - Lock.acquire(context); - - Intent svcIntent = new Intent(context, ShareService.class); - context.startService(svcIntent); - } - -} diff --git a/src/org/jtb/alogcat/ShareService.java b/src/org/jtb/alogcat/ShareService.java deleted file mode 100644 index 68a1eff..0000000 --- a/src/org/jtb/alogcat/ShareService.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.jtb.alogcat; - -import java.util.Date; - -import android.app.IntentService; -import android.content.Intent; -import android.text.Html; -import android.util.Log; - -public class ShareService extends IntentService { - public ShareService() { - super("saveService"); - } - - @Override - protected void onHandleIntent(Intent intent) { - //Log.d("alogcat", "handling intent: " + intent.getAction()); - - Prefs prefs = new Prefs(this); - - LogDumper dumper = new LogDumper(this); - boolean html = prefs.isShareHtml(); - String content = dumper.dump(html); - - Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); - - // emailIntent.setType("message/rfc822"); - if (html) { - shareIntent.setType("text/html"); - } else { - shareIntent.setType("text/plain"); - } - - shareIntent.putExtra( - android.content.Intent.EXTRA_SUBJECT, - "Android Log: " - + LogActivity.LOG_DATE_FORMAT.format(new Date())); - shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, - html ? Html.fromHtml(content) : content); - Intent chooserIntent = Intent - .createChooser(shareIntent, "Share Android Log ..."); - chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(chooserIntent); - - Lock.release(); - } -} diff --git a/src/org/jtb/alogcat/Textsize.java b/src/org/jtb/alogcat/Textsize.java deleted file mode 100644 index c44558e..0000000 --- a/src/org/jtb/alogcat/Textsize.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.jtb.alogcat; - -import org.jtb.alogcat.R; - -import android.content.Context; -import android.util.SparseArray; - -public enum Textsize { - SMALL(8, R.string.small_title), - MEDIUM(10, R.string.medium_title), - LARGE(12, R.string.large_title); - - private static Textsize[] byOrder = new Textsize[3]; - - static { - byOrder[0] = SMALL; - byOrder[1] = MEDIUM; - byOrder[2] = LARGE; - } - - private static final SparseArray VALUE_MAP = new SparseArray(); - - static { - VALUE_MAP.put(SMALL.mValue, SMALL); - VALUE_MAP.put(MEDIUM.mValue, MEDIUM); - VALUE_MAP.put(LARGE.mValue, LARGE); - } - - private Integer mValue; - private int mTitleId; - - private Textsize(Integer value, int titleId) { - mValue = value; - mTitleId = titleId; - } - - public String getTitle(Context context) { - return context.getResources().getString(mTitleId); - } - - public static Textsize getByOrder(int order) { - return byOrder[order]; - } - - public Integer getValue() { - return mValue; - } -}