diff options
Diffstat (limited to 'AndroidClient/app/src')
29 files changed, 218 insertions, 0 deletions
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 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="winter.snowman.notifications"> + + <uses-permission android:name="android.permission.INTERNET"/> + + <application android:allowBackup="true" + android:label="@string/app_name" + android:icon="@drawable/ic_launcher" + android:theme="@style/AppTheme"> + + <activity android:name=".WebViewActivity" + android:label="@string/app_name" + android:screenOrientation="portrait" + android:configChanges="orientation|keyboardHidden" > + + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + + </activity> + + <service android:name=".NotifListenerService" + android:label="@string/app_name" + android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" > + <intent-filter> + <action android:name="android.service.notification.NotificationListenerService" /> + </intent-filter> + + </service> + + </application> + +</manifest> diff --git a/AndroidClient/app/src/main/ic_launcher-web.png b/AndroidClient/app/src/main/ic_launcher-web.png Binary files differnew file mode 100644 index 0000000..ff6dc63 --- /dev/null +++ b/AndroidClient/app/src/main/ic_launcher-web.png 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 Binary files differnew file mode 100755 index 0000000..a1acbb5 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_disabled_holo.png 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 Binary files differnew file mode 100755 index 0000000..1b75394 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_focused_holo.png 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 Binary files differnew file mode 100755 index 0000000..4900d70 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_normal_holo.png 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 Binary files differnew file mode 100755 index 0000000..7469c47 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-hdpi/apptheme_scrubber_control_pressed_holo.png diff --git a/AndroidClient/app/src/main/res/drawable-hdpi/ic_launcher.png b/AndroidClient/app/src/main/res/drawable-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..00bc047 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-hdpi/ic_launcher.png 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 Binary files differnew file mode 100755 index 0000000..00bc047 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_disabled_holo.png 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 Binary files differnew file mode 100755 index 0000000..00bc047 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_focused_holo.png 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 Binary files differnew file mode 100755 index 0000000..31abfb5 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_normal_holo.png 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 Binary files differnew file mode 100755 index 0000000..a296f4c --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-mdpi/apptheme_scrubber_control_pressed_holo.png diff --git a/AndroidClient/app/src/main/res/drawable-mdpi/ic_launcher.png b/AndroidClient/app/src/main/res/drawable-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..2067e78 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-mdpi/ic_launcher.png 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 Binary files differnew file mode 100755 index 0000000..00bc047 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_disabled_holo.png 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 Binary files differnew file mode 100755 index 0000000..2f38b65 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_focused_holo.png 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 Binary files differnew file mode 100755 index 0000000..af951cb --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_normal_holo.png 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 Binary files differnew file mode 100755 index 0000000..00bc047 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-xhdpi/apptheme_scrubber_control_pressed_holo.png diff --git a/AndroidClient/app/src/main/res/drawable-xhdpi/ic_launcher.png b/AndroidClient/app/src/main/res/drawable-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..00bc047 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-xhdpi/ic_launcher.png 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 Binary files differnew file mode 100755 index 0000000..a64250e --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_disabled_holo.png 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 Binary files differnew file mode 100755 index 0000000..6a80a0e --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_focused_holo.png 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 Binary files differnew file mode 100755 index 0000000..715ca84 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_normal_holo.png 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 Binary files differnew file mode 100755 index 0000000..185e67c --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-xxhdpi/apptheme_scrubber_control_pressed_holo.png diff --git a/AndroidClient/app/src/main/res/drawable-xxhdpi/ic_launcher.png b/AndroidClient/app/src/main/res/drawable-xxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..2332309 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable-xxhdpi/ic_launcher.png 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 Binary files differnew file mode 100755 index 0000000..00bc047 --- /dev/null +++ b/AndroidClient/app/src/main/res/drawable/apptheme_scrubber_control_selector_holo_light.xml 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2010 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:id="@android:id/background" + android:drawable="@drawable/apptheme_scrubber_track_holo_light" /> + <item android:id="@android:id/secondaryProgress"> + <scale android:scaleWidth="100%" + android:drawable="@drawable/apptheme_scrubber_secondary_holo" /> + </item> + <item android:id="@android:id/progress"> + <scale android:scaleWidth="100%" + android:drawable="@drawable/apptheme_scrubber_primary_holo" /> + </item> +</layer-list> diff --git a/AndroidClient/app/src/main/res/layout/main.xml b/AndroidClient/app/src/main/res/layout/main.xml Binary files differnew file mode 100644 index 0000000..00bc047 --- /dev/null +++ b/AndroidClient/app/src/main/res/layout/main.xml 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 @@ +<resources> + <string name="app_name">Snowman</string> +</resources> 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 @@ +<resources> + + <!-- Base application theme. --> + <style name="AppTheme" parent="@android:style/Theme.Holo.Light"> + </style> + +</resources> |
