mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-23 00:33:09 +02:00
Intent contants
This commit is contained in:
@@ -30,32 +30,28 @@ import com.health.openscale.gui.preferences.ReminderPreferences;
|
||||
|
||||
import static android.content.Context.NOTIFICATION_SERVICE;
|
||||
|
||||
public class ReminderBootReceiver extends BroadcastReceiver {
|
||||
public class ReminderBootReceiver extends BroadcastReceiver
|
||||
{
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
if (intent.hasExtra("alarmIntent")) {
|
||||
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
if (intent.hasExtra(ReminderPreferences.INTENT_EXTRA_ALARM))
|
||||
{
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
String notifyText = prefs.getString("reminderNotifyText", context.getResources().getString(R.string.default_value_reminder_notify_text));
|
||||
String notifyText = prefs.getString(ReminderPreferences.PREFERENCE_KEY_REMINDER_NOTIFY_TEXT,
|
||||
context.getResources().getString(R.string.default_value_reminder_notify_text));
|
||||
|
||||
NotificationCompat.Builder mBuilder =
|
||||
new NotificationCompat.Builder(context)
|
||||
.setSmallIcon(R.drawable.ic_launcher)
|
||||
.setContentTitle("openScale")
|
||||
.setContentText(notifyText)
|
||||
.setAutoCancel(true);
|
||||
new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_launcher)
|
||||
.setContentTitle(context.getString(R.string.app_name))
|
||||
.setContentText(notifyText)
|
||||
.setAutoCancel(true);
|
||||
|
||||
Intent notifyIntent = new Intent(context, MainActivity.class);
|
||||
|
||||
PendingIntent notifyPendingIntent =
|
||||
PendingIntent.getActivity(
|
||||
context,
|
||||
0,
|
||||
notifyIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
);
|
||||
PendingIntent.getActivity(context, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
mBuilder.setContentIntent(notifyPendingIntent);
|
||||
|
||||
@@ -63,8 +59,10 @@ public class ReminderBootReceiver extends BroadcastReceiver {
|
||||
mNotifyMgr.notify(0x01, mBuilder.build());
|
||||
}
|
||||
|
||||
if (intent.getAction() != null) {
|
||||
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
|
||||
if (intent.getAction() != null)
|
||||
{
|
||||
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED))
|
||||
{
|
||||
ReminderPreferences.scheduleAlarms(context);
|
||||
}
|
||||
}
|
||||
|
@@ -45,10 +45,13 @@ import java.util.Set;
|
||||
public class ReminderPreferences extends PreferenceFragment
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
{
|
||||
public static final String INTENT_EXTRA_ALARM = "alarmIntent";
|
||||
public static final String PREFERENCE_KEY_REMINDER_NOTIFY_TEXT = "reminderNotifyText";
|
||||
|
||||
private static final String PREFERENCE_KEY_REMINDER_ENABLE = "reminderEnable";
|
||||
private static final String PREFERENCE_KEY_REMINDER_WEEKDAYS = "reminderWeekdays";
|
||||
private static final String PREFERENCE_KEY_REMINDER_TIME = "reminderTime";
|
||||
private static final String PREFERENCE_KEY_REMINDER_NOTIFY_TEXT = "reminderNotifyText";
|
||||
|
||||
|
||||
private static ArrayList<PendingIntent> pendingAlarms = new ArrayList<>();
|
||||
|
||||
@@ -115,7 +118,7 @@ public class ReminderPreferences extends PreferenceFragment
|
||||
AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
|
||||
Intent alarmIntent = new Intent(context, ReminderBootReceiver.class);
|
||||
alarmIntent.putExtra("alarmIntent", true);
|
||||
alarmIntent.putExtra(INTENT_EXTRA_ALARM, true);
|
||||
|
||||
PendingIntent alarmPendingIntent =
|
||||
PendingIntent.getBroadcast(context, dayOfWeek, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
Reference in New Issue
Block a user