Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
298 additions
and
290 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...rpicker/build/intermediates/incremental/packageDebugResources/compile-file-map.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 12 additions & 7 deletions
19
app/src/main/java/com/ellenluo/minimaList/AlarmManagerReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
package com.ellenluo.minimaList; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Build; | ||
import android.support.v4.content.WakefulBroadcastReceiver; | ||
|
||
/** | ||
* AlarmManagerReceiver | ||
* Created by Ellen Luo | ||
* BroadcastReceiver that calls a notification service when a task reminder fires. | ||
*/ | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.support.v4.content.WakefulBroadcastReceiver; | ||
|
||
public class AlarmManagerReceiver extends WakefulBroadcastReceiver { | ||
|
||
public void onReceive(Context context, Intent intent) { | ||
long id = intent.getExtras().getLong("id"); | ||
String text = intent.getExtras().getString("text"); | ||
|
||
// start notification service | ||
Intent service = new Intent(context, NotifService.class); | ||
Intent service = new Intent(context, NotificationService.class); | ||
service.putExtra("id", id); | ||
service.putExtra("text", text); | ||
context.startService(service); | ||
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
context.startForegroundService(service); | ||
} else { | ||
context.startService(service); | ||
} | ||
} | ||
|
||
} |
43 changes: 22 additions & 21 deletions
43
app/src/main/java/com/ellenluo/minimaList/BootCompletedReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,39 @@ | ||
package com.ellenluo.minimaList; | ||
|
||
/** | ||
* BootCompletedReceiver | ||
* Created by Ellen Luo | ||
* BroadcastReceiver that resets all reminders after device reboot (powering off device cancels notifications). | ||
*/ | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* BootCompletedReceiver | ||
* Created by Ellen Luo | ||
* BroadcastReceiver that resets all reminders after device reboot (powering off device cancels notifications). | ||
*/ | ||
public class BootCompletedReceiver extends BroadcastReceiver { | ||
|
||
@Override | ||
public void onReceive(Context context, Intent incomingIntent) { | ||
// get task list | ||
DBHandler db = new DBHandler(context); | ||
ArrayList<Task> taskList = db.getAllTasks(); | ||
|
||
// set new reminders | ||
for (int i = 0; i < taskList.size(); i++) { | ||
Task curTask = taskList.get(i); | ||
|
||
if (curTask.getRemind() != -1 && curTask.getRemind() > System.currentTimeMillis()) { | ||
Helper h = new Helper(context); | ||
h.setReminder(curTask.getName(), curTask.getId(), curTask.getRemind()); | ||
if (incomingIntent.getAction() != null && incomingIntent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { | ||
// get task list | ||
DBHandler db = new DBHandler(context); | ||
ArrayList<Task> taskList = db.getAllTasks(); | ||
|
||
// set new reminders | ||
for (int i = 0; i < taskList.size(); i++) { | ||
Task curTask = taskList.get(i); | ||
|
||
if (curTask.getRemind() != -1 && curTask.getRemind() > System.currentTimeMillis()) { | ||
Helper h = new Helper(context); | ||
h.setReminder(curTask.getName(), curTask.getId(), curTask.getRemind()); | ||
} | ||
} | ||
} | ||
|
||
// schedules widget update at midnight | ||
Helper h = new Helper(context); | ||
h.scheduleUpdate(); | ||
// schedules widget update at midnight | ||
Helper h = new Helper(context); | ||
h.scheduleUpdate(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.