// Path: SWADroid/src/main/java/es/ugr/swad/swadroid/utils/NotificationUtils.java
// @TargetApi(Build.VERSION_CODES.O)
// public class NotificationUtils extends ContextWrapper {
// 
//     private NotificationManager mManager;
//     public static final String SWADROID_CHANNEL_ID = "es.ugr.swad.swadroid.SWADROID";
//     public static final String SWADROID_CHANNEL_NAME = "SWADROID CHANNEL";
// 
//     public NotificationUtils(Context base) {
//         super(base);
//         createChannels();
//     }
// 
//     public void createChannels() {
// 
//         // create SWADroid channel
//         NotificationChannel androidChannel = new NotificationChannel(SWADROID_CHANNEL_ID,
//                 SWADROID_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
//         // Sets whether notifications posted to this channel should display notification lights
//         androidChannel.enableLights(true);
//         // Sets whether notification posted to this channel should vibrate.
//         androidChannel.enableVibration(true);
//         // Sets the notification light color for notifications posted to this channel
//         androidChannel.setLightColor(Color.GREEN);
//         // Sets whether notifications posted to this channel appear on the lockscreen or not
//         androidChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
// 
//         getManager().createNotificationChannel(androidChannel);
//     }
// 
//     public NotificationManager getManager() {
//         if (mManager == null) {
//             mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//         }
//         return mManager;
//     }
// }
// 
// Path: SWADroid/src/main/java/es/ugr/swad/swadroid/utils/NotificationUtils.java
// public static final String SWADROID_CHANNEL_ID = "es.ugr.swad.swadroid.SWADROID";


import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.BitmapFactory;
import androidx.core.app.NotificationCompat;
import es.ugr.swad.swadroid.utils.NotificationUtils;
import static es.ugr.swad.swadroid.utils.NotificationUtils.SWADROID_CHANNEL_ID;
/*
 *  This file is part of SWADroid.
 *
 *  Copyright (C) 2010 Juan Miguel Boyero Corral <juanmi1982@gmail.com>
 *
 *  SWADroid is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  SWADroid is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with SWADroid.  If not, see <http://www.gnu.org/licenses/>.
 */

package es.ugr.swad.swadroid.gui;




/**
 * Class for create notification alerts.
 *
 * @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
 */
public class AlertNotificationFactory {
	public static NotificationCompat.Builder createAlertNotificationBuilder(Context context, String contentTitle, String contentText,
			String ticker, PendingIntent pendingIntent, int smallIcon, int largeIcon,
			boolean autocancel, boolean ongoing, boolean onlyAlertOnce) {
		
		int flags = 0;

    	NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context, SWADROID_CHANNEL_ID)
            .setAutoCancel(autocancel)
            .setSmallIcon(smallIcon)
            .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), largeIcon))
            .setContentTitle(contentTitle)
            .setContentText(contentText)
            .setTicker(ticker)
            .setOngoing(ongoing)
            .setOnlyAlertOnce(onlyAlertOnce)
        	.setWhen(System.currentTimeMillis());
            //.setLights(Color.GREEN, 500, 500);

        //Launch activity on alert click
    	if(pendingIntent != null) {
            notifBuilder.setContentIntent(pendingIntent);
    	}
        
        //Add sound, vibration and lights
        flags |= Notification.DEFAULT_SOUND;
        flags |= Notification.DEFAULT_VIBRATE;
// Path: SWADroid/src/main/java/es/ugr/swad/swadroid/utils/NotificationUtils.java
// @TargetApi(Build.VERSION_CODES.O)
// public class NotificationUtils extends ContextWrapper {
// 
//     private NotificationManager mManager;
//     public static final String SWADROID_CHANNEL_ID = "es.ugr.swad.swadroid.SWADROID";
//     public static final String SWADROID_CHANNEL_NAME = "SWADROID CHANNEL";
// 
//     public NotificationUtils(Context base) {
//         super(base);
//         createChannels();
//     }
// 
//     public void createChannels() {
// 
//         // create SWADroid channel
//         NotificationChannel androidChannel = new NotificationChannel(SWADROID_CHANNEL_ID,
//                 SWADROID_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
//         // Sets whether notifications posted to this channel should display notification lights
//         androidChannel.enableLights(true);
//         // Sets whether notification posted to this channel should vibrate.
//         androidChannel.enableVibration(true);
//         // Sets the notification light color for notifications posted to this channel
//         androidChannel.setLightColor(Color.GREEN);
//         // Sets whether notifications posted to this channel appear on the lockscreen or not
//         androidChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
// 
//         getManager().createNotificationChannel(androidChannel);
//     }
// 
//     public NotificationManager getManager() {
//         if (mManager == null) {
//             mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//         }
//         return mManager;
//     }
// }
// 
// Path: SWADroid/src/main/java/es/ugr/swad/swadroid/utils/NotificationUtils.java
// public static final String SWADROID_CHANNEL_ID = "es.ugr.swad.swadroid.SWADROID";


// Path: SWADroid/src/main/java/es/ugr/swad/swadroid/gui/AlertNotificationFactory.java
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.BitmapFactory;
import androidx.core.app.NotificationCompat;
import es.ugr.swad.swadroid.utils.NotificationUtils;
import static es.ugr.swad.swadroid.utils.NotificationUtils.SWADROID_CHANNEL_ID;

/*
 *  This file is part of SWADroid.
 *
 *  Copyright (C) 2010 Juan Miguel Boyero Corral <juanmi1982@gmail.com>
 *
 *  SWADroid is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  SWADroid is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with SWADroid.  If not, see <http://www.gnu.org/licenses/>.
 */

package es.ugr.swad.swadroid.gui;




/**
 * Class for create notification alerts.
 *
 * @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
 */
public class AlertNotificationFactory {
	public static NotificationCompat.Builder createAlertNotificationBuilder(Context context, String contentTitle, String contentText,
			String ticker, PendingIntent pendingIntent, int smallIcon, int largeIcon,
			boolean autocancel, boolean ongoing, boolean onlyAlertOnce) {
		
		int flags = 0;

    	NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context, SWADROID_CHANNEL_ID)
            .setAutoCancel(autocancel)
            .setSmallIcon(smallIcon)
            .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), largeIcon))
            .setContentTitle(contentTitle)
            .setContentText(contentText)
            .setTicker(ticker)
            .setOngoing(ongoing)
            .setOnlyAlertOnce(onlyAlertOnce)
        	.setWhen(System.currentTimeMillis());
            //.setLights(Color.GREEN, 500, 500);

        //Launch activity on alert click
    	if(pendingIntent != null) {
            notifBuilder.setContentIntent(pendingIntent);
    	}
        
        //Add sound, vibration and lights
        flags |= Notification.DEFAULT_SOUND;
        flags |= Notification.DEFAULT_VIBRATE;
        flags |= Notification.DEFAULT_LIGHTS;