Commit 53fe0a5e authored by Sebastián Katzer's avatar Sebastián Katzer
Browse files

Release v0.8rc

parent 7f6c1ce0
Loading
Loading
Loading
Loading
+103 −53
Changes for plugin.xml: 103 added lines, 53 removed lines.
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
        xmlns:android="http://schemas.android.com/apk/res/android"
        id="de.appplant.cordova.plugin.local-notification"
        version="0.8.0dev">
        version="0.8.0rc">

    <name>LocalNotification</name>

@@ -14,12 +14,16 @@

    <author>Sebastián Katzer</author>

    <!-- cordova -->
    <engines>
        <engine name="cordova" version=">=3.0.0" />
    </engines>

    <dependency id="org.apache.cordova.device" url="https://github.com/apache/cordova-plugin-device" />
    <dependency
        id="org.apache.cordova.device"
        url="https://github.com/apache/cordova-plugin-device" />

    <!-- js -->
    <js-module src="www/local-notification.js" name="LocalNotification">
        <clobbers target="cordova.plugins.notification.local" />
        <clobbers target="plugin.notification.local" />
@@ -34,15 +38,15 @@
            </feature>
        </config-file>

        <header-file src="src/ios/AppDelegate+APPLocalNotification.h" />
        <source-file src="src/ios/AppDelegate+APPLocalNotification.m" />

        <header-file src="src/ios/APPLocalNotification.h" />
        <source-file src="src/ios/APPLocalNotification.m" />

        <header-file src="src/ios/APPLocalNotificationOptions.h" />
        <source-file src="src/ios/APPLocalNotificationOptions.m" />

        <header-file src="src/ios/AppDelegate+APPLocalNotification.h" />
        <source-file src="src/ios/AppDelegate+APPLocalNotification.m" />

        <header-file src="src/ios/UIApplication+APPLocalNotification.h" />
        <source-file src="src/ios/UIApplication+APPLocalNotification.m" />

@@ -59,38 +63,39 @@
        </config-file>

        <config-file target="AndroidManifest.xml" parent="/manifest/application">
            <!--
             * The alarm receiver is triggered when a scheduled alarm is fired. This class
             * reads the information in the intent and displays this information in the
             * Android notification bar. The notification uses the default notification
             * sound and it vibrates the phone.
            -->
            <receiver android:name="de.appplant.cordova.plugin.localnotification.Receiver" android:exported="false" />

			<!--
             * The delete intent receiver is triggered when the user clears a notification
			 * manually. It unpersists the cleared notification from the shared preferences.
            -->
            <receiver android:name="de.appplant.cordova.plugin.localnotification.DeleteIntentReceiver" android:exported="false"/>

            <!--
             * This class is triggered upon reboot of the device. It needs to re-register
             * the alarms with the AlarmManager since these alarms are lost in case of
             * reboot.
             -->
            <receiver android:name="de.appplant.cordova.plugin.localnotification.Restore" >

            <receiver
                android:name="de.appplant.cordova.plugin.localnotification.TriggerReceiver"
                android:exported="false" />

            <receiver
                android:name="de.appplant.cordova.plugin.localnotification.ClearReceiver"
                android:exported="false" />

            <activity
                android:name="de.appplant.cordova.plugin.localnotification.ClickActivity"
                android:launchMode="singleInstance"
                android:theme="@android:style/Theme.NoDisplay" />

            <receiver
                android:name="de.appplant.cordova.plugin.notification.TriggerReceiver"
                android:exported="false" />

            <receiver
                android:name="de.appplant.cordova.plugin.notification.ClearReceiver"
                android:exported="false" />

            <receiver android:name="de.appplant.cordova.plugin.localnotification.RestoreReceiver" >
                <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED" />
                </intent-filter>
            </receiver>

            <activity
                android:name="de.appplant.cordova.plugin.notification.ClickActivity"
                android:launchMode="singleInstance"
                android:theme="@android:style/Theme.NoDisplay" />

            <!--
             * 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" android:launchMode="singleInstance" android:theme="@android:style/Theme.NoDisplay" />
        </config-file>

        <config-file target="AndroidManifest.xml" parent="/manifest">
@@ -99,29 +104,74 @@

        <lib-file src="libs/android/android-support-v4.jar" />

        <source-file src="src/android/LocalNotification.java" 		target-dir="src/de/appplant/cordova/plugin/localnotification" />
        <source-file src="src/android/Receiver.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" />
		<source-file src="src/android/DeleteIntentReceiver.java"  	target-dir="src/de/appplant/cordova/plugin/localnotification" />

		<source-file src="src/android/notification/Options.java"           	target-dir="src/de/appplant/cordova/plugin/notification" />
		<source-file src="src/android/notification/Asset.java"           	target-dir="src/de/appplant/cordova/plugin/notification" />
		<source-file src="src/android/notification/Manager.java"           	target-dir="src/de/appplant/cordova/plugin/notification" />
		<source-file src="src/android/notification/NotificationBuilder.java" target-dir="src/de/appplant/cordova/plugin/notification" />
		<source-file src="src/android/notification/NotificationWrapper.java" target-dir="src/de/appplant/cordova/plugin/notification" />
    </platform>
        <source-file
            src="src/android/LocalNotification.java"
            target-dir="src/de/appplant/cordova/plugin/localnotification" />

    <!-- wp8 -->
<!--     <platform name="wp8">
        <config-file target="config.xml" parent="/*">
            <feature name="LocalNotification">
                <param name="wp-package" value="LocalNotification"/>
            </feature>
        </config-file>
        <source-file
            src="src/android/TriggerReceiver.java"
            target-dir="src/de/appplant/cordova/plugin/localnotification" />

        <source-file src="src/wp8/LocalNotification.cs" />
        <source-file src="src/wp8/Options.cs" />
    </platform> -->
        <source-file
            src="src/android/ClickActivity.java"
            target-dir="src/de/appplant/cordova/plugin/localnotification" />

        <source-file
            src="src/android/ClearReceiver.java"
            target-dir="src/de/appplant/cordova/plugin/localnotification" />

        <source-file
            src="src/android/RestoreReceiver.java"
            target-dir="src/de/appplant/cordova/plugin/localnotification" />

        <source-file
            src="src/android/notification/AbstractClearReceiver.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

        <source-file
            src="src/android/notification/AbstractClickActivity.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

        <source-file
            src="src/android/notification/AbstractRestoreReceiver.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

        <source-file
            src="src/android/notification/AbstractTriggerReceiver.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

        <source-file
            src="src/android/notification/AssetUtil.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

        <source-file
            src="src/android/notification/Builder.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

        <source-file
            src="src/android/notification/ClearReceiver.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

        <source-file
            src="src/android/notification/ClickActivity.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

        <source-file
            src="src/android/notification/Manager.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

        <source-file
            src="src/android/notification/Notification.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

        <source-file
            src="src/android/notification/Options.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

        <source-file
            src="src/android/notification/TriggerReceiver.java"
            target-dir="src/de/appplant/cordova/plugin/notification" />

    </platform>

</plugin>
+48 −0
Changes for src/android/ClearReceiver.java: 48 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
 *
 * @APPPLANT_LICENSE_HEADER_START@
 *
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apache License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. Please obtain a copy of the License at
 * http://opensource.org/licenses/Apache-2.0/ and read it before using this
 * file.
 *
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 *
 * @APPPLANT_LICENSE_HEADER_END@
 */

package de.appplant.cordova.plugin.localnotification;

import de.appplant.cordova.plugin.notification.Notification;


/**
 * The clear intent receiver is triggered when the user clears a
 * notification manually. It un-persists the cleared notification from the
 * shared preferences.
 */
public class ClearReceiver extends de.appplant.cordova.plugin.notification.ClearReceiver {

    /**
     * Called when a local notification was cleared from outside of the app.
     *
     * @param notification
     *      Wrapper around the local notification
     */
    @Override
    public void onClear (Notification notification) {
        super.onClear(notification);
        LocalNotification.fireEvent("clear", notification);
    }

}
+66 −0
Changes for src/android/ClickActivity.java: 66 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
 *
 * @APPPLANT_LICENSE_HEADER_START@
 *
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apache License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. Please obtain a copy of the License at
 * http://opensource.org/licenses/Apache-2.0/ and read it before using this
 * file.
 *
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 *
 * @APPPLANT_LICENSE_HEADER_END@
 */

package de.appplant.cordova.plugin.localnotification;

import de.appplant.cordova.plugin.notification.*;
import de.appplant.cordova.plugin.notification.TriggerReceiver;

/**
 * The receiver activity is triggered when a notification is clicked by a user.
 * The activity calls the background callback and brings the launch intent
 * up to foreground.
 */
public class ClickActivity extends de.appplant.cordova.plugin.notification.ClickActivity {

    /**
     * Called when local notification was clicked by the user.
     *
     * @param notification
     *      Wrapper around the local notification
     */
    @Override
    public void onClick(Notification notification) {
        LocalNotification.fireEvent("click", notification);

        if (!notification.isRepeating()) {
            LocalNotification.fireEvent("cancel", notification);
        }

        super.onClick(notification);
    }

    /**
     * Build notification specified by options.
     *
     * @param builder
     *      Notification builder
     */
    @Override
    public Notification buildNotification (Builder builder) {
        return builder
                .setTriggerReceiver(TriggerReceiver.class)
                .build();
    }

}
+0 −80
Changes for src/android/DeleteIntentReceiver.java: 0 added lines, 80 removed lines.
Original line number Diff line number Diff line
/*
    Copyright 2013-2014 appPlant UG

    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
*/

package de.appplant.cordova.plugin.localnotification;

import java.util.Date;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import de.appplant.cordova.plugin.notification.Options;

public class DeleteIntentReceiver extends BroadcastReceiver {

    public static final String OPTIONS = "LOCAL_NOTIFICATION_OPTIONS";
	
    /**
     * Is called when a Notification is cleared manualy by the User
     */
	@Override
	public void onReceive(Context context, Intent intent) {
        Options options = null;
        Bundle bundle   = intent.getExtras();
        JSONObject args;

        try {
            args    = new JSONObject(bundle.getString(OPTIONS));
            options = new Options(context).parse(args);
        } catch (JSONException e) {
            return;
        }

        // The context may got lost if the app was not running before
        LocalNotification.setContext(context);
        
        Date now = new Date();
		if ((options.getInterval()!=0)){
			options.setInitDate();
			LocalNotification.persist(options.getId(), options.getJSONObject());
		}
		else if((new Date(options.getDate()).before(now))){
			LocalNotification.unpersist(options.getId());
		}
		
		fireClearEvent(options);
	}
	
    /**
     * Fires onclear event.
     */
    private void fireClearEvent (Options options) {
    	JSONArray data = new JSONArray().put(options.getJSONObject());
        LocalNotification.fireEvent("clear", options.getId(), options.getJSON(),data);
    }

}
+330 −324

File changed.

Preview size limit exceeded, changes collapsed.

Loading