diff --git a/app/app.iml b/app/app.iml
index a262149..e3c8e19 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -87,6 +87,7 @@
+
diff --git a/app/build.gradle b/app/build.gradle
index d97354a..cd7a62d 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -24,4 +24,6 @@ dependencies {
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:recyclerview-v7:22.0.0'
compile 'com.getbase:floatingactionbutton:1.9.0'
+ compile 'com.wdullaer:materialdatetimepicker:1.2.1'
+
}
diff --git a/app/src/main/java/com/blanyal/remindme/AddReminder.java b/app/src/main/java/com/blanyal/remindme/AddReminder.java
index b5243aa..800af06 100644
--- a/app/src/main/java/com/blanyal/remindme/AddReminder.java
+++ b/app/src/main/java/com/blanyal/remindme/AddReminder.java
@@ -23,13 +23,38 @@
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
+import android.text.Editable;
+import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+import com.getbase.floatingactionbutton.FloatingActionButton;
+import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
+import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout;
+import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
-public class AddReminder extends ActionBarActivity {
+import java.util.Calendar;
+
+
+public class AddReminder extends ActionBarActivity implements
+ TimePickerDialog.OnTimeSetListener,
+ DatePickerDialog.OnDateSetListener{
private Toolbar mToolbar;
+ private EditText mReminderText;
+ private TextView mDateText, mTimeText, mRepeatText;
+ private FloatingActionButton mFAB1;
+ private FloatingActionButton mFAB2;
+ private Calendar mCalendar;
+ private int mYear, mMonth, mHour, mMinute, mDay;
+ private String mTitle;
+ private String mTime;
+ private String mDate;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -38,29 +63,135 @@ protected void onCreate(Bundle savedInstanceState) {
mToolbar = (Toolbar) findViewById(R.id.toolbar);
- mToolbar.setTitle(R.string.title_activity_add_reminder);
+ mFAB1 = (FloatingActionButton) findViewById(R.id.starred1);
+ mFAB2 = (FloatingActionButton) findViewById(R.id.starred2);
+ mReminderText = (EditText) findViewById(R.id.reminder_title);
+ mDateText = (TextView) findViewById(R.id.set_date);
+ mTimeText = (TextView) findViewById(R.id.set_time);
+ mRepeatText = (TextView) findViewById(R.id.set_repeat);
+
+
+ setSupportActionBar(mToolbar);
+ getSupportActionBar().setTitle(R.string.title_activity_add_reminder);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setHomeButtonEnabled(true);
+
+
+ mCalendar = Calendar.getInstance();
+ mHour = mCalendar.get(Calendar.HOUR_OF_DAY);
+ mMinute = mCalendar.get(Calendar.MINUTE);
+ mYear = mCalendar.get(Calendar.YEAR);
+ mMonth = mCalendar.get(Calendar.MONTH);
+ mDay = mCalendar.get(Calendar.DATE);
+
+
+ mDate = mDay + "/" + mMonth + "/" + mYear;
+ mTime = mHour + ":" + mMinute;
+
+
+ mReminderText.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ mTitle = s.toString().trim();
+ mReminderText.setError(null);
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+
+ }
+ });
+
+ mDateText.setText(mDate);
+ mTimeText.setText(mTime);
+
+ }
+
+
+ public void setTime(View v){
+ Calendar now = Calendar.getInstance();
+ TimePickerDialog tpd = TimePickerDialog.newInstance(
+ this,
+ now.get(Calendar.HOUR_OF_DAY),
+ now.get(Calendar.MINUTE),
+ false
+ );
+ tpd.setThemeDark(false);
+ tpd.show(getFragmentManager(), "Timepickerdialog");
+ }
+ public void setDate(View v){
+ Calendar now = Calendar.getInstance();
+ DatePickerDialog dpd = DatePickerDialog.newInstance(
+ this,
+ now.get(Calendar.YEAR),
+ now.get(Calendar.MONTH),
+ now.get(Calendar.DAY_OF_MONTH)
+ );
+ dpd.show(getFragmentManager(), "Datepickerdialog");
+ }
+
+ @Override
+ public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) {
+ mTime = hourOfDay + ":" + minute;
+ mTimeText.setText(mTime);
+ }
+
+ @Override
+ public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
+ mDate = dayOfMonth + "/" + monthOfYear + "/" + year;
+ mDateText.setText(mDate);
+ }
+
+
+
+ @Override
+ public void onBackPressed() {
+ super.onBackPressed();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_main, menu);
+ getMenuInflater().inflate(R.menu.menu_add_reminder, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
-
- //noinspection SimplifiableIfStatement
- if (id == R.id.action_settings) {
- return true;
- }
+ switch (item.getItemId()) {
+
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+
+ case R.id.save_reminder:
+ mReminderText.setText(mTitle);
+
+ if (mReminderText.getText().toString().length() == 0)
+ mReminderText.setError("Reminder Title cannot be blank!");
- return super.onOptionsItemSelected(item);
+ else {
+ Toast.makeText(getApplicationContext(), "Saved",
+ Toast.LENGTH_SHORT).show();
+ onBackPressed();
+ }
+ return true;
+
+ case R.id.discard_reminder:
+ Toast.makeText(getApplicationContext(), "Discarded",
+ Toast.LENGTH_SHORT).show();
+
+ onBackPressed();
+ return true;
+
+ default:
+ return super.onOptionsItemSelected(item);
+ }
}
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/blanyal/remindme/Reminder.java b/app/src/main/java/com/blanyal/remindme/Reminder.java
new file mode 100644
index 0000000..d88212d
--- /dev/null
+++ b/app/src/main/java/com/blanyal/remindme/Reminder.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2015 Blanyal D'souza.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package com.blanyal.remindme;
+
+
+public class Reminder {
+
+ private int mID;
+ private String mTitle;
+ private String mDate;
+ private String mTime;
+ private Boolean mRepeat;
+ private String mRepeatNo;
+ private String mRepeatType;
+ private Boolean mActive;
+
+
+ public Reminder(int ID, String Title, String Date, String Time, Boolean Repeat, String RepeatNo, String RepeatType, Boolean Active){
+ mID = ID;
+ mTitle = Title;
+ mDate = Date;
+ mTime = Time;
+ mRepeat = Repeat;
+ mRepeatNo = RepeatNo;
+ mRepeatType = RepeatType;
+ mActive = Active;
+ }
+
+ public Reminder(String Title, String Date, String Time, Boolean Repeat, String RepeatNo, String RepeatType, Boolean Active){
+ mTitle = Title;
+ mDate = Date;
+ mTime = Time;
+ mRepeat = Repeat;
+ mRepeatNo = RepeatNo;
+ mRepeatType = RepeatType;
+ mActive = Active;
+ }
+
+ public Reminder(){}
+
+ public int getID() {
+ return mID;
+ }
+
+ public void setID(int ID) {
+ mID = ID;
+ }
+
+ public String getTitle() {
+ return mTitle;
+ }
+
+ public void setTitle(String title) {
+ mTitle = title;
+ }
+
+ public String getDate() {
+ return mDate;
+ }
+
+ public void setDate(String date) {
+ mDate = date;
+ }
+
+ public String getTime() {
+ return mTime;
+ }
+
+ public void setTime(String time) {
+ mTime = time;
+ }
+
+ public Boolean isRepeat() {
+ return mRepeat;
+ }
+
+ public void setRepeat(Boolean repeat) {
+ mRepeat = repeat;
+ }
+
+ public String getRepeatType() {
+ return mRepeatType;
+ }
+
+ public void setRepeatType(String repeatType) {
+ mRepeatType = repeatType;
+ }
+
+ public String getRepeatNo() {
+ return mRepeatNo;
+ }
+
+ public void setRepeatNo(String repeatNo) {
+ mRepeatNo = repeatNo;
+ }
+
+ public Boolean isActive() {
+ return mActive;
+ }
+
+ public void setActive(Boolean active) {
+ mActive = active;
+ }
+}
diff --git a/app/src/main/java/com/blanyal/remindme/ReminderDatabase.java b/app/src/main/java/com/blanyal/remindme/ReminderDatabase.java
new file mode 100644
index 0000000..8017f8c
--- /dev/null
+++ b/app/src/main/java/com/blanyal/remindme/ReminderDatabase.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2015 Blanyal D'souza.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+
+package com.blanyal.remindme;
+
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ReminderDatabase extends SQLiteOpenHelper {
+
+ // Database Version
+ private static final int DATABASE_VERSION = 1;
+
+ // Database Name
+ private static final String DATABASE_NAME = "Reminders";
+
+ // Table name
+ private static final String TABLE_REMINDERS = "reminders";
+
+ // Table Columns names
+ private static final String KEY_ID = "id";
+ private static final String KEY_TITLE = "title";
+ private static final String KEY_DATE = "date";
+ private static final String KEY_TIME = "time";
+ private static final String KEY_REPEAT = "repeat";
+ private static final String KEY_REPEAT_NO = "repeat_no";
+ private static final String KEY_REPEAT_TYPE = "repeat_type";
+ private static final String KEY_ACTIVE = "active";
+
+ public ReminderDatabase(Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
+ }
+
+ // Creating Tables
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ String CREATE_REMINDERS_TABLE = "CREATE TABLE " + TABLE_REMINDERS +
+ "("
+ + KEY_ID + " INTEGER PRIMARY KEY,"
+ + KEY_TITLE + " TEXT,"
+ + KEY_DATE + " TEXT,"
+ + KEY_TIME + " INTEGER,"
+ + KEY_REPEAT + " BOOLEAN,"
+ + KEY_REPEAT_NO + " INTEGER,"
+ + KEY_REPEAT_TYPE + " TEXT,"
+ + KEY_ACTIVE + "BOOLEAN" + ")";
+ db.execSQL(CREATE_REMINDERS_TABLE);
+ }
+
+ // Upgrading database
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ // Drop older table if existed
+ if (oldVersion >= newVersion)
+ return;
+ db.execSQL("DROP TABLE IF EXISTS " + TABLE_REMINDERS);
+
+ // Create tables again
+
+ onCreate(db);
+ }
+
+ // Adding new Reminder
+ public void addReminder(Reminder reminder){
+ SQLiteDatabase db = this.getWritableDatabase();
+ ContentValues values = new ContentValues();
+
+ values.put(KEY_TITLE , reminder.getTitle());
+ values.put(KEY_DATE , reminder.getDate());
+ values.put(KEY_TIME , reminder.getTime());
+ values.put(KEY_REPEAT , reminder.isRepeat());
+ values.put(KEY_REPEAT_NO , reminder.getRepeatNo());
+ values.put(KEY_REPEAT_TYPE, reminder.getRepeatType());
+ values.put(KEY_ACTIVE, reminder.isActive());
+
+ // Inserting Row
+ db.insert(TABLE_REMINDERS, null, values);
+ db.close(); // Closing database connection
+
+ }
+
+
+ // Getting single Reminder
+ public Reminder getReminder(int id){
+ SQLiteDatabase db = this.getReadableDatabase();
+
+ Cursor cursor = db.query(TABLE_REMINDERS,new String[]
+ {
+ KEY_ID,
+ KEY_TITLE,
+ KEY_DATE,
+ KEY_TIME,
+ KEY_REPEAT,
+ KEY_REPEAT_NO,
+ KEY_REPEAT_TYPE,
+ KEY_ACTIVE
+ }, KEY_ID + "=?",
+
+ new String[] {String.valueOf(id)}, null, null, null, null);
+ if (cursor != null)
+ cursor.moveToFirst();
+
+ Reminder reminder = new Reminder(cursor.getString(0),
+ cursor.getString(1),cursor.getString(2), Boolean.parseBoolean(cursor.getString(3)),
+ cursor.getString(4), cursor.getString(5), Boolean.parseBoolean(cursor.getString(6)));
+
+ return reminder;
+ }
+
+ // Getting all Reminders
+ public List getAllReminders(){
+ List reminderList = new ArrayList<>();
+
+ // Select all Query
+ String selectQuery = "SELECT * FROM " + TABLE_REMINDERS;
+
+ SQLiteDatabase db = this.getWritableDatabase();
+ Cursor cursor = db.rawQuery(selectQuery, null);
+
+ // Looping through all rows and adding to list
+ if(cursor.moveToFirst()){
+ do{
+ Reminder reminder = new Reminder();
+ reminder.setID(Integer.parseInt(cursor.getString(0)));
+ reminder.setTitle(cursor.getString(1));
+ reminder.setDate(cursor.getString(2));
+ reminder.setTime(cursor.getString(3));
+ reminder.setRepeat(Boolean.parseBoolean(cursor.getString(4)));
+ reminder.setRepeatNo(cursor.getString(5));
+ reminder.setRepeatType(cursor.getString(6));
+ reminder.setActive(Boolean.parseBoolean(cursor.getString(7)));
+
+ // Adding Reminders to list
+ reminderList.add(reminder);
+ } while (cursor.moveToNext());
+ }
+
+ return reminderList;
+ }
+
+ // Getting Reminders Count
+ public int getRemindersCount(){
+ String countQuery = "SELECT * FROM " + TABLE_REMINDERS;
+ SQLiteDatabase db = this.getReadableDatabase();
+ Cursor cursor = db.rawQuery(countQuery,null);
+ cursor.close();
+
+ return cursor.getCount();
+ }
+
+ // Updating single Reminder
+ public int updateReminder(Reminder reminder){
+ SQLiteDatabase db = this.getWritableDatabase();
+ ContentValues values = new ContentValues();
+ values.put(KEY_TITLE , reminder.getTitle());
+ values.put(KEY_DATE , reminder.getDate());
+ values.put(KEY_TIME , reminder.getTime());
+ values.put(KEY_REPEAT , reminder.isRepeat());
+ values.put(KEY_REPEAT_NO , reminder.getRepeatNo());
+ values.put(KEY_REPEAT_TYPE, reminder.getRepeatType());
+ values.put(KEY_ACTIVE, reminder.isActive());
+
+ // Updating row
+ return db.update(TABLE_REMINDERS, values, KEY_ID + "=?",
+ new String[]{String.valueOf(reminder.getID())});
+
+ }
+
+ // Deleting single Reminder
+ public void deleteReminder(Reminder reminder){
+ SQLiteDatabase db = this.getWritableDatabase();
+ db.delete(TABLE_REMINDERS, KEY_ID + "=?",
+ new String[]{String.valueOf(reminder.getID())});
+ db.close();
+ }
+
+
+
+}
diff --git a/app/src/main/res/layout/activity_add_reminder.xml b/app/src/main/res/layout/activity_add_reminder.xml
index c8b4bff..ecc394d 100644
--- a/app/src/main/res/layout/activity_add_reminder.xml
+++ b/app/src/main/res/layout/activity_add_reminder.xml
@@ -72,13 +72,14 @@
android:textSize="15dp"
android:gravity="center_vertical"
android:layout_marginLeft="72dp"
- android:textColor="@color/abc_secondary_text_material_light"
+ android:textColor="@color/abc_secondary_text_material_dark"
android:layout_height="72dp"/>
@@ -106,7 +107,7 @@
@@ -130,6 +131,7 @@
@@ -157,7 +159,7 @@
@@ -180,6 +182,7 @@
@@ -207,7 +210,7 @@
@@ -242,6 +246,20 @@
android:background="@drawable/toolbar_dropshadow" />
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
index 594e88e..5ac269b 100644
--- a/app/src/main/res/values-v21/styles.xml
+++ b/app/src/main/res/values-v21/styles.xml
@@ -8,7 +8,7 @@
- true
- @color/primary_dark
- - @style/ThemeOverlay.AppCompat.Light
+ - @style/ThemeOverlay.AppCompat
- @android:transition/move
- @android:transition/move
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 7f30902..9b5ae76 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -2,10 +2,11 @@
#ffffff
- #f44336
- #d32f2f
- #536dfe
+ #009688
+ #00796b
+ #3f51b5
#888888
- #3d5afe
+ #3949ab
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 44a1b8b..7dfd2c4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -11,5 +11,9 @@
Date
Time
Repeat
+ Off
+
+ Discard Reminder
+ Save Reminder
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 4fbd204..9c4e2bc 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -3,13 +3,13 @@
-