Loading plugin.xml +8 −0 Changes for plugin.xml: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -63,6 +63,13 @@ <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <!-- * The receiver activity is triggered when a notification is clicked by a user. * The activity calls the background callback and brings the launch inten * up to foreground. --> <activity android:name="de.appplant.cordova.plugin.localnotification.ReceiverActivity"></activity> </config-file> <config-file target="AndroidManifest.xml" parent="/manifest"> Loading @@ -74,6 +81,7 @@ <source-file src="src/android/Receiver.java" target-dir="src/de/appplant/cordova/plugin/localnotification" /> <source-file src="src/android/Options.java" target-dir="src/de/appplant/cordova/plugin/localnotification" /> <source-file src="src/android/Restore.java" target-dir="src/de/appplant/cordova/plugin/localnotification" /> <source-file src="src/android/ReceiverActivity.java" target-dir="src/de/appplant/cordova/plugin/localnotification" /> </platform> <!-- wp8 --> Loading src/android/Receiver.java +4 −16 Changes for src/android/Receiver.java: 4 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -115,9 +115,10 @@ public class Receiver extends BroadcastReceiver { * Fügt der Notification einen onclick Handler hinzu. */ private Builder setClickEvent (Builder notification) { String packageName = context.getPackageName(); Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent intent = new Intent(context, ReceiverActivity.class) .putExtra(OPTIONS, options.getJSONObject().toString()); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); return notification.setContentIntent(contentIntent); } Loading Loading @@ -163,17 +164,4 @@ public class Receiver extends BroadcastReceiver { LocalNotification.webView.sendJavascript(function + "(" + options.getId() + ")"); } } /** * Ruft die `background` Callback Funktion auf. */ private void invokeBackgroundCallback () { String function = options.getBackground(); // after reboot, LocalNotification.webView is always null // may be call background callback later if (function != null && LocalNotification.webView != null) { LocalNotification.webView.sendJavascript(function + "(" + options.getId() + ")"); } } } No newline at end of file src/android/ReceiverActivity.java 0 → 100644 +63 −0 Changes for src/android/ReceiverActivity.java: 63 added lines, 0 removed lines. Original line number Diff line number Diff line /** * Cordova LocalNotification Plugin * * Created by Sebastian Katzer (github.com/katzer). * Copyright 2013 Sebastian Katzer. All rights reserved. * LGPL v2.1 licensed */ package de.appplant.cordova.plugin.localnotification; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; public class ReceiverActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = this.getIntent(); Bundle bundle = intent.getExtras(); try { JSONObject args = new JSONObject(bundle.getString(Receiver.OPTIONS)); Options options = new Options(getApplicationContext()).parse(args); invokeBackgroundCallback(options); launchMainIntent(); } catch (JSONException e) {} } /** * Launch main intent for package. */ private void launchMainIntent () { Context context = getApplicationContext(); String packageName = context.getPackageName(); Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName); launchIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); context.startActivity(launchIntent); } /** * Ruft die `background` Callback Funktion auf. */ private void invokeBackgroundCallback (Options options) { String function = options.getBackground(); // after reboot, LocalNotification.webView is always null // may be call background callback later if (function != null && LocalNotification.webView != null) { LocalNotification.webView.sendJavascript(function + "(" + options.getId() + ")"); } } } Loading
plugin.xml +8 −0 Changes for plugin.xml: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -63,6 +63,13 @@ <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <!-- * The receiver activity is triggered when a notification is clicked by a user. * The activity calls the background callback and brings the launch inten * up to foreground. --> <activity android:name="de.appplant.cordova.plugin.localnotification.ReceiverActivity"></activity> </config-file> <config-file target="AndroidManifest.xml" parent="/manifest"> Loading @@ -74,6 +81,7 @@ <source-file src="src/android/Receiver.java" target-dir="src/de/appplant/cordova/plugin/localnotification" /> <source-file src="src/android/Options.java" target-dir="src/de/appplant/cordova/plugin/localnotification" /> <source-file src="src/android/Restore.java" target-dir="src/de/appplant/cordova/plugin/localnotification" /> <source-file src="src/android/ReceiverActivity.java" target-dir="src/de/appplant/cordova/plugin/localnotification" /> </platform> <!-- wp8 --> Loading
src/android/Receiver.java +4 −16 Changes for src/android/Receiver.java: 4 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -115,9 +115,10 @@ public class Receiver extends BroadcastReceiver { * Fügt der Notification einen onclick Handler hinzu. */ private Builder setClickEvent (Builder notification) { String packageName = context.getPackageName(); Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent intent = new Intent(context, ReceiverActivity.class) .putExtra(OPTIONS, options.getJSONObject().toString()); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); return notification.setContentIntent(contentIntent); } Loading Loading @@ -163,17 +164,4 @@ public class Receiver extends BroadcastReceiver { LocalNotification.webView.sendJavascript(function + "(" + options.getId() + ")"); } } /** * Ruft die `background` Callback Funktion auf. */ private void invokeBackgroundCallback () { String function = options.getBackground(); // after reboot, LocalNotification.webView is always null // may be call background callback later if (function != null && LocalNotification.webView != null) { LocalNotification.webView.sendJavascript(function + "(" + options.getId() + ")"); } } } No newline at end of file
src/android/ReceiverActivity.java 0 → 100644 +63 −0 Changes for src/android/ReceiverActivity.java: 63 added lines, 0 removed lines. Original line number Diff line number Diff line /** * Cordova LocalNotification Plugin * * Created by Sebastian Katzer (github.com/katzer). * Copyright 2013 Sebastian Katzer. All rights reserved. * LGPL v2.1 licensed */ package de.appplant.cordova.plugin.localnotification; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; public class ReceiverActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = this.getIntent(); Bundle bundle = intent.getExtras(); try { JSONObject args = new JSONObject(bundle.getString(Receiver.OPTIONS)); Options options = new Options(getApplicationContext()).parse(args); invokeBackgroundCallback(options); launchMainIntent(); } catch (JSONException e) {} } /** * Launch main intent for package. */ private void launchMainIntent () { Context context = getApplicationContext(); String packageName = context.getPackageName(); Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName); launchIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); context.startActivity(launchIntent); } /** * Ruft die `background` Callback Funktion auf. */ private void invokeBackgroundCallback (Options options) { String function = options.getBackground(); // after reboot, LocalNotification.webView is always null // may be call background callback later if (function != null && LocalNotification.webView != null) { LocalNotification.webView.sendJavascript(function + "(" + options.getId() + ")"); } } }