aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Klein <jlklein@google.com>2015-07-15 13:31:45 -0700
committerJeremy Klein <jlklein@google.com>2015-07-15 14:24:10 -0700
commitcabd426608f2c6776ecd1ef2ac0053dcc352adbc (patch)
tree9d0c6458577f7c6752dbc47482cc06dfe4c7d042
parentf688ba9d4c3d63e68267518f1d0773fcfb919085 (diff)
downloadconnectbot-cabd426608f2c6776ecd1ef2ac0053dcc352adbc.tar.gz
connectbot-cabd426608f2c6776ecd1ef2ac0053dcc352adbc.tar.bz2
connectbot-cabd426608f2c6776ecd1ef2ac0053dcc352adbc.zip
Add the v4 support library and update the notification API.
Switch to using NotificationCompat.Builder. This will allow for the creation of a "disconnect all" button in the notification (see #93).
-rw-r--r--app/app.iml4
-rw-r--r--app/build.gradle10
-rw-r--r--app/src/main/AndroidManifest.xml2
-rw-r--r--app/src/main/java/org/connectbot/service/ConnectionNotifier.java58
4 files changed, 40 insertions, 34 deletions
diff --git a/app/app.iml b/app/app.iml
index 1914fd4..2b8fc3e 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -85,7 +85,9 @@
<excludeFolder url="file://$MODULE_DIR$/build/test-results" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
- <orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
+ <orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
+ <orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
</component>
</module> \ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index d3da188..ad8ba26 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -4,13 +4,13 @@ apply from: '../config/quality.gradle'
apply from: '../config/translations.gradle'
android {
- compileSdkVersion 20
- buildToolsVersion "20.0.0"
+ compileSdkVersion 22
+ buildToolsVersion "21.0.0"
defaultConfig {
applicationId "org.connectbot"
minSdkVersion 4
- targetSdkVersion 15
+ targetSdkVersion 22
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_5
targetCompatibility JavaVersion.VERSION_1_5
@@ -34,6 +34,10 @@ android {
release
}
+ dependencies {
+ compile "com.android.support:support-v4:22.0.+"
+ }
+
buildTypes {
release {
minifyEnabled true
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 71f25e7..406f3b9 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -21,7 +21,7 @@
android:versionCode="374"
android:installLocation="auto">
- <uses-sdk android:targetSdkVersion="15" android:minSdkVersion="4" />
+ <uses-sdk android:targetSdkVersion="22" android:minSdkVersion="4" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
diff --git a/app/src/main/java/org/connectbot/service/ConnectionNotifier.java b/app/src/main/java/org/connectbot/service/ConnectionNotifier.java
index e42525d..3d3bf71 100644
--- a/app/src/main/java/org/connectbot/service/ConnectionNotifier.java
+++ b/app/src/main/java/org/connectbot/service/ConnectionNotifier.java
@@ -35,6 +35,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
+import android.support.v4.app.NotificationCompat;
/**
* @author Kenny Root
@@ -43,6 +44,7 @@ import android.graphics.Color;
*/
public abstract class ConnectionNotifier {
private static final int ONLINE_NOTIFICATION = 1;
+ private static final int ONLINE_NOTIFICATION_DISCONNECT = 1;
private static final int ACTIVITY_NOTIFICATION = 2;
public static ConnectionNotifier getInstance() {
@@ -56,16 +58,17 @@ public abstract class ConnectionNotifier {
return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
}
- protected Notification newNotification(Context context) {
- Notification notification = new Notification();
- notification.icon = R.drawable.notification_icon;
- notification.when = System.currentTimeMillis();
+ protected NotificationCompat.Builder newNotificationBuilder(Context context) {
+ NotificationCompat.Builder builder =
+ new NotificationCompat.Builder(context)
+ .setSmallIcon(R.drawable.notification_icon)
+ .setWhen(System.currentTimeMillis());
- return notification;
+ return builder;
}
protected Notification newActivityNotification(Context context, HostBean host) {
- Notification notification = newNotification(context);
+ NotificationCompat.Builder notification = newNotificationBuilder(context);
Resources res = context.getResources();
@@ -79,45 +82,42 @@ public abstract class ConnectionNotifier {
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
- notification.setLatestEventInfo(context, res.getString(R.string.app_name), contentText, contentIntent);
+ notification.setContentTitle(res.getString(R.string.app_name))
+ .setContentText(contentText)
+ .setContentIntent(contentIntent);
- notification.flags = Notification.FLAG_AUTO_CANCEL;
+ notification.setAutoCancel(true);
- notification.flags |= Notification.DEFAULT_LIGHTS;
+ int ledOnMS = 300;
+ int ledOffMS = 1000;
+ notification.setDefaults(Notification.DEFAULT_LIGHTS);
if (HostDatabase.COLOR_RED.equals(host.getColor()))
- notification.ledARGB = Color.RED;
+ notification.setLights(Color.RED, ledOnMS, ledOffMS);
else if (HostDatabase.COLOR_GREEN.equals(host.getColor()))
- notification.ledARGB = Color.GREEN;
+ notification.setLights(Color.GREEN, ledOnMS, ledOffMS);
else if (HostDatabase.COLOR_BLUE.equals(host.getColor()))
- notification.ledARGB = Color.BLUE;
+ notification.setLights(Color.BLUE, ledOnMS, ledOffMS);
else
- notification.ledARGB = Color.WHITE;
- notification.ledOnMS = 300;
- notification.ledOffMS = 1000;
- notification.flags |= Notification.FLAG_SHOW_LIGHTS;
+ notification.setLights(Color.WHITE, ledOnMS, ledOffMS);
- return notification;
+ return notification.build();
}
protected Notification newRunningNotification(Context context) {
- Notification notification = newNotification(context);
+ NotificationCompat.Builder notification = newNotificationBuilder(context);
- notification.flags = Notification.FLAG_ONGOING_EVENT
- | Notification.FLAG_NO_CLEAR;
- notification.when = 0;
+ notification.setOngoing(true);
+ notification.setWhen(0);
- notification.contentIntent = PendingIntent.getActivity(context,
+ notification.setContentIntent(PendingIntent.getActivity(context,
ONLINE_NOTIFICATION,
- new Intent(context, ConsoleActivity.class), 0);
+ new Intent(context, ConsoleActivity.class), 0));
Resources res = context.getResources();
+ notification.setContentTitle(res.getString(R.string.app_name));
+ notification.setContentText(res.getString(R.string.app_is_running));
- notification.setLatestEventInfo(context,
- res.getString(R.string.app_name),
- res.getString(R.string.app_is_running),
- notification.contentIntent);
-
- return notification;
+ return notification.build();
}
public void showActivityNotification(Service context, HostBean host) {