mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-28 19:45:50 +01:00
Make all intents explicit
This commit is contained in:
parent
fad092b6f8
commit
05d3cfb01c
@ -62,6 +62,7 @@ public class SleepAlarmWidget extends AppWidgetProvider {
|
||||
|
||||
// Add our own click intent
|
||||
Intent intent = new Intent(context, SleepAlarmWidget.class);
|
||||
intent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
intent.setAction(ACTION_CLICK);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||
PendingIntent clickPI = PendingIntentUtils.getBroadcast(
|
||||
@ -149,6 +150,7 @@ public class SleepAlarmWidget extends AppWidgetProvider {
|
||||
AlarmManager am = (AlarmManager) packageContext.getSystemService(Context.ALARM_SERVICE);
|
||||
// TODO: launch the alarm configuration activity when clicking the alarm in the status bar
|
||||
Intent intent = new Intent(packageContext, ConfigureAlarms.class);
|
||||
intent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
PendingIntent pi = PendingIntentUtils.getBroadcast(packageContext, 0, intent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT, false);
|
||||
am.setAlarmClock(new AlarmManager.AlarmClockInfo(triggerTime, pi), pi);
|
||||
|
@ -90,6 +90,7 @@ public class Widget extends AppWidgetProvider {
|
||||
|
||||
//onclick refresh
|
||||
Intent intent = new Intent(context, Widget.class);
|
||||
intent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
intent.setAction(WIDGET_CLICK);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||
PendingIntent refreshDataIntent = PendingIntentUtils.getBroadcast(
|
||||
@ -98,17 +99,20 @@ public class Widget extends AppWidgetProvider {
|
||||
|
||||
//open GB main window
|
||||
Intent startMainIntent = new Intent(context, ControlCenterv2.class);
|
||||
startMainIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
PendingIntent startMainPIntent = PendingIntentUtils.getActivity(context, 0, startMainIntent, 0, false);
|
||||
views.setOnClickPendingIntent(R.id.todaywidget_header_icon, startMainPIntent);
|
||||
|
||||
//alarms popup menu
|
||||
Intent startAlarmListIntent = new Intent(context, WidgetAlarmsActivity.class);
|
||||
startAlarmListIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
startAlarmListIntent.putExtra(GBDevice.EXTRA_DEVICE, deviceForWidget);
|
||||
PendingIntent startAlarmListPIntent = PendingIntentUtils.getActivity(context, appWidgetId, startAlarmListIntent, PendingIntent.FLAG_UPDATE_CURRENT, false);
|
||||
views.setOnClickPendingIntent(R.id.todaywidget_header_alarm_icon, startAlarmListPIntent);
|
||||
|
||||
//charts
|
||||
Intent startChartsIntent = new Intent(context, ActivityChartsActivity.class);
|
||||
startChartsIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
startChartsIntent.putExtra(GBDevice.EXTRA_DEVICE, deviceForWidget);
|
||||
PendingIntent startChartsPIntent = PendingIntentUtils.getActivity(context, appWidgetId, startChartsIntent, PendingIntent.FLAG_CANCEL_CURRENT, false);
|
||||
views.setOnClickPendingIntent(R.id.todaywidget_bottom_layout, startChartsPIntent);
|
||||
|
@ -976,6 +976,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
|
||||
private void testNotification() {
|
||||
Intent notificationIntent = new Intent(getApplicationContext(), DebugActivity.class);
|
||||
notificationIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
PendingIntent pendingIntent = PendingIntentUtils.getActivity(getApplicationContext(), 0,
|
||||
@ -985,6 +986,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
.build();
|
||||
|
||||
Intent replyIntent = new Intent(ACTION_REPLY);
|
||||
replyIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
|
||||
PendingIntent replyPendingIntent = PendingIntentUtils.getBroadcast(this, 0, replyIntent, 0, true);
|
||||
|
||||
|
@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
@ -59,6 +60,7 @@ public class PeriodicExporter extends BroadcastReceiver {
|
||||
|
||||
public static void scheduleAlarm(Context context, Integer autoExportInterval, boolean autoExportEnabled) {
|
||||
Intent i = new Intent(context, PeriodicExporter.class);
|
||||
i.setPackage(BuildConfig.APPLICATION_ID);
|
||||
PendingIntent pi = PendingIntentUtils.getBroadcast(context, 0, i, 0, false);
|
||||
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
am.cancel(pi);
|
||||
|
@ -34,6 +34,7 @@ import java.time.zone.ZoneRules;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
@ -98,6 +99,7 @@ public class TimeChangeReceiver extends BroadcastReceiver {
|
||||
final ZoneOffsetTransition transition = zoneRules.nextTransition(now);
|
||||
|
||||
final Intent i = new Intent(ACTION_DST_CHANGED_OR_PERIODIC_SYNC);
|
||||
i.setPackage(BuildConfig.APPLICATION_ID);
|
||||
final PendingIntent pi = PendingIntentUtils.getBroadcast(context, 0, i, 0, false);
|
||||
|
||||
final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
|
@ -36,6 +36,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
@ -164,6 +165,7 @@ public class GBLocationService extends BroadcastReceiver {
|
||||
private void updateNotification() {
|
||||
if (!providersByDevice.isEmpty()) {
|
||||
final Intent notificationIntent = new Intent(context, GBLocationService.class);
|
||||
notificationIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
final PendingIntent pendingIntent = PendingIntentUtils.getActivity(context, 0, notificationIntent, 0, false);
|
||||
|
||||
|
@ -56,6 +56,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.CameraActivity;
|
||||
@ -292,6 +293,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
|
||||
private void handleGBDeviceEventFindPhoneStartNotification(final boolean ring) {
|
||||
LOG.info("Got handleGBDeviceEventFindPhoneStartNotification");
|
||||
Intent intent = new Intent(context, FindPhoneActivity.class);
|
||||
intent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
intent.putExtra(FindPhoneActivity.EXTRA_RING, ring);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
|
@ -39,6 +39,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
@ -210,6 +211,7 @@ public class UM25Support extends UM25BaseSupport {
|
||||
// handle change from over threshold to below threshold
|
||||
wasOverNotificationCurrent = false;
|
||||
Intent activityIntent = new Intent(getContext(), DataActivity.class);
|
||||
activityIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
Notification notification = new NotificationCompat.Builder(getContext(), GB.NOTIFICATION_CHANNEL_HIGH_PRIORITY_ID)
|
||||
.setSmallIcon(R.drawable.ic_notification_low_battery)
|
||||
.setContentTitle("USB current")
|
||||
|
@ -54,6 +54,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBEnvironment;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -170,6 +171,7 @@ public class GB {
|
||||
|
||||
private static PendingIntent getContentIntent(Context context) {
|
||||
Intent notificationIntent = new Intent(context, ControlCenterv2.class);
|
||||
notificationIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
PendingIntent pendingIntent = PendingIntentUtils.getActivity(context, 0,
|
||||
@ -211,6 +213,7 @@ public class GB {
|
||||
}
|
||||
|
||||
Intent deviceCommunicationServiceIntent = new Intent(context, DeviceCommunicationService.class);
|
||||
deviceCommunicationServiceIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
if (connected) {
|
||||
deviceCommunicationServiceIntent.setAction(DeviceService.ACTION_DISCONNECT);
|
||||
PendingIntent disconnectPendingIntent = PendingIntentUtils.getService(context, 0, deviceCommunicationServiceIntent, PendingIntent.FLAG_ONE_SHOT, false);
|
||||
@ -264,6 +267,7 @@ public class GB {
|
||||
|
||||
if (anyDeviceSupportesActivityDataFetching) {
|
||||
Intent deviceCommunicationServiceIntent = new Intent(context, DeviceCommunicationService.class);
|
||||
deviceCommunicationServiceIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
deviceCommunicationServiceIntent.setAction(DeviceService.ACTION_FETCH_RECORDED_DATA);
|
||||
deviceCommunicationServiceIntent.putExtra(EXTRA_RECORDED_DATA_TYPES, ActivityKind.TYPE_ACTIVITY);
|
||||
PendingIntent fetchPendingIntent = PendingIntentUtils.getService(context, 1, deviceCommunicationServiceIntent, PendingIntent.FLAG_ONE_SHOT, false);
|
||||
@ -319,6 +323,7 @@ public class GB {
|
||||
// Not sure whether it is worth the complexity to fix this
|
||||
if (!GBApplication.getPrefs().getBoolean(GBPrefs.RECONNECT_ONLY_TO_CONNECTED, true) || !GBApplication.getPrefs().getStringSet(GBPrefs.LAST_DEVICE_ADDRESSES, Collections.emptySet()).isEmpty()) {
|
||||
Intent deviceCommunicationServiceIntent = new Intent(context, DeviceCommunicationService.class);
|
||||
deviceCommunicationServiceIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
deviceCommunicationServiceIntent.setAction(DeviceService.ACTION_CONNECT);
|
||||
PendingIntent reconnectPendingIntent = PendingIntentUtils.getService(context, 2, deviceCommunicationServiceIntent, PendingIntent.FLAG_ONE_SHOT, false);
|
||||
builder.addAction(R.drawable.ic_notification, context.getString(R.string.controlcenter_connect), reconnectPendingIntent);
|
||||
@ -502,6 +507,7 @@ public class GB {
|
||||
private static Notification createTransferNotification(String title, String text, boolean ongoing,
|
||||
int percentage, Context context) {
|
||||
Intent notificationIntent = new Intent(context, ControlCenterv2.class);
|
||||
notificationIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
PendingIntent pendingIntent = PendingIntentUtils.getActivity(context, 0,
|
||||
@ -539,6 +545,7 @@ public class GB {
|
||||
private static Notification createInstallNotification(String text, boolean ongoing,
|
||||
int percentage, Context context) {
|
||||
Intent notificationIntent = new Intent(context, ControlCenterv2.class);
|
||||
notificationIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
PendingIntent pendingIntent = PendingIntentUtils.getActivity(context, 0,
|
||||
@ -569,6 +576,7 @@ public class GB {
|
||||
|
||||
private static Notification createBatteryLowNotification(String text, String bigText, Context context) {
|
||||
Intent notificationIntent = new Intent(context, ControlCenterv2.class);
|
||||
notificationIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
PendingIntent pendingIntent = PendingIntentUtils.getActivity(context, 0,
|
||||
@ -591,6 +599,7 @@ public class GB {
|
||||
|
||||
private static Notification createBatteryFullNotification(String text, String bigText, Context context) {
|
||||
Intent notificationIntent = new Intent(context, ControlCenterv2.class);
|
||||
notificationIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
PendingIntent pendingIntent = PendingIntentUtils.getActivity(context, 0,
|
||||
@ -637,6 +646,7 @@ public class GB {
|
||||
|
||||
public static Notification createExportFailedNotification(String text, Context context) {
|
||||
Intent notificationIntent = new Intent(context, SettingsActivity.class);
|
||||
notificationIntent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
PendingIntent pendingIntent = PendingIntentUtils.getActivity(context, 0,
|
||||
|
Loading…
Reference in New Issue
Block a user