forked from jens/Automation
permission for play sound
This commit is contained in:
parent
9a6083247f
commit
23502f52bb
@ -3,6 +3,7 @@ package com.jens.automation2;
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@ -21,6 +22,8 @@ import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.jens.automation2.receivers.NotificationListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -683,17 +686,14 @@ public class ActivityPermissions extends Activity
|
||||
case Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE:
|
||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.notification))
|
||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||
|
||||
break;
|
||||
case permissionNameGoogleActivityDetection:
|
||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.activityDetection))
|
||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||
|
||||
break;
|
||||
case Manifest.permission.ACTIVITY_RECOGNITION:
|
||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.activityDetection))
|
||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||
|
||||
break;
|
||||
case Manifest.permission.ACCESS_COARSE_LOCATION:
|
||||
// usingElements.add(getResources().getString(R.string.android_permission_ACCESS_COARSE_LOCATION));
|
||||
@ -1168,10 +1168,6 @@ public class ActivityPermissions extends Activity
|
||||
private void setHaveAllPermissions()
|
||||
{
|
||||
setResult(RESULT_OK);
|
||||
// All permissions have been granted.
|
||||
NotificationManager mNotificationManager = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.cancel(notificationIdPermissions);
|
||||
ActivityMainScreen.updateMainScreen();
|
||||
|
||||
try
|
||||
{
|
||||
@ -1182,6 +1178,14 @@ public class ActivityPermissions extends Activity
|
||||
// Activity may not have been loaded, yet.
|
||||
}
|
||||
|
||||
// All permissions have been granted.
|
||||
NotificationManager mNotificationManager = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.cancel(notificationIdPermissions);
|
||||
if(AutomationService.getInstance() != null)
|
||||
AutomationService.getInstance().cancelNotification();
|
||||
|
||||
ActivityMainScreen.updateMainScreen();
|
||||
|
||||
this.finish();
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.jens.automation2.Trigger.Trigger_Enum;
|
||||
import com.jens.automation2.location.LocationProvider;
|
||||
@ -407,6 +408,14 @@ public class AutomationService extends Service implements OnInitListener
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelNotification()
|
||||
{
|
||||
// stopForeground(false);
|
||||
NotificationManagerCompat.from(AutomationService.this).cancelAll();
|
||||
// NotificationManagerCompat.from(AutomationService.this).cancel(ActivityPermissions.notificationIdPermissions);
|
||||
// NotificationManagerCompat.from(AutomationService.this).cancel(AutomationService.notificationIdRestrictions);
|
||||
}
|
||||
|
||||
protected void checkForMissingBackgroundLocationPermission()
|
||||
{
|
||||
if(Miscellaneous.googleToBlameForLocation(true))
|
||||
@ -421,23 +430,6 @@ public class AutomationService extends Service implements OnInitListener
|
||||
else
|
||||
Miscellaneous.createDismissableNotification(getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi);
|
||||
}
|
||||
|
||||
/*
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||
{
|
||||
if (BuildConfig.FLAVOR.equalsIgnoreCase("googlePlayFlavor"))
|
||||
{
|
||||
if (Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest))
|
||||
{
|
||||
Intent intent = new Intent(AutomationService.this, ActivityMainTabLayout.class);
|
||||
PendingIntent pi = PendingIntent.getActivity(AutomationService.this, 0, intent, 0);
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1)
|
||||
Miscellaneous.createDismissableNotificationWithDelay(2200, getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi);
|
||||
else
|
||||
Miscellaneous.createDismissableNotification(getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public static void startAutomationService(Context context, boolean startAtBoot)
|
||||
|
@ -911,6 +911,7 @@ public class Miscellaneous extends Service
|
||||
dismissableNotificationBuilder.setContentText(textToDisplay);
|
||||
dismissableNotificationBuilder.setContentIntent(pendingIntent);
|
||||
dismissableNotificationBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(textToDisplay));
|
||||
dismissableNotificationBuilder.setAutoCancel(true);
|
||||
|
||||
Notification dismissableNotification = dismissableNotificationBuilder.build();
|
||||
|
||||
@ -1012,6 +1013,7 @@ public class Miscellaneous extends Service
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
builder.setCategory(Notification.CATEGORY_SERVICE);
|
||||
|
||||
builder.setAutoCancel(true);
|
||||
builder.setWhen(System.currentTimeMillis());
|
||||
builder.setContentIntent(myPendingIntent);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user