diff --git a/.idea/misc.xml b/.idea/misc.xml
index 99202cc2..1dc74551 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,30 +5,31 @@
-
-
-
-
+
\ No newline at end of file
diff --git a/app/app.iml b/app/app.iml
index 2a197e74..61638d0f 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -50,13 +50,6 @@
-
-
-
-
-
-
-
@@ -64,6 +57,13 @@
+
+
+
+
+
+
+
@@ -71,13 +71,6 @@
-
-
-
-
-
-
-
@@ -85,31 +78,36 @@
+
+
+
+
+
+
+
-
+
+
-
-
-
+
-
+
-
@@ -122,8 +120,8 @@
-
+
diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestStoreRetrieveData.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestStoreRetrieveData.java
index f698fe54..9c904b47 100644
--- a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestStoreRetrieveData.java
+++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestStoreRetrieveData.java
@@ -27,6 +27,7 @@
import android.test.ActivityUnitTestCase;
import com.example.avjindersinghsekhon.minimaltodo.Main.MainActivity;
+import com.example.avjindersinghsekhon.minimaltodo.Main.MainFragment;
import com.example.avjindersinghsekhon.minimaltodo.Utility.StoreRetrieveData;
import com.example.avjindersinghsekhon.minimaltodo.Utility.ToDoItem;
@@ -42,7 +43,7 @@ public class TestStoreRetrieveData extends ActivityUnitTestCase {
private MainActivity mMainActivity;
private ArrayList mOriginalData;
- ArrayList mTestData;
+ private ArrayList mTestData;
public TestStoreRetrieveData() {
super(MainActivity.class);
@@ -168,6 +169,6 @@ public void testArrayListToJsonArrayConversion() {
private StoreRetrieveData getDataStorage() {
Context context = getInstrumentation().getTargetContext();
- return new StoreRetrieveData(context, MainActivity.FILENAME);
+ return new StoreRetrieveData(context, MainFragment.FILENAME);
}
}
diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainFragment.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainFragment.java
index 8577de1e..ffb52312 100644
--- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainFragment.java
+++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainFragment.java
@@ -1,7 +1,9 @@
package com.example.avjindersinghsekhon.minimaltodo.Main;
import android.app.AlarmManager;
+import android.app.NotificationManager;
import android.app.PendingIntent;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
@@ -35,6 +37,7 @@
import com.example.avjindersinghsekhon.minimaltodo.Analytics.AnalyticsApplication;
import com.example.avjindersinghsekhon.minimaltodo.AppDefault.AppDefaultFragment;
import com.example.avjindersinghsekhon.minimaltodo.R;
+import com.example.avjindersinghsekhon.minimaltodo.Reminder.ReminderActivity;
import com.example.avjindersinghsekhon.minimaltodo.Reminder.ReminderFragment;
import com.example.avjindersinghsekhon.minimaltodo.Settings.SettingsActivity;
import com.example.avjindersinghsekhon.minimaltodo.Utility.ItemTouchHelperClass;
@@ -49,6 +52,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
+import java.util.UUID;
import static android.app.Activity.RESULT_CANCELED;
import static android.content.Context.ALARM_SERVICE;
@@ -60,6 +64,7 @@ public class MainFragment extends AppDefaultFragment {
private ArrayList mToDoItemsArrayList;
private CoordinatorLayout mCoordLayout;
public static final String TODOITEM = "com.avjindersinghsekhon.com.avjindersinghsekhon.minimaltodo.MainActivity";
+ public static final String TAG = "MainFragment";
private MainFragment.BasicListAdapter adapter;
private static final int REQUEST_ID_TODO_ITEM = 100;
private ToDoItem mJustDeletedToDoItem;
@@ -385,6 +390,8 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (!existed) {
addToDataStore(item);
}
+// });
+
}
@@ -397,6 +404,7 @@ private AlarmManager getAlarmManager() {
private boolean doesPendingIntentExist(Intent i, int requestCode) {
PendingIntent pi = PendingIntent.getService(getContext(), requestCode, i, PendingIntent.FLAG_NO_CREATE);
return pi != null;
+
}
private void createAlarm(Intent i, int requestCode, long timeInMillis) {
@@ -407,6 +415,7 @@ private void createAlarm(Intent i, int requestCode, long timeInMillis) {
}
private void deleteAlarm(Intent i, int requestCode) {
+ Log.d(TAG, "deleteAlarm: called");
if (doesPendingIntentExist(i, requestCode)) {
PendingIntent pi = PendingIntent.getService(getContext(), requestCode, i, PendingIntent.FLAG_NO_CREATE);
pi.cancel();
@@ -415,6 +424,17 @@ private void deleteAlarm(Intent i, int requestCode) {
}
}
+ private void deleteNotification(UUID mTodoUUID) {
+ int NOTIFICATION_ID = mTodoUUID.hashCode();
+ Intent notificationIntent = new Intent(getContext(),ReminderActivity.class);
+ PendingIntent i = PendingIntent.getActivity(getContext(), NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_NO_CREATE);
+
+ if (i != null){
+ NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.cancel(NOTIFICATION_ID);
+ }
+ }
+
private void addToDataStore(ToDoItem item) {
mToDoItemsArrayList.add(item);
adapter.notifyItemInserted(mToDoItemsArrayList.size() - 1);
@@ -431,8 +451,8 @@ public void makeUpItems(ArrayList items, int len) {
}
}
-
public class BasicListAdapter extends RecyclerView.Adapter implements ItemTouchHelperClass.ItemTouchHelperAdapter {
+
private ArrayList items;
@Override
@@ -451,6 +471,7 @@ public void onItemMoved(int fromPosition, int toPosition) {
@Override
public void onItemRemoved(final int position) {
+ Log.d(TAG, "onItemRemoved: position: "+position);
//Remove this line if not using Google Analytics
app.send(this, "Action", "Swiped Todo Away");
@@ -458,6 +479,7 @@ public void onItemRemoved(final int position) {
mIndexOfDeletedToDoItem = position;
Intent i = new Intent(getContext(), TodoNotificationService.class);
deleteAlarm(i, mJustDeletedToDoItem.getIdentifier().hashCode());
+ deleteNotification(mJustDeletedToDoItem.getIdentifier());
notifyItemRemoved(position);
// String toShow = (mJustDeletedToDoItem.getToDoText().length()>20)?mJustDeletedToDoItem.getToDoText().substring(0, 20)+"...":mJustDeletedToDoItem.getToDoText();
@@ -559,7 +581,6 @@ public int getItemCount() {
this.items = items;
}
-
@SuppressWarnings("deprecation")
public class ViewHolder extends RecyclerView.ViewHolder {
@@ -569,6 +590,7 @@ public class ViewHolder extends RecyclerView.ViewHolder {
// TextView mColorTextView;
ImageView mColorImageView;
TextView mTimeTextView;
+
// int color = -1;
public ViewHolder(View v) {
@@ -590,8 +612,8 @@ public void onClick(View v) {
linearLayout = (LinearLayout) v.findViewById(R.id.listItemLinearLayout);
}
-
}
+
}
//Used when using custom fonts
diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/DeleteNotificationService.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/DeleteNotificationService.java
index 67d98657..3398ee14 100644
--- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/DeleteNotificationService.java
+++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/DeleteNotificationService.java
@@ -11,6 +11,7 @@
public class DeleteNotificationService extends IntentService {
+ public static final String TAG = "DeleteNotificationService";
private StoreRetrieveData storeRetrieveData;
private ArrayList mToDoItems;
private ToDoItem mItem;
diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ToDoItem.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ToDoItem.java
index 46ca6ba3..94904022 100644
--- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ToDoItem.java
+++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ToDoItem.java
@@ -35,6 +35,15 @@ public ToDoItem(String todoBody,String tododescription, boolean hasReminder, Da
mTodoIdentifier = UUID.randomUUID();
}
+ public ToDoItem(String todoBody, boolean hasReminder, Date todoDate){
+ mToDoText = todoBody;
+ mHasReminder = hasReminder;
+ mToDoDate = todoDate;
+ mTodoColor = 1677725;
+ mToDoDescription = "";
+ mTodoIdentifier = UUID.randomUUID();
+ }
+
public ToDoItem(JSONObject jsonObject) throws JSONException {
mToDoText = jsonObject.getString(TODOTEXT);
mToDoDescription = jsonObject.getString(TODODESCRIPTION);
diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/TodoNotificationService.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/TodoNotificationService.java
index 87f379bb..8c710bee 100644
--- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/TodoNotificationService.java
+++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/TodoNotificationService.java
@@ -18,6 +18,7 @@ public class TodoNotificationService extends IntentService {
public static final String TODOUUID = "com.avjindersekhon.todonotificationserviceuuid";
private String mTodoText;
private UUID mTodoUUID;
+ private int mUUIDHash;
private Context mContext;
public TodoNotificationService() {
@@ -28,6 +29,7 @@ public TodoNotificationService() {
protected void onHandleIntent(Intent intent) {
mTodoText = intent.getStringExtra(TODOTEXT);
mTodoUUID = (UUID) intent.getSerializableExtra(TODOUUID);
+ mUUIDHash = mTodoUUID.hashCode();
Log.d("OskarSchindler", "onHandleIntent called");
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
@@ -44,7 +46,7 @@ protected void onHandleIntent(Intent intent) {
.setContentIntent(PendingIntent.getActivity(this, mTodoUUID.hashCode(), i, PendingIntent.FLAG_UPDATE_CURRENT))
.build();
- manager.notify(100, notification);
+ manager.notify(mUUIDHash, notification);
// Uri defaultRingone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
// MediaPlayer mp = new MediaPlayer();
// try{