package com.example.patrice.repeat_request_02;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.app.NotificationManager;
import android.support.v4.app.NotificationCompat;
import android.view.View;
import android.content.Context;

//http://www.androidbegin.com/tutorial/android-broadcast-receiver-notification-tutorial/

public class Notification extends BroadcastReceiver
{

    NotificationManager nm;

    @Override
    public void onReceive(Context context, Intent intent)
    {
       /* nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        CharSequence from = "Lokesh";
        CharSequence message = "Notification Test...";
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0,     new Intent(), 0);
        Notification notif = new Notification(R.drawable.ic_replay_30_black_36dp,  "Notification Test...", System.currentTimeMillis());
        notif.setLatestEventInfo(context, from, message, contentIntent);
        nm.notify(1, notif);*/


        NotificationCompat.Builder mBuilder =  new NotificationCompat.Builder(context)
                        .setSmallIcon(R.drawable.ic_replay_30_black_36dp)
                        .setContentTitle("My notification")
                        .setContentText("Hello World!");

        NotificationManager notificationmanager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationmanager.notify(0, mBuilder.build());

    }

    public void Notification(Context context, String message)
    {
        // Set Notification Title
       // String strtitle = context.getString(R.string.notificationtitle);
        // Open NotificationView Class on Notification Click
        //Intent intent = new Intent(context, NotificationView.class);
        // Send data to NotificationView Class
        //intent.putExtra("title", strtitle);
        //intent.putExtra("text", message);
        // Open NotificationView.java Activity
        //PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent,  PendingIntent.FLAG_UPDATE_CURRENT);

        // Create Notification using NotificationCompat.Builder
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context)

                .setSmallIcon(R.drawable.ic_replay_30_black_36dp)
                .setContentTitle("My notification")
                .setContentText("Hello World!");

        /*        // Set Icon
                .setSmallIcon(R.drawable.logosmall)
                // Set Ticker Message
                .setTicker(message)
                // Set Title
                .setContentTitle(context.getString(R.string.notificationtitle))
                // Set Text
                .setContentText(message)
                // Add an Action Button below Notification
                .addAction(R.drawable.ic_launcher, "Action Button", pIntent)
                // Set PendingIntent into Notification
                .setContentIntent(pIntent)
                // Dismiss Notification
                .setAutoCancel(true);
*/
        NotificationManager notificationmanager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationmanager.notify(0, builder.build());

    }

}