Skip to content

Commit

Permalink
Merge pull request #6 from blanyal/database
Browse files Browse the repository at this point in the history
Various Improvements
  • Loading branch information
blanyal committed Apr 14, 2015
2 parents 769ec54 + fab3b67 commit 5273bee
Show file tree
Hide file tree
Showing 11 changed files with 525 additions and 28 deletions.
1 change: 1 addition & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="materialdatetimepicker-1.2.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="floatingactionbutton-1.9.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
Expand Down
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

}
159 changes: 145 additions & 14 deletions app/src/main/java/com/blanyal/remindme/AddReminder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
}

}
119 changes: 119 additions & 0 deletions app/src/main/java/com/blanyal/remindme/Reminder.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading

0 comments on commit 5273bee

Please sign in to comment.