diff --git a/android-colorpicker/build/intermediates/incremental/packageDebugResources/compile-file-map.properties b/android-colorpicker/build/intermediates/incremental/packageDebugResources/compile-file-map.properties
index 92a4bd3..fc32ab1 100644
--- a/android-colorpicker/build/intermediates/incremental/packageDebugResources/compile-file-map.properties
+++ b/android-colorpicker/build/intermediates/incremental/packageDebugResources/compile-file-map.properties
@@ -1,4 +1,4 @@
-#Fri Aug 17 16:02:18 EDT 2018
+#Fri Aug 17 18:56:36 EDT 2018
/Users/ellen/Documents/minimaList/android-colorpicker/src/main/res/drawable/color_picker_swatch.xml=/Users/ellen/Documents/minimaList/android-colorpicker/build/intermediates/packaged_res/debug/drawable/color_picker_swatch.xml
/Users/ellen/Documents/minimaList/android-colorpicker/src/main/res/layout/color_picker_swatch.xml=/Users/ellen/Documents/minimaList/android-colorpicker/build/intermediates/packaged_res/debug/layout/color_picker_swatch.xml
/Users/ellen/Documents/minimaList/android-colorpicker/src/main/res/layout/color_picker_dialog.xml=/Users/ellen/Documents/minimaList/android-colorpicker/build/intermediates/packaged_res/debug/layout/color_picker_dialog.xml
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 96e2d5d..a5d1950 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -60,7 +60,7 @@
android:label="@string/title_activity_intro" />
repeatAdapter = ArrayAdapter.createFromResource(this, R.array.repeat_options,
android.R.layout.simple_spinner_dropdown_item);
repeatSpinner.setAdapter(repeatAdapter);
// initialize new list instructions/text field
- tvAddList = (TextView) findViewById(R.id.new_list_instructions);
- etAddList = (EditText) findViewById(R.id.list_name);
+ tvAddList = findViewById(R.id.new_list_instructions);
+ etAddList = findViewById(R.id.list_name);
// set up reminder switch
- Switch remindSwitch = (Switch) findViewById(R.id.remind_switch);
+ Switch remindSwitch = findViewById(R.id.remind_switch);
remindSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@@ -146,7 +145,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
});
// set up list spinner
- Spinner listSpinner = (Spinner) findViewById(R.id.list_spinner);
+ Spinner listSpinner = findViewById(R.id.list_spinner);
db = new DBHandler(this);
listList = db.getAllLists();
@@ -234,12 +233,12 @@ public void onDateSet(DatePicker view, int year, int month, int day) {
if (picker == 0) {
due = Calendar.getInstance();
due.set(year, month, day, 0, 0, 0);
- tvDueDate.setText(monthArray[month] + " " + day + ", " + year);
+ tvDueDate.setText(getString(R.string.add_task_due_date, monthArray[month], day, year));
btnClearDue.setVisibility(View.VISIBLE);
} else {
remind = Calendar.getInstance();
remind.set(year, month, day, 0, 0, 0);
- tvRemindDate.setText(monthArray[month] + " " + day + ", " + year);
+ tvRemindDate.setText(getString(R.string.add_task_due_date, monthArray[month], day, year));
btnClearRemind.setVisibility(View.VISIBLE);
}
@@ -281,8 +280,8 @@ public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// add task to database
@SuppressWarnings("ConstantConditions")
private void addTask() {
- EditText etName = (EditText) findViewById(R.id.task_name);
- EditText etDetails = (EditText) findViewById(R.id.task_details);
+ EditText etName = findViewById(R.id.task_name);
+ EditText etDetails = findViewById(R.id.task_details);
String taskName = etName.getText().toString().trim();
String details = etDetails.getText().toString();
diff --git a/app/src/main/java/com/ellenluo/minimaList/AlarmManagerReceiver.java b/app/src/main/java/com/ellenluo/minimaList/AlarmManagerReceiver.java
index 04e1dd3..21f5f32 100644
--- a/app/src/main/java/com/ellenluo/minimaList/AlarmManagerReceiver.java
+++ b/app/src/main/java/com/ellenluo/minimaList/AlarmManagerReceiver.java
@@ -1,15 +1,15 @@
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) {
@@ -17,10 +17,15 @@ public void onReceive(Context context, Intent intent) {
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);
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/ellenluo/minimaList/BootCompletedReceiver.java b/app/src/main/java/com/ellenluo/minimaList/BootCompletedReceiver.java
index e548eb0..7d07fc2 100644
--- a/app/src/main/java/com/ellenluo/minimaList/BootCompletedReceiver.java
+++ b/app/src/main/java/com/ellenluo/minimaList/BootCompletedReceiver.java
@@ -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 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 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();
+ }
}
}
diff --git a/app/src/main/java/com/ellenluo/minimaList/DBHandler.java b/app/src/main/java/com/ellenluo/minimaList/DBHandler.java
index 0e9c400..4869ee8 100644
--- a/app/src/main/java/com/ellenluo/minimaList/DBHandler.java
+++ b/app/src/main/java/com/ellenluo/minimaList/DBHandler.java
@@ -1,11 +1,5 @@
package com.ellenluo.minimaList;
-/**
- * DBHandler
- * Created by Ellen Luo
- * SQLiteOpenHelper that creates SQLite tables to store tasks and lists and allows various database operations.
- */
-
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
@@ -15,6 +9,11 @@
import java.util.ArrayList;
import java.util.Locale;
+/**
+ * DBHandler
+ * Created by Ellen Luo
+ * SQLiteOpenHelper that creates SQLite tables to store tasks and lists and allows various database operations.
+ */
public class DBHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
@@ -155,7 +154,7 @@ ArrayList getAllTasks() {
}
// update task in table
- int updateTask(Task task) {
+ void updateTask(Task task) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_TASK_NAME, task.getName());
@@ -165,7 +164,7 @@ int updateTask(Task task) {
values.put(KEY_TASK_REPEAT, task.getRepeat());
values.put(KEY_TASK_NEXT_REMIND, task.getNextRemind());
values.put(KEY_TASK_LIST, task.getList());
- return db.update(TABLE_TASKS, values, KEY_TASK_ID + " = ?", new String[]{String.valueOf(task.getId())});
+ db.update(TABLE_TASKS, values, KEY_TASK_ID + " = ?", new String[]{String.valueOf(task.getId())});
}
// delete task from table
@@ -243,12 +242,11 @@ ArrayList getAllLists() {
}
// update list in table
- int updateList(List list) {
+ void updateList(List list) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_LIST_NAME, list.getName());
-
- return db.update(TABLE_LISTS, values, KEY_LIST_ID + " = ?", new String[]{String.valueOf(list.getId())});
+ db.update(TABLE_LISTS, values, KEY_LIST_ID + " = ?", new String[]{String.valueOf(list.getId())});
}
// delete list from table
diff --git a/app/src/main/java/com/ellenluo/minimaList/DatePickerFragment.java b/app/src/main/java/com/ellenluo/minimaList/DatePickerFragment.java
index 1a67b46..7db1ca2 100644
--- a/app/src/main/java/com/ellenluo/minimaList/DatePickerFragment.java
+++ b/app/src/main/java/com/ellenluo/minimaList/DatePickerFragment.java
@@ -1,14 +1,9 @@
package com.ellenluo.minimaList;
-/**
- * DatePickerFragment
- * Created by Ellen Luo
- * DialogFragment that displays a calendar date picker.
- */
-
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
+import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
@@ -16,6 +11,11 @@
import java.util.Calendar;
+/**
+ * DatePickerFragment
+ * Created by Ellen Luo
+ * DialogFragment that displays a calendar date picker.
+ */
public class DatePickerFragment extends DialogFragment {
OnDateSetListener listener;
@@ -38,9 +38,11 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
}
@Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- listener = (OnDateSetListener) activity;
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ if (context instanceof Activity){
+ listener = (OnDateSetListener) context;
+ }
}
}
diff --git a/app/src/main/java/com/ellenluo/minimaList/EditTaskActivity.java b/app/src/main/java/com/ellenluo/minimaList/EditTaskActivity.java
index 821b88b..b94c302 100644
--- a/app/src/main/java/com/ellenluo/minimaList/EditTaskActivity.java
+++ b/app/src/main/java/com/ellenluo/minimaList/EditTaskActivity.java
@@ -1,11 +1,5 @@
package com.ellenluo.minimaList;
-/**
- * EditTaskActivity
- * Created by Ellen Luo
- * Activity that allows users to modify the parameters of a task.
- */
-
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
@@ -38,6 +32,11 @@
import java.util.Date;
import java.util.Locale;
+/**
+ * EditTaskActivity
+ * Created by Ellen Luo
+ * Activity that allows users to modify the parameters of a task.
+ */
public class EditTaskActivity extends AppCompatActivity implements TimePickerFragment.OnTimeSetListener,
DatePickerFragment.OnDateSetListener {
@@ -88,7 +87,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_edit_task);
// set up toolbar
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@@ -107,15 +106,15 @@ protected void onCreate(Bundle savedInstanceState) {
curTask = db.getTask(id);
// set fields to current values
- etName = (EditText) findViewById(R.id.task_name);
- etDetails = (EditText) findViewById(R.id.task_details);
+ etName = findViewById(R.id.task_name);
+ etDetails = findViewById(R.id.task_details);
etName.setText(curTask.getName());
etDetails.setText(curTask.getDetails());
// set up current due date/time
- tvDueDate = (TextView) findViewById(R.id.due_date);
- tvDueTime = (TextView) findViewById(R.id.due_time);
- btnClearDue = (Button) findViewById(R.id.clear_due);
+ tvDueDate = findViewById(R.id.due_date);
+ tvDueTime = findViewById(R.id.due_time);
+ btnClearDue = findViewById(R.id.clear_due);
if (curTask.getDue() != -1) {
Calendar cal = Calendar.getInstance();
@@ -134,13 +133,13 @@ protected void onCreate(Bundle savedInstanceState) {
}
// set up current reminder
- final Button btnSetRemind = (Button) findViewById(R.id.set_remind);
- Switch remindSwitch = (Switch) findViewById(R.id.remind_switch);
- tvRemindDate = (TextView) findViewById(R.id.remind_date);
- tvRemindTime = (TextView) findViewById(R.id.remind_time);
- btnClearRemind = (Button) findViewById(R.id.clear_remind);
- tvRepeat = (TextView) findViewById(R.id.repeat);
- repeatSpinner = (Spinner) findViewById(R.id.repeat_spinner);
+ final Button btnSetRemind = findViewById(R.id.set_remind);
+ Switch remindSwitch = findViewById(R.id.remind_switch);
+ tvRemindDate = findViewById(R.id.remind_date);
+ tvRemindTime = findViewById(R.id.remind_time);
+ btnClearRemind = findViewById(R.id.clear_remind);
+ tvRepeat = findViewById(R.id.repeat);
+ repeatSpinner = findViewById(R.id.repeat_spinner);
ArrayAdapter repeatAdapter = ArrayAdapter.createFromResource(this, R.array.repeat_options,
android.R.layout.simple_spinner_dropdown_item);
repeatSpinner.setAdapter(repeatAdapter);
@@ -200,11 +199,11 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
});
// initialize new list instructions/text field
- tvAddList = (TextView) findViewById(R.id.new_list_instructions);
- etAddList = (EditText) findViewById(R.id.list_name);
+ tvAddList = findViewById(R.id.new_list_instructions);
+ etAddList = findViewById(R.id.list_name);
// set up spinner
- Spinner listSpinner = (Spinner) findViewById(R.id.list_spinner);
+ Spinner listSpinner = findViewById(R.id.list_spinner);
ArrayList listList = db.getAllLists();
size = listList.size();
@@ -292,12 +291,12 @@ public void onDateSet(DatePicker view, int year, int month, int day) {
if (picker == 0) {
due = Calendar.getInstance();
due.set(year, month, day);
- tvDueDate.setText(monthArray[month] + " " + day + ", " + year);
+ tvDueDate.setText(getString(R.string.add_task_due_date, monthArray[month], day, year));
btnClearDue.setVisibility(View.VISIBLE);
} else {
remind = Calendar.getInstance();
remind.set(year, month, day);
- tvRemindDate.setText(monthArray[month] + " " + day + ", " + year);
+ tvRemindDate.setText(getString(R.string.add_task_due_date, monthArray[month], day, year));
btnClearRemind.setVisibility(View.VISIBLE);
}
diff --git a/app/src/main/java/com/ellenluo/minimaList/FeedbackFragment.java b/app/src/main/java/com/ellenluo/minimaList/FeedbackFragment.java
index 3226818..dc46206 100644
--- a/app/src/main/java/com/ellenluo/minimaList/FeedbackFragment.java
+++ b/app/src/main/java/com/ellenluo/minimaList/FeedbackFragment.java
@@ -1,14 +1,9 @@
package com.ellenluo.minimaList;
-/**
- * FeedbackFragment
- * Created by Ellen Luo
- * Fragment that allows users to submit feedback by email.
- */
-
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
@@ -17,14 +12,14 @@
import android.widget.EditText;
import android.widget.Spinner;
-import com.google.android.gms.analytics.Tracker;
-import com.google.android.gms.tasks.RuntimeExecutionException;
-
+/**
+ * FeedbackFragment
+ * Created by Ellen Luo
+ * Fragment that allows users to submit feedback by email.
+ */
public class FeedbackFragment extends Fragment {
- private Tracker tracker;
-
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_feedback, container, false);
if (container != null) {
@@ -32,10 +27,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
}
// find all fields
- final EditText etName = (EditText) v.findViewById(R.id.user_name);
- final EditText etMessage = (EditText) v.findViewById(R.id.message);
- final Spinner feedbackType = (Spinner) v.findViewById(R.id.feedback_type);
- Button btnSubmit = (Button) v.findViewById(R.id.send_feedback);
+ final EditText etName = v.findViewById(R.id.user_name);
+ final EditText etMessage = v.findViewById(R.id.message);
+ final Spinner feedbackType = v.findViewById(R.id.feedback_type);
+ Button btnSubmit = v.findViewById(R.id.send_feedback);
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
diff --git a/app/src/main/java/com/ellenluo/minimaList/Helper.java b/app/src/main/java/com/ellenluo/minimaList/Helper.java
index d7bf9e0..9cbdd94 100644
--- a/app/src/main/java/com/ellenluo/minimaList/Helper.java
+++ b/app/src/main/java/com/ellenluo/minimaList/Helper.java
@@ -1,11 +1,5 @@
package com.ellenluo.minimaList;
-/**
- * Helper
- * Created by Ellen Luo
- * Helper class that contains methods used by multiple classes.
- */
-
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
@@ -19,10 +13,16 @@
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
+import android.util.Log;
import android.widget.Spinner;
import java.util.Calendar;
+/**
+ * Helper
+ * Created by Ellen Luo
+ * Helper class that contains methods used by multiple classes.
+ */
class Helper {
private Context context;
@@ -78,6 +78,7 @@ void setReminder(String name, long id, long remindMillis) {
intent.putExtra("id", id);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.context, (int) id, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
+ Log.d("Helper", "Setting reminder with id " + id);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
alarmManager.set(AlarmManager.RTC_WAKEUP, remindMillis, pendingIntent);
diff --git a/app/src/main/java/com/ellenluo/minimaList/IntroActivity.java b/app/src/main/java/com/ellenluo/minimaList/IntroActivity.java
index 157d056..0e6b6b2 100644
--- a/app/src/main/java/com/ellenluo/minimaList/IntroActivity.java
+++ b/app/src/main/java/com/ellenluo/minimaList/IntroActivity.java
@@ -12,7 +12,6 @@
* Created by Ellen Luo
* Activity that displays an image with basic instructions.
*/
-
public class IntroActivity extends AppCompatActivity {
@Override
diff --git a/app/src/main/java/com/ellenluo/minimaList/List.java b/app/src/main/java/com/ellenluo/minimaList/List.java
index d9a557b..76409f1 100644
--- a/app/src/main/java/com/ellenluo/minimaList/List.java
+++ b/app/src/main/java/com/ellenluo/minimaList/List.java
@@ -5,7 +5,6 @@
* Created by Ellen Luo
* Class to represent a List object with an id and name.
*/
-
class List {
// parameters
diff --git a/app/src/main/java/com/ellenluo/minimaList/MainActivity.java b/app/src/main/java/com/ellenluo/minimaList/MainActivity.java
index 68b1f57..5d955ba 100644
--- a/app/src/main/java/com/ellenluo/minimaList/MainActivity.java
+++ b/app/src/main/java/com/ellenluo/minimaList/MainActivity.java
@@ -1,11 +1,5 @@
package com.ellenluo.minimaList;
-/**
- * MainActivity
- * Created by Ellen Luo
- * Activity that switches between fragments using a side navigation drawer and allows adding/editing lists.
- */
-
import android.app.AlertDialog;
import android.app.Dialog;
import android.appwidget.AppWidgetManager;
@@ -39,6 +33,11 @@
import java.util.ArrayList;
+/**
+ * MainActivity
+ * Created by Ellen Luo
+ * Activity that switches between fragments using a side navigation drawer and allows adding/editing lists.
+ */
public class MainActivity extends AppCompatActivity {
private DBHandler db;
@@ -81,7 +80,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
// set up toolbar
- toolbar = (Toolbar) findViewById(R.id.toolbar);
+ toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
@@ -89,8 +88,8 @@ protected void onCreate(Bundle savedInstanceState) {
}
// set up navigation menu
- mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- nvDrawer = (NavigationView) findViewById(R.id.nav_view);
+ mDrawer = findViewById(R.id.drawer_layout);
+ nvDrawer = findViewById(R.id.nav_view);
setupDrawerContent(nvDrawer);
drawerToggle = setupDrawerToggle();
@@ -100,7 +99,7 @@ protected void onCreate(Bundle savedInstanceState) {
refreshLists();
// set up floating add button
- fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, AddTaskActivity.class);
@@ -117,7 +116,6 @@ public void onClick(View view) {
// check for faulty value
if (newList != null) {
- boolean exists = false;
for (int i = 0; i < listList.size(); i++) {
if (newList.equals(listList.get(i).getName())) {
curList = newList;
@@ -296,11 +294,11 @@ public void showEditDialog() {
setDialogWidth(dialog);
// set text field to current name
- etListName = (EditText) dialog.findViewById(R.id.list_name);
+ etListName = dialog.findViewById(R.id.list_name);
etListName.setText(pref.getString("current_list", "All Tasks"));
// save button
- Button btnSave = (Button) dialog.findViewById(R.id.save_changes);
+ Button btnSave = dialog.findViewById(R.id.save_changes);
btnSave.setOnClickListener(new View.OnClickListener() {
@Override
@@ -405,7 +403,7 @@ public void onClick(DialogInterface dialog, int which) {
});
// delete button
- Button btnDelete = (Button) dialog.findViewById(R.id.delete_list);
+ Button btnDelete = dialog.findViewById(R.id.delete_list);
btnDelete.setOnClickListener(new View.OnClickListener() {
@Override
@@ -485,10 +483,10 @@ public void showAddDialog() {
setDialogWidth(dialog);
// initialize text field
- etListName = (EditText) dialog.findViewById(R.id.list_name);
+ etListName = dialog.findViewById(R.id.list_name);
// add button
- Button btnAdd = (Button) dialog.findViewById(R.id.add_list);
+ Button btnAdd = dialog.findViewById(R.id.add_list);
btnAdd.setOnClickListener(new View.OnClickListener() {
@Override
@@ -571,7 +569,7 @@ public void onClick(DialogInterface dialog, int which) {
});
// cancel button
- Button btnCancel = (Button) dialog.findViewById(R.id.cancel);
+ Button btnCancel = dialog.findViewById(R.id.cancel);
btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
diff --git a/app/src/main/java/com/ellenluo/minimaList/MainFragment.java b/app/src/main/java/com/ellenluo/minimaList/MainFragment.java
index 16ff73f..4d00a40 100644
--- a/app/src/main/java/com/ellenluo/minimaList/MainFragment.java
+++ b/app/src/main/java/com/ellenluo/minimaList/MainFragment.java
@@ -1,15 +1,10 @@
package com.ellenluo.minimaList;
-/**
- * MainFragment
- * Created by Ellen Luo
- * Fragment that displays a list of either all tasks, or the tasks in a particular list.
- */
-
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Paint;
import android.os.Bundle;
+import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
@@ -23,7 +18,11 @@
import java.util.ArrayList;
-
+/**
+ * MainFragment
+ * Created by Ellen Luo
+ * Fragment that displays a list of either all tasks, or the tasks in a particular list.
+ */
public class MainFragment extends Fragment {
private DBHandler db;
@@ -33,7 +32,7 @@ public class MainFragment extends Fragment {
private View v;
private ImageView ivEmpty;
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
v = inflater.inflate(R.layout.fragment_main, container, false);
if (container != null) {
@@ -42,7 +41,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
// set up task list
db = new DBHandler(getActivity());
- ListView lvTasks = (ListView) v.findViewById(R.id.task_list);
+ ListView lvTasks = v.findViewById(R.id.task_list);
SharedPreferences pref = getActivity().getSharedPreferences("Main", PREFERENCE_MODE_PRIVATE);
// set list to view
@@ -56,7 +55,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
db.close();
// set up empty view
- ivEmpty = (ImageView) v.findViewById(R.id.empty_list);
+ ivEmpty = v.findViewById(R.id.empty_list);
lvTasks.setEmptyView(ivEmpty);
// set custom list adapter
@@ -80,7 +79,7 @@ public void onItemClick(AdapterView> adapter, View view, int position, long id
@Override
public boolean onItemLongClick(AdapterView> av, View v, final int pos, long id) {
final Task task = taskList.get(pos);
- final TextView tvName = (TextView) v.findViewById(R.id.task_row_name);
+ final TextView tvName = v.findViewById(R.id.task_row_name);
tvName.setPaintFlags(tvName.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
// undo snackbar
diff --git a/app/src/main/java/com/ellenluo/minimaList/NotifService.java b/app/src/main/java/com/ellenluo/minimaList/NotificationService.java
similarity index 71%
rename from app/src/main/java/com/ellenluo/minimaList/NotifService.java
rename to app/src/main/java/com/ellenluo/minimaList/NotificationService.java
index b256c01..3b7065b 100644
--- a/app/src/main/java/com/ellenluo/minimaList/NotifService.java
+++ b/app/src/main/java/com/ellenluo/minimaList/NotificationService.java
@@ -1,13 +1,8 @@
package com.ellenluo.minimaList;
-/**
- * NotifService
- * Created by Ellen Luo
- * IntentService that creates a notification reminder with optional vibration, LED light and sound settings.
- */
-
import android.app.IntentService;
import android.app.Notification;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
@@ -21,65 +16,40 @@
import java.util.Calendar;
-public class NotifService extends IntentService {
+/**
+ * NotificationService
+ * Created by Ellen Luo
+ * Service that creates a notification reminder with optional vibration, LED light and sound settings.
+ */
+public class NotificationService extends IntentService {
- public NotifService() {
- super(NotifService.class.getName());
+ private final String NOTIFICATION_CHANNEL_ID = "reminder_channel";
+
+ public NotificationService() {
+ super(NotificationService.class.getName());
}
@Override
public void onHandleIntent(Intent intent) {
- // get extras
long id = intent.getExtras().getLong("id");
- String text = intent.getExtras().getString("text");
-
- // get notification settings from preferences
- SharedPreferences prefSettings = PreferenceManager.getDefaultSharedPreferences(this);
- String sound = prefSettings.getString("sound", "DEFAULT_NOTIFICATION_URI");
- boolean vibration = prefSettings.getBoolean("vibration", true);
- boolean light = prefSettings.getBoolean("light", true);
-
- // open details when notification clicked
- Intent newIntent = new Intent(this, TaskDetailsActivity.class);
- newIntent.putExtra("id", id);
- PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, newIntent, PendingIntent.FLAG_ONE_SHOT);
-
- // set up notification
- NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.ic_notif)
- .setContentTitle(text)
- .setContentText("Tap for more details")
- .setPriority(Notification.PRIORITY_HIGH)
- .setContentIntent(pendingIntent)
- .setAutoCancel(true);
-
- // vibration option
- if (vibration) {
- builder.setVibrate(new long[]{0, 1000});
- }
-
- // LED light option
- if (light) {
- builder.setLights(ContextCompat.getColor(this, R.color.colorAccent), 2000, 1000);
- }
-
- // sound option
- if (sound.length() > 0) {
- Uri notifUri = Uri.parse(sound);
- builder.setSound(notifUri);
- }
+ NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- // set notification color
- if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- builder.setColor(ContextCompat.getColor(this, R.color.colorAccent));
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ // Configure the notification channel
+ NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "Reminders",
+ NotificationManager.IMPORTANCE_HIGH);
+ notificationChannel.setDescription("Main channel for reminders");
+ notificationChannel.enableLights(true);
+ notificationChannel.enableVibration(true);
+ manager.createNotificationChannel(notificationChannel);
+
+ startForeground((int) id, buildNotification(intent, manager));
+ } else {
+ manager.notify((int) id, buildNotification(intent, manager));
}
- // send notification
- Notification notif = builder.build();
- NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- manager.notify((int) id, notif);
- Log.d("NotifService", "notification sent at " + Calendar.getInstance().getTimeInMillis());
- Log.d("NotifService", "task id is " + id);
+ Log.d("NotificationService", "notification sent at " + Calendar.getInstance().getTimeInMillis());
+ Log.d("NotificationService", "task id is " + id);
// set next reminder (if recurring)
DBHandler db = new DBHandler(this);
@@ -99,8 +69,8 @@ public void onHandleIntent(Intent intent) {
long nextMillis = cal.getTimeInMillis();
curTask.setNextRemind(nextMillis);
db.updateTask(curTask);
- Log.d("NotifService", "setting reminder for " + nextMillis);
- Log.d("NotifService", "new task id is " + curTask.getId());
+ Log.d("NotificationService", "setting reminder for " + nextMillis);
+ Log.d("NotificationService", "new task id is " + curTask.getId());
h.setReminder(curTask.getName(), curTask.getId(), nextMillis);
break;
}
@@ -129,4 +99,54 @@ public void onHandleIntent(Intent intent) {
AlarmManagerReceiver.completeWakefulIntent(intent);
}
+ private Notification buildNotification(Intent intent, NotificationManager manager) {
+ // get extras
+ long id = intent.getExtras().getLong("id");
+ String text = intent.getExtras().getString("text");
+
+ // get notification settings from preferences
+ SharedPreferences prefSettings = PreferenceManager.getDefaultSharedPreferences(this);
+ String sound = prefSettings.getString("sound", "DEFAULT_NOTIFICATION_URI");
+ boolean vibration = prefSettings.getBoolean("vibration", true);
+ boolean light = prefSettings.getBoolean("light", true);
+
+ // open details when notification clicked
+ Intent newIntent = new Intent(this, TaskDetailsActivity.class);
+ newIntent.putExtra("id", id);
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, newIntent, PendingIntent.FLAG_ONE_SHOT);
+
+ // set up notification
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
+ .setSmallIcon(R.drawable.ic_notif)
+ .setContentTitle(text)
+ .setContentText("Tap for more details")
+ .setPriority(Notification.PRIORITY_HIGH)
+ .setContentIntent(pendingIntent)
+ .setAutoCancel(true);
+
+ // vibration option
+ if (vibration) {
+ builder.setVibrate(new long[]{0, 1000});
+ }
+
+ // LED light option
+ if (light) {
+ builder.setLights(ContextCompat.getColor(this, R.color.colorAccent), 2000, 1000);
+ }
+
+ // sound option
+ if (sound.length() > 0) {
+ Uri notifUri = Uri.parse(sound);
+ builder.setSound(notifUri);
+ }
+
+ // set notification color
+ if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ builder.setColor(ContextCompat.getColor(this, R.color.colorAccent));
+ }
+
+ // send notification
+ return builder.build();
+ }
+
}
diff --git a/app/src/main/java/com/ellenluo/minimaList/SettingsFragment.java b/app/src/main/java/com/ellenluo/minimaList/SettingsFragment.java
index 9439ca4..0760ee8 100644
--- a/app/src/main/java/com/ellenluo/minimaList/SettingsFragment.java
+++ b/app/src/main/java/com/ellenluo/minimaList/SettingsFragment.java
@@ -1,11 +1,5 @@
package com.ellenluo.minimaList;
-/**
- * SettingsFragment
- * Created by Ellen Luo
- * PreferenceFragment that allows users to set display, theme and notification settings.
- */
-
import android.app.AlertDialog;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
@@ -19,6 +13,11 @@
import java.util.ArrayList;
+/**
+ * SettingsFragment
+ * Created by Ellen Luo
+ * PreferenceFragment that allows users to set display, theme and notification settings.
+ */
public class SettingsFragment extends PreferenceFragment {
private static final int PREFERENCE_MODE_PRIVATE = 0;
diff --git a/app/src/main/java/com/ellenluo/minimaList/Task.java b/app/src/main/java/com/ellenluo/minimaList/Task.java
index f270073..204b0db 100644
--- a/app/src/main/java/com/ellenluo/minimaList/Task.java
+++ b/app/src/main/java/com/ellenluo/minimaList/Task.java
@@ -5,7 +5,6 @@
* Created by Ellen Luo
* Class to represent a Task object with id, name, details, due date, reminder and list parameters.
*/
-
public class Task {
// parameters
diff --git a/app/src/main/java/com/ellenluo/minimaList/TaskDetailsActivity.java b/app/src/main/java/com/ellenluo/minimaList/TaskDetailsActivity.java
index 9f0376e..f0765ef 100644
--- a/app/src/main/java/com/ellenluo/minimaList/TaskDetailsActivity.java
+++ b/app/src/main/java/com/ellenluo/minimaList/TaskDetailsActivity.java
@@ -1,11 +1,5 @@
package com.ellenluo.minimaList;
-/**
- * TaskDetailsActivity
- * Created by Ellen Luo
- * Activity that allows users to view the parameters of a task.
- */
-
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
@@ -29,7 +23,11 @@
import java.util.Date;
import java.util.Locale;
-
+/**
+ * TaskDetailsActivity
+ * Created by Ellen Luo
+ * Activity that allows users to view the parameters of a task.
+ */
public class TaskDetailsActivity extends AppCompatActivity {
private DBHandler db = new DBHandler(this);
@@ -58,7 +56,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_task_details);
// set up toolbar
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@@ -78,13 +76,13 @@ protected void onCreate(Bundle savedInstanceState) {
curTask = db.getTask(id);
// set task info
- TextView tvName = (TextView) findViewById(R.id.task_name);
- TextView tvDue = (TextView) findViewById(R.id.due_date);
- TextView tvRemind = (TextView) findViewById(R.id.reminder);
- TextView tvRepeatLabel = (TextView) findViewById(R.id.repeat_label);
- TextView tvRepeat = (TextView) findViewById(R.id.repeat);
- TextView tvList = (TextView) findViewById(R.id.list);
- TextView tvDetails = (TextView) findViewById(R.id.details);
+ TextView tvName = findViewById(R.id.task_name);
+ TextView tvDue = findViewById(R.id.due_date);
+ TextView tvRemind = findViewById(R.id.reminder);
+ TextView tvRepeatLabel = findViewById(R.id.repeat_label);
+ TextView tvRepeat = findViewById(R.id.repeat);
+ TextView tvList = findViewById(R.id.list);
+ TextView tvDetails = findViewById(R.id.details);
tvName.setText(curTask.getName());
tvDetails.setText(curTask.getDetails());
@@ -102,13 +100,13 @@ protected void onCreate(Bundle savedInstanceState) {
Date date = cal.getTime();
if (militaryTime) {
- tvDue.setText(new SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault()).format(date) + " " +
- getString(R.string.details_at) + " "
- + new SimpleDateFormat("HH:mm", Locale.getDefault()).format(date));
+ tvDue.setText(getString(R.string.details_date,
+ new SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault()).format(date),
+ new SimpleDateFormat("HH:mm", Locale.getDefault()).format(date)));
} else {
- tvDue.setText(new SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault()).format(date) + " " +
- getString(R.string.details_at) + " "
- + new SimpleDateFormat("hh:mm a", Locale.getDefault()).format(date));
+ tvDue.setText(getString(R.string.details_date,
+ new SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault()).format(date),
+ new SimpleDateFormat("hh:mm a", Locale.getDefault()).format(date)));
}
}
@@ -119,13 +117,13 @@ protected void onCreate(Bundle savedInstanceState) {
Date date = cal.getTime();
if (militaryTime) {
- tvRemind.setText(new SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault()).format(date) + " " +
- getString(R.string.details_at) + " " + new SimpleDateFormat("HH:mm", Locale.getDefault())
- .format(date));
+ tvRemind.setText(getString(R.string.details_date,
+ new SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault()).format(date),
+ new SimpleDateFormat("HH:mm", Locale.getDefault()).format(date)));
} else {
- tvRemind.setText(new SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault()).format(date) + " " +
- getString(R.string.details_at) + " " + new SimpleDateFormat("hh:mm a", Locale.getDefault())
- .format(date));
+ tvRemind.setText(getString(R.string.details_date,
+ new SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault()).format(date),
+ new SimpleDateFormat("hh:mm a", Locale.getDefault()).format(date)));
}
tvRepeatLabel.setVisibility(View.VISIBLE);
@@ -133,7 +131,7 @@ protected void onCreate(Bundle savedInstanceState) {
}
// task completed checkbox
- CheckBox cbComplete = (CheckBox) findViewById(R.id.cb_complete);
+ CheckBox cbComplete = findViewById(R.id.cb_complete);
cbComplete.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
diff --git a/app/src/main/java/com/ellenluo/minimaList/TaskListAdapter.java b/app/src/main/java/com/ellenluo/minimaList/TaskListAdapter.java
index 508fc5d..1dd17b4 100644
--- a/app/src/main/java/com/ellenluo/minimaList/TaskListAdapter.java
+++ b/app/src/main/java/com/ellenluo/minimaList/TaskListAdapter.java
@@ -1,11 +1,5 @@
package com.ellenluo.minimaList;
-/**
- * TaskListAdapter
- * Created by Ellen Luo
- * ArrayAdapter that displays task info with a custom row layout.
- */
-
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
@@ -23,6 +17,11 @@
import java.util.Date;
import java.util.Locale;
+/**
+ * TaskListAdapter
+ * Created by Ellen Luo
+ * ArrayAdapter that displays task info with a custom row layout.
+ */
class TaskListAdapter extends ArrayAdapter {
private DBHandler db;
@@ -64,11 +63,11 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
// set name
Task curTask = this.taskList.get(position);
- TextView tvName = (TextView) v.findViewById(R.id.task_row_name);
+ TextView tvName = v.findViewById(R.id.task_row_name);
tvName.setText(curTask.getName());
// set list
- TextView tvList = (TextView) v.findViewById(R.id.task_row_list);
+ TextView tvList = v.findViewById(R.id.task_row_list);
tvList.setTextColor(color);
if (curTask.getList() != -1) {
@@ -79,9 +78,9 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
}
// get due date & time text
- TextView tvDate = (TextView) v.findViewById(R.id.task_row_date);
+ TextView tvDate = v.findViewById(R.id.task_row_date);
tvDate.setTextColor(color);
- TextView tvTime = (TextView) v.findViewById(R.id.task_row_time);
+ TextView tvTime = v.findViewById(R.id.task_row_time);
long millis = curTask.getDue();
if (millis != -1) {
diff --git a/app/src/main/java/com/ellenluo/minimaList/TimePickerFragment.java b/app/src/main/java/com/ellenluo/minimaList/TimePickerFragment.java
index 02ed8fb..f43a2d5 100644
--- a/app/src/main/java/com/ellenluo/minimaList/TimePickerFragment.java
+++ b/app/src/main/java/com/ellenluo/minimaList/TimePickerFragment.java
@@ -1,14 +1,9 @@
package com.ellenluo.minimaList;
-/**
- * TimePickerFragment
- * Created by Ellen Luo
- * DialogFragment that displays a time picker.
- */
-
import android.app.Activity;
import android.app.Dialog;
import android.app.TimePickerDialog;
+import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
@@ -18,6 +13,11 @@
import java.util.Calendar;
+/**
+ * TimePickerFragment
+ * Created by Ellen Luo
+ * DialogFragment that displays a time picker.
+ */
public class TimePickerFragment extends DialogFragment {
OnTimeSetListener listener;
@@ -43,9 +43,11 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
}
@Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- listener = (OnTimeSetListener) activity;
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ if (context instanceof Activity){
+ listener = (TimePickerFragment.OnTimeSetListener) context;
+ }
}
}
diff --git a/app/src/main/java/com/ellenluo/minimaList/WidgetConfigureActivity.java b/app/src/main/java/com/ellenluo/minimaList/WidgetConfigureActivity.java
index fba9616..ae9a00b 100644
--- a/app/src/main/java/com/ellenluo/minimaList/WidgetConfigureActivity.java
+++ b/app/src/main/java/com/ellenluo/minimaList/WidgetConfigureActivity.java
@@ -1,11 +1,5 @@
package com.ellenluo.minimaList;
-/**
- * WidgetConfigureActivity
- * Created by Ellen Luo
- * Activity that allows users to select a list for the widget to display.
- */
-
import android.appwidget.AppWidgetManager;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -21,6 +15,11 @@
import java.util.ArrayList;
+/**
+ * WidgetConfigureActivity
+ * Created by Ellen Luo
+ * Activity that allows users to select a list for the widget to display.
+ */
public class WidgetConfigureActivity extends AppCompatActivity {
private static final int PREFERENCE_MODE_PRIVATE = 0;
@@ -47,7 +46,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_widget_configure);
// set up toolbar
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@@ -72,7 +71,7 @@ protected void onCreate(Bundle savedInstanceState) {
}
// set up list spinner
- listSpinner = (Spinner) findViewById(R.id.display_list);
+ listSpinner = findViewById(R.id.display_list);
db = new DBHandler(this);
ArrayList listList = db.getAllLists();
@@ -121,11 +120,9 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
-
if (id == R.id.action_add) {
addWidget();
}
-
return super.onOptionsItemSelected(item);
}
diff --git a/app/src/main/java/com/ellenluo/minimaList/WidgetListProvider.java b/app/src/main/java/com/ellenluo/minimaList/WidgetListProvider.java
index 2fd3e69..06db023 100644
--- a/app/src/main/java/com/ellenluo/minimaList/WidgetListProvider.java
+++ b/app/src/main/java/com/ellenluo/minimaList/WidgetListProvider.java
@@ -1,11 +1,5 @@
package com.ellenluo.minimaList;
-/**
- * WidgetListProvider
- * Created by Ellen Luo
- * RemoteViewsFactory that populates a widget with tasks in the selected list using a custom row layout.
- */
-
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
@@ -24,6 +18,11 @@
import java.util.Date;
import java.util.Locale;
+/**
+ * WidgetListProvider
+ * Created by Ellen Luo
+ * RemoteViewsFactory that populates a widget with tasks in the selected list using a custom row layout.
+ */
class WidgetListProvider implements RemoteViewsService.RemoteViewsFactory {
private DBHandler db;
@@ -31,7 +30,7 @@ class WidgetListProvider implements RemoteViewsService.RemoteViewsFactory {
private static final int PREFERENCE_MODE_PRIVATE = 0;
private ArrayList taskList;
- private Context context = null;
+ private Context context;
private String list;
diff --git a/app/src/main/java/com/ellenluo/minimaList/WidgetProvider.java b/app/src/main/java/com/ellenluo/minimaList/WidgetProvider.java
index f0725cc..6d28000 100644
--- a/app/src/main/java/com/ellenluo/minimaList/WidgetProvider.java
+++ b/app/src/main/java/com/ellenluo/minimaList/WidgetProvider.java
@@ -1,11 +1,5 @@
package com.ellenluo.minimaList;
-/**
- * WidgetProvider
- * Created by Ellen Luo
- * AppWidgetProvider that creates and updates widgets.
- */
-
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
@@ -18,6 +12,11 @@
import android.support.v4.content.ContextCompat;
import android.widget.RemoteViews;
+/**
+ * WidgetProvider
+ * Created by Ellen Luo
+ * AppWidgetProvider that creates and updates widgets.
+ */
public class WidgetProvider extends AppWidgetProvider {
private static final int PREFERENCE_MODE_PRIVATE = 0;
@@ -25,7 +24,7 @@ public class WidgetProvider extends AppWidgetProvider {
@Override
public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(ACTION_SCHEDULED_UPDATE)) {
+ if (intent.getAction() != null && intent.getAction().equals(ACTION_SCHEDULED_UPDATE)) {
AppWidgetManager manager = AppWidgetManager.getInstance(context);
int[] ids = manager.getAppWidgetIds(new ComponentName(context, WidgetProvider.class));
onUpdate(context, manager, ids);
diff --git a/app/src/main/java/com/ellenluo/minimaList/WidgetService.java b/app/src/main/java/com/ellenluo/minimaList/WidgetService.java
index d128ac4..3a1b8a2 100644
--- a/app/src/main/java/com/ellenluo/minimaList/WidgetService.java
+++ b/app/src/main/java/com/ellenluo/minimaList/WidgetService.java
@@ -1,14 +1,13 @@
package com.ellenluo.minimaList;
+import android.content.Intent;
+import android.widget.RemoteViewsService;
+
/**
* WidgetService
* Created by Ellen Luo
* RemoteViewsService that calls WidgetListProvider to populate widgets.
*/
-
-import android.content.Intent;
-import android.widget.RemoteViewsService;
-
public class WidgetService extends RemoteViewsService {
@Override
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f295053..0f882ee 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -32,6 +32,7 @@
successfully removed
Deleting
Undo
+ %s %d, %d
Task:
@@ -43,6 +44,7 @@
List:
Complete?
at
+ %s at %s
Add List