2016-07-18 06:14:17 +02:00
|
|
|
package util;
|
|
|
|
|
|
2016-08-24 11:31:13 +02:00
|
|
|
import android.app.Notification;
|
|
|
|
|
import android.app.NotificationManager;
|
|
|
|
|
import android.app.PendingIntent;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.support.v4.app.NotificationCompat;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
|
|
import beyondsoft.bewomitarbeiterapp.ChatActivity;
|
|
|
|
|
import beyondsoft.bewomitarbeiterapp.R;
|
|
|
|
|
|
2016-07-18 06:14:17 +02:00
|
|
|
/**
|
|
|
|
|
* Created by JettenM on 05.07.2016.
|
|
|
|
|
*/
|
|
|
|
|
public class Util {
|
|
|
|
|
public static final String PREFS_NAME = "BeWoMitarbeiterPrefsFile";
|
|
|
|
|
|
|
|
|
|
public static final String PREFS_SERVERADDRESS_KEY = "serverAddress";
|
|
|
|
|
|
2016-08-03 11:50:16 +02:00
|
|
|
public static final String PREFS_TOKEN_KEY = "serverAddress";
|
|
|
|
|
public static final String PREFS_TENANT_KEY = "tenant";
|
2016-07-18 06:14:17 +02:00
|
|
|
public static final String PREFS_USERNAME_KEY = "username";
|
2016-08-03 11:50:16 +02:00
|
|
|
public static final String PREFS_PASSWORD = "password";
|
|
|
|
|
|
2016-08-24 11:31:13 +02:00
|
|
|
|
|
|
|
|
public static void SetNotify(String username, String message, int recipientOid, boolean isTeam, String teamMemberOids, String teamMemberNames, Context packageContext){
|
|
|
|
|
NotificationCompat.Builder mBuilder =
|
|
|
|
|
new NotificationCompat.Builder(packageContext)
|
|
|
|
|
.setSmallIcon(R.drawable.ic_stat_name)
|
|
|
|
|
.setContentTitle(username)
|
|
|
|
|
.setContentText(message)
|
|
|
|
|
.setAutoCancel(true)
|
|
|
|
|
.setDefaults(Notification.DEFAULT_SOUND)
|
|
|
|
|
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }) //Notification.Default_Vibrate
|
|
|
|
|
.setLights(Color.YELLOW, 3000, 3000) //Notification.Default_Lights
|
|
|
|
|
.setOngoing(true);
|
|
|
|
|
|
|
|
|
|
Log.i("CHAT_SET_NOTIFY", username + "; " + recipientOid + "; " + isTeam + "; " + teamMemberOids + "; " + teamMemberNames);
|
|
|
|
|
|
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
|
bundle.putString("Name", username);
|
|
|
|
|
bundle.putInt("RecipientOid", recipientOid);
|
|
|
|
|
bundle.putBoolean("IsTeam", isTeam);
|
|
|
|
|
bundle.putString("TeamMemberOids", teamMemberOids);
|
|
|
|
|
bundle.putString("TeamMemberNames", teamMemberNames);
|
|
|
|
|
|
|
|
|
|
Intent resultIntent = new Intent(packageContext, ChatActivity.class);
|
|
|
|
|
resultIntent.putExtras(bundle);
|
|
|
|
|
|
|
|
|
|
resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
|
|
|
|
|
|
|
|
PendingIntent resultPendingIntent = PendingIntent.getActivity(packageContext.getApplicationContext(), (int) (Math.random() * 100), resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
|
|
NotificationManager mNotifyMgr = (NotificationManager) packageContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
|
|
|
|
|
|
|
mBuilder.setContentIntent(resultPendingIntent);
|
|
|
|
|
|
|
|
|
|
mNotifyMgr.notify((new Random()).nextInt(9999 - 1000) + 1000, mBuilder.build());
|
|
|
|
|
}
|
2016-07-18 06:14:17 +02:00
|
|
|
}
|