From 76edd6c448c55c4f9bcf37509ec372149c966993 Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 25 Dec 2015 13:38:31 +0100 Subject: first commit --- AndroidClient/app/.gitignore | 1 + AndroidClient/app/app.iml | 91 +++++++++++++++ AndroidClient/app/build.gradle | 28 +++++ AndroidClient/app/proguard-rules.pro | 17 +++ AndroidClient/app/src/main/AndroidManifest.xml | 34 ++++++ AndroidClient/app/src/main/ic_launcher-web.png | Bin 0 -> 16925 bytes .../notifications/NotifListenerService.java | 129 +++++++++++++++++++++ .../snowman/notifications/WebViewActivity.java | 17 +++ .../apptheme_scrubber_control_disabled_holo.png | Bin 0 -> 883 bytes .../apptheme_scrubber_control_focused_holo.png | Bin 0 -> 1096 bytes .../apptheme_scrubber_control_normal_holo.png | Bin 0 -> 1342 bytes .../apptheme_scrubber_control_pressed_holo.png | Bin 0 -> 1669 bytes .../app/src/main/res/drawable-hdpi/ic_launcher.png | Bin 0 -> 128 bytes .../apptheme_scrubber_control_disabled_holo.png | Bin 0 -> 128 bytes .../apptheme_scrubber_control_focused_holo.png | Bin 0 -> 128 bytes .../apptheme_scrubber_control_normal_holo.png | Bin 0 -> 800 bytes .../apptheme_scrubber_control_pressed_holo.png | Bin 0 -> 947 bytes .../app/src/main/res/drawable-mdpi/ic_launcher.png | Bin 0 -> 1980 bytes .../apptheme_scrubber_control_disabled_holo.png | Bin 0 -> 128 bytes .../apptheme_scrubber_control_focused_holo.png | Bin 0 -> 1363 bytes .../apptheme_scrubber_control_normal_holo.png | Bin 0 -> 1593 bytes .../apptheme_scrubber_control_pressed_holo.png | Bin 0 -> 128 bytes .../src/main/res/drawable-xhdpi/ic_launcher.png | Bin 0 -> 128 bytes .../apptheme_scrubber_control_disabled_holo.png | Bin 0 -> 1415 bytes .../apptheme_scrubber_control_focused_holo.png | Bin 0 -> 1793 bytes .../apptheme_scrubber_control_normal_holo.png | Bin 0 -> 2390 bytes .../apptheme_scrubber_control_pressed_holo.png | Bin 0 -> 2609 bytes .../src/main/res/drawable-xxhdpi/ic_launcher.png | Bin 0 -> 8496 bytes ...ptheme_scrubber_control_selector_holo_light.xml | Bin 0 -> 128 bytes ...eme_scrubber_progress_horizontal_holo_light.xml | 28 +++++ AndroidClient/app/src/main/res/layout/main.xml | Bin 0 -> 128 bytes AndroidClient/app/src/main/res/values/strings.xml | 3 + AndroidClient/app/src/main/res/values/styles.xml | 7 ++ 33 files changed, 355 insertions(+) create mode 100644 AndroidClient/app/.gitignore create mode 100644 AndroidClient/app/app.iml create mode 100644 AndroidClient/app/build.gradle create mode 100644 AndroidClient/app/proguard-rules.pro create mode 100644 AndroidClient/app/src/main/AndroidManifest.xml create mode 100644 AndroidClient/app/src/main/ic_launcher-web.png create mode 100644 AndroidClient/app/src/main/java/winter/snowman/notifications/NotifListenerService.java create mode 100644 AndroidClient/app/src/main/java/winter/snowman/notifications/WebViewActivity.java create mode 100755 AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_disabled_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_focused_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_normal_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_pressed_holo.png create mode 100644 AndroidClient/app/src/main/res/drawable-hdpi/ic_launcher.png create mode 100755 AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_disabled_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_focused_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_normal_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_pressed_holo.png create mode 100644 AndroidClient/app/src/main/res/drawable-mdpi/ic_launcher.png create mode 100755 AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_disabled_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_focused_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_normal_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_pressed_holo.png create mode 100644 AndroidClient/app/src/main/res/drawable-xhdpi/ic_launcher.png create mode 100755 AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_disabled_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_focused_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_normal_holo.png create mode 100755 AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_pressed_holo.png create mode 100644 AndroidClient/app/src/main/res/drawable-xxhdpi/ic_launcher.png create mode 100755 AndroidClient/app/src/main/res/drawable/apptheme_scrubber_control_selector_holo_light.xml create mode 100755 AndroidClient/app/src/main/res/drawable/apptheme_scrubber_progress_horizontal_holo_light.xml create mode 100644 AndroidClient/app/src/main/res/layout/main.xml create mode 100644 AndroidClient/app/src/main/res/values/strings.xml create mode 100644 AndroidClient/app/src/main/res/values/styles.xml (limited to 'AndroidClient/app') diff --git a/AndroidClient/app/.gitignore b/AndroidClient/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/AndroidClient/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/AndroidClient/app/app.iml b/AndroidClient/app/app.iml new file mode 100644 index 0000000..4bffb70 --- /dev/null +++ b/AndroidClient/app/app.iml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AndroidClient/app/build.gradle b/AndroidClient/app/build.gradle new file mode 100644 index 0000000..c69adc5 --- /dev/null +++ b/AndroidClient/app/build.gradle @@ -0,0 +1,28 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "21" + + defaultConfig { + applicationId "winter.snowman.notifications" + minSdkVersion 19 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:21.0.2' +} diff --git a/AndroidClient/app/proguard-rules.pro b/AndroidClient/app/proguard-rules.pro new file mode 100644 index 0000000..22d7812 --- /dev/null +++ b/AndroidClient/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/christian/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# 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/AndroidClient/app/src/main/AndroidManifest.xml b/AndroidClient/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a6014da --- /dev/null +++ b/AndroidClient/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AndroidClient/app/src/main/ic_launcher-web.png b/AndroidClient/app/src/main/ic_launcher-web.png new file mode 100644 index 0000000..ff6dc63 Binary files /dev/null and b/AndroidClient/app/src/main/ic_launcher-web.png differ diff --git a/AndroidClient/app/src/main/java/winter/snowman/notifications/NotifListenerService.java b/AndroidClient/app/src/main/java/winter/snowman/notifications/NotifListenerService.java new file mode 100644 index 0000000..dde3d1f --- /dev/null +++ b/AndroidClient/app/src/main/java/winter/snowman/notifications/NotifListenerService.java @@ -0,0 +1,129 @@ +package winter.snowman.notifications; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.service.notification.NotificationListenerService; +import android.service.notification.StatusBarNotification; +import android.util.Log; + +import java.net.URL; +import java.io.InputStream; +import java.io.BufferedInputStream; +import java.net.URLConnection; +import java.net.HttpURLConnection; + +/** + * Created by christian on 1/1/15. + */ +public class NotifListenerService extends NotificationListenerService { + private String TAG = this.getClass().getSimpleName(); + + private NotifListenerServiceReceiver notifListenerServiceReceiver; + + @Override + public void onCreate() { + super.onCreate(); + notifListenerServiceReceiver = new NotifListenerServiceReceiver(); + + IntentFilter filter = new IntentFilter(); + filter.addAction("com.cle.ambientnotifications.NOTIFICATION_LISTENER_SERVICE"); + registerReceiver(notifListenerServiceReceiver, filter); + + Log.d(TAG, "NotifListenerService is running"); + } + + @Override + public void onDestroy() { + super.onDestroy(); + unregisterReceiver(notifListenerServiceReceiver); + } + + private void notificationOff() { + Log.i(TAG, "********** notification off"); + URL url; + HttpURLConnection urlConnection; + try { + url = new URL("http://snowman/api?led2=clear"); + urlConnection = (HttpURLConnection) url.openConnection(); + } catch (Exception e) { + e.printStackTrace(); + return; + } + try { + InputStream in = new BufferedInputStream(urlConnection.getInputStream()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + urlConnection.disconnect(); + } + } + + private void notificationOn() { + Log.i(TAG, "********** notification on"); + URL url; + HttpURLConnection urlConnection; + try { + url = new URL("http://snowman/api?led2=blink"); + urlConnection = (HttpURLConnection) url.openConnection(); + } catch (Exception e) { + e.printStackTrace(); + return; + } + try { + InputStream in = new BufferedInputStream(urlConnection.getInputStream()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + urlConnection.disconnect(); + } + } + + @Override + public void onNotificationPosted(StatusBarNotification notif) { + Log.i(TAG, "********** onNotificationPosted"); + Log.i(TAG,"ID :" + notif.getId() + "t" + notif.getNotification().tickerText + + "t" + notif.getPackageName()); + notificationOn(); + } + + @Override + public void onNotificationRemoved(StatusBarNotification notif) { + Log.i(TAG, "********** onNotificationRemoved"); + Log.i(TAG,"ID :" + notif.getId() + "t" + notif.getNotification().tickerText + + "t" + notif.getPackageName()); + notificationOff(); + }; + + class NotifListenerServiceReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + if (intent.getStringExtra("command").equals("clearall")) { + NotifListenerService.this.cancelAllNotifications(); + } else if (intent.getStringExtra("command").equals("list")) { + Log.d(TAG, "command received"); + + Intent i = new Intent("com.cle.ambientnotifications.NOTIFICATION_LISTENER"); + i.putExtra("notification_event", "========="); + sendBroadcast(i); + + int counter = 1; + for (StatusBarNotification notif : NotifListenerService.this.getActiveNotifications()) { + Intent notifIntent = + new Intent("com.cle.ambientnotifications.NOTIFICATION_LISTENER"); + notifIntent.putExtra("notification_event", counter + " " + + notif.getPackageName() + "\n"); + sendBroadcast(notifIntent); + counter += 1; + } + + Intent listIntent = + new Intent("com.cle.ambientnotifications.NOTIFICATION_LISTENER"); + listIntent.putExtra("notification_event", "==== Notification List ===="); + sendBroadcast(listIntent); + } + } + } +} diff --git a/AndroidClient/app/src/main/java/winter/snowman/notifications/WebViewActivity.java b/AndroidClient/app/src/main/java/winter/snowman/notifications/WebViewActivity.java new file mode 100644 index 0000000..0618fd2 --- /dev/null +++ b/AndroidClient/app/src/main/java/winter/snowman/notifications/WebViewActivity.java @@ -0,0 +1,17 @@ +package winter.snowman.notifications; + +import android.app.Activity; +import android.webkit.WebView; +import android.os.Bundle; + +public class WebViewActivity extends Activity { + + private WebView webView; + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + webView = (WebView) findViewById(R.id.webView); + webView.loadUrl("http://snowman"); + } +} diff --git a/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_disabled_holo.png b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_disabled_holo.png new file mode 100755 index 0000000..a1acbb5 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_disabled_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_focused_holo.png b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_focused_holo.png new file mode 100755 index 0000000..1b75394 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_focused_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_normal_holo.png b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_normal_holo.png new file mode 100755 index 0000000..4900d70 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_normal_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_pressed_holo.png b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_pressed_holo.png new file mode 100755 index 0000000..7469c47 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_pressed_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-hdpi/ic_launcher.png b/AndroidClient/app/src/main/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..00bc047 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-hdpi/ic_launcher.png differ diff --git a/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_disabled_holo.png b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_disabled_holo.png new file mode 100755 index 0000000..00bc047 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_disabled_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_focused_holo.png b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_focused_holo.png new file mode 100755 index 0000000..00bc047 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_focused_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_normal_holo.png b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_normal_holo.png new file mode 100755 index 0000000..31abfb5 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_normal_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_pressed_holo.png b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_pressed_holo.png new file mode 100755 index 0000000..a296f4c Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_pressed_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-mdpi/ic_launcher.png b/AndroidClient/app/src/main/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..2067e78 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-mdpi/ic_launcher.png differ diff --git a/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_disabled_holo.png b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_disabled_holo.png new file mode 100755 index 0000000..00bc047 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_disabled_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_focused_holo.png b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_focused_holo.png new file mode 100755 index 0000000..2f38b65 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_focused_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_normal_holo.png b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_normal_holo.png new file mode 100755 index 0000000..af951cb Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_normal_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_pressed_holo.png b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_pressed_holo.png new file mode 100755 index 0000000..00bc047 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_pressed_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-xhdpi/ic_launcher.png b/AndroidClient/app/src/main/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..00bc047 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-xhdpi/ic_launcher.png differ diff --git a/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_disabled_holo.png b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_disabled_holo.png new file mode 100755 index 0000000..a64250e Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_disabled_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_focused_holo.png b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_focused_holo.png new file mode 100755 index 0000000..6a80a0e Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_focused_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_normal_holo.png b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_normal_holo.png new file mode 100755 index 0000000..715ca84 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_normal_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_pressed_holo.png b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_pressed_holo.png new file mode 100755 index 0000000..185e67c Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_pressed_holo.png differ diff --git a/AndroidClient/app/src/main/res/drawable-xxhdpi/ic_launcher.png b/AndroidClient/app/src/main/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..2332309 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/AndroidClient/app/src/main/res/drawable/apptheme_scrubber_control_selector_holo_light.xml b/AndroidClient/app/src/main/res/drawable/apptheme_scrubber_control_selector_holo_light.xml new file mode 100755 index 0000000..00bc047 Binary files /dev/null and b/AndroidClient/app/src/main/res/drawable/apptheme_scrubber_control_selector_holo_light.xml differ diff --git a/AndroidClient/app/src/main/res/drawable/apptheme_scrubber_progress_horizontal_holo_light.xml b/AndroidClient/app/src/main/res/drawable/apptheme_scrubber_progress_horizontal_holo_light.xml new file mode 100755 index 0000000..9535874 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable/apptheme_scrubber_progress_horizontal_holo_light.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + diff --git a/AndroidClient/app/src/main/res/layout/main.xml b/AndroidClient/app/src/main/res/layout/main.xml new file mode 100644 index 0000000..00bc047 Binary files /dev/null and b/AndroidClient/app/src/main/res/layout/main.xml differ diff --git a/AndroidClient/app/src/main/res/values/strings.xml b/AndroidClient/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..0727d11 --- /dev/null +++ b/AndroidClient/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Snowman + diff --git a/AndroidClient/app/src/main/res/values/styles.xml b/AndroidClient/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..69a8ed9 --- /dev/null +++ b/AndroidClient/app/src/main/res/values/styles.xml @@ -0,0 +1,7 @@ + + + + + + -- cgit v1.3.1