Notification channels
This commit is contained in:
parent
ec61a3ffa5
commit
59c7a2d313
@ -3,7 +3,6 @@ package com.jens.automation2;
|
|||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -11,7 +10,6 @@ import android.net.Uri;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Xml;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@ -29,11 +27,8 @@ import androidx.core.text.HtmlCompat;
|
|||||||
|
|
||||||
import com.jens.automation2.AutomationService.serviceCommands;
|
import com.jens.automation2.AutomationService.serviceCommands;
|
||||||
import com.jens.automation2.Trigger.Trigger_Enum;
|
import com.jens.automation2.Trigger.Trigger_Enum;
|
||||||
import com.jens.automation2.location.CellLocationChangedReceiver;
|
|
||||||
import com.jens.automation2.location.LocationProvider;
|
import com.jens.automation2.location.LocationProvider;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
@ -41,8 +41,6 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
protected final static int notificationIdRestrictions = 1005;
|
protected final static int notificationIdRestrictions = 1005;
|
||||||
protected final static int notificationIdLocationRestriction = 1006;
|
protected final static int notificationIdLocationRestriction = 1006;
|
||||||
|
|
||||||
// final static String NOTIFICATION_CHANNEL_ID = "com.jens.automation2";
|
|
||||||
|
|
||||||
final static String NOTIFICATION_CHANNEL_ID_SERVICE = "com.jens.automation2_service";
|
final static String NOTIFICATION_CHANNEL_ID_SERVICE = "com.jens.automation2_service";
|
||||||
final static String NOTIFICATION_CHANNEL_NAME_SERVICE = "Service notification";
|
final static String NOTIFICATION_CHANNEL_NAME_SERVICE = "Service notification";
|
||||||
|
|
||||||
@ -73,7 +71,6 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
lockSoundChangesEnd = Calendar.getInstance();
|
lockSoundChangesEnd = Calendar.getInstance();
|
||||||
|
|
||||||
lockSoundChangesEnd.add(Calendar.MINUTE, Settings.lockSoundChangesInterval);
|
lockSoundChangesEnd.add(Calendar.MINUTE, Settings.lockSoundChangesInterval);
|
||||||
// ActivityMainScreen.getActivityMainScreenInstance().updateMainScreen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkLockSoundChangesTimeElapsed()
|
public void checkLockSoundChangesTimeElapsed()
|
||||||
@ -117,18 +114,6 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
|
|
||||||
public boolean checkStartupRequirements(Context context, boolean startAtBoot)
|
public boolean checkStartupRequirements(Context context, boolean startAtBoot)
|
||||||
{
|
{
|
||||||
// if (!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, AutomationService.this))
|
|
||||||
// {
|
|
||||||
// /*
|
|
||||||
// Don't have permission to access external storage. This is a show stopper as
|
|
||||||
// the configuration file is stored on external storage.
|
|
||||||
// */
|
|
||||||
// Miscellaneous.logEvent("e", "Permission", "Don't have permission to access external storage. Will request it now.", 4);
|
|
||||||
//// Toast.makeText(AutomationService.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
|
||||||
// ActivityPermissions.requestSpecificPermission(ActivityPermissions.writeExternalStoragePermissionName);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT >= 28)
|
if(Build.VERSION.SDK_INT >= 28)
|
||||||
{
|
{
|
||||||
if (!ActivityPermissions.havePermission(Manifest.permission.FOREGROUND_SERVICE, AutomationService.this))
|
if (!ActivityPermissions.havePermission(Manifest.permission.FOREGROUND_SERVICE, AutomationService.this))
|
||||||
@ -143,9 +128,14 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PointOfInterest.getPointOfInterestCollection() == null | PointOfInterest.getPointOfInterestCollection().size() == 0
|
if (
|
||||||
|
|
PointOfInterest.getPointOfInterestCollection() == null
|
||||||
Rule.getRuleCollection() == null | Rule.getRuleCollection().size() == 0
|
||
|
||||||
|
PointOfInterest.getPointOfInterestCollection().size() == 0
|
||||||
|
||
|
||||||
|
Rule.getRuleCollection() == null
|
||||||
|
||
|
||||||
|
Rule.getRuleCollection().size() == 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (startAtBoot)
|
if (startAtBoot)
|
||||||
@ -181,7 +171,7 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
//if still no POIs...
|
//if still no POIs...
|
||||||
if (Rule.getRuleCollection() == null | Rule.getRuleCollection().size() == 0)
|
if (Rule.getRuleCollection() == null || Rule.getRuleCollection().size() == 0)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("w", "AutomationService", context.getResources().getString(R.string.serviceWontStart), 1);
|
Miscellaneous.logEvent("w", "AutomationService", context.getResources().getString(R.string.serviceWontStart), 1);
|
||||||
Toast.makeText(context, context.getResources().getString(R.string.serviceWontStart), Toast.LENGTH_LONG).show();
|
Toast.makeText(context, context.getResources().getString(R.string.serviceWontStart), Toast.LENGTH_LONG).show();
|
||||||
|
@ -85,6 +85,7 @@ import java.util.Calendar;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
@ -984,10 +985,16 @@ public class Miscellaneous extends Service
|
|||||||
{
|
{
|
||||||
NotificationManager nm = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager nm = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
List<NotificationChannel> channels = nm.getNotificationChannels();
|
List<NotificationChannel> channels = nm.getNotificationChannels();
|
||||||
if(channels.size() > 3)
|
|
||||||
|
if(!Settings.hasBeenDone(Settings.constNotificationChannelCleanupApk118) && BuildConfig.VERSION_CODE < 120)
|
||||||
{
|
{
|
||||||
|
// Perform a one-time cleanup of notification channels as they have been redesigned.
|
||||||
|
|
||||||
for(NotificationChannel c : channels)
|
for(NotificationChannel c : channels)
|
||||||
nm.deleteNotificationChannel(c.getId());
|
nm.deleteNotificationChannel(c.getId());
|
||||||
|
|
||||||
|
Settings.considerDone(Settings.constNotificationChannelCleanupApk118);
|
||||||
|
Settings.writeSettings(Miscellaneous.getAnyContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationChannel channel = findExistingChannel(channels, channelId);
|
NotificationChannel channel = findExistingChannel(channels, channelId);
|
||||||
|
@ -20,6 +20,7 @@ public class Settings implements SharedPreferences
|
|||||||
public static final String zipFileName = "automation.zip";
|
public static final String zipFileName = "automation.zip";
|
||||||
|
|
||||||
public static final String constNewsOptInDone ="newsOptInDone";
|
public static final String constNewsOptInDone ="newsOptInDone";
|
||||||
|
public static final String constNotificationChannelCleanupApk118 ="notificationChannelCleanupApk118";
|
||||||
|
|
||||||
public static long minimumDistanceChangeForGpsUpdate;
|
public static long minimumDistanceChangeForGpsUpdate;
|
||||||
public static long minimumDistanceChangeForNetworkUpdate;
|
public static long minimumDistanceChangeForNetworkUpdate;
|
||||||
|
Loading…
Reference in New Issue
Block a user