[logcatudp] 2 new revisions pushed by jmad...@gmail.com on 2010-10-29 16:58 GMT

0 views
Skip to first unread message

logc...@googlecode.com

unread,
Oct 29, 2010, 12:59:21 PM10/29/10
to logcatud...@googlegroups.com
2 new revisions:

Revision: 5c93e758ab
Author: jma...@gmail.com
Date: Fri Oct 29 08:08:01 2010
Log: Implemented start at boot option.
http://code.google.com/p/logcatudp/source/detail?r=5c93e758ab

Revision: 793835f619
Author: jma...@gmail.com
Date: Fri Oct 29 09:57:46 2010
Log: Added statusbar notification.
http://code.google.com/p/logcatudp/source/detail?r=793835f619

==============================================================================
Revision: 5c93e758ab
Author: jma...@gmail.com
Date: Fri Oct 29 08:08:01 2010
Log: Implemented start at boot option.
http://code.google.com/p/logcatudp/source/detail?r=5c93e758ab

Added:
/src/sk/madzik/android/logcatudp/LogcatUdpReceiver.java
Modified:
/AndroidManifest.xml
/src/sk/madzik/android/logcatudp/LogcatUdpService.java

=======================================
--- /dev/null
+++ /src/sk/madzik/android/logcatudp/LogcatUdpReceiver.java Fri Oct 29
08:08:01 2010
@@ -0,0 +1,22 @@
+package sk.madzik.android.logcatudp;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.util.Log;
+
+public class LogcatUdpReceiver extends BroadcastReceiver {
+ private static final String TAG = "LogcaUdpReceiver";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d(TAG, "Boot completed; starting service ...");
+ SharedPreferences settings =
context.getSharedPreferences(LogcatUdpCfg.Preferences.PREFS_NAME,
Context.MODE_PRIVATE);
+
+ if (settings.getBoolean(LogcatUdpCfg.Preferences.AUTO_START, true)) {
+ context.startService(new Intent(context, LogcatUdpService.class));
+ Log.i(TAG, "Service Started");
+ }
+ }
+}
=======================================
--- /AndroidManifest.xml Tue Oct 26 14:34:53 2010
+++ /AndroidManifest.xml Fri Oct 29 08:08:01 2010
@@ -5,6 +5,7 @@
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS" />
+ <uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:debuggable="true">
@@ -17,6 +18,13 @@
</intent-filter>
</activity>
<service android:name="LogcatUdpService"></service>
+ <receiver android:name="LogcatUdpReceiver"
+ android:enabled="true"
+ android:exported="false">
+ <intent-filter>
+ <action
android:name="android.intent.action.BOOT_COMPLETED"></action>
+ </intent-filter>
+ </receiver>

</application>
<uses-sdk android:minSdkVersion="3" />
=======================================
--- /src/sk/madzik/android/logcatudp/LogcatUdpService.java Tue Oct 26
14:34:53 2010
+++ /src/sk/madzik/android/logcatudp/LogcatUdpService.java Fri Oct 29
08:08:01 2010
@@ -46,7 +46,6 @@

// TODO: notification on statusbar

- // TODO: read logcat, open udp port, send lines (thread)
try {
mSocket = new DatagramSocket();
} catch (SocketException e) {

==============================================================================
Revision: 793835f619
Author: jma...@gmail.com
Date: Fri Oct 29 09:57:46 2010
Log: Added statusbar notification.
http://code.google.com/p/logcatudp/source/detail?r=793835f619

Added:
/res/drawable/notif_icon.png
Modified:
/gen/sk/madzik/android/logcatudp/R.java
/res/values/strings.xml
/src/sk/madzik/android/logcatudp/LogcatUdpReceiver.java
/src/sk/madzik/android/logcatudp/LogcatUdpService.java

=======================================
--- /dev/null
+++ /res/drawable/notif_icon.png Fri Oct 29 09:57:46 2010
Binary file, no diff available.
=======================================
--- /gen/sk/madzik/android/logcatudp/R.java Tue Oct 26 14:27:21 2010
+++ /gen/sk/madzik/android/logcatudp/R.java Fri Oct 29 09:57:46 2010
@@ -12,6 +12,7 @@
}
public static final class drawable {
public static final int icon=0x7f020000;
+ public static final int notif_icon=0x7f020001;
}
public static final class id {
public static final int activateServiceBtn=0x7f050007;
@@ -36,6 +37,8 @@
public static final int mnuClear=0x7f040009;
public static final int mnuClose=0x7f040008;
public static final int mnuSave=0x7f040007;
+ public static final int notif_message=0x7f04000b;
+ public static final int notif_text=0x7f04000a;
public static final int send_ids=0x7f040001;
public static final int server_port=0x7f040003;
}
=======================================
--- /res/values/strings.xml Tue Oct 26 14:27:21 2010
+++ /res/values/strings.xml Fri Oct 29 09:57:46 2010
@@ -11,4 +11,6 @@
<string name="mnuSave">Save</string>
<string name="mnuClose">Cancel/Close</string>
<string name="mnuClear">Clear log</string>
+<string name="notif_text">LogcatUDP service running</string>
+<string name="notif_message">Configure Logcat to UDP, restart or stop
sending.</string>
</resources>
=======================================
--- /src/sk/madzik/android/logcatudp/LogcatUdpReceiver.java Fri Oct 29
08:08:01 2010
+++ /src/sk/madzik/android/logcatudp/LogcatUdpReceiver.java Fri Oct 29
09:57:46 2010
@@ -16,7 +16,7 @@

if (settings.getBoolean(LogcatUdpCfg.Preferences.AUTO_START, true)) {
context.startService(new Intent(context, LogcatUdpService.class));
- Log.i(TAG, "Service Started");
+ Log.i(TAG, "Starting Service");
}
}
}
=======================================
--- /src/sk/madzik/android/logcatudp/LogcatUdpService.java Fri Oct 29
08:08:01 2010
+++ /src/sk/madzik/android/logcatudp/LogcatUdpService.java Fri Oct 29
09:57:46 2010
@@ -3,6 +3,9 @@
import java.net.DatagramSocket;
import java.net.SocketException;

+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
@@ -26,6 +29,8 @@

private DatagramSocket mSocket = null;
private LogcatThread mLogcatThread = null;
+ private NotificationManager mNotificationManager = null;
+ private int SERVICE_NOTIFICATION_ID = 1;

@Override
public void onCreate() {
@@ -44,7 +49,18 @@
mConfig.mDestServer =
settings.getString(LogcatUdpCfg.Preferences.DEST_SERVER,
LogcatUdpCfg.DEF_SERVER);
mConfig.mDestPort = settings.getInt(LogcatUdpCfg.Preferences.DEST_PORT,
LogcatUdpCfg.DEF_PORT);

- // TODO: notification on statusbar
+ // status bar notification icon manager
+ mNotificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
+ int icon = R.drawable.notif_icon;
+ Notification notif = new Notification( icon,
this.getString(R.string.notif_text), System.currentTimeMillis() );
+ notif.flags |= Notification.FLAG_ONGOING_EVENT;
+ notif.flags |= Notification.FLAG_NO_CLEAR;
+ notif.setLatestEventInfo(
+ getApplicationContext(),
+ this.getString(R.string.notif_text),
+ this.getString(R.string.notif_message),
+ PendingIntent.getActivity(this, 0, new Intent(this,
LogcatUdpCfg.class), 0) );
+ mNotificationManager.notify( SERVICE_NOTIFICATION_ID, notif );

try {
mSocket = new DatagramSocket();
@@ -72,6 +88,7 @@
Log.w(TAG, "Joining logcat thread exception.");
}
}
+ mNotificationManager.cancelAll();
isRunning = false;
}

Reply all
Reply to author
Forward
0 new messages