diff options
author | Kenny Root <kenny@the-b.org> | 2015-07-16 06:35:02 -0700 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2015-07-16 06:35:02 -0700 |
commit | 96eb22234d8bd350a853cc0533dd2430dfc04594 (patch) | |
tree | fb6a7f47ef582250a07491448383120f4b13b653 | |
parent | f688ba9d4c3d63e68267518f1d0773fcfb919085 (diff) | |
parent | 83510cc3e77a0c5afda2df8c3ca6d06f096c91ea (diff) | |
download | connectbot-96eb22234d8bd350a853cc0533dd2430dfc04594.tar.gz connectbot-96eb22234d8bd350a853cc0533dd2430dfc04594.tar.bz2 connectbot-96eb22234d8bd350a853cc0533dd2430dfc04594.zip |
Merge pull request #99 from jklein24/gradle-conversion
Add the v4 support library and update the notification API.
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | app/app.iml | 4 | ||||
-rw-r--r-- | app/build.gradle | 10 | ||||
-rw-r--r-- | app/src/main/AndroidManifest.xml | 2 | ||||
-rw-r--r-- | app/src/main/java/org/connectbot/service/ConnectionNotifier.java | 57 |
5 files changed, 41 insertions, 34 deletions
diff --git a/.travis.yml b/.travis.yml index 4979aa7..d05375b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,9 @@ before_script: android: components: - build-tools-22.0.0 + - android-22 - extra-android-support + - extra-android-m2repository license: - '.+' 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..c480143 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 @@ -56,16 +57,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 builder = newNotificationBuilder(context); Resources res = context.getResources(); @@ -79,45 +81,42 @@ public abstract class ConnectionNotifier { PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); - notification.setLatestEventInfo(context, res.getString(R.string.app_name), contentText, contentIntent); + builder.setContentTitle(res.getString(R.string.app_name)) + .setContentText(contentText) + .setContentIntent(contentIntent); - notification.flags = Notification.FLAG_AUTO_CANCEL; + builder.setAutoCancel(true); - notification.flags |= Notification.DEFAULT_LIGHTS; + int ledOnMS = 300; + int ledOffMS = 1000; + builder.setDefaults(Notification.DEFAULT_LIGHTS); if (HostDatabase.COLOR_RED.equals(host.getColor())) - notification.ledARGB = Color.RED; + builder.setLights(Color.RED, ledOnMS, ledOffMS); else if (HostDatabase.COLOR_GREEN.equals(host.getColor())) - notification.ledARGB = Color.GREEN; + builder.setLights(Color.GREEN, ledOnMS, ledOffMS); else if (HostDatabase.COLOR_BLUE.equals(host.getColor())) - notification.ledARGB = Color.BLUE; + builder.setLights(Color.BLUE, ledOnMS, ledOffMS); else - notification.ledARGB = Color.WHITE; - notification.ledOnMS = 300; - notification.ledOffMS = 1000; - notification.flags |= Notification.FLAG_SHOW_LIGHTS; + builder.setLights(Color.WHITE, ledOnMS, ledOffMS); - return notification; + return builder.build(); } protected Notification newRunningNotification(Context context) { - Notification notification = newNotification(context); + NotificationCompat.Builder builder = newNotificationBuilder(context); - notification.flags = Notification.FLAG_ONGOING_EVENT - | Notification.FLAG_NO_CLEAR; - notification.when = 0; + builder.setOngoing(true); + builder.setWhen(0); - notification.contentIntent = PendingIntent.getActivity(context, + builder.setContentIntent(PendingIntent.getActivity(context, ONLINE_NOTIFICATION, - new Intent(context, ConsoleActivity.class), 0); + new Intent(context, ConsoleActivity.class), 0)); Resources res = context.getResources(); + builder.setContentTitle(res.getString(R.string.app_name)); + builder.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 builder.build(); } public void showActivityNotification(Service context, HostBean host) { |