Commit 8c87a0cf authored by RAUSHAN RAJ's avatar RAUSHAN RAJ

Firebase auth and data pushing working

parent e9ed32f3
# Remindly # Remindly
Android reminder app Android reminderDO app
Features Features
------- -------
- Material Design UI - Material Design UI
- Repeating reminders. Set intervals in minutes, hours, days, weeks and months - Repeating reminderDOS. Set intervals in minutes, hours, days, weeks and months
- Completely free and ad-free - Completely free and ad-free
......
...@@ -7,7 +7,7 @@ android { ...@@ -7,7 +7,7 @@ android {
buildToolsVersion "29.0.2" buildToolsVersion "29.0.2"
defaultConfig { defaultConfig {
applicationId "com.blanyal.remindme" applicationId "com.sudogeeks.talking_reminder"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 29 targetSdkVersion 29
versionCode 2 versionCode 2
...@@ -41,13 +41,13 @@ dependencies { ...@@ -41,13 +41,13 @@ dependencies {
implementation 'org.jetbrains:annotations-java5:15.0' implementation 'org.jetbrains:annotations-java5:15.0'
// add the Firebase SDK Dependencies // add the Firebase SDK Dependencies
// implementation 'com.google.firebase:firebase-analytics:17.2.0' implementation 'com.google.firebase:firebase-analytics:17.2.0'
// implementation 'com.google.firebase:firebase-database:19.2.0' implementation 'com.google.firebase:firebase-database:19.2.0'
// implementation 'com.google.firebase:firebase-auth:19.1.0' implementation 'com.google.firebase:firebase-auth:19.1.0'
// implementation 'com.firebaseui:firebase-ui-auth:6.0.2' implementation 'com.firebaseui:firebase-ui-auth:6.0.2'
// implementation 'com.google.firebase:firebase-appindexing:19.0.0' // implementation 'com.google.firebase:firebase-appindexing:19.0.0'
// implementation 'com.google.firebase:firebase-firestore:21.2.0' // implementation 'com.google.firebase:firebase-firestore:21.2.0'
// implementation 'com.google.gms:google-services:4.3.2' // implementation 'com.google.gms:google-services:4.3.2'
// implementation 'com.google.firebase:firebase-storage:19.1.0' // implementation 'com.google.firebase:firebase-storage:19.1.0'
} }
//apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
\ No newline at end of file \ No newline at end of file
...@@ -14,19 +14,33 @@ import androidx.core.app.NotificationCompat; ...@@ -14,19 +14,33 @@ import androidx.core.app.NotificationCompat;
import java.util.Calendar; import java.util.Calendar;
/** \brief A class to do something
*
* description class ke andar
*
*
*
*
*/
public class AlarmReceiver extends BroadcastReceiver { public class AlarmReceiver extends BroadcastReceiver {
AlarmManager mAlarmManager; AlarmManager mAlarmManager;
PendingIntent mPendingIntent; PendingIntent mPendingIntent;
@Override @Override
/** description
* @param context: what context is
* @return void
*
*
*/
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
int mReceivedID = Integer.parseInt(intent.getStringExtra(ReminderEditActivity.EXTRA_REMINDER_ID)); int mReceivedID = Integer.parseInt(intent.getStringExtra(ReminderEditActivity.EXTRA_REMINDER_ID));
//Get notification title from Reminder Database //Get notification title from ReminderDO Database
ReminderDatabase rb = new ReminderDatabase(context); ReminderDatabase rb = new ReminderDatabase(context);
Reminder reminder = rb.getReminder(mReceivedID); ReminderDO reminderDO = rb.getReminder(mReceivedID);
String mTitle = reminder.getTitle(); String mTitle = reminderDO.getTitle();
// Create intent to open ReminderEditActivity on notification click // Create intent to open ReminderEditActivity on notification click
...@@ -80,10 +94,16 @@ public class AlarmReceiver extends BroadcastReceiver { ...@@ -80,10 +94,16 @@ public class AlarmReceiver extends BroadcastReceiver {
} }
/**
*
* @param context
* @param calendar
* @param ID
*/
public void setAlarm(Context context, Calendar calendar, int ID) { public void setAlarm(Context context, Calendar calendar, int ID) {
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// Put Reminder ID in Intent Extra // Put ReminderDO ID in Intent Extra
Intent intent = new Intent(context, AlarmReceiver.class); Intent intent = new Intent(context, AlarmReceiver.class);
intent.putExtra(ReminderEditActivity.EXTRA_REMINDER_ID, Integer.toString(ID)); intent.putExtra(ReminderEditActivity.EXTRA_REMINDER_ID, Integer.toString(ID));
mPendingIntent = PendingIntent.getBroadcast(context, ID, intent, PendingIntent.FLAG_CANCEL_CURRENT); mPendingIntent = PendingIntent.getBroadcast(context, ID, intent, PendingIntent.FLAG_CANCEL_CURRENT);
...@@ -109,7 +129,7 @@ public class AlarmReceiver extends BroadcastReceiver { ...@@ -109,7 +129,7 @@ public class AlarmReceiver extends BroadcastReceiver {
public void setRepeatAlarm(Context context, Calendar calendar, int ID, long RepeatTime) { public void setRepeatAlarm(Context context, Calendar calendar, int ID, long RepeatTime) {
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// Put Reminder ID in Intent Extra // Put ReminderDO ID in Intent Extra
Intent intent = new Intent(context, AlarmReceiver.class); Intent intent = new Intent(context, AlarmReceiver.class);
intent.putExtra(ReminderEditActivity.EXTRA_REMINDER_ID, Integer.toString(ID)); intent.putExtra(ReminderEditActivity.EXTRA_REMINDER_ID, Integer.toString(ID));
mPendingIntent = PendingIntent.getBroadcast(context, ID, intent, PendingIntent.FLAG_CANCEL_CURRENT); mPendingIntent = PendingIntent.getBroadcast(context, ID, intent, PendingIntent.FLAG_CANCEL_CURRENT);
...@@ -135,7 +155,7 @@ public class AlarmReceiver extends BroadcastReceiver { ...@@ -135,7 +155,7 @@ public class AlarmReceiver extends BroadcastReceiver {
public void cancelAlarm(Context context, int ID) { public void cancelAlarm(Context context, int ID) {
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// Cancel Alarm using Reminder ID // Cancel Alarm using ReminderDO ID
mPendingIntent = PendingIntent.getBroadcast(context, ID, new Intent(context, AlarmReceiver.class), 0); mPendingIntent = PendingIntent.getBroadcast(context, ID, new Intent(context, AlarmReceiver.class), 0);
mAlarmManager.cancel(mPendingIntent); mAlarmManager.cancel(mPendingIntent);
......
...@@ -38,9 +38,9 @@ public class BootReceiver extends BroadcastReceiver { ...@@ -38,9 +38,9 @@ public class BootReceiver extends BroadcastReceiver {
mCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance();
mAlarmReceiver = new AlarmReceiver(); mAlarmReceiver = new AlarmReceiver();
List<Reminder> reminders = rb.getAllReminders(); List<ReminderDO> reminderDOS = rb.getAllReminders();
for (Reminder rm : reminders) { for (ReminderDO rm : reminderDOS) {
mReceivedID = rm.getID(); mReceivedID = rm.getID();
mRepeat = rm.getRepeat(); mRepeat = rm.getRepeat();
mRepeatNo = rm.getRepeatNo(); mRepeatNo = rm.getRepeatNo();
......
...@@ -36,10 +36,10 @@ public class NotificationHelper extends ContextWrapper { ...@@ -36,10 +36,10 @@ public class NotificationHelper extends ContextWrapper {
} }
int mReceivedID = Integer.parseInt(intent.getStringExtra(ReminderEditActivity.EXTRA_REMINDER_ID)); int mReceivedID = Integer.parseInt(intent.getStringExtra(ReminderEditActivity.EXTRA_REMINDER_ID));
// //
//Get notification title from Reminder Database //Get notification title from ReminderDO Database
ReminderDatabase rb = new ReminderDatabase(base); ReminderDatabase rb = new ReminderDatabase(base);
Reminder reminder = rb.getReminder(mReceivedID); ReminderDO reminderDO = rb.getReminder(mReceivedID);
mTitle = reminder.getTitle(); mTitle = reminderDO.getTitle();
// Create intent to open ReminderEditActivity on notification click // Create intent to open ReminderEditActivity on notification click
Intent editIntent = new Intent(base, ReminderEditActivity.class); Intent editIntent = new Intent(base, ReminderEditActivity.class);
......
...@@ -31,6 +31,10 @@ import androidx.core.content.ContextCompat; ...@@ -31,6 +31,10 @@ import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
...@@ -71,6 +75,10 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -71,6 +75,10 @@ public class ReminderAddActivity extends AppCompatActivity {
private String mRepeatType; private String mRepeatType;
private String mActive; private String mActive;
private FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
private FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
private DatabaseReference dbReference = firebaseDatabase.getReference().child("reminders");
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -109,7 +117,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -109,7 +117,7 @@ public class ReminderAddActivity extends AppCompatActivity {
mDate = mDay + "/" + mMonth + "/" + mYear; mDate = mDay + "/" + mMonth + "/" + mYear;
mTime = mHour + ":" + mMinute; mTime = mHour + ":" + mMinute;
// Setup Reminder Title EditText // Setup ReminderDO Title EditText
mTitleText.addTextChangedListener(new TextWatcher() { mTitleText.addTextChangedListener(new TextWatcher() {
@Override @Override
...@@ -358,16 +366,16 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -358,16 +366,16 @@ public class ReminderAddActivity extends AppCompatActivity {
mRepeatNoText = (TextView) findViewById(R.id.set_repeat_no); mRepeatNoText = (TextView) findViewById(R.id.set_repeat_no);
mRepeatTypeText = (TextView) findViewById(R.id.set_repeat_type); mRepeatTypeText = (TextView) findViewById(R.id.set_repeat_type);
*/ */
Reminder talkingReminder = new Reminder(); ReminderDO talkingReminderDO = new ReminderDO();
talkingReminder.setTitle(mTitle); talkingReminderDO.setTitle(mTitle);
talkingReminder.setDate(mDate); talkingReminderDO.setDate(mDate);
talkingReminder.setTime(mTime); talkingReminderDO.setTime(mTime);
talkingReminder.setRepeat(mRepeat); talkingReminderDO.setRepeat(mRepeat);
talkingReminder.setRepeatNo(mRepeatNo); talkingReminderDO.setRepeatNo(mRepeatNo);
talkingReminder.setRepeatType(mRepeatType); talkingReminderDO.setRepeatType(mRepeatType);
Gson gson = new GsonBuilder().setPrettyPrinting().create(); Gson gson = new GsonBuilder().setPrettyPrinting().create();
//String fileName=Environment.getExternalStorageDirectory()+"talkingReminder.json"; //String fileName=Environment.getExternalStorageDirectory()+"talkingReminderDO.json";
//First write the data to a temporary file //First write the data to a temporary file
FileOutputStream outputStream; FileOutputStream outputStream;
...@@ -384,7 +392,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -384,7 +392,7 @@ public class ReminderAddActivity extends AppCompatActivity {
} }
try { try {
String fileContents = gson.toJson(talkingReminder); String fileContents = gson.toJson(talkingReminderDO);
outputStream = openFileOutput(filename, Context.MODE_PRIVATE); outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
outputStream.write(fileContents.getBytes()); outputStream.write(fileContents.getBytes());
outputStream.close(); outputStream.close();
...@@ -403,8 +411,16 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -403,8 +411,16 @@ public class ReminderAddActivity extends AppCompatActivity {
public void saveReminder() { public void saveReminder() {
ReminderDatabase rb = new ReminderDatabase(this); ReminderDatabase rb = new ReminderDatabase(this);
// Creating Reminder // Creating ReminderDO
int ID = rb.addReminder(new Reminder(mTitle, mDate, mTime, mRepeat, mRepeatNo, mRepeatType, mActive)); int ID = rb.addReminder(new ReminderDO(mTitle, mDate, mTime, mRepeat, mRepeatNo, mRepeatType, mActive));
//Storing Reminders in firebase database
ReminderDO reminderDO = new ReminderDO(mTitle, mDate, mTime, mRepeat, mRepeatNo, mRepeatType, mActive);
FirebaseUser user = firebaseAuth.getCurrentUser();
reminderDO.setOwnerID(user.getEmail());
reminderDO.setReceiverID("null");
dbReference.child(user.getUid()).push().setValue(reminderDO);
// Set up calender for creating the notification // Set up calender for creating the notification
mCalendar.set(Calendar.MONTH, --mMonth); mCalendar.set(Calendar.MONTH, --mMonth);
...@@ -473,7 +489,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -473,7 +489,7 @@ public class ReminderAddActivity extends AppCompatActivity {
mTitleText.setText(mTitle); mTitleText.setText(mTitle);
if (mTitleText.getText().toString().trim().length() == 0) if (mTitleText.getText().toString().trim().length() == 0)
mTitleText.setError("Reminder Title cannot be blank!"); mTitleText.setError("ReminderDO Title cannot be blank!");
else { else {
saveReminder(); saveReminder();
......
package com.sudogeeks.talking_reminder; package com.sudogeeks.talking_reminder;
// Reminder class import lombok.Data;
public class Reminder { import lombok.EqualsAndHashCode;
import lombok.ToString;
// ReminderDO class
//@Data
@Data
public class ReminderDO {
private int mID; private int mID;
private String mTitle; private String mTitle;
private String mDate; private String mDate;
...@@ -10,9 +16,11 @@ public class Reminder { ...@@ -10,9 +16,11 @@ public class Reminder {
private String mRepeatNo; private String mRepeatNo;
private String mRepeatType; private String mRepeatType;
private String mActive; private String mActive;
private String ownerID = null; //Email Id of the owner/creater of the reminder
private String receiverID = null; //Email Id of the receiver of the reminder;
public Reminder(int ID, String Title, String Date, String Time, String Repeat, String RepeatNo, String RepeatType, String Active) { public ReminderDO(int ID, String Title, String Date, String Time, String Repeat, String RepeatNo, String RepeatType, String Active) {
mID = ID; mID = ID;
mTitle = Title; mTitle = Title;
mDate = Date; mDate = Date;
...@@ -23,7 +31,7 @@ public class Reminder { ...@@ -23,7 +31,7 @@ public class Reminder {
mActive = Active; mActive = Active;
} }
public Reminder(String Title, String Date, String Time, String Repeat, String RepeatNo, String RepeatType, String Active) { public ReminderDO(String Title, String Date, String Time, String Repeat, String RepeatNo, String RepeatType, String Active) {
mTitle = Title; mTitle = Title;
mDate = Date; mDate = Date;
mTime = Time; mTime = Time;
...@@ -33,7 +41,23 @@ public class Reminder { ...@@ -33,7 +41,23 @@ public class Reminder {
mActive = Active; mActive = Active;
} }
public Reminder() { ReminderDO() {
}
public String getOwnerID() {
return ownerID;
}
public void setOwnerID(String ownerID) {
this.ownerID = ownerID;
}
public String getReceiverID() {
return receiverID;
}
public void setReceiverID(String receiverID) {
this.receiverID = receiverID;
} }
public int getID() { public int getID() {
......
...@@ -62,18 +62,18 @@ public class ReminderDatabase extends SQLiteOpenHelper { ...@@ -62,18 +62,18 @@ public class ReminderDatabase extends SQLiteOpenHelper {
onCreate(db); onCreate(db);
} }
// Adding new Reminder // Adding new ReminderDO
public int addReminder(Reminder reminder) { public int addReminder(ReminderDO reminderDO) {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(KEY_TITLE, reminder.getTitle()); values.put(KEY_TITLE, reminderDO.getTitle());
values.put(KEY_DATE, reminder.getDate()); values.put(KEY_DATE, reminderDO.getDate());
values.put(KEY_TIME, reminder.getTime()); values.put(KEY_TIME, reminderDO.getTime());
values.put(KEY_REPEAT, reminder.getRepeat()); values.put(KEY_REPEAT, reminderDO.getRepeat());
values.put(KEY_REPEAT_NO, reminder.getRepeatNo()); values.put(KEY_REPEAT_NO, reminderDO.getRepeatNo());
values.put(KEY_REPEAT_TYPE, reminder.getRepeatType()); values.put(KEY_REPEAT_TYPE, reminderDO.getRepeatType());
values.put(KEY_ACTIVE, reminder.getActive()); values.put(KEY_ACTIVE, reminderDO.getActive());
// Inserting Row // Inserting Row
long ID = db.insert(TABLE_REMINDERS, null, values); long ID = db.insert(TABLE_REMINDERS, null, values);
...@@ -81,8 +81,8 @@ public class ReminderDatabase extends SQLiteOpenHelper { ...@@ -81,8 +81,8 @@ public class ReminderDatabase extends SQLiteOpenHelper {
return (int) ID; return (int) ID;
} }
// Getting single Reminder // Getting single ReminderDO
public Reminder getReminder(int id) { public ReminderDO getReminder(int id) {
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_REMINDERS, new String[] Cursor cursor = db.query(TABLE_REMINDERS, new String[]
...@@ -102,16 +102,16 @@ public class ReminderDatabase extends SQLiteOpenHelper { ...@@ -102,16 +102,16 @@ public class ReminderDatabase extends SQLiteOpenHelper {
if (cursor != null) if (cursor != null)
cursor.moveToFirst(); cursor.moveToFirst();
Reminder reminder = new Reminder(Integer.parseInt(cursor.getString(0)), cursor.getString(1), ReminderDO reminderDO = new ReminderDO(Integer.parseInt(cursor.getString(0)), cursor.getString(1),
cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(2), cursor.getString(3), cursor.getString(4),
cursor.getString(5), cursor.getString(6), cursor.getString(7)); cursor.getString(5), cursor.getString(6), cursor.getString(7));
return reminder; return reminderDO;
} }
// Getting all Reminders // Getting all Reminders
public List<Reminder> getAllReminders() { public List<ReminderDO> getAllReminders() {
List<Reminder> reminderList = new ArrayList<>(); List<ReminderDO> reminderDOList = new ArrayList<>();
// Select all Query // Select all Query
String selectQuery = "SELECT * FROM " + TABLE_REMINDERS; String selectQuery = "SELECT * FROM " + TABLE_REMINDERS;
...@@ -122,21 +122,21 @@ public class ReminderDatabase extends SQLiteOpenHelper { ...@@ -122,21 +122,21 @@ public class ReminderDatabase extends SQLiteOpenHelper {
// Looping through all rows and adding to list // Looping through all rows and adding to list
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
do { do {
Reminder reminder = new Reminder(); ReminderDO reminderDO = new ReminderDO();
reminder.setID(Integer.parseInt(cursor.getString(0))); reminderDO.setID(Integer.parseInt(cursor.getString(0)));
reminder.setTitle(cursor.getString(1)); reminderDO.setTitle(cursor.getString(1));
reminder.setDate(cursor.getString(2)); reminderDO.setDate(cursor.getString(2));
reminder.setTime(cursor.getString(3)); reminderDO.setTime(cursor.getString(3));
reminder.setRepeat(cursor.getString(4)); reminderDO.setRepeat(cursor.getString(4));
reminder.setRepeatNo(cursor.getString(5)); reminderDO.setRepeatNo(cursor.getString(5));
reminder.setRepeatType(cursor.getString(6)); reminderDO.setRepeatType(cursor.getString(6));
reminder.setActive(cursor.getString(7)); reminderDO.setActive(cursor.getString(7));
// Adding Reminders to list // Adding Reminders to list
reminderList.add(reminder); reminderDOList.add(reminderDO);
} while (cursor.moveToNext()); } while (cursor.moveToNext());
} }
return reminderList; return reminderDOList;
} }
// Getting Reminders Count // Getting Reminders Count
...@@ -149,28 +149,28 @@ public class ReminderDatabase extends SQLiteOpenHelper { ...@@ -149,28 +149,28 @@ public class ReminderDatabase extends SQLiteOpenHelper {
return cursor.getCount(); return cursor.getCount();
} }
// Updating single Reminder // Updating single ReminderDO
public int updateReminder(Reminder reminder) { public int updateReminder(ReminderDO reminderDO) {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(KEY_TITLE, reminder.getTitle()); values.put(KEY_TITLE, reminderDO.getTitle());
values.put(KEY_DATE, reminder.getDate()); values.put(KEY_DATE, reminderDO.getDate());
values.put(KEY_TIME, reminder.getTime()); values.put(KEY_TIME, reminderDO.getTime());
values.put(KEY_REPEAT, reminder.getRepeat()); values.put(KEY_REPEAT, reminderDO.getRepeat());
values.put(KEY_REPEAT_NO, reminder.getRepeatNo()); values.put(KEY_REPEAT_NO, reminderDO.getRepeatNo());
values.put(KEY_REPEAT_TYPE, reminder.getRepeatType()); values.put(KEY_REPEAT_TYPE, reminderDO.getRepeatType());
values.put(KEY_ACTIVE, reminder.getActive()); values.put(KEY_ACTIVE, reminderDO.getActive());
// Updating row // Updating row
return db.update(TABLE_REMINDERS, values, KEY_ID + "=?", return db.update(TABLE_REMINDERS, values, KEY_ID + "=?",
new String[]{String.valueOf(reminder.getID())}); new String[]{String.valueOf(reminderDO.getID())});
} }
// Deleting single Reminder // Deleting single ReminderDO
public void deleteReminder(Reminder reminder) { public void deleteReminder(ReminderDO reminderDO) {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_REMINDERS, KEY_ID + "=?", db.delete(TABLE_REMINDERS, KEY_ID + "=?",
new String[]{String.valueOf(reminder.getID())}); new String[]{String.valueOf(reminderDO.getID())});
db.close(); db.close();
} }
} }
...@@ -64,7 +64,7 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -64,7 +64,7 @@ public class ReminderEditActivity extends AppCompatActivity {
private int mYear, mMonth, mHour, mMinute, mDay; private int mYear, mMonth, mHour, mMinute, mDay;
private long mRepeatTime; private long mRepeatTime;
private Calendar mCalendar; private Calendar mCalendar;
private Reminder mReceivedReminder; private ReminderDO mReceivedReminderDO;
private ReminderDatabase rb; private ReminderDatabase rb;
private AlarmReceiver mAlarmReceiver; private AlarmReceiver mAlarmReceiver;
...@@ -91,7 +91,7 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -91,7 +91,7 @@ public class ReminderEditActivity extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setHomeButtonEnabled(true);
// Setup Reminder Title EditText // Setup ReminderDO Title EditText
mTitleText.addTextChangedListener(new TextWatcher() { mTitleText.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
...@@ -116,24 +116,24 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -116,24 +116,24 @@ public class ReminderEditActivity extends AppCompatActivity {
/*Intent intent = getIntent(); /*Intent intent = getIntent();
if(intent.getType().equals("text/"+Utility.FILE_EXTENSION)){ if(intent.getType().equals("text/"+Utility.FILE_EXTENSION)){
mReceivedReminder.setTitle(intent.getStringExtra("mTitle")); mReceivedReminderDO.setTitle(intent.getStringExtra("mTitle"));
System.out.println("**********************************"); System.out.println("**********************************");
System.out.println(mReceivedReminder.getTitle()); System.out.println(mReceivedReminderDO.getTitle());
System.out.println("**********************************"); System.out.println("**********************************");
} }
else {*/ else {*/
// Get reminder id from intent // Get reminder id from intent
mReceivedReminder = rb.getReminder(mReceivedID); mReceivedReminderDO = rb.getReminder(mReceivedID);
//} //}
// Get values from reminder // Get values from reminder
mTitle = mReceivedReminder.getTitle(); mTitle = mReceivedReminderDO.getTitle();
mDate = mReceivedReminder.getDate(); mDate = mReceivedReminderDO.getDate();
mTime = mReceivedReminder.getTime(); mTime = mReceivedReminderDO.getTime();
mRepeat = mReceivedReminder.getRepeat(); mRepeat = mReceivedReminderDO.getRepeat();
mRepeatNo = mReceivedReminder.getRepeatNo(); mRepeatNo = mReceivedReminderDO.getRepeatNo();
mRepeatType = mReceivedReminder.getRepeatType(); mRepeatType = mReceivedReminderDO.getRepeatType();
mActive = mReceivedReminder.getActive(); mActive = mReceivedReminderDO.getActive();
// Setup TextViews using reminder values // Setup TextViews using reminder values
mTitleText.setText(mTitle); mTitleText.setText(mTitle);
...@@ -381,16 +381,16 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -381,16 +381,16 @@ public class ReminderEditActivity extends AppCompatActivity {
// On clicking the update button // On clicking the update button
public void updateReminder() { public void updateReminder() {
// Set new values in the reminder // Set new values in the reminder
mReceivedReminder.setTitle(mTitle); mReceivedReminderDO.setTitle(mTitle);
mReceivedReminder.setDate(mDate); mReceivedReminderDO.setDate(mDate);
mReceivedReminder.setTime(mTime); mReceivedReminderDO.setTime(mTime);
mReceivedReminder.setRepeat(mRepeat); mReceivedReminderDO.setRepeat(mRepeat);
mReceivedReminder.setRepeatNo(mRepeatNo); mReceivedReminderDO.setRepeatNo(mRepeatNo);
mReceivedReminder.setRepeatType(mRepeatType); mReceivedReminderDO.setRepeatType(mRepeatType);
mReceivedReminder.setActive(mActive); mReceivedReminderDO.setActive(mActive);
// Update reminder // Update reminder
rb.updateReminder(mReceivedReminder); rb.updateReminder(mReceivedReminderDO);
// Set up calender for creating the notification // Set up calender for creating the notification
mCalendar.set(Calendar.MONTH, --mMonth); mCalendar.set(Calendar.MONTH, --mMonth);
...@@ -461,7 +461,7 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -461,7 +461,7 @@ public class ReminderEditActivity extends AppCompatActivity {
mTitleText.setText(mTitle); mTitleText.setText(mTitle);
if (mTitleText.getText().toString().length() == 0) if (mTitleText.getText().toString().length() == 0)
mTitleText.setError("Reminder Title cannot be blank!"); mTitleText.setError("ReminderDO Title cannot be blank!");
else { else {
updateReminder(); updateReminder();
......
...@@ -75,7 +75,7 @@ public class ReminderReceiveActivity extends AppCompatActivity { ...@@ -75,7 +75,7 @@ public class ReminderReceiveActivity extends AppCompatActivity {
try { try {
JSONObject obj = new JSONObject(reminderJson.toString()); JSONObject obj = new JSONObject(reminderJson.toString());
//Reminder talkingReminder=new Reminder(); //ReminderDO talkingReminder=new ReminderDO();
mTitleText = findViewById(R.id.reminder_title); mTitleText = findViewById(R.id.reminder_title);
mDateText = findViewById(R.id.set_date); mDateText = findViewById(R.id.set_date);
mTimeText = findViewById(R.id.set_time); mTimeText = findViewById(R.id.set_time);
...@@ -102,7 +102,7 @@ public class ReminderReceiveActivity extends AppCompatActivity { ...@@ -102,7 +102,7 @@ public class ReminderReceiveActivity extends AppCompatActivity {
/*Intent senderIntent = new Intent(context, ReminderEditActivity.class); /*Intent senderIntent = new Intent(context, ReminderEditActivity.class);
senderIntent.putExtra("received", true); senderIntent.putExtra("received", true);
senderIntent.putExtra("mTitle", "First Receive Reminder test"); senderIntent.putExtra("mTitle", "First Receive ReminderDO test");
startActivity(senderIntent);*/ startActivity(senderIntent);*/
} }
} }
...@@ -110,8 +110,8 @@ public class ReminderReceiveActivity extends AppCompatActivity { ...@@ -110,8 +110,8 @@ public class ReminderReceiveActivity extends AppCompatActivity {
public void saveSendReminder() { public void saveSendReminder() {
ReminderDatabase rb = new ReminderDatabase(this); ReminderDatabase rb = new ReminderDatabase(this);
// Creating Reminder // Creating ReminderDO
int ID = rb.addReminder(new Reminder(mTitleText.getText().toString(), mDateText.getText().toString(), mTimeText.getText().toString(), mRepeat, mRepeatNoText.getText().toString(), mRepeatTypeText.getText().toString(), mActive)); int ID = rb.addReminder(new ReminderDO(mTitleText.getText().toString(), mDateText.getText().toString(), mTimeText.getText().toString(), mRepeat, mRepeatNoText.getText().toString(), mRepeatTypeText.getText().toString(), mActive));
// Set up calender for creating the notification // Set up calender for creating the notification
......
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
tools:context="com.blanyal.talking_reminder.MainActivity"> tools:context="com.sudogeeks.talking_reminder.MainActivity">
<item
<!-- <item android:id="@+id/action_licenses"--> android:id="@+id/sign_out"
<!-- android:title="@string/title_activity_licenses"--> android:orderInCategory="100"
<!-- app:showAsAction="never"/>--> android:title="@string/sign_out"
app:showAsAction="never" />
</menu> </menu>
\ No newline at end of file
...@@ -3,4 +3,6 @@ ...@@ -3,4 +3,6 @@
<color name="primary">#008577</color> <color name="primary">#008577</color>
<color name="primary_dark">#00574B</color> <color name="primary_dark">#00574B</color>
<color name="accent">#D81B60</color> <color name="accent">#D81B60</color>
<color name="textheader">#ffffff</color>
<color name="textbody">#000000</color>
</resources> </resources>
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<string name="action_discard_reminder">Discard Reminder</string> <string name="action_discard_reminder">Discard Reminder</string>
<string name="action_save_reminder">Save Reminder</string> <string name="action_save_reminder">Save Reminder</string>
<string name="no_reminders">Click on the plus button below to begin creating your reminders!</string> <string name="no_reminders">Click on the plus button below to begin creating your reminderDOS!</string>
<string name="sign_out">sign_out</string>
</resources> </resources>
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base"/> <!-- <style name="AppTheme" parent="AppTheme.Base"/>-->
<style name="AppTheme.NoActionBar"> <style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
...@@ -17,5 +17,4 @@ ...@@ -17,5 +17,4 @@
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
<item name="windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>
</style> </style>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment