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