Commit 32ca20d4 authored by PANKAJ KUMAR's avatar PANKAJ KUMAR

Alarm on-off option is working at the time of adding new reminder. During...

Alarm on-off option is working at the time of adding new reminder. During editing reminder this option causes app to crash.
parent 167e7542
......@@ -36,7 +36,7 @@
<activity
android:name="com.sudogeeks.talking_reminder.ReminderAddActivity"
android:label="@string/activity_add_reminder_label">
android:label="@string/add_reminder_label">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
......@@ -44,7 +44,7 @@
<activity
android:name="com.sudogeeks.talking_reminder.ReminderEditActivity"
android:label="@string/activity_edit_reminder_label" />
android:label="@string/edit_reminder_label" />
<receiver android:name="com.sudogeeks.talking_reminder.AlarmReceiver"/>
......
......@@ -145,9 +145,11 @@ public class MainActivity extends AppCompatActivity {
}
};
/**onCreate() implementation
/**
* onCreate() implementation
* Overridden method. In this method initial life cycle of the app is implemented.
* If user is not authenticated then user is sent for login/signup, else database instance and main view is initialized
*
* @param savedInstanceState
*/
@Override
......@@ -168,7 +170,7 @@ public class MainActivity extends AppCompatActivity {
if (user != null) {
//User is signed in
reminderDatabaseReference = firebaseDatabase.getReference().child("reminders").child(user.getUid());
Toast.makeText(MainActivity.this, "You're now signed in.\nWelcome to Talking ReminderDO!", Toast.LENGTH_SHORT).show();
//Toast.makeText(MainActivity.this, "You're now signed in.\nWelcome to Talking ReminderDO!", Toast.LENGTH_SHORT).show();
attachDatabaseReadListener();
} else {
//User is signed out
......@@ -271,7 +273,8 @@ public class MainActivity extends AppCompatActivity {
}
}
/**Define what happens when user closes the app
/**
* Define what happens when user closes the app
* Overridden method
*/
@Override
......@@ -284,7 +287,8 @@ public class MainActivity extends AppCompatActivity {
//reminderAdapter.clear();
}
/** Create context menu for long press actions
/**
* Create context menu for long press actions
*
* @param menu
* @param view
......@@ -308,7 +312,8 @@ public class MainActivity extends AppCompatActivity {
startActivityForResult(i, 1);
}
/** Standard method for handling the outcome of an activity.
/**
* Standard method for handling the outcome of an activity.
* If user signs in is successful then only take the user to main page. Else force the user to login in first
*
* @param requestCode
......@@ -332,9 +337,9 @@ public class MainActivity extends AppCompatActivity {
}
}
/** Define the behaviour of the app in case user comes back after suspending the app.
/**
* Define the behaviour of the app in case user comes back after suspending the app.
* -Recreate recycler view : This is done so that newly created reminders are also displayed
*/
@Override
public void onResume() {
......@@ -352,7 +357,8 @@ public class MainActivity extends AppCompatActivity {
mAdapter.setItemCount(getDefaultItemCount());
}
/** Layout manager for recycler view
/**
* Layout manager for recycler view
*
* @return LinearLayoutManager instance
*/
......@@ -360,7 +366,8 @@ public class MainActivity extends AppCompatActivity {
return new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
}
/** Helper method
/**
* Helper method
*
* @return integer 100
*/
......@@ -371,7 +378,7 @@ public class MainActivity extends AppCompatActivity {
/**
* Creating main menu
*
* @param Menu object
* @param menu object
* @return boolean
*/
@Override
......@@ -380,7 +387,8 @@ public class MainActivity extends AppCompatActivity {
return true;
}
/**Defines behaviours for the menu items.
/**
* Defines behaviours for the menu items.
*
* @param item
* @return Boolean
......@@ -398,8 +406,9 @@ public class MainActivity extends AppCompatActivity {
}
/**\brief Adapter class (Inner Class) for implementing recycler view
*
/**
* \brief Adapter class (Inner Class) for implementing recycler view
* <p>
* This class will handle how to display the reminder data on the main page.
*/
public class SimpleAdapter extends RecyclerView.Adapter<SimpleAdapter.VerticalItemHolder> {
......@@ -420,7 +429,8 @@ public class MainActivity extends AppCompatActivity {
notifyItemRemoved(selected);
}
/** View holder for recycler view items
/**
* View holder for recycler view items
* Overridden method
*
* @param container
......@@ -435,7 +445,8 @@ public class MainActivity extends AppCompatActivity {
return new VerticalItemHolder(root, this);
}
/**Bind a reminder item to a position in the main view
/**
* Bind a reminder item to a position in the main view
* Overridden method
*
* @param itemHolder
......@@ -450,7 +461,8 @@ public class MainActivity extends AppCompatActivity {
itemHolder.setActiveImage(item.mActive);
}
/**Retuns the number of reminders in the database
/**
* Retuns the number of reminders in the database
*
* @return
*/
......@@ -466,7 +478,8 @@ public class MainActivity extends AppCompatActivity {
notifyDataSetChanged();
}
/** Prepare data for each reminder item to facilitate proper displaying in the view.
/**
* Prepare data for each reminder item to facilitate proper displaying in the view.
* this Helper method required because all the data in database are not directly representable.
*
* @param count
......@@ -524,7 +537,8 @@ public class MainActivity extends AppCompatActivity {
return items;
}
/** Data-Object class for recycler view items
/**
* Data-Object class for recycler view items
* This class is slightly different form ReminderDO class. Very specific to the requirement of the recyler view
*/
public class ReminderItem {
......@@ -535,7 +549,8 @@ public class MainActivity extends AppCompatActivity {
public String mRepeatType;
public String mActive;
/**Constructor
/**
* Constructor
*
* @param Title
* @param DateTime
......@@ -554,8 +569,8 @@ public class MainActivity extends AppCompatActivity {
}
}
/** Inner class to compare date and time so that items can be sorted in ascending/decending order of date and time
*
/**
* Inner class to compare date and time so that items can be sorted in ascending/decending order of date and time
*/
public class DateTimeComparator implements Comparator {
DateFormat f = new SimpleDateFormat("dd/mm/yyyy hh:mm");
......@@ -572,8 +587,8 @@ public class MainActivity extends AppCompatActivity {
}
}
/** UI and data class (Adapter) for recycler view items
*
/**
* UI and data class (Adapter) for recycler view items
*/
public class VerticalItemHolder extends SwappingHolder
implements View.OnClickListener, View.OnLongClickListener {
......@@ -607,7 +622,8 @@ public class MainActivity extends AppCompatActivity {
mThumbnailImage = itemView.findViewById(R.id.thumbnail_image);
}
/** On clicking a reminder item
/**
* On clicking a reminder item
*
* @param view
*/
......@@ -624,7 +640,8 @@ public class MainActivity extends AppCompatActivity {
}
}
/** On long press enter action mode with context menu
/**
* On long press enter action mode with context menu
*
* @param view
* @return
......@@ -637,7 +654,8 @@ public class MainActivity extends AppCompatActivity {
return true;
}
/** Set reminder title view
/**
* Set reminder title view
*
* @param reminderTitle
*/
......@@ -657,7 +675,8 @@ public class MainActivity extends AppCompatActivity {
mThumbnailImage.setImageDrawable(mDrawableBuilder);
}
/** Set date and time views
/**
* Set date and time views
*
* @param datetime
*/
......@@ -665,7 +684,8 @@ public class MainActivity extends AppCompatActivity {
mDateAndTimeText.setText(datetime);
}
/** Set repeat views
/**
* Set repeat views
*
* @param repeat
* @param repeatNo
......@@ -679,13 +699,15 @@ public class MainActivity extends AppCompatActivity {
}
}
/** Set active image as on or off
/**
* Set active image as on or off
* This method is apparently not consistent because on/off behaviour doesn't always work
*
* @param active
*/
public void setActiveImage(String active) {
if (active.equals("true")) {
mActiveImage.setImageResource(R.drawable.ic_notifications_active);
mActiveImage.setImageResource(R.drawable.ic_notifications_on);
} else if (active.equals("false")) {
mActiveImage.setImageResource(R.drawable.ic_notifications_off);
}
......
......@@ -92,18 +92,16 @@ public class ReminderAddActivity extends AppCompatActivity {
mRepeatText = findViewById(R.id.set_repeat);
mRepeatNoText = findViewById(R.id.set_repeat_no);
mRepeatTypeText = findViewById(R.id.set_repeat_type);
mFAB1 = findViewById(R.id.starred1);
mFAB2 = findViewById(R.id.starred2);
// Setup Toolbar
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle(R.string.activity_add_reminder_label);
getSupportActionBar().setTitle(R.string.add_reminder_label);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
// Initialize default values
mActive = "true";
mRepeat = "true";
mRepeat = "false";
mRepeatNo = Integer.toString(1);
mRepeatType = "Hour";
......@@ -170,16 +168,6 @@ public class ReminderAddActivity extends AppCompatActivity {
mActive = savedInstanceState.getString(KEY_ACTIVE);
}
// Setup up active buttons
if (mActive.equals("false")) {
mFAB1.show();
mFAB2.hide();
} else if (mActive.equals("true")) {
mFAB1.hide();
mFAB2.show();
}
}
// To save state on device rotation
......@@ -240,47 +228,6 @@ public class ReminderAddActivity extends AppCompatActivity {
datePickerDialog.show();
}
// Obtain time from time picker
// @Override
// public void onTimeSet(TimePicker timePicker, int hourOfDay, int minute) {
// mHour = hourOfDay;
// mMinute = minute;
// if (minute < 10) {
// mTime = hourOfDay + ":" + "0" + minute;
// } else {
// mTime = hourOfDay + ":" + minute;
// }
// mTimeText.setText(mTime);
// }
// Obtain date from date picker
// @Override
// public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) {
// monthOfYear ++;
// mDay = dayOfMonth;
// mMonth = monthOfYear;
// mYear = year;
// mDate = dayOfMonth + "/" + monthOfYear + "/" + year;
// mDateText.setText(mDate);
// }
// On clicking the active button
public void selectFab1(View v) {
mFAB1 = findViewById(R.id.starred1);
mFAB1.hide();
mFAB2 = findViewById(R.id.starred2);
mFAB2.show();
mActive = "true";
}
// On clicking the inactive button
public void selectFab2(View v) {
mFAB2 = findViewById(R.id.starred2);
mFAB2.hide();
mFAB1 = findViewById(R.id.starred1);
mFAB1.show();
mActive = "false";
}
// On clicking the repeat switch
public void onSwitchRepeat(View view) {
......@@ -294,6 +241,10 @@ public class ReminderAddActivity extends AppCompatActivity {
}
}
public void onSwitchRing(View view) {
mActive = Boolean.toString(((Switch) view).isChecked());
}
// On clicking repeat type button
public void selectRepeatType(View v) {
final String[] items = new String[5];
......
......@@ -87,7 +87,7 @@ public class ReminderEditActivity extends AppCompatActivity {
// Setup Toolbar
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle(R.string.activity_edit_reminder_label);
getSupportActionBar().setTitle(R.string.edit_reminder_label);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
......
......@@ -53,7 +53,7 @@ public class ReminderReceiveActivity extends AppCompatActivity {
// Setup Toolbar
mToolbar = findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle(R.string.activity_add_reminder_label);
getSupportActionBar().setTitle(R.string.add_reminder_label);
//Get the file from intent
Intent intent = getIntent();
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M7.58,4.08L6.15,2.65C3.75,4.48 2.17,7.3 2.03,10.5h2c0.15,-2.65 1.51,-4.97 3.55,-6.42zM19.97,10.5h2c-0.15,-3.2 -1.73,-6.02 -4.12,-7.85l-1.42,1.43c2.02,1.45 3.39,3.77 3.54,6.42zM18,11c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2v-5zM12,22c0.14,0 0.27,-0.01 0.4,-0.04 0.65,-0.14 1.18,-0.58 1.44,-1.18 0.1,-0.24 0.15,-0.5 0.15,-0.78h-4c0.01,1.1 0.9,2 2.01,2z"/>
</vector>
<vector android:height="24dp" android:tint="#00D5DA"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z"/>
</vector>
<vector android:height="24dp" android:tint="#646464"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M9,9m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0"/>
<path android:fillColor="#FF000000" android:pathData="M9,15c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4zM16.76,5.36l-1.68,1.69c0.84,1.18 0.84,2.71 0,3.89l1.68,1.69c2.02,-2.02 2.02,-5.07 0,-7.27zM20.07,2l-1.63,1.63c2.77,3.02 2.77,7.56 0,10.74L20.07,16c3.9,-3.89 3.91,-9.95 0,-14z"/>
</vector>
......@@ -19,9 +19,11 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/reminder_list"
android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:layout_below="@+id/toolbar"
android:layout_marginTop="0dp"
android:background="#FFFFFF" />
<TextView
android:id="@+id/no_reminder_text"
......
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="?android:attr/selectableItemBackground"
android:layout_height="86dp">
android:layout_height="86dp"
android:background="@color/fui_transparent">
<ImageView android:layout_width="40dp"
<ImageView
android:id="@+id/thumbnail_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_centerVertical="true"
android:id="@+id/thumbnail_image"/>
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" />
<LinearLayout
android:layout_width="match_parent"
......@@ -19,49 +18,50 @@
android:layout_centerVertical="true"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_toRightOf="@id/thumbnail_image"
android:layout_toLeftOf="@+id/active_image"
android:layout_toRightOf="@id/thumbnail_image"
android:orientation="vertical">
<TextView
android:id="@+id/recycle_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:layout_height="wrap_content"
android:textColor="@color/abc_primary_text_material_dark"
tools:text="Title"
android:textSize="16dp"/>
android:textColor="@color/textbody"
android:textSize="16dp"
tools:text="Title" />
<TextView
android:id="@+id/recycle_date_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:layout_height="wrap_content"
android:textColor="@color/primary"
android:textSize="13dp"
android:textColor="@color/abc_secondary_text_material_dark"
tools:text="Date and Time"/>
tools:text="Date and Time" />
<TextView
android:id="@+id/recycle_repeat_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:layout_height="wrap_content"
android:textColor="@color/primary"
android:textSize="13dp"
android:textColor="@color/abc_secondary_text_material_dark"
tools:text="Repeat No and Type"/>
tools:text="Repeat No and Type" />
</LinearLayout>
<ImageView android:layout_width="wrap_content"
android:layout_alignParentRight="true"
<ImageView
android:id="@+id/active_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:src="@drawable/ic_notifications_off"
android:layout_centerVertical="true"
android:id="@+id/active_image"/>
android:src="@drawable/ic_notifications_off" />
</RelativeLayout>
\ No newline at end of file
......@@ -6,16 +6,16 @@
<item android:id="@+id/discard_reminder"
android:icon="@drawable/ic_delete_white"
android:title="@string/action_discard_reminder"
android:title="@string/discard_reminder"
app:showAsAction="ifRoom" />
<item android:id="@+id/send_reminder"
android:icon="@drawable/ic_send"
android:title="@string/action_discard_reminder"
app:showAsAction="ifRoom" />
android:title="@string/send_reminder"
app:showAsAction="always" />
<item android:id="@+id/save_reminder"
android:icon="@drawable/ic_save_white"
android:title="@string/action_save_reminder"
app:showAsAction="ifRoom" />
android:title="@string/save_reminder"
app:showAsAction="always" />
</menu>
......@@ -3,6 +3,6 @@
<item android:id="@+id/save_reminder"
android:icon="@drawable/ic_save_white"
android:title="@string/action_save_reminder"
android:title="@string/save_reminder"
app:showAsAction="ifRoom" />
</menu>
\ No newline at end of file
......@@ -2,8 +2,8 @@
<resources>
<string name="app_name">Talking Reminder</string>
<string name="activity_add_reminder_label">Add Reminder</string>
<string name="activity_edit_reminder_label">Edit Reminder</string>
<string name="add_reminder_label">Add Reminder</string>
<string name="edit_reminder_label">Edit Reminder</string>
<string name="add_reminder">Reminder</string>
<string name="details">Details</string>
<string name="date">Date</string>
......@@ -13,10 +13,11 @@
<string name="repeat_no">Repetition Interval </string>
<string name="repeat_type">Type of Repetitions</string>
<string name="action_discard_reminder">Discard Reminder</string>
<string name="action_save_reminder">Save Reminder</string>
<string name="discard_reminder">Discard Reminder</string>
<string name="save_reminder">Save Reminder</string>
<string name="no_reminders">Click on the plus button below to begin creating your reminderDOS!</string>
<string name="sign_out">sign_out</string>
<string name="sign_out">Sign out</string>
<string name="send_reminder">Send Reminder</string>
</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