├── assets
├── play.bmp
├── Thumbs.db
├── email.bmp
├── phone.bmp
├── timer.bmp
├── idle_call.bmp
├── idle_sms.bmp
├── message.bmp
├── idle_gmail.bmp
├── idle_icons_row.bmp
├── weather_cloudy.bmp
├── weather_rain.bmp
├── weather_snow.bmp
├── weather_sunny.bmp
├── weather_wind.bmp
├── metawatch_16pt_11pxl.ttf
├── weather_thunderstorm.bmp
├── metawatch_8pt_5pxl_CAPS.ttf
├── metawatch_8pt_7pxl_CAPS.ttf
└── mdpi
│ └── _pre_production
│ └── notification.svg
├── res
├── drawable-hdpi
│ ├── icon.png
│ ├── connected.png
│ ├── disconnected.png
│ ├── connected_large.png
│ └── disconnected_large.png
├── drawable-ldpi
│ └── icon.png
├── drawable-mdpi
│ └── icon.png
├── layout
│ ├── main.xml
│ ├── device_selection.xml
│ ├── notification.xml
│ ├── list_item.xml
│ └── settings.xml
├── menu
│ ├── menu.xml
│ └── test.xml
└── values
│ └── strings.xml
├── .settings
└── org.eclipse.jdt.core.prefs
├── .classpath
├── default.properties
├── project.properties
├── src
└── org
│ ├── anddev
│ └── android
│ │ └── weatherforecast
│ │ └── weather
│ │ ├── WeatherUtils.java
│ │ ├── WeatherSet.java
│ │ ├── WeatherForecastCondition.java
│ │ ├── WeatherCurrentCondition.java
│ │ └── GoogleWeatherHandler.java
│ └── metawatch
│ └── manager
│ ├── BootUpReceiver.java
│ ├── CallVibrate.java
│ ├── AlarmReceiver.java
│ ├── TestSmsLoop.java
│ ├── ImageViewer.java
│ ├── CallStateListener.java
│ ├── MediaControl.java
│ ├── Settings.java
│ ├── Call.java
│ ├── ApiIntentReceiver.java
│ ├── MetaWatch.java
│ ├── Message.java
│ ├── Application.java
│ ├── IntentReceiver.java
│ ├── Test.java
│ ├── Utils.java
│ ├── Idle.java
│ ├── DeviceSelection.java
│ ├── NotificationBuilder.java
│ ├── GmailMonitor.java
│ ├── Monitors.java
│ ├── Notification.java
│ └── MetaWatchService.java
├── NOTICE
├── README
├── MW_v0.2.4b_APK_API.txt
├── .project
├── proguard.cfg
├── AndroidManifest.xml
└── LICENSE
/assets/play.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/play.bmp
--------------------------------------------------------------------------------
/assets/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/Thumbs.db
--------------------------------------------------------------------------------
/assets/email.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/email.bmp
--------------------------------------------------------------------------------
/assets/phone.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/phone.bmp
--------------------------------------------------------------------------------
/assets/timer.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/timer.bmp
--------------------------------------------------------------------------------
/assets/idle_call.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/idle_call.bmp
--------------------------------------------------------------------------------
/assets/idle_sms.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/idle_sms.bmp
--------------------------------------------------------------------------------
/assets/message.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/message.bmp
--------------------------------------------------------------------------------
/assets/idle_gmail.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/idle_gmail.bmp
--------------------------------------------------------------------------------
/assets/idle_icons_row.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/idle_icons_row.bmp
--------------------------------------------------------------------------------
/assets/weather_cloudy.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/weather_cloudy.bmp
--------------------------------------------------------------------------------
/assets/weather_rain.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/weather_rain.bmp
--------------------------------------------------------------------------------
/assets/weather_snow.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/weather_snow.bmp
--------------------------------------------------------------------------------
/assets/weather_sunny.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/weather_sunny.bmp
--------------------------------------------------------------------------------
/assets/weather_wind.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/weather_wind.bmp
--------------------------------------------------------------------------------
/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/assets/metawatch_16pt_11pxl.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/metawatch_16pt_11pxl.ttf
--------------------------------------------------------------------------------
/assets/weather_thunderstorm.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/weather_thunderstorm.bmp
--------------------------------------------------------------------------------
/res/drawable-hdpi/connected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/res/drawable-hdpi/connected.png
--------------------------------------------------------------------------------
/assets/metawatch_8pt_5pxl_CAPS.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/metawatch_8pt_5pxl_CAPS.ttf
--------------------------------------------------------------------------------
/assets/metawatch_8pt_7pxl_CAPS.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/assets/metawatch_8pt_7pxl_CAPS.ttf
--------------------------------------------------------------------------------
/res/drawable-hdpi/disconnected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/res/drawable-hdpi/disconnected.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/connected_large.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/res/drawable-hdpi/connected_large.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/disconnected_large.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaWatchOpenProjects/MWM-for-Android-Gen1/HEAD/res/drawable-hdpi/disconnected_large.png
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | #Sun May 22 00:01:09 CEST 2011
2 | eclipse.preferences.version=1
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
4 | org.eclipse.jdt.core.compiler.compliance=1.5
5 | org.eclipse.jdt.core.compiler.source=1.5
6 |
--------------------------------------------------------------------------------
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/default.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "build.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-13
12 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-13
12 |
--------------------------------------------------------------------------------
/src/org/anddev/android/weatherforecast/weather/WeatherUtils.java:
--------------------------------------------------------------------------------
1 | package org.anddev.android.weatherforecast.weather;
2 |
3 | /** Useful Utility in working with temperatures. (conversions). */
4 | public class WeatherUtils {
5 |
6 | public static int fahrenheitToCelsius(int tFahrenheit) {
7 | return (int) ((5.0f / 9.0f) * (tFahrenheit - 32));
8 | }
9 |
10 | public static int celsiusToFahrenheit(int tCelsius) {
11 | return (int) ((9.0f / 5.0f) * tCelsius + 32);
12 | }
13 | }
--------------------------------------------------------------------------------
/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | =========================================================================
2 | == NOTICE file for Meta Watch Manager for Android ==
3 | == ==
4 | =========================================================================
5 |
6 | Meta Watch Manager for Android
7 | Copyright 2011 Meta Watch Ltd.
8 |
9 | Android Weather Forecast - Google Weather API
10 | This software were developed by plusminus from anddev.org
11 | (Android Weather Forecast - Google Weather API)
12 |
13 |
14 |
--------------------------------------------------------------------------------
/res/layout/device_selection.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Welcome. This is the Meta Watch Manager (MWM) for Android project.
2 |
3 | Read the LICENSE and the NOTICE files in the root.
4 |
5 | Visit us at http://www.metawatch.org
6 |
7 | Report bugs and request enhancements at: http://bugs.metawatch.org
8 |
9 | Meta Watch will be keeping this project up to date and periodically releasing new
10 | stable versions on the Metawatch.org website and on the Android Market.
11 |
12 | Contributing your code to this project is encouraged.
13 | To contribute your code, you must please fill out and submit a contributor agreement.
14 | You can find this in the developer section of the metawatch.org website.
15 |
16 | Have fun!
--------------------------------------------------------------------------------
/MW_v0.2.4b_APK_API.txt:
--------------------------------------------------------------------------------
1 | Handled:
2 |
3 | org.metawatch.manager.NOTIFICATION
4 | "array" - int[96*96]
5 | or
6 | "buffer" - byte[96*96/8] // encoded buffer
7 | --
8 | "vibrate_on" - int // ms
9 | "vibrate_off" - int // ms
10 | "vibrate_cycles" - int
11 |
12 | org.metawatch.manager.APPLICATION_UPDATE
13 | "array" - int[96*96]
14 | or
15 | "buffer" - byte[96*96/8] // encoded buffer
16 |
17 | org.metawatch.manager.APPLICATION_START
18 |
19 | org.metawatch.manager.APPLICATION_STOP
20 |
21 |
22 | org.metawatch.manager.IDLE_BUTTONS_OVERRIDE
23 | "buttons" - byte[] // buttons to override
24 |
25 |
26 |
27 |
28 |
29 |
30 | Broadcasted:
31 |
32 | org.metawatch.manager.BUTTON_PRESS
33 | "button" - byte
34 | "mode" - String // ("application", "idle")
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/BootUpReceiver.java:
--------------------------------------------------------------------------------
1 | package org.metawatch.manager;
2 |
3 | import org.metawatch.manager.MetaWatchService.Preferences;
4 |
5 | import android.content.BroadcastReceiver;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.content.SharedPreferences;
9 | import android.preference.PreferenceManager;
10 |
11 | public class BootUpReceiver extends BroadcastReceiver {
12 |
13 | @Override
14 | public void onReceive(Context context, Intent intent) {
15 |
16 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
17 |
18 |
19 | if (sharedPreferences.getBoolean("StartOnBoot", Preferences.startOnBoot)) {
20 | context.startService(new Intent(context, MetaWatchService.class));
21 | }
22 |
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/res/layout/notification.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
19 |
--------------------------------------------------------------------------------
/res/layout/list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
12 |
13 |
22 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | MetaWatch
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembernames class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembernames class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers enum * {
30 | public static **[] values();
31 | public static ** valueOf(java.lang.String);
32 | }
33 |
34 | -keep class * implements android.os.Parcelable {
35 | public static final android.os.Parcelable$Creator *;
36 | }
37 |
--------------------------------------------------------------------------------
/src/org/anddev/android/weatherforecast/weather/WeatherSet.java:
--------------------------------------------------------------------------------
1 | package org.anddev.android.weatherforecast.weather;
2 |
3 | import java.util.ArrayList;
4 |
5 | /**
6 | * Combines one WeatherCurrentCondition with a List of
7 | * WeatherForecastConditions.
8 | */
9 | public class WeatherSet {
10 |
11 | // ===========================================================
12 | // Fields
13 | // ===========================================================
14 |
15 | private WeatherCurrentCondition myCurrentCondition = null;
16 | private ArrayList myForecastConditions =
17 | new ArrayList(4);
18 |
19 | // ===========================================================
20 | // Getter & Setter
21 | // ===========================================================
22 |
23 | public WeatherCurrentCondition getWeatherCurrentCondition() {
24 | return myCurrentCondition;
25 | }
26 |
27 | public void setWeatherCurrentCondition(
28 | WeatherCurrentCondition myCurrentWeather) {
29 | this.myCurrentCondition = myCurrentWeather;
30 | }
31 |
32 | public ArrayList getWeatherForecastConditions() {
33 | return this.myForecastConditions;
34 | }
35 |
36 | public WeatherForecastCondition getLastWeatherForecastCondition() {
37 | return this.myForecastConditions
38 | .get(this.myForecastConditions.size() - 1);
39 | }
40 | }
--------------------------------------------------------------------------------
/res/menu/test.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | MetaWatch
4 |
5 | Main
6 |
7 | Start On Boot
8 | Start MetaWatch service on boot
9 |
10 |
11 | Notifications
12 | Call
13 | Incoming call notification
14 | SMS
15 | New text message notification
16 | K9 mail
17 | New E-mail notification (K-9 mail)
18 | Alarm
19 | Alarm clock alert
20 | Music
21 | Music track/artist info
22 |
23 | Device
24 | MAC
25 | Watch Bluetooth MAC address
26 |
27 |
28 | - Small
29 | - Medium
30 | - Large
31 |
32 |
33 | - 1
34 | - 2
35 | - 3
36 |
37 |
38 | Other
39 |
40 |
41 | Tests
42 | Settings
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/org/anddev/android/weatherforecast/weather/WeatherForecastCondition.java:
--------------------------------------------------------------------------------
1 | package org.anddev.android.weatherforecast.weather;
2 |
3 | /**
4 | * Holds the information between the -tag of what the
5 | * Google Weather API returned.
6 | */
7 | public class WeatherForecastCondition {
8 |
9 | // ===========================================================
10 | // Fields
11 | // ===========================================================
12 |
13 | private String dayofWeek = null;
14 | private Integer tempMin = null;
15 | private Integer tempMax = null;
16 | private String iconURL = null;
17 | private String condition = null;
18 |
19 | // ===========================================================
20 | // Constructors
21 | // ===========================================================
22 |
23 | public WeatherForecastCondition() {
24 |
25 | }
26 |
27 | // ===========================================================
28 | // Getter & Setter
29 | // ===========================================================
30 |
31 | public String getDayofWeek() {
32 | return dayofWeek;
33 | }
34 |
35 | public void setDayofWeek(String dayofWeek) {
36 | this.dayofWeek = dayofWeek;
37 | }
38 |
39 | public Integer getTempMinCelsius() {
40 | return tempMin;
41 | }
42 |
43 | public void setTempMinCelsius(Integer tempMin) {
44 | this.tempMin = tempMin;
45 | }
46 |
47 | public Integer getTempMaxCelsius() {
48 | return tempMax;
49 | }
50 |
51 | public void setTempMaxCelsius(Integer tempMax) {
52 | this.tempMax = tempMax;
53 | }
54 |
55 | public String getIconURL() {
56 | return iconURL;
57 | }
58 |
59 | public void setIconURL(String iconURL) {
60 | this.iconURL = iconURL;
61 | }
62 |
63 | public String getCondition() {
64 | return condition;
65 | }
66 |
67 | public void setCondition(String condition) {
68 | this.condition = condition;
69 | }
70 | }
--------------------------------------------------------------------------------
/src/org/anddev/android/weatherforecast/weather/WeatherCurrentCondition.java:
--------------------------------------------------------------------------------
1 | package org.anddev.android.weatherforecast.weather;
2 |
3 | /**
4 | * Holds the information between the -tag of what the Google
5 | * Weather API returned.
6 | */
7 | public class WeatherCurrentCondition {
8 |
9 | // ===========================================================
10 | // Fields
11 | // ===========================================================
12 |
13 | private String dayofWeek = null;
14 | private Integer tempCelcius = null;
15 | private Integer tempFahrenheit = null;
16 | private String iconURL = null;
17 | private String condition = null;
18 | private String windCondition = null;
19 | private String humidity = null;
20 | private String city = null;
21 |
22 | // ===========================================================
23 | // Constructors
24 | // ===========================================================
25 |
26 | public WeatherCurrentCondition() {
27 |
28 | }
29 |
30 | // ===========================================================
31 | // Getter & Setter
32 | // ===========================================================
33 |
34 | public String getCity() {
35 | return this.city;
36 | }
37 |
38 | public String getDayofWeek() {
39 | return this.dayofWeek;
40 | }
41 |
42 | public void setDayofWeek(String dayofWeek) {
43 | this.dayofWeek = dayofWeek;
44 | }
45 |
46 | public Integer getTempCelcius() {
47 | return this.tempCelcius;
48 | }
49 |
50 | public void setTempCelcius(Integer temp) {
51 | this.tempCelcius = temp;
52 | }
53 |
54 | public Integer getTempFahrenheit() {
55 | return this.tempFahrenheit;
56 | }
57 |
58 | public void setTempFahrenheit(Integer temp) {
59 | this.tempFahrenheit = temp;
60 | }
61 |
62 | public String getIconURL() {
63 | return this.iconURL;
64 | }
65 |
66 | public void setCity(String city) {
67 | this.city = city;
68 | }
69 |
70 | public void setIconURL(String iconURL) {
71 | this.iconURL = iconURL;
72 | }
73 |
74 | public String getCondition() {
75 | return this.condition;
76 | }
77 |
78 | public void setCondition(String condition) {
79 | this.condition = condition;
80 | }
81 |
82 | public String getWindCondition() {
83 | return this.windCondition;
84 | }
85 |
86 | public void setWindCondition(String windCondition) {
87 | this.windCondition = windCondition;
88 | }
89 |
90 | public String getHumidity() {
91 | return this.humidity;
92 | }
93 |
94 | public void setHumidity(String humidity) {
95 | this.humidity = humidity;
96 | }
97 | }
--------------------------------------------------------------------------------
/src/org/metawatch/manager/CallVibrate.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * CallVibrate.java *
27 | * CallVibrate *
28 | * While in incoming call mode *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import org.metawatch.manager.MetaWatchService.WatchType;
36 |
37 | public class CallVibrate implements Runnable {
38 |
39 | public void run() {
40 |
41 | while (Call.isRinging) {
42 | Protocol.vibrate(1000, 0, 1);
43 | if (MetaWatchService.watchType == WatchType.DIGITAL)
44 | Protocol.updateDisplay(2);
45 | else
46 | Protocol.updateOledsNotification();
47 |
48 | try {
49 | Thread.sleep(2000);
50 | } catch (InterruptedException e) {
51 | }
52 | }
53 |
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/AlarmReceiver.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | /*****************************************************************************
8 | * Copyright (c) 2011 Meta Watch Ltd. *
9 | * www.MetaWatch.org *
10 | * *
11 | =============================================================================
12 | * *
13 | * Licensed under the Apache License, Version 2.0 (the "License"); *
14 | * you may not use this file except in compliance with the License. *
15 | * You may obtain a copy of the License at *
16 | * *
17 | * http://www.apache.org/licenses/LICENSE-2.0 *
18 | * *
19 | * Unless required by applicable law or agreed to in writing, software *
20 | * distributed under the License is distributed on an "AS IS" BASIS, *
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
22 | * See the License for the specific language governing permissions and *
23 | * limitations under the License. *
24 | * *
25 | *****************************************************************************/
26 |
27 | /*****************************************************************************
28 | * AlarmReceiver.java *
29 | * AlarmReceiver *
30 | * Receiver for RTC wakeup intents used for weather updates *
31 | * *
32 | * *
33 | *****************************************************************************/
34 |
35 | package org.metawatch.manager;
36 |
37 | import android.content.BroadcastReceiver;
38 | import android.content.Context;
39 | import android.content.Intent;
40 | import android.util.Log;
41 |
42 | public class AlarmReceiver extends BroadcastReceiver {
43 |
44 | @Override
45 | public void onReceive(Context context, Intent intent) {
46 |
47 | Log.d(MetaWatch.TAG, "intent rec: "+ intent.toString());
48 |
49 | if (intent.hasExtra("action_update")) {
50 |
51 | Monitors.updateWeatherData(context);
52 |
53 | return;
54 | }
55 |
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/TestSmsLoop.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * TestSmsLoop.java *
27 | * TestSmsLoop *
28 | * Sending test SMS in a loop *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import android.content.Context;
36 |
37 | public class TestSmsLoop implements Runnable {
38 |
39 | Context context;
40 | boolean runLoop;
41 |
42 | public TestSmsLoop(Context context) {
43 | this.context = context;
44 | }
45 |
46 | public void run() {
47 | runLoop = true;
48 | for (int i = 1; runLoop; i++) {
49 | NotificationBuilder.createSMS(context, "123-456-789", "\n Test SMS #" + i);
50 | try {
51 | Thread.sleep(MetaWatchService.Preferences.smsLoopInterval*1000);
52 | } catch (InterruptedException e) {
53 | }
54 | }
55 | }
56 |
57 | public void stop() {
58 | runLoop = false;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/ImageViewer.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * ImageViewer.java *
27 | * ImageViewer *
28 | * System wide "Send to watch" that shows pictures in app mode *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import android.app.Activity;
36 | import android.content.Intent;
37 | import android.graphics.BitmapFactory;
38 | import android.os.Bundle;
39 | import android.util.Log;
40 |
41 | public class ImageViewer extends Activity {
42 |
43 | @Override
44 | protected void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 |
47 | Intent i = getIntent();
48 |
49 | Log.d(MetaWatch.TAG, "action: " + i.getAction());
50 | Log.d(MetaWatch.TAG, "data: "+ i.getData().getPath() );
51 |
52 | Application.updateAppMode(this, BitmapFactory.decodeFile(i.getData().getPath()));
53 |
54 | finish();
55 | }
56 |
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/assets/mdpi/_pre_production/notification.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
41 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/CallStateListener.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * CallStateListener.java *
27 | * CallStateListener *
28 | * Listener waiting for incoming call *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import android.content.Context;
36 | import android.telephony.PhoneStateListener;
37 | import android.telephony.TelephonyManager;
38 |
39 |
40 | class CallStateListener extends PhoneStateListener {
41 |
42 | Context context;
43 |
44 | public CallStateListener(Context ctx) {
45 | super();
46 | context = ctx;
47 | }
48 |
49 | @Override
50 | public void onCallStateChanged(int state, String incomingNumber) {
51 | super.onCallStateChanged(state, incomingNumber);
52 |
53 | if (!MetaWatchService.Preferences.notifyCall)
54 | return;
55 |
56 | if (incomingNumber == null)
57 | incomingNumber = "";
58 |
59 | switch (state) {
60 | case TelephonyManager.CALL_STATE_RINGING:
61 | //String name = Utils.getContactNameFromNumber(context, incomingNumber);
62 | //SendCommand.sendIncomingCallStart(incomingNumber, name, photo);
63 | Call.startCall(context, incomingNumber);
64 | break;
65 | case TelephonyManager.CALL_STATE_IDLE:
66 | Call.endCall(context);
67 | break;
68 | case TelephonyManager.CALL_STATE_OFFHOOK:
69 | Call.endCall(context);
70 | break;
71 | }
72 |
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/MediaControl.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * MediaControl.java *
27 | * MediaControl *
28 | * Volume control and vanilla Android player control via intents *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import android.content.Context;
36 | import android.content.Intent;
37 | import android.media.AudioManager;
38 |
39 | public class MediaControl {
40 |
41 | final static byte VOLUME_UP = 10;
42 | final static byte VOLUME_DOWN = 11;
43 | final static byte NEXT = 15;
44 | final static byte PREVIOUS = 16;
45 | final static byte TOGGLE = 20;
46 |
47 | public static void next(Context context) {
48 | context.sendBroadcast(new Intent("com.android.music.musicservicecommand.next"));
49 | }
50 |
51 | public static void previous(Context context) {
52 | context.sendBroadcast(new Intent("com.android.music.musicservicecommand.previous"));
53 | }
54 |
55 | public static void togglePause(Context context) {
56 | context.sendBroadcast(new Intent("com.android.music.musicservicecommand.togglepause"));
57 | }
58 |
59 | public static void volumeDown(AudioManager audioManager) {
60 | audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, 0);
61 | }
62 |
63 | public static void volumeUp(AudioManager audioManager) {
64 | audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 0);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/Settings.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * Settings.java *
27 | * Settings *
28 | * Preference activity *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import android.content.Context;
36 | import android.content.Intent;
37 | import android.os.Bundle;
38 | import android.preference.EditTextPreference;
39 | import android.preference.Preference;
40 | import android.preference.Preference.OnPreferenceClickListener;
41 | import android.preference.PreferenceActivity;
42 | import android.preference.PreferenceScreen;
43 | import android.util.Log;
44 |
45 | public class Settings extends PreferenceActivity {
46 |
47 | Context context;
48 |
49 | PreferenceScreen preferenceScreen;
50 | Preference discovery;
51 |
52 | EditTextPreference editTextMac;
53 |
54 | @Override
55 | protected void onCreate(Bundle savedInstanceState) {
56 | super.onCreate(savedInstanceState);
57 | context = this;
58 |
59 | setTitle(getString(R.string.app_name) + " - " + getString(R.string.activitiy_title_settings));
60 |
61 | addPreferencesFromResource(R.layout.settings);
62 |
63 | preferenceScreen = getPreferenceScreen();
64 |
65 | }
66 |
67 | @Override
68 | protected void onStart() {
69 |
70 | Log.d(MetaWatch.TAG, "set onstart");
71 |
72 | editTextMac = (EditTextPreference) preferenceScreen.findPreference("MAC");
73 | editTextMac.setText(MetaWatchService.Preferences.watchMacAddress);
74 |
75 | discovery = preferenceScreen.findPreference("Discovery");
76 | discovery.setOnPreferenceClickListener(new OnPreferenceClickListener() {
77 |
78 | public boolean onPreferenceClick(Preference arg0) {
79 |
80 | Log.d(MetaWatch.TAG, "discovery click");
81 |
82 | startActivity(new Intent(context, DeviceSelection.class));
83 |
84 | return false;
85 | }
86 | });
87 |
88 | super.onStart();
89 | }
90 |
91 |
92 |
93 |
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/Call.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * Call.java *
27 | * Call *
28 | * Call watch mode *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import org.metawatch.manager.MetaWatchService.WatchType;
36 | import org.metawatch.manager.Notification.VibratePattern;
37 |
38 | import android.content.Context;
39 | import android.graphics.Bitmap;
40 |
41 | public class Call {
42 |
43 | public static boolean isRinging = false;
44 |
45 | public static void startCall(Context context, String number) {
46 | toCall();
47 |
48 | isRinging = true;
49 |
50 | Bitmap bitmap;
51 | String name = Utils.getContactNameFromNumber(context, number);
52 |
53 | if (name.equals(number))
54 | bitmap = NotificationBuilder.smartLines(context, "phone.bmp", new String[] { number});
55 | else
56 | bitmap = NotificationBuilder.smartLines(context, "phone.bmp", new String[] { number, name });
57 |
58 | if (MetaWatchService.watchType == WatchType.DIGITAL) {
59 | Protocol.sendLcdBitmap(bitmap, MetaWatchService.WatchBuffers.NOTIFICATION);
60 | Protocol.updateDisplay(2);
61 | } else {
62 | Notification.addOledNotification(context, Protocol.createOled1line(context, "phone.bmp", "Call from"), Protocol.createOled1line(context, null, name), null, 0, new VibratePattern(true, 500, 500, 3));
63 | }
64 |
65 | Thread ringer = new Thread(new CallVibrate());
66 | ringer.start();
67 | }
68 |
69 | public static void endCall(Context context) {
70 | isRinging = false;
71 | exitCall(context);
72 | }
73 |
74 | static void toCall() {
75 | MetaWatchService.watchState = MetaWatchService.WatchStates.CALL;
76 | MetaWatchService.WatchModes.CALL = true;
77 | }
78 |
79 | static void exitCall(Context context) {
80 |
81 | MetaWatchService.WatchModes.CALL = false;
82 |
83 | if (MetaWatchService.WatchModes.NOTIFICATION == true)
84 | Notification.toNotification(context);
85 | else if (MetaWatchService.WatchModes.APPLICATION == true)
86 | Application.toApp();
87 | else if (MetaWatchService.WatchModes.IDLE == true)
88 | Idle.toIdle(context);
89 | }
90 |
91 | }
92 |
93 |
94 |
--------------------------------------------------------------------------------
/res/layout/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
14 |
15 |
16 |
17 |
20 |
26 |
32 |
38 |
44 |
50 |
56 |
57 |
58 |
61 |
67 |
72 |
73 |
74 |
75 |
78 |
84 |
90 |
100 |
106 |
112 |
119 |
125 |
131 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/ApiIntentReceiver.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * ApiIntentReceiver.java *
27 | * ApiIntentReceiver *
28 | * Intent receiver for 3rd party software *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import org.metawatch.manager.Notification.VibratePattern;
36 |
37 | import android.content.BroadcastReceiver;
38 | import android.content.Context;
39 | import android.content.Intent;
40 | import android.os.Bundle;
41 |
42 | public class ApiIntentReceiver extends BroadcastReceiver {
43 |
44 | @Override
45 | public void onReceive(Context context, Intent intent) {
46 |
47 | String action = intent.getAction();
48 |
49 | // add digital watch check
50 |
51 | if (action.equals("org.metawatch.manager.APPLICATION_UPDATE")) {
52 | if (intent.hasExtra("array")) {
53 | int[] array = intent.getIntArrayExtra("array");
54 | Application.updateAppMode(context, array);
55 | } else if (intent.hasExtra("buffer")) {
56 | byte[] buffer = intent.getByteArrayExtra("buffer");
57 | Application.updateAppMode(context, buffer);
58 | }
59 | return;
60 | }
61 |
62 | if (action.equals("org.metawatch.manager.APPLICATION_START")) {
63 | Application.startAppMode();
64 | return;
65 | }
66 |
67 | if (action.equals("org.metawatch.manager.APPLICATION_STOP")) {
68 | Application.startAppMode();
69 | return;
70 | }
71 |
72 | if (action.equals("org.metawatch.manager.IDLE_BUTTONS_OVERRIDE")) {
73 | Bundle bundle = intent.getExtras();
74 | if (bundle.containsKey("buttons")) {
75 | Idle.overridenButtons = bundle.getByteArray("buttons");
76 | } else {
77 | Idle.overridenButtons = null;
78 | }
79 | return;
80 | }
81 |
82 | if (action.equals("org.metawatch.manager.NOTIFICATION")) {
83 | if (intent.hasExtra("array")) {
84 | int[] array = intent.getIntArrayExtra("array");
85 | VibratePattern vibrate = null;
86 | if (intent.hasExtra("vibrate_on") && intent.hasExtra("vibrate_off") && intent.hasExtra("vibrate_cycles")) {
87 | int vibrateOn = intent.getIntExtra("vibrate_on", 500);
88 | int vibrateOff = intent.getIntExtra("vibrate_off", 500);
89 | int vibrateCycles = intent.getIntExtra("vibrate_cycles", 3);
90 | vibrate = new VibratePattern(true, vibrateOn, vibrateOff, vibrateCycles);
91 | }
92 | Notification.addArrayNotification(context, array, vibrate);
93 | } else if (intent.hasExtra("buffer")) {
94 | byte[] buffer = intent.getByteArrayExtra("buffer");
95 | VibratePattern vibrate = null;
96 | if (intent.hasExtra("vibrate_on") && intent.hasExtra("vibrate_off") && intent.hasExtra("vibrate_cycles")) {
97 | int vibrateOn = intent.getIntExtra("vibrate_on", 500);
98 | int vibrateOff = intent.getIntExtra("vibrate_off", 500);
99 | int vibrateCycles = intent.getIntExtra("vibrate_cycles", 3);
100 | vibrate = new VibratePattern(true, vibrateOn, vibrateOff, vibrateCycles);
101 | }
102 | Notification.addBufferNotification(context, buffer, vibrate);
103 | }
104 | return;
105 | }
106 |
107 | }
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/MetaWatch.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * MetaWatch.java *
27 | * MetaWatch *
28 | * Main activity with menu *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import org.metawatch.manager.MetaWatchService.Preferences;
36 |
37 | import android.app.Activity;
38 | import android.app.AlertDialog;
39 | import android.content.DialogInterface;
40 | import android.content.Intent;
41 | import android.os.Bundle;
42 | import android.view.Menu;
43 | import android.view.MenuInflater;
44 | import android.view.MenuItem;
45 | import android.webkit.WebView;
46 |
47 | public class MetaWatch extends Activity {
48 |
49 | public static final String TAG = "MetaWatch";
50 |
51 | @Override
52 | public void onCreate(Bundle savedInstanceState) {
53 | super.onCreate(savedInstanceState);
54 | setContentView(R.layout.main);
55 | setTitle(getString(R.string.app_name));
56 | }
57 |
58 | @Override
59 | public boolean onCreateOptionsMenu(Menu menu) {
60 | MenuInflater inflater = getMenuInflater();
61 | inflater.inflate(R.menu.menu, menu);
62 | return true;
63 | }
64 |
65 | @Override
66 | protected void onStart() {
67 | super.onStart();
68 |
69 | MetaWatchService.loadPreferences(this);
70 |
71 | if (Preferences.idleMusicControls)
72 | Protocol.enableMediaButtons();
73 | //else
74 | //Protocol.disableMediaButtons();
75 |
76 | if (Preferences.idleReplay)
77 | Protocol.enableReplayButton();
78 | //else
79 | //Protocol.disableReplayButton();
80 |
81 | Protocol.configureMode();
82 | }
83 |
84 | @Override
85 | public boolean onOptionsItemSelected(MenuItem item) {
86 | switch (item.getItemId()) {
87 | case R.id.start:
88 | startService();
89 | return true;
90 | case R.id.stop:
91 | stopService();
92 | return true;
93 | case R.id.test:
94 | startActivity(new Intent(this, Test.class));
95 | return true;
96 | case R.id.settings:
97 | startActivity(new Intent(this, Settings.class));
98 | return true;
99 | case R.id.about:
100 | showAbout();
101 | return true;
102 | case R.id.exit:
103 | exit();
104 | return true;
105 | default:
106 | return super.onOptionsItemSelected(item);
107 | }
108 | }
109 |
110 | void startService() {
111 | startService(new Intent(this, MetaWatchService.class));
112 | }
113 |
114 | void stopService() {
115 | stopService(new Intent(this, MetaWatchService.class));
116 | }
117 |
118 | void exit() {
119 | System.exit(0);
120 | }
121 |
122 | void showAbout() {
123 |
124 | WebView webView = new WebView(this);
125 | String html = "About" +
126 | "MetaWatch
" +
127 | "Version " + Utils.getVersion(this) + ".
" +
128 | "© Copyright 2011 Meta Watch Ltd.
" +
129 | "";
130 | webView.loadData(html, "text/html", "utf-8");
131 |
132 | new AlertDialog.Builder(this).setView(webView).setCancelable(true).setPositiveButton("OK", new DialogInterface.OnClickListener() {
133 | //@Override
134 | public void onClick(DialogInterface dialog, int which) {
135 | dialog.dismiss();
136 | }
137 | }).show();
138 | }
139 |
140 | }
--------------------------------------------------------------------------------
/src/org/metawatch/manager/Message.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright (c) 2011 Meta Watch Ltd. *
3 | * www.MetaWatch.org *
4 | * *
5 | =============================================================================
6 | * *
7 | * Licensed under the Apache License, Version 2.0 (the "License"); *
8 | * you may not use this file except in compliance with the License. *
9 | * You may obtain a copy of the License at *
10 | * *
11 | * http://www.apache.org/licenses/LICENSE-2.0 *
12 | * *
13 | * Unless required by applicable law or agreed to in writing, software *
14 | * distributed under the License is distributed on an "AS IS" BASIS, *
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
16 | * See the License for the specific language governing permissions and *
17 | * limitations under the License. *
18 | * *
19 | *****************************************************************************/
20 |
21 | /*****************************************************************************
22 | * Message.java *
23 | * Message *
24 | * Message type constants *
25 | * *
26 | * *
27 | *****************************************************************************/
28 |
29 | package org.metawatch.manager;
30 |
31 | public enum Message
32 | {
33 | InvalidMessage(0x00),
34 |
35 | GetDeviceType(0x01),
36 | GetDeviceTypeResponse(0x02),
37 | GetInfoString(0x03),
38 | GetInfoStringResponse(0x04),
39 | DiagnosticLoopback(0x05),
40 | EnterShippingModeMsg(0x06),
41 | SoftwareResetMsg(0x07),
42 | ConnectionTimeoutMsg(0x08),
43 | TurnRadioOnMsg(0x09),
44 | TurnRadioOffMsg(0x0a),
45 | SppReserved(0x0b),
46 | PariringControlMsg(0x0c),
47 | EnterSniffModeMsg(0x0d),
48 | xxReEnterSniffModeMsg(0x0e),
49 | LinkAlarmMsg(0x0f),
50 |
51 | /*
52 | * OLED display related commands
53 | */
54 | OledWriteBufferMsg(0x10),
55 | OledConfigureModeMsg(0x11),
56 | OledChangeModeMsg(0x12),
57 | OledWriteScrollBufferMsg(0x13),
58 | OledScrollMsg(0x14),
59 | OledShowIdleBufferMsg(0x15),
60 | OledCrownMenuMsg(0x16),
61 | OledCrownMenuButtonMsg(0x17),
62 |
63 | /*
64 | * Status and control
65 | */
66 |
67 | /* move the hands hours), mins and seconds */
68 | AdvanceWatchHandsMsg(0x20),
69 |
70 | /* config and (dis)enable vibrate */
71 | SetVibrateMode(0x23),
72 |
73 | /* Sets the RTC */
74 | SetRealTimeClock(0x26),
75 | GetRealTimeClock(0x27),
76 | GetRealTimeClockResponse(0x28),
77 |
78 | /* osal nv */
79 | NvalOperationMsg(0x30),
80 | NvalOperationResponseMsg(0x31),
81 |
82 | /* status of the current display operation */
83 | StatusChangeEvent(0x33),
84 |
85 | ButtonEventMsg(0x34),
86 |
87 | GeneralPurposePhoneMsg(0x35),
88 | GeneralPurposeWatchMsg(0x36),
89 | /*
90 | * LCD display related commands
91 | */
92 | WriteBuffer(0x40),
93 | ConfigureMode(0x41),
94 | ConfigureIdleBufferSize(0x42),
95 | UpdateDisplay(0x43),
96 | LoadTemplate(0x44),
97 | UpdateMyDisplaySram(0x45),
98 | EnableButtonMsg(0x46),
99 | DisableButtonMsg(0x47),
100 | ReadButtonConfigMsg(0x48),
101 | ReadButtonConfigResponse(0x49),
102 | UpdateMyDisplayLcd(0x4a),
103 |
104 | /* */
105 | BatteryChargeControl(0x52),
106 | BatteryConfigMsg(0x53),
107 | LowBatteryWarningMsgHost(0x54),
108 | LowBatteryBtOffMsgHost(0x55),
109 | ReadBatteryVoltageMsg(0x56),
110 | ReadBatteryVoltageResponse(0x57),
111 | ReadLightSensorMsg(0x58),
112 | ReadLightSensorResponse(0x59),
113 | LowBatteryWarningMsg(0x5a),
114 | LowBatteryBtOffMsg(0x5b),
115 |
116 | /*****************************************************************************
117 | *
118 | * User Reserved 0x60-0x70-0x80-0x90
119 | *
120 | ****************************************************************************/
121 |
122 |
123 | /*****************************************************************************
124 | *
125 | * Watch/Internal Use Only
126 | *
127 | ****************************************************************************/
128 | IdleUpdate(0xa0),
129 | xxxInitialIdleUpdate(0xa1),
130 | WatchDrawnScreenTimeout(0xa2),
131 | ClearLcdSpecial(0xa3),
132 | WriteLcd(0xa4),
133 | ClearLcd(0xa5),
134 | ChangeModeMsg(0xa6),
135 | ModeTimeoutMsg(0xa7),
136 | WatchStatusMsg(0xa8),
137 | MenuModeMsg(0xa9),
138 | BarCode(0xaa),
139 | ListPairedDevicesMsg(0xab),
140 | ConnectionStateChangeMsg(0xac),
141 | ModifyTimeMsg(0xad),
142 | MenuButtonMsg(0xae),
143 | ToggleSecondsMsg(0xaf),
144 | SplashTimeoutMsg(0xb0),
145 |
146 | LedChange(0xc0),
147 |
148 | QueryMemoryMsg(0xd0),
149 |
150 | AccelerometerSteps(0xea),
151 | AccelerometerRawData(0xeb);
152 | public byte msg;
153 | static public final byte start = 0x01;
154 | //byte ID()
155 | //{
156 | //return msg;
157 | //}
158 | Message(int msg)
159 | {
160 | this.msg = (byte)msg;
161 | }
162 |
163 | } ;
--------------------------------------------------------------------------------
/src/org/metawatch/manager/Application.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * Application.java *
27 | * Application *
28 | * Application watch mode *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import android.content.Context;
36 | import android.graphics.Bitmap;
37 |
38 | public class Application {
39 |
40 | public static void startAppMode() {
41 | MetaWatchService.WatchModes.APPLICATION = true;
42 | }
43 |
44 | public static void stopAppMode(Context context) {
45 | exitApp(context);
46 | }
47 |
48 | public static void updateAppMode(Context context) {
49 | MetaWatchService.WatchModes.APPLICATION = true;
50 |
51 | if (MetaWatchService.WatchModes.APPLICATION == true) {
52 |
53 | // enable app mode if there is no parent mode currently active
54 | if (MetaWatchService.watchState < MetaWatchService.WatchStates.APPLICATION)
55 | MetaWatchService.watchState = MetaWatchService.WatchStates.APPLICATION;
56 |
57 | if (MetaWatchService.watchState == MetaWatchService.WatchStates.APPLICATION) {
58 | //Bitmap bitmap = createLcdApp(context);
59 | Bitmap bitmap = Protocol.createTextBitmap(context, "Starting application mode ...");
60 | Protocol.sendLcdBitmap(bitmap, MetaWatchService.WatchBuffers.APPLICATION);
61 | Protocol.updateDisplay(MetaWatchService.WatchBuffers.APPLICATION);
62 | }
63 | }
64 | }
65 |
66 | public static void updateAppMode(Context context, Bitmap bitmap) {
67 | MetaWatchService.WatchModes.APPLICATION = true;
68 |
69 | if (MetaWatchService.WatchModes.APPLICATION == true) {
70 |
71 | // enable app mode if there is no parent mode currently active
72 | if (MetaWatchService.watchState < MetaWatchService.WatchStates.APPLICATION)
73 | MetaWatchService.watchState = MetaWatchService.WatchStates.APPLICATION;
74 |
75 | if (MetaWatchService.watchState == MetaWatchService.WatchStates.APPLICATION) {
76 | Protocol.sendLcdBitmap(bitmap, MetaWatchService.WatchBuffers.APPLICATION);
77 | Protocol.updateDisplay(MetaWatchService.WatchBuffers.APPLICATION);
78 | }
79 | }
80 | }
81 |
82 | public static void updateAppMode(Context context, int[] array) {
83 | MetaWatchService.WatchModes.APPLICATION = true;
84 |
85 | if (MetaWatchService.WatchModes.APPLICATION == true) {
86 |
87 | // enable app mode if there is no parent mode currently active
88 | if (MetaWatchService.watchState < MetaWatchService.WatchStates.APPLICATION)
89 | MetaWatchService.watchState = MetaWatchService.WatchStates.APPLICATION;
90 |
91 | if (MetaWatchService.watchState == MetaWatchService.WatchStates.APPLICATION) {
92 | Protocol.sendLcdArray(array, MetaWatchService.WatchBuffers.APPLICATION);
93 | Protocol.updateDisplay(MetaWatchService.WatchBuffers.APPLICATION);
94 | }
95 | }
96 | }
97 |
98 | public static void updateAppMode(Context context, byte[] buffer) {
99 | MetaWatchService.WatchModes.APPLICATION = true;
100 |
101 | if (MetaWatchService.WatchModes.APPLICATION == true) {
102 |
103 | // enable app mode if there is no parent mode currently active
104 | if (MetaWatchService.watchState < MetaWatchService.WatchStates.APPLICATION)
105 | MetaWatchService.watchState = MetaWatchService.WatchStates.APPLICATION;
106 |
107 | if (MetaWatchService.watchState == MetaWatchService.WatchStates.APPLICATION) {
108 | Protocol.sendLcdBuffer(buffer, MetaWatchService.WatchBuffers.APPLICATION);
109 | Protocol.updateDisplay(MetaWatchService.WatchBuffers.APPLICATION);
110 | }
111 | }
112 | }
113 |
114 |
115 |
116 | public static void toApp() {
117 | MetaWatchService.watchState = MetaWatchService.WatchStates.APPLICATION;
118 | // update screen with cached buffer
119 | Protocol.updateDisplay(MetaWatchService.WatchBuffers.APPLICATION);
120 | }
121 |
122 | public static void exitApp(Context context) {
123 | MetaWatchService.WatchModes.APPLICATION = false;
124 |
125 | if (MetaWatchService.WatchModes.IDLE == true) {
126 | Idle.toIdle(context);
127 | }
128 | }
129 |
130 |
131 |
132 |
133 | }
134 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/IntentReceiver.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * IntentReceiver.java *
27 | * IntentReceiver *
28 | * Notifications receiver *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import android.content.BroadcastReceiver;
36 | import android.content.Context;
37 | import android.content.Intent;
38 | import android.os.Bundle;
39 | import android.telephony.SmsMessage;
40 | import android.util.Log;
41 |
42 | public class IntentReceiver extends BroadcastReceiver {
43 |
44 | @Override
45 | public void onReceive(Context context, Intent intent) {
46 |
47 | String action = intent.getAction();
48 | //Log.d(MetaWatch.TAG, action);
49 |
50 | /*
51 | Bundle b = intent.getExtras();
52 | for (String key : b.keySet()) {
53 | Log.d(MetaWatch.TAG, "extra: " + key);
54 | }
55 | Log.d(MetaWatch.TAG, intent.getDataString());
56 | */
57 |
58 | if (action.equals("android.intent.action.PROVIDER_CHANGED")) {
59 |
60 | if (!MetaWatchService.Preferences.notifyGmail)
61 | return;
62 |
63 | if (!Utils.isGmailAccessSupported(context)) {
64 | String recipient = "You";
65 | Bundle bundle = intent.getExtras();
66 |
67 | if (bundle.containsKey("account"))
68 | recipient = bundle.getString("account");
69 | Log.d(MetaWatch.TAG, "count for " + recipient + ": " + bundle.getInt("count"));
70 | int count = bundle.getInt("count");
71 | Monitors.updateGmailUnreadCount(recipient, count);
72 |
73 | if (count > 0)
74 | NotificationBuilder.createGmailBlank(context, recipient);
75 | else
76 | Idle.updateLcdIdle(context);
77 | return;
78 | }
79 | }
80 |
81 | if (action.equals("android.provider.Telephony.SMS_RECEIVED")) {
82 |
83 | if (!MetaWatchService.Preferences.notifySMS)
84 | return;
85 |
86 | Bundle bundle = intent.getExtras();
87 | if (bundle.containsKey("pdus")) {
88 | Object[] pdus = (Object[]) bundle.get("pdus");
89 | SmsMessage[] smsMessage = new SmsMessage[pdus.length];
90 | for (int i = 0; i < smsMessage.length; i++) {
91 | smsMessage[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
92 | String number = smsMessage[i].getOriginatingAddress();
93 | String body = smsMessage[i].getDisplayMessageBody();
94 |
95 | NotificationBuilder.createSMS(context, number, body);
96 | }
97 | }
98 | return;
99 | }
100 |
101 | if (action.equals("com.fsck.k9.intent.action.EMAIL_RECEIVED")) {
102 |
103 | if (!MetaWatchService.Preferences.notifyK9)
104 | return;
105 |
106 | Bundle bundle = intent.getExtras();
107 | String subject = bundle.getString("com.fsck.k9.intent.extra.SUBJECT");
108 | String sender = bundle.getString("com.fsck.k9.intent.extra.FROM");
109 | NotificationBuilder.createK9(context, sender, subject);
110 | return;
111 | }
112 |
113 | if (action.equals("com.android.alarmclock.ALARM_ALERT") || action.equals("com.htc.android.worldclock.ALARM_ALERT") || action.equals("com.android.deskclock.ALARM_ALERT") || action.equals("com.sonyericsson.alarm.ALARM_ALERT") ) {
114 |
115 | if (!MetaWatchService.Preferences.notifyAlarm)
116 | return;
117 |
118 | NotificationBuilder.createAlarm(context);
119 | return;
120 | }
121 |
122 | if (intent.getAction().equals("com.android.music.metachanged") || intent.getAction().equals("com.htc.music.metachanged"))
123 | //if (intent.getAction().equals("com.android.music.metachanged") || intent.getAction().equals("com.htc.music.metachanged") || intent.getAction().equals("com.android.music.playstatechanged") || intent.getAction().equals("com.htc.music.playstatechanged"))
124 | {
125 | if (!MetaWatchService.Preferences.notifyMusic)
126 | return;
127 |
128 | String artist = "";
129 | String track = "";
130 |
131 | if (intent.hasExtra("artist"))
132 | artist = intent.getStringExtra("artist");
133 | if (intent.hasExtra("track"))
134 | track = intent.getStringExtra("track");
135 |
136 | NotificationBuilder.createMusic(context, artist, track);
137 | return;
138 | }
139 |
140 | }
141 |
142 | }
143 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
35 |
36 |
37 |
38 |
39 |
40 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
82 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
102 |
103 |
105 |
106 |
107 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/src/org/anddev/android/weatherforecast/weather/GoogleWeatherHandler.java:
--------------------------------------------------------------------------------
1 | package org.anddev.android.weatherforecast.weather;
2 |
3 | import org.xml.sax.Attributes;
4 | import org.xml.sax.SAXException;
5 | import org.xml.sax.helpers.DefaultHandler;
6 |
7 | /**
8 | * SAXHandler capable of extracting information out of the xml-data returned by
9 | * the Google Weather API.
10 | */
11 | public class GoogleWeatherHandler extends DefaultHandler {
12 |
13 | // ===========================================================
14 | // Fields
15 | // ===========================================================
16 |
17 | @SuppressWarnings("unused")
18 | private String city = "";
19 |
20 | private WeatherSet myWeatherSet = null;
21 | @SuppressWarnings("unused")
22 | private boolean in_forecast_information = false;
23 | private boolean in_current_conditions = false;
24 | private boolean in_forecast_conditions = false;
25 |
26 | private boolean usingSITemperature = false; // false means Fahrenheit
27 |
28 | // ===========================================================
29 | // Constructors
30 | // ===========================================================
31 |
32 | // ===========================================================
33 | // Getter & Setter
34 | // ===========================================================
35 |
36 | public WeatherSet getWeatherSet() {
37 | return this.myWeatherSet;
38 | }
39 |
40 | // ===========================================================
41 | // Methods
42 | // ===========================================================
43 | @Override
44 | public void startDocument() throws SAXException {
45 | this.myWeatherSet = new WeatherSet();
46 | }
47 |
48 | @Override
49 | public void endDocument() throws SAXException {
50 | // Nothing
51 | }
52 |
53 | @Override
54 | public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
55 | // 'Outer' Tags
56 | if (localName.equals("forecast_information")) {
57 | this.in_forecast_information = true;
58 | } else if (localName.equals("current_conditions")) {
59 | this.myWeatherSet.setWeatherCurrentCondition(new WeatherCurrentCondition());
60 | this.in_current_conditions = true;
61 | } else if (localName.equals("forecast_conditions")) {
62 | this.myWeatherSet.getWeatherForecastConditions().add(new WeatherForecastCondition());
63 | this.in_forecast_conditions = true;
64 | } else {
65 | String dataAttribute = atts.getValue("data");
66 | // 'Inner' Tags of ""
67 | if (localName.equals("city")) {
68 | this.city = dataAttribute;
69 | //Log.d("ow", "city detected");
70 | } else if (localName.equals("postal_code")) {
71 | } else if (localName.equals("latitude_e6")) {
72 | /* One could use this to convert city-name to Lat/Long. */
73 | } else if (localName.equals("longitude_e6")) {
74 | /* One could use this to convert city-name to Lat/Long. */
75 | } else if (localName.equals("forecast_date")) {
76 | } else if (localName.equals("current_date_time")) {
77 | } else if (localName.equals("unit_system")) {
78 | if (dataAttribute.equals("SI"))
79 | this.usingSITemperature = true;
80 | }
81 | // SHARED(!) 'Inner' Tags within "" AND
82 | // ""
83 | else if (localName.equals("day_of_week")) {
84 | if (this.in_current_conditions) {
85 | this.myWeatherSet.getWeatherCurrentCondition().setDayofWeek(dataAttribute);
86 | } else if (this.in_forecast_conditions) {
87 | this.myWeatherSet.getLastWeatherForecastCondition().setDayofWeek(dataAttribute);
88 | }
89 | } else if (localName.equals("icon")) {
90 | if (this.in_current_conditions) {
91 | this.myWeatherSet.getWeatherCurrentCondition().setIconURL(
92 | dataAttribute);
93 | } else if (this.in_forecast_conditions) {
94 | this.myWeatherSet.getLastWeatherForecastCondition()
95 | .setIconURL(dataAttribute);
96 | }
97 | } else if (localName.equals("condition")) {
98 | if (this.in_current_conditions) {
99 | this.myWeatherSet.getWeatherCurrentCondition()
100 | .setCondition(dataAttribute);
101 | } else if (this.in_forecast_conditions) {
102 | this.myWeatherSet.getLastWeatherForecastCondition()
103 | .setCondition(dataAttribute);
104 | }
105 | }
106 | // 'Inner' Tags within ""
107 | else if (localName.equals("temp_f")) {
108 | this.myWeatherSet.getWeatherCurrentCondition()
109 | .setTempFahrenheit(Integer.parseInt(dataAttribute));
110 | } else if (localName.equals("temp_c")) {
111 | this.myWeatherSet.getWeatherCurrentCondition().setTempCelcius(
112 | Integer.parseInt(dataAttribute));
113 | } else if (localName.equals("humidity")) {
114 | this.myWeatherSet.getWeatherCurrentCondition().setHumidity(
115 | dataAttribute);
116 | } else if (localName.equals("wind_condition")) {
117 | this.myWeatherSet.getWeatherCurrentCondition()
118 | .setWindCondition(dataAttribute);
119 | }
120 | // 'Inner' Tags within ""
121 | else if (localName.equals("low")) {
122 | int temp = Integer.parseInt(dataAttribute);
123 | if (this.usingSITemperature) {
124 | this.myWeatherSet.getLastWeatherForecastCondition()
125 | .setTempMinCelsius(temp);
126 | } else {
127 | this.myWeatherSet.getLastWeatherForecastCondition()
128 | .setTempMinCelsius(
129 | WeatherUtils.fahrenheitToCelsius(temp));
130 | }
131 | } else if (localName.equals("high")) {
132 | int temp = Integer.parseInt(dataAttribute);
133 | if (this.usingSITemperature) {
134 | this.myWeatherSet.getLastWeatherForecastCondition()
135 | .setTempMaxCelsius(temp);
136 | } else {
137 | this.myWeatherSet.getLastWeatherForecastCondition()
138 | .setTempMaxCelsius(
139 | WeatherUtils.fahrenheitToCelsius(temp));
140 | }
141 | }
142 | }
143 | }
144 |
145 | @Override
146 | public void endElement(String namespaceURI, String localName, String qName)
147 | throws SAXException {
148 | if (localName.equals("forecast_information")) {
149 | this.in_forecast_information = false;
150 | } else if (localName.equals("current_conditions")) {
151 | this.in_current_conditions = false;
152 | } else if (localName.equals("forecast_conditions")) {
153 | this.in_forecast_conditions = false;
154 | }
155 | }
156 |
157 | @Override
158 | public void characters(char ch[], int start, int length) {
159 | /*
160 | * Would be called on the following structure: characters
161 | */
162 | }
163 | }
--------------------------------------------------------------------------------
/src/org/metawatch/manager/Test.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * Test.java *
27 | * Test *
28 | * Activity for sending test commands *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import org.metawatch.manager.MetaWatchService.WatchType;
36 | import org.metawatch.manager.Notification.VibratePattern;
37 |
38 | import android.app.Activity;
39 | import android.content.Context;
40 | import android.os.Bundle;
41 | import android.view.Menu;
42 | import android.view.MenuInflater;
43 | import android.view.MenuItem;
44 |
45 | public class Test extends Activity {
46 |
47 | @Override
48 | protected void onCreate(Bundle savedInstanceState) {
49 | super.onCreate(savedInstanceState);
50 | setTitle(getString(R.string.app_name) + " - " + getString(R.string.activitiy_title_tests));
51 | }
52 |
53 | @Override
54 | public boolean onCreateOptionsMenu(Menu menu) {
55 | MenuInflater inflater = getMenuInflater();
56 | inflater.inflate(R.menu.test, menu);
57 | return true;
58 | }
59 |
60 | @Override
61 | public boolean onOptionsItemSelected(MenuItem item) {
62 | switch (item.getItemId()) {
63 | case R.id.notification:
64 | if (MetaWatchService.watchType == WatchType.DIGITAL)
65 | Notification.addTextNotification(this, "Notification", new VibratePattern(true, 500, 500, 3), Notification.notificationTimeout);
66 | else
67 | Notification.addOledNotification(this, Protocol.createOled2lines(this, "Display A, line 1", "Display A, line 2"), Protocol.createOled2lines(this, "Display B, line 1", "Display B, line 2"), null, 0, null);
68 | return true;
69 | case R.id.application_start:
70 | if (MetaWatchService.watchType == WatchType.DIGITAL)
71 | Application.startAppMode();
72 | return true;
73 | case R.id.sms_start:
74 | startSmsTestLoop(this);
75 | return true;
76 | case R.id.sms_stop:
77 | stopSmsTestLoop();
78 | return true;
79 | case R.id.application_update:
80 | if (MetaWatchService.watchType == WatchType.DIGITAL)
81 | Application.updateAppMode(this);
82 | return true;
83 | case R.id.application_stop:
84 | if (MetaWatchService.watchType == WatchType.DIGITAL)
85 | Application.stopAppMode(this);
86 | return true;
87 | case R.id.sms:
88 | NotificationBuilder.createSMS(this, "555-123-456", "Rights groups report systematic state violence is being unleashed on Bahrain's opposition movement.");
89 | //NotificationBuilder.createSMS(this, "123-456-789", "Test SMS #" + "x");
90 | return true;
91 | case R.id.k9:
92 | NotificationBuilder.createK9(this, "e@mail.com", "Subject line");
93 | return true;
94 | case R.id.alarm:
95 | NotificationBuilder.createAlarm(this);
96 | return true;
97 | case R.id.music:
98 | NotificationBuilder.createMusic(this, "Park", "Who is Aliandra");
99 | return true;
100 | case R.id.call_start:
101 | Call.startCall(this, "555-123-4567");
102 | return true;
103 | case R.id.call_stop:
104 | Call.endCall(this);
105 | return true;
106 | case R.id.vibrate:
107 | Protocol.vibrate(300, 500, 3);
108 | return true;
109 | case R.id.set_rtc:
110 | Protocol.sendRtcNow(this);
111 | return true;
112 | case R.id.load_template:
113 | if (MetaWatchService.watchType == WatchType.DIGITAL)
114 | Protocol.loadTemplate(0);
115 | return true;
116 | case R.id.activate_buffer:
117 | if (MetaWatchService.watchType == WatchType.DIGITAL)
118 | Protocol.activateBuffer(0);
119 | return true;
120 | case R.id.update_display:
121 | if (MetaWatchService.watchType == WatchType.DIGITAL)
122 | Protocol.updateDisplay(0);
123 | return true;
124 | case R.id.write_bufer:
125 | if (MetaWatchService.watchType == WatchType.DIGITAL)
126 | Protocol.writeBuffer();
127 | return true;
128 | case R.id.test: {
129 | //Protocol.test(this);
130 | //NotificationBuilder.createSMS(this, "555-123-4567", "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20.");
131 | Protocol.setNvalTime(true);
132 | //Protocol.configureMode();
133 | //Protocol.readButtonConfiguration();
134 | //Protocol.enableMediaButtons();
135 | //Protocol.queryNvalTime();
136 | /*
137 | Log.d(MetaWatch.TAG, "sending notif test");
138 | Protocol.loadTemplate(2);
139 | Protocol.sendLcdBitmap(Protocol.createTextBitmap(this, "abc"), true);
140 | Protocol.updateDisplay(2);
141 | */
142 | }
143 | return true;
144 | default:
145 | return super.onOptionsItemSelected(item);
146 | }
147 | }
148 |
149 | void startSmsTestLoop(final Context context) {
150 | if (MetaWatchService.testSmsLoop != null)
151 | MetaWatchService.testSmsLoop.stop();
152 | MetaWatchService.testSmsLoop = new TestSmsLoop(context);
153 | Thread thread = new Thread(MetaWatchService.testSmsLoop);
154 | thread.start();
155 | }
156 |
157 | void stopSmsTestLoop() {
158 | MetaWatchService.testSmsLoop.stop();
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/Utils.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * Utils.java *
27 | * Utils *
28 | * Different utils *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import java.io.IOException;
36 | import java.io.InputStream;
37 |
38 | import android.accounts.Account;
39 | import android.accounts.AccountManager;
40 | import android.content.Context;
41 | import android.content.pm.PackageInfo;
42 | import android.content.pm.PackageManager;
43 | import android.content.pm.PackageManager.NameNotFoundException;
44 | import android.database.Cursor;
45 | import android.graphics.Bitmap;
46 | import android.graphics.BitmapFactory;
47 | import android.net.Uri;
48 | import android.provider.CallLog;
49 | import android.provider.ContactsContract.PhoneLookup;
50 | import android.util.Log;
51 |
52 | public class Utils {
53 |
54 | public static String getContactNameFromNumber(Context context, String number) {
55 |
56 | if (number.equals(""))
57 | return "Private number";
58 |
59 | String[] projection = new String[] { PhoneLookup.DISPLAY_NAME, PhoneLookup.NUMBER };
60 | Uri contactUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
61 | Cursor c = context.getContentResolver().query(contactUri, projection, null, null, null);
62 |
63 | if (c.moveToFirst()) {
64 | String name = c.getString(c.getColumnIndex(PhoneLookup.DISPLAY_NAME));
65 |
66 | if (name.length() > 0)
67 | return name;
68 | else
69 | return number;
70 | }
71 |
72 | return number;
73 | }
74 |
75 | public static int getUnreadSmsCount(Context context) {
76 |
77 | int count = 0;
78 |
79 | Cursor cursor = context.getContentResolver().query(
80 | Uri.withAppendedPath(Uri.parse("content://sms"), "inbox"),
81 | new String[] { "_id" },
82 | "read=0",
83 | null,
84 | null
85 | );
86 |
87 | if (cursor != null) {
88 | try {
89 | count = cursor.getCount();
90 | } finally {
91 | cursor.close();
92 | }
93 | }
94 | return count;
95 | }
96 |
97 | public static int getMissedCallsCount(Context context) {
98 | int missed = 0;
99 | try {
100 | Cursor cursor = context.getContentResolver().query(android.provider.CallLog.Calls.CONTENT_URI, null, null, null, null);
101 | cursor.moveToFirst();
102 |
103 | while (true) {
104 | if (cursor.getInt(cursor.getColumnIndex(CallLog.Calls.TYPE)) == 3)
105 | missed += cursor.getInt(cursor.getColumnIndex(CallLog.Calls.NEW));
106 |
107 | if (cursor.isLast())
108 | break;
109 |
110 | cursor.moveToNext();
111 | }
112 |
113 | } catch (Exception x) {
114 | }
115 | return missed;
116 | }
117 |
118 | public static int getUnreadGmailCount(Context context, String account, String label) {
119 | try {
120 | int nameColumn = 0;
121 |
122 | Cursor c = context.getContentResolver().query(Uri.parse("content://gmail-ls/labels/" + account), null, null, null, null);
123 | c.moveToFirst();
124 |
125 | for (int i = 0; i < c.getColumnCount(); i++)
126 | if (c.getColumnName(i).equals("canonicalName")) {
127 | nameColumn = i;
128 | break;
129 | }
130 |
131 | while (true) {
132 | if (c.getString(nameColumn).equals(label))
133 | for (int i = 0; i < c.getColumnCount(); i++) {
134 | if (c.getColumnName(i).equals("numUnreadConversations")) {
135 | return Integer.parseInt(c.getString(i));
136 | }
137 | }
138 |
139 | c.moveToNext();
140 |
141 | if (c.isLast()) {
142 | break;
143 | }
144 | }
145 | } catch (Exception x) {
146 | Log.d(MetaWatch.TAG, x.toString());
147 | }
148 |
149 | return 0;
150 | }
151 |
152 | public static String getGoogleAccountName(Context context) {
153 | AccountManager accountManager = AccountManager.get(context);
154 | Account[] accounts = accountManager.getAccounts();
155 | int count = accounts.length;
156 | Account account = null;
157 |
158 | for (int i = 0; i < count; i++) {
159 | account = accounts[i];
160 | if (account.type.equals("com.google")) {
161 | return account.name;
162 | }
163 | }
164 | return "";
165 | }
166 |
167 | public static Bitmap loadBitmapFromAssets(Context context, String path) {
168 | try {
169 | InputStream inputStream = context.getAssets().open(path);
170 | Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
171 | inputStream.close();
172 | //Log.d(MetaWatch.TAG, "ok");
173 | return bitmap;
174 | } catch (IOException e) {
175 | //Log.d(MetaWatch.TAG, e.toString());
176 | return null;
177 | }
178 | }
179 | /*
180 | public static Bitmap loadBitmapFromPath(Context context, String path) {
181 | return BitmapFactory.decodeFile(path);
182 | }
183 | */
184 |
185 | public static String getVersion(Context context) {
186 | try {
187 | PackageManager packageManager = context.getPackageManager();
188 | PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
189 | return packageInfo.versionName;
190 | } catch (NameNotFoundException e) {
191 | }
192 | return "unknown";
193 | }
194 |
195 | public static boolean isGmailAccessSupported(Context context) {
196 |
197 |
198 | try {
199 | PackageManager packageManager = context.getPackageManager();
200 | PackageInfo packageInfo = packageManager.getPackageInfo("com.google.android.gm", 0);
201 | // check for Gmail version earlier than v2.3.5 (169)
202 | if (packageInfo.versionCode < 169)
203 | return true;
204 |
205 | } catch (NameNotFoundException e) {
206 | }
207 |
208 |
209 | return false;
210 | }
211 |
212 |
213 | }
214 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/Idle.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * Idle.java *
27 | * Idle *
28 | * Idle watch mode *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import org.metawatch.manager.Monitors.WeatherData;
36 |
37 | import android.content.Context;
38 | import android.graphics.Bitmap;
39 | import android.graphics.Canvas;
40 | import android.graphics.Color;
41 | import android.graphics.Paint;
42 | import android.graphics.Typeface;
43 | import android.text.StaticLayout;
44 | import android.text.TextPaint;
45 |
46 | public class Idle {
47 |
48 | public static byte[] overridenButtons = null;
49 |
50 | static Bitmap createLcdIdle(Context context) {
51 | Bitmap bitmap = Bitmap.createBitmap(96, 96, Bitmap.Config.RGB_565);
52 | Canvas canvas = new Canvas(bitmap);
53 |
54 | Paint paintSmall = new Paint();
55 | paintSmall.setColor(Color.BLACK);
56 | paintSmall.setTextSize(8);
57 | Typeface typefaceSmall = Typeface.createFromAsset(context.getAssets(), "metawatch_8pt_5pxl_CAPS.ttf");
58 | paintSmall.setTypeface(typefaceSmall);
59 |
60 | Paint paintLarge = new Paint();
61 | paintLarge.setColor(Color.BLACK);
62 | paintLarge.setTextSize(16);
63 | Typeface typefaceLarge = Typeface.createFromAsset(context.getAssets(), "metawatch_16pt_11pxl.ttf");
64 | paintLarge.setTypeface(typefaceLarge);
65 |
66 | canvas.drawColor(Color.WHITE);
67 |
68 | canvas = drawLine(canvas, 32);
69 |
70 | if (WeatherData.received) {
71 | // condition
72 | canvas.save();
73 | TextPaint paint = new TextPaint(paintSmall);
74 | StaticLayout layout = new StaticLayout(WeatherData.condition, paint, 36, android.text.Layout.Alignment.ALIGN_NORMAL, 1.3f, 0, false);
75 | canvas.translate(3, 40); //position the text
76 | layout.draw(canvas);
77 |
78 | canvas.restore();
79 |
80 | // icon
81 | Bitmap image = Utils.loadBitmapFromAssets(context, WeatherData.icon);
82 | canvas.drawBitmap(image, 37, 35, null);
83 |
84 | // temperatures
85 | canvas.drawText(WeatherData.temp, 64, 46, paintLarge);
86 | canvas.drawText(WeatherData.tempHigh, 64, 54, paintSmall);
87 | canvas.drawText(WeatherData.tempLow, 64, 62, paintSmall);
88 | canvas.drawText(WeatherData.city, 3, 62, paintSmall);
89 |
90 | } else {
91 | canvas.drawText("no data", 34, 50, paintSmall);
92 | }
93 |
94 | canvas = drawLine(canvas, 64);
95 |
96 | // icons row
97 | //Bitmap imageI = Utils.loadBitmapFromAssets(context, "idle_icons_row.bmp");
98 | //canvas.drawBitmap(imageI, 0, 66, null);
99 |
100 | int rows = 3;
101 | /*
102 | if (Utils.isGmailAccessSupported(context))
103 | rows = 3;
104 | else
105 | rows = 2;
106 | */
107 |
108 | // icons
109 | for (int i = 0; i < rows; i++) {
110 | int slotSpace = 96/rows;
111 | int slotX = slotSpace/2-12;
112 | int iconX = slotSpace*i + slotX;
113 | switch (i) {
114 | case 0:
115 | canvas.drawBitmap(Utils.loadBitmapFromAssets(context, "idle_call.bmp"), iconX, 67, null);
116 | break;
117 | case 1:
118 | canvas.drawBitmap(Utils.loadBitmapFromAssets(context, "idle_sms.bmp"), iconX, 67, null);
119 | break;
120 | case 2:
121 | canvas.drawBitmap(Utils.loadBitmapFromAssets(context, "idle_gmail.bmp"), iconX, 67, null);
122 | break;
123 | }
124 | }
125 |
126 | // unread counters
127 | for (int i = 0; i < rows; i++) {
128 | String count = "";
129 | switch (i) {
130 | case 0:
131 | count = Integer.toString(Utils.getMissedCallsCount(context));
132 | break;
133 | case 1:
134 | count = Integer.toString(Utils.getUnreadSmsCount(context));
135 | break;
136 | case 2:
137 | if (Utils.isGmailAccessSupported(context))
138 | count = Integer.toString(Utils.getUnreadGmailCount(context, Utils.getGoogleAccountName(context), "^i"));
139 | else
140 | count = Integer.toString(Monitors.getGmailUnreadCount());
141 | break;
142 | }
143 |
144 | int slotSpace = 96/rows;
145 | int slotX = (int) (slotSpace/2-paintSmall.measureText(count)/2);
146 | int countX = slotSpace*i + slotX;
147 |
148 | canvas.drawText(count, countX, 92, paintSmall);
149 | }
150 |
151 | /*
152 | FileOutputStream fos = new FileOutputStream("/sdcard/test.png");
153 | image.compress(Bitmap.CompressFormat.PNG, 100, fos);
154 | fos.close();
155 | Log.d("ow", "bmp ok");
156 | */
157 | return bitmap;
158 | }
159 |
160 | public static Canvas drawLine(Canvas canvas, int y) {
161 | Paint paint = new Paint();
162 | paint.setColor(Color.BLACK);
163 |
164 | int left = 3;
165 |
166 | for (int i = 0+left; i < 96-left; i += 3)
167 | canvas.drawLine(i, y, i+2, y, paint);
168 |
169 | return canvas;
170 | }
171 |
172 | public static void sendLcdIdle(Context context) {
173 | Bitmap bitmap = createLcdIdle(context);
174 | //Protocol.loadTemplate(0);
175 | Protocol.sendLcdBitmap(bitmap, MetaWatchService.WatchBuffers.IDLE);
176 | //Protocol.activateBuffer();
177 | Protocol.updateDisplay(0);
178 | }
179 |
180 | public static boolean toIdle(Context context) {
181 | // check for parent modes
182 |
183 | MetaWatchService.WatchModes.IDLE = true;
184 | MetaWatchService.watchState = MetaWatchService.WatchStates.IDLE;
185 |
186 | sendLcdIdle(context);
187 | //Protocol.updateDisplay(0);
188 |
189 | return true;
190 | }
191 |
192 | public static void updateLcdIdle(Context context) {
193 | if (MetaWatchService.watchState == MetaWatchService.WatchStates.IDLE)
194 | sendLcdIdle(context);
195 | }
196 |
197 | public static boolean isIdleButtonOverriden(byte button) {
198 | if (overridenButtons != null)
199 | for (int i = 0; i < overridenButtons.length; i++)
200 | if (overridenButtons[i] == button)
201 | return true;
202 | return false;
203 | }
204 |
205 | }
206 |
--------------------------------------------------------------------------------
/src/org/metawatch/manager/DeviceSelection.java:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*****************************************************************************
6 | * Copyright (c) 2011 Meta Watch Ltd. *
7 | * www.MetaWatch.org *
8 | * *
9 | =============================================================================
10 | * *
11 | * Licensed under the Apache License, Version 2.0 (the "License"); *
12 | * you may not use this file except in compliance with the License. *
13 | * You may obtain a copy of the License at *
14 | * *
15 | * http://www.apache.org/licenses/LICENSE-2.0 *
16 | * *
17 | * Unless required by applicable law or agreed to in writing, software *
18 | * distributed under the License is distributed on an "AS IS" BASIS, *
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 | * See the License for the specific language governing permissions and *
21 | * limitations under the License. *
22 | * *
23 | *****************************************************************************/
24 |
25 | /*****************************************************************************
26 | * DeviceSelection.java *
27 | * DeviceSelection *
28 | * Bluetooth device picker activity *
29 | * *
30 | * *
31 | *****************************************************************************/
32 |
33 | package org.metawatch.manager;
34 |
35 | import java.util.ArrayList;
36 | import java.util.HashMap;
37 | import java.util.List;
38 | import java.util.Map;
39 | import java.util.Set;
40 |
41 | import android.app.Activity;
42 | import android.app.ProgressDialog;
43 | import android.bluetooth.BluetoothAdapter;
44 | import android.bluetooth.BluetoothDevice;
45 | import android.content.BroadcastReceiver;
46 | import android.content.Context;
47 | import android.content.DialogInterface;
48 | import android.content.DialogInterface.OnCancelListener;
49 | import android.content.Intent;
50 | import android.content.IntentFilter;
51 | import android.os.Bundle;
52 | import android.os.Handler;
53 | import android.os.Message;
54 | import android.util.Log;
55 | import android.view.View;
56 | import android.widget.AdapterView;
57 | import android.widget.AdapterView.OnItemClickListener;
58 | import android.widget.ListView;
59 | import android.widget.SimpleAdapter;
60 | import android.widget.Toast;
61 |
62 | public class DeviceSelection extends Activity {
63 |
64 | class Receiver extends BroadcastReceiver {
65 | @Override
66 | public void onReceive(Context context, Intent intent) {
67 |
68 | if (intent.getAction().equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED)) {
69 | Log.d(MetaWatch.TAG, "discovery finished");
70 |
71 | pdWait.dismiss();
72 |
73 | if (list.size() == 0) {
74 | sendToast("No watch found");
75 | finish();
76 | }
77 | }
78 |
79 | if (intent.getAction().equals(BluetoothDevice.ACTION_FOUND)) {
80 | Log.d(MetaWatch.TAG, "device found");
81 |
82 | BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
83 |
84 | if (device.getBondState() == BluetoothDevice.BOND_BONDED)
85 | return;
86 |
87 | String deviceName = device.getName();
88 | String deviceMac = device.getAddress();
89 |
90 | //int cl = device.getBluetoothClass().getMajorDeviceClass();
91 | //Log.d(MetaWatch.TAG, "device class: " + cl);
92 |
93 | addToList(deviceMac, deviceName);
94 | }
95 | }
96 | }
97 |
98 | ProgressDialog pdWait = null;
99 |
100 | Context context;
101 | ListView listView;
102 | //static ArrayList menuList = new ArrayList();
103 | List