Skip to content
Browse files

Cleanup

  • Loading branch information...
1 parent d123b24 commit 19f4c039e6e6e35b6609df5a2d90c7e30ca312fc @willhou committed Sep 18, 2011
Showing with 56 additions and 14 deletions.
  1. +40 −0 proguard.cfg
  2. +16 −14 src/com/maize/bluetoothNotification/BluetoothBroadcastReceiver.java
View
40 proguard.cfg
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
View
30 src/com/maize/bluetoothNotification/BluetoothBroadcastReceiver.java
@@ -13,25 +13,27 @@
public class BluetoothBroadcastReceiver extends BroadcastReceiver {
- final String TAG = "BluetoothBroadcastReceiver";
+ final String TAG = "BluetoothBroadcastReceiver";
final String PATH_SETTINGS_PKG = "com.android.settings";
final String PATH_SETTINGS_BLUETOOTH = ".bluetooth.BluetoothSettings";
final int ID = 46709394;
- SharedPreferences prefs;
+ SharedPreferences prefs;
- @Override
- public void onReceive(Context context, Intent intent) {
+ @Override
+ public void onReceive(Context context, Intent intent) {
prefs = PreferenceManager.getDefaultSharedPreferences(context);
- String action = intent.getAction();
- BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = null;
+
String tickerText = null;
String contentText = "Address: " + device.getAddress();
- Log.d(TAG, action);
-
+
+ String action = intent.getAction();
+ Log.d(TAG, action);
+
if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
Log.d(TAG, "Bond state changed to " + state);
@@ -66,13 +68,13 @@ else if (BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED.equals(action)
tickerText = "Request disconnect from " + device.getName();
}
else return;
-
+
notification = constructNotification(context, tickerText, tickerText, contentText);
manager.notify(ID, notification);
- }
+ }
- Notification constructNotification(Context context, String tickerText, String titleText, String contentText) {
- Notification notification = new Notification();
+ private Notification constructNotification(Context context, String tickerText, String titleText, String contentText) {
+ Notification notification = new Notification();
notification.icon = R.drawable.icon;
notification.when = System.currentTimeMillis();
notification.tickerText = tickerText;
@@ -91,6 +93,6 @@ else if (prefs.getBoolean(Key.VIBRATE, true)) {
notificationIntent.setClassName(PATH_SETTINGS_PKG, PATH_SETTINGS_PKG + PATH_SETTINGS_BLUETOOTH);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, titleText, contentText, contentIntent);
- return notification;
- }
+ return notification;
+ }
}

0 comments on commit 19f4c03

Please sign in to comment.
Something went wrong with that request. Please try again.