Skip to content
This repository was archived by the owner on Feb 1, 2020. It is now read-only.

Commit 6ecb0ff

Browse files
committed
updating removed API calls in notification mechanism
Change-Id: Id6cce21009e53aa60fa355f0974e8e5490ac7245
1 parent e33edcd commit 6ecb0ff

11 files changed

Lines changed: 81 additions & 48 deletions

File tree

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 33 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AnySoftKeyboard-API.iml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
</configuration>
99
</facet>
1010
</component>
11-
<component name="NewModuleRootManager" inherit-compiler-output="true">
12-
<output url="file://$MODULE_DIR$/build" />
13-
<output-test url="file://$MODULE_DIR$/build" />
11+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
1412
<exclude-output />
1513
<content url="file://$MODULE_DIR$">
1614
<excludeFolder url="file://$MODULE_DIR$/.gradle" />

api/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

api/api.iml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
1313
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
1414
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
15-
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
1615
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
1716
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
18-
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
17+
<afterSyncTasks>
18+
<task>generateDebugAndroidTestSources</task>
19+
<task>generateDebugSources</task>
20+
</afterSyncTasks>
1921
<option name="ALLOW_USER_CONFIGURATION" value="false" />
2022
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
2123
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
@@ -25,7 +27,7 @@
2527
</configuration>
2628
</facet>
2729
</component>
28-
<component name="NewModuleRootManager" inherit-compiler-output="false">
30+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
2931
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
3032
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
3133
<exclude-output />
@@ -35,13 +37,13 @@
3537
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
3638
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
3739
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
38-
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
40+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
3941
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
4042
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
4143
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
4244
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
4345
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
44-
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" />
46+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
4547
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
4648
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
4749
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
@@ -70,8 +72,8 @@
7072
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
7173
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
7274
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
73-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" />
74-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
75+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.0/jars" />
76+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.0/jars" />
7577
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
7678
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
7779
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@@ -87,10 +89,10 @@
8789
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
8890
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
8991
</content>
90-
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
92+
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
9193
<orderEntry type="sourceFolder" forTests="false" />
92-
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
93-
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
94-
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
94+
<orderEntry type="library" exported="" name="appcompat-v7-23.0.0" level="project" />
95+
<orderEntry type="library" exported="" name="support-v4-23.0.0" level="project" />
96+
<orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
9597
</component>
9698
</module>

api/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 22
5-
buildToolsVersion '22.0.1'
4+
compileSdkVersion 23
5+
buildToolsVersion '23.0.0'
66

77
defaultConfig {
8-
minSdkVersion 15
9-
targetSdkVersion 22
8+
minSdkVersion 7
9+
targetSdkVersion 23
1010
versionCode 1
1111
versionName "1.0"
1212
}
@@ -20,5 +20,5 @@ android {
2020

2121
dependencies {
2222
compile fileTree(dir: 'libs', include: ['*.jar'])
23-
compile 'com.android.support:appcompat-v7:22.2.0'
23+
compile 'com.android.support:appcompat-v7:23.0.0'
2424
}

api/src/main/java/com/anysoftkeyboard/api/LanguageChangeddBroadcastReceiver.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.anysoftkeyboard.api;
22

33

4-
import android.app.Notification;
54
import android.app.NotificationManager;
65
import android.app.PendingIntent;
76
import android.content.BroadcastReceiver;
87
import android.content.Context;
98
import android.content.Intent;
9+
import android.support.v4.app.NotificationCompat;
1010

1111

1212
/**
@@ -50,17 +50,18 @@ public final void onReceive(Context context, Intent intent) {
5050
private void sendNotification(Context ctx, Intent i) {
5151
int icon = i.getExtras().getInt("current_layout_resid");
5252
String name = i.getExtras().getString("current_layout_name");
53-
String ns = Context.NOTIFICATION_SERVICE;
54-
NotificationManager nm =
55-
(NotificationManager) ctx.getSystemService(ns);
56-
long when = System.currentTimeMillis();
57-
Notification notification =
58-
new Notification(icon, name, when);
5953
Intent intent = new Intent(Intent.ACTION_DEFAULT);
60-
//intent.setData(Uri.parse("http://www.google.com"));
6154
PendingIntent pi = PendingIntent.getActivity(ctx, 0, intent, 0);
62-
notification.setLatestEventInfo(ctx, "AnySoftKeyboard", name, pi);
63-
nm.notify(1, notification);
55+
56+
NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
57+
58+
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
59+
builder.setSmallIcon(icon);
60+
builder.setContentTitle("AnySoftKeyboard");
61+
builder.setContentText(name);
62+
builder.setContentIntent(pi);
63+
64+
nm.notify(1, builder.build());
6465
}
6566

6667
private void cancelNotification(Context ctx, Intent i) {

api/src/main/java/com/anysoftkeyboard/api/LayoutChangedBroadcastReceiver.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.content.BroadcastReceiver;
88
import android.content.Context;
99
import android.content.Intent;
10+
import android.support.v4.app.NotificationCompat;
1011

1112

1213
/**
@@ -33,30 +34,31 @@ public final void onReceive(Context ctx, Intent intent) {
3334
String pack = intent.getExtras().getString(NOTIFY_LAYOUT_SWITCH_CURRENT_LAYOUT_PACKAGE);
3435
if (!currentPackage.equals(pack)) {
3536
String ns = Context.NOTIFICATION_SERVICE;
36-
NotificationManager nm =
37-
(NotificationManager) ctx.getSystemService(ns);
37+
NotificationManager nm = (NotificationManager) ctx.getSystemService(ns);
3838
nm.cancel(1);
3939
return;
4040
}
4141

4242
int icon = intent.getExtras().getInt(NOTIFY_LAYOUT_SWITCH_CURRENT_LAYOUT_RESID);
4343
String name = intent.getExtras().getString(NOTIFY_LAYOUT_SWITCH_CURRENT_LAYOUT_NAME);
44+
String title = intent.getExtras().getString(NOTIFY_LAYOUT_SWITCH_NOTIFICATION_TITLE);
4445
int flags = intent.getExtras().getInt(NOTIFY_LAYOUT_SWITCH_NOTIFICATION_FLAGS);
4546

4647
//prepare notification
48+
Intent i = new Intent(ctx, InfoActivity.class);
49+
PendingIntent pi = PendingIntent.getActivity(ctx, 0, i, 0);
50+
4751
String ns = Context.NOTIFICATION_SERVICE;
48-
NotificationManager nm =
49-
(NotificationManager) ctx.getSystemService(ns);
50-
long when = System.currentTimeMillis();
51-
Notification notification =
52-
new Notification(icon, name, when);
53-
notification.defaults = 0;
52+
NotificationManager nm = (NotificationManager) ctx.getSystemService(ns);
53+
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
54+
builder.setSmallIcon(icon);
55+
builder.setContentTitle(title);
56+
builder.setContentText(name);
57+
builder.setDefaults(0);
58+
builder.setContentIntent(pi);
59+
Notification notification = builder.build();
5460
notification.flags = flags;
5561

56-
57-
Intent i = new Intent(ctx, InfoActivity.class);
58-
PendingIntent pi = PendingIntent.getActivity(ctx, 0, i, 0);
59-
notification.setLatestEventInfo(ctx, intent.getExtras().getString(NOTIFY_LAYOUT_SWITCH_NOTIFICATION_TITLE), name, pi);
6062
nm.notify(1, notification);
6163
}
6264

0 commit comments

Comments
 (0)