Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Optionally send all notifications to watch, with blacklist.
Browse files Browse the repository at this point in the history
  • Loading branch information
PurpleGuitar committed Oct 12, 2011
1 parent 695e826 commit f592ec2
Show file tree
Hide file tree
Showing 11 changed files with 321 additions and 27 deletions.
6 changes: 6 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
android:configChanges="keyboardHidden|orientation"
android:launchMode="singleTask">
</activity>
<activity
android:label="App Blacklist"
android:name=".AppBlacklist"
android:configChanges="keyboardHidden|orientation"
android:launchMode="singleTask">
</activity>
<receiver android:name=".IntentReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ CHANGELOG
v0.7:
=======================================================================

- Added option to forward all notifications to the watch. A new
settings screen is available to blacklist apps that you don't want
to receive notifications from. (Requires accessibility in Android
Settings) [db1nto, damis648]

- Made vibrate pattern customizable for:
- SMS
- Gmail
- K9
- Alarm
- Music
- Calendar
- Other apps

- Added album info to music notification on digital watch.

Expand Down
18 changes: 0 additions & 18 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,6 @@ TO DO
WISH LIST
=======================================================================

- Create buzzing scheme:
- 1 buzz: minor events (music track change)
- 2 buzz: normal events (notifications, email)
- 3 buzz: urgent events (SMS, calendar)

- Other notification types via Accessibility?
- Pandora track changes?
- Facebook notifications?
- Twitter notifications?
- Google+ notifications?
- Parcel notifications? "Your package has arrived!" :)
- Turn-by-turn navigation?
- anDGS notifications: "It's your turn to play!"
- Remember the Milk notifications: "A task is due!"
- Weather channel severe weather?

- Maybe just forward all notifications, with a blacklist? [db1nto]

- Notify on new voicemail?

- Optionally left-pad scrolling text on analog, to maximize the time
Expand Down
15 changes: 15 additions & 0 deletions res/layout/app_blacklist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout android:id="@+id/app_blacklist_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@android:id/list"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</ListView>
</LinearLayout>
</LinearLayout>
13 changes: 13 additions & 0 deletions res/layout/app_blacklist_list_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView android:id="@+id/app_blacklist_list_item_icon"
android:layout_width="48dp" android:layout_height="48dp"
android:layout_marginRight="6dip" android:src="@drawable/icon" />
<TextView android:layout_width="wrap_content" android:layout_weight="1"
android:layout_height="wrap_content" android:id="@+id/app_blacklist_list_item_name"
android:textSize="30px" android:text="Hello There"></TextView>
<CheckBox android:id="@+id/app_blacklist_list_item_check"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="4px" android:layout_marginRight="10px"></CheckBox>
</LinearLayout>
21 changes: 21 additions & 0 deletions res/layout/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,27 @@
android:enabled="true"
android:defaultValue="3"
/>
<CheckBoxPreference
android:title="@string/settings_OtherNotification"
android:key="NotifyOtherNotification"
android:summary="@string/settings_OtherNotification_desc"
android:defaultValue="true"
/>
<ListPreference
android:entries="@array/settings_number_buzzes_names"
android:entryValues="@array/settings_number_buzzes_values"
android:dialogTitle="Number of Buzzes"
android:key="settingsOtherNotificationNumberBuzzes"
android:title="Other Apps Vibrate Pattern"
android:negativeButtonText="Cancel"
android:enabled="true"
android:defaultValue="1"
/>
<Preference
android:title="Application Blacklist"
android:key="appBlacklist"
android:summary="List of applications to ignore notifications from"
/>
</PreferenceCategory>

<PreferenceCategory
Expand Down
2 changes: 2 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<string name="settings_Music_desc">Music artist/album/track info</string>
<string name="settings_Calendar">Calendar</string>
<string name="settings_Calendar_desc">Calendar notifications (requires Accessibility in Android settings)</string>
<string name="settings_OtherNotification">Other Apps</string>
<string name="settings_OtherNotification_desc">Other notifications (requires Accessibility in Android settings)</string>

<string name="settings_Device">Device</string>
<string name="settings_Mac">MAC</string>
Expand Down
173 changes: 173 additions & 0 deletions src/org/metawatch/manager/AppBlacklist.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
package org.metawatch.manager;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class AppBlacklist extends Activity {

public static final String DEFAULT_BLACKLIST = "com.android.mms,com.google.android.gm,com.fsck.k9,com.android.alarmclock,com.htc.android.worldclock,com.android.deskclock,com.sonyericsson.alarm";
private List<AppInfo> appInfos;

private class AppLoader extends AsyncTask<Void, Void, List<AppInfo>> {
private ProgressDialog pdWait;

@Override
protected void onPreExecute() {
pdWait = new ProgressDialog(AppBlacklist.this);
pdWait.setTitle("Loading apps, please wait...");
pdWait.show();
}

@Override
protected List<AppInfo> doInBackground(Void... params) {
SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(AppBlacklist.this);
String blacklist = sharedPreferences.getString("appBlacklist",
DEFAULT_BLACKLIST);
PackageManager pm = getPackageManager();
List<PackageInfo> packages = pm.getInstalledPackages(0);
List<AppInfo> appInfos = new ArrayList<AppInfo>();
for (PackageInfo pi : packages) {
/* Ignore system (non-versioned) packages */
if (pi.versionName == null) {
continue;
}
/* Ignore Android System */
if (pi.packageName.equals("android")) {
continue;
}
AppInfo appInfo = new AppInfo();
appInfo.packageInfo = pi;
appInfo.name = appInfo.packageInfo.applicationInfo
.loadLabel(pm).toString();
appInfo.icon = appInfo.packageInfo.applicationInfo.loadIcon(pm);
appInfo.isBlacklisted = blacklist.contains(pi.packageName);
appInfos.add(appInfo);
}
Collections.sort(appInfos);

// for (AppInfo appInfo : appInfos) {
// Log.d(MetaWatch.TAG, "appName='" + appInfo.name
// + "' packageName='" + appInfo.packageInfo.packageName +
// "' selected="
// + appInfo.selected);
// }

return appInfos;
}

@Override
protected void onPostExecute(List<AppInfo> appInfos) {

ListView listView = (ListView) findViewById(android.R.id.list);
// listView.setAdapter(new ArrayAdapter<String>(this,
// android.R.layout.simple_list_item_1, menuList));
listView.setAdapter(new BlacklistAdapter(AppBlacklist.this,
appInfos));
AppBlacklist.this.appInfos = appInfos;
pdWait.dismiss();

}

}

public class AppInfo implements Comparable<AppInfo> {
String name;
Drawable icon;
PackageInfo packageInfo;
boolean isBlacklisted;

public int compareTo(AppInfo another) {
return this.name.compareTo(another.name);
}
}

class BlacklistAdapter extends ArrayAdapter<AppInfo> {
private final Activity context;
private final List<AppInfo> apps;

public BlacklistAdapter(Activity context, List<AppInfo> apps) {
super(context, R.layout.app_blacklist_list_item, apps);
this.context = context;
this.apps = apps;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = null;
LayoutInflater inflater = context.getLayoutInflater();
view = inflater.inflate(R.layout.app_blacklist_list_item, null);
ImageView icon = (ImageView) view
.findViewById(R.id.app_blacklist_list_item_icon);
TextView appName = (TextView) view
.findViewById(R.id.app_blacklist_list_item_name);
CheckBox checkbox = (CheckBox) view
.findViewById(R.id.app_blacklist_list_item_check);
final AppInfo appInfo = apps.get(position);
icon.setImageDrawable(appInfo.icon);
appName.setText(appInfo.name);
checkbox.setChecked(appInfo.isBlacklisted);
checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
appInfo.isBlacklisted = isChecked;
}
});
return view;
}

}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.app_blacklist);

AppLoader appLoader = new AppLoader();
appLoader.execute((Void[]) null);
}

@Override
protected void onPause() {
super.onPause();
StringBuilder sb = new StringBuilder();
for (AppInfo appInfo : appInfos) {
if (appInfo.isBlacklisted) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(appInfo.packageInfo.packageName);
}
}
SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = sharedPreferences.edit();
String blacklist = sb.toString();
editor.putString("appBlacklist", blacklist);
editor.commit();
Log.d(MetaWatch.TAG, "App blacklist: " + blacklist);
}

}
Loading

0 comments on commit f592ec2

Please sign in to comment.