Commit aa997a7a authored by PANKAJ KUMAR's avatar PANKAJ KUMAR

Bug fix: Crashing problem associated with alarm toggle button on edit reminder page is resolved

parent 32ca20d4
...@@ -30,7 +30,6 @@ import androidx.core.app.ActivityCompat; ...@@ -30,7 +30,6 @@ import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; 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.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser; import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.DatabaseReference;
...@@ -62,8 +61,6 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -62,8 +61,6 @@ public class ReminderAddActivity extends AppCompatActivity {
private Toolbar mToolbar; private Toolbar mToolbar;
private EditText mTitleText; private EditText mTitleText;
private TextView mDateText, mTimeText, mRepeatText, mRepeatNoText, mRepeatTypeText; private TextView mDateText, mTimeText, mRepeatText, mRepeatNoText, mRepeatTypeText;
private FloatingActionButton mFAB1;
private FloatingActionButton mFAB2;
private Calendar mCalendar; private Calendar mCalendar;
private int mYear, mMonth, mHour, mMinute, mDay; private int mYear, mMonth, mHour, mMinute, mDay;
private long mRepeatTime; private long mRepeatTime;
...@@ -89,7 +86,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -89,7 +86,7 @@ public class ReminderAddActivity extends AppCompatActivity {
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);
mRepeatText = findViewById(R.id.set_repeat); mRepeatText = findViewById(R.id.repeat_status);
mRepeatNoText = findViewById(R.id.set_repeat_no); mRepeatNoText = findViewById(R.id.set_repeat_no);
mRepeatTypeText = findViewById(R.id.set_repeat_type); mRepeatTypeText = findViewById(R.id.set_repeat_type);
...@@ -310,13 +307,6 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -310,13 +307,6 @@ public class ReminderAddActivity extends AppCompatActivity {
//on clicking the send button //on clicking the send button
public void saveReminderToTempStorage(String filename) { public void saveReminderToTempStorage(String filename) {
/* mTitleText = (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);
mRepeatNoText = (TextView) findViewById(R.id.set_repeat_no);
mRepeatTypeText = (TextView) findViewById(R.id.set_repeat_type);
*/
ReminderDO talkingReminderDO = new ReminderDO(); ReminderDO talkingReminderDO = new ReminderDO();
talkingReminderDO.setTitle(mTitle); talkingReminderDO.setTitle(mTitle);
talkingReminderDO.setDate(mDate); talkingReminderDO.setDate(mDate);
......
...@@ -22,8 +22,6 @@ import android.widget.Toast; ...@@ -22,8 +22,6 @@ import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.Calendar; import java.util.Calendar;
...@@ -47,17 +45,13 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -47,17 +45,13 @@ public class ReminderEditActivity extends AppCompatActivity {
private static final long milMonth = 2592000000L; private static final long milMonth = 2592000000L;
private Toolbar mToolbar; private Toolbar mToolbar;
private EditText mTitleText; private EditText mTitleText;
private TextView mDateText, mTimeText, mRepeatText, mRepeatNoText, mRepeatTypeText; private TextView mDateText, mTimeText, mRepeatText, mRepeatNoText, mRepeatTypeText, mRingStatusText;
private FloatingActionButton mFAB1; private Switch mRepeatSwitch, mRingSwitch;
private FloatingActionButton mFAB2;
private Switch mRepeatSwitch;
private String mTitle; private String mTitle;
private String mTime; private String mTime;
private String mDate; private String mDate;
private String mRepeatNo; private String mRepeatNo, mRepeatType, mRepeat;
private String mRepeatType; private String mRingStatus;
private String mActive;
private String mRepeat;
private String[] mDateSplit; private String[] mDateSplit;
private String[] mTimeSplit; private String[] mTimeSplit;
private int mReceivedID; private int mReceivedID;
...@@ -78,12 +72,12 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -78,12 +72,12 @@ public class ReminderEditActivity extends AppCompatActivity {
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);
mRepeatText = findViewById(R.id.set_repeat); mRepeatText = findViewById(R.id.repeat_status);
mRepeatNoText = findViewById(R.id.set_repeat_no); mRepeatNoText = findViewById(R.id.set_repeat_no);
mRepeatTypeText = findViewById(R.id.set_repeat_type); mRepeatTypeText = findViewById(R.id.set_repeat_type);
// mFAB1 = (FloatingActionButton) findViewById(R.id.starred1);
//mFAB2 = (FloatingActionButton) findViewById(R.id.starred2);
mRepeatSwitch = findViewById(R.id.repeat_switch); mRepeatSwitch = findViewById(R.id.repeat_switch);
mRingSwitch = findViewById(R.id.ring_switch);
mRingStatusText = findViewById(R.id.ring_status);
// Setup Toolbar // Setup Toolbar
setSupportActionBar(mToolbar); setSupportActionBar(mToolbar);
...@@ -133,7 +127,7 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -133,7 +127,7 @@ public class ReminderEditActivity extends AppCompatActivity {
mRepeat = mReceivedReminderDO.getRepeat(); mRepeat = mReceivedReminderDO.getRepeat();
mRepeatNo = mReceivedReminderDO.getRepeatNo(); mRepeatNo = mReceivedReminderDO.getRepeatNo();
mRepeatType = mReceivedReminderDO.getRepeatType(); mRepeatType = mReceivedReminderDO.getRepeatType();
mActive = mReceivedReminderDO.getActive(); mRingStatus = mReceivedReminderDO.getActive();
// Setup TextViews using reminder values // Setup TextViews using reminder values
mTitleText.setText(mTitle); mTitleText.setText(mTitle);
...@@ -169,18 +163,11 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -169,18 +163,11 @@ public class ReminderEditActivity extends AppCompatActivity {
mRepeatTypeText.setText(savedRepeatType); mRepeatTypeText.setText(savedRepeatType);
mRepeatType = savedRepeatType; mRepeatType = savedRepeatType;
mActive = savedInstanceState.getString(KEY_ACTIVE); mRingStatus = savedInstanceState.getString(KEY_ACTIVE);
} }
// // Setup up active buttons // Setup ring switch toggle value
// if (mActive.equals("false")) { mRingSwitch.setChecked(Boolean.parseBoolean(mRingStatus));
// mFAB1.show();
// mFAB2.hide();
//
// } else if (mActive.equals("true")) {
// mFAB1.hide();
// mFAB2.show();
// }
// Setup repeat switch // Setup repeat switch
if (mRepeat.equals("false")) { if (mRepeat.equals("false")) {
...@@ -216,7 +203,7 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -216,7 +203,7 @@ public class ReminderEditActivity extends AppCompatActivity {
outState.putCharSequence(KEY_REPEAT, mRepeatText.getText()); outState.putCharSequence(KEY_REPEAT, mRepeatText.getText());
outState.putCharSequence(KEY_REPEAT_NO, mRepeatNoText.getText()); outState.putCharSequence(KEY_REPEAT_NO, mRepeatNoText.getText());
outState.putCharSequence(KEY_REPEAT_TYPE, mRepeatTypeText.getText()); outState.putCharSequence(KEY_REPEAT_TYPE, mRepeatTypeText.getText());
outState.putCharSequence(KEY_ACTIVE, mActive); outState.putCharSequence(KEY_ACTIVE, mRingStatus);
} }
@Override @Override
...@@ -265,49 +252,7 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -265,49 +252,7 @@ public class ReminderEditActivity extends AppCompatActivity {
datePickerDialog.show(); datePickerDialog.show();
} }
// Obtain time from time picker // Repeat toggle
// @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 = (FloatingActionButton) findViewById(R.id.starred1);
// mFAB1.hide();
// mFAB2 = (FloatingActionButton) findViewById(R.id.starred2);
// mFAB2.show();
// mActive = "true";
// }
//
// // On clicking the inactive button
// public void selectFab2(View v) {
// mFAB2 = (FloatingActionButton) findViewById(R.id.starred2);
// mFAB2.hide();
// mFAB1 = (FloatingActionButton) findViewById(R.id.starred1);
// mFAB1.show();
// mActive = "false";
// }
// On clicking the repeat switch
public void onSwitchRepeat(View view) { public void onSwitchRepeat(View view) {
boolean on = ((Switch) view).isChecked(); boolean on = ((Switch) view).isChecked();
if (on) { if (on) {
...@@ -320,6 +265,12 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -320,6 +265,12 @@ public class ReminderEditActivity extends AppCompatActivity {
} }
} }
// Alert toggle
public void onSwitchRing(View view) {
mRingStatus = Boolean.toString(((Switch) view).isChecked());
}
// On clicking repeat type button // On clicking repeat type button
public void selectRepeatType(View v) { public void selectRepeatType(View v) {
final String[] items = new String[5]; final String[] items = new String[5];
...@@ -387,7 +338,7 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -387,7 +338,7 @@ public class ReminderEditActivity extends AppCompatActivity {
mReceivedReminderDO.setRepeat(mRepeat); mReceivedReminderDO.setRepeat(mRepeat);
mReceivedReminderDO.setRepeatNo(mRepeatNo); mReceivedReminderDO.setRepeatNo(mRepeatNo);
mReceivedReminderDO.setRepeatType(mRepeatType); mReceivedReminderDO.setRepeatType(mRepeatType);
mReceivedReminderDO.setActive(mActive); mReceivedReminderDO.setActive(mRingStatus);
// Update reminder // Update reminder
rb.updateReminder(mReceivedReminderDO); rb.updateReminder(mReceivedReminderDO);
...@@ -417,7 +368,7 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -417,7 +368,7 @@ public class ReminderEditActivity extends AppCompatActivity {
} }
// Create a new notification // Create a new notification
if (mActive.equals("true")) { if (mRingStatus.equals("true")) {
if (mRepeat.equals("true")) { if (mRepeat.equals("true")) {
mAlarmReceiver.setRepeatAlarm(getApplicationContext(), mCalendar, mReceivedID, mRepeatTime); mAlarmReceiver.setRepeatAlarm(getApplicationContext(), mCalendar, mReceivedID, mRepeatTime);
} else if (mRepeat.equals("false")) { } else if (mRepeat.equals("false")) {
......
...@@ -79,7 +79,7 @@ public class ReminderReceiveActivity extends AppCompatActivity { ...@@ -79,7 +79,7 @@ public class ReminderReceiveActivity extends AppCompatActivity {
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);
mRepeatText = findViewById(R.id.set_repeat); mRepeatText = findViewById(R.id.repeat_status);
mRepeatNoText = findViewById(R.id.set_repeat_no); mRepeatNoText = findViewById(R.id.set_repeat_no);
mRepeatTypeText = findViewById(R.id.set_repeat_type); mRepeatTypeText = findViewById(R.id.set_repeat_type);
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_below="@id/add_reminder_layout_top" android:layout_below="@id/add_reminder_layout_top"
android:background="#FFFFFF"> android:background="@color/fui_bgGoogle">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -83,6 +83,13 @@ ...@@ -83,6 +83,13 @@
android:textColor="@color/textbody" android:textColor="@color/textbody"
android:textSize="15dp" /> android:textSize="15dp" />
<TextView
android:id="@+id/ring_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/primary"
android:textSize="15dp" />
</LinearLayout> </LinearLayout>
<Switch <Switch
...@@ -93,7 +100,6 @@ ...@@ -93,7 +100,6 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:background="@color/fui_transparent"
android:checked="true" android:checked="true"
android:onClick="onSwitchRing" android:onClick="onSwitchRing"
android:textOff="Off" android:textOff="Off"
...@@ -224,7 +230,7 @@ ...@@ -224,7 +230,7 @@
android:textSize="15dp" /> android:textSize="15dp" />
<TextView <TextView
android:id="@+id/set_repeat" android:id="@+id/repeat_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/primary" android:textColor="@color/primary"
...@@ -240,14 +246,12 @@ ...@@ -240,14 +246,12 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:background="@color/fui_transparent"
android:checked="false" android:checked="false"
android:cursorVisible="true"
android:onClick="onSwitchRepeat" android:onClick="onSwitchRepeat"
android:shadowColor="#C1EFFD" android:shadowColor="#00FFFFFF"
android:textOff="Off" android:textOff="Off"
android:textOn="On" android:textOn="On" />
android:visibility="visible"
tools:visibility="visible" />
</RelativeLayout> </RelativeLayout>
......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout
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:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
...@@ -183,7 +180,7 @@ ...@@ -183,7 +180,7 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:id="@+id/set_repeat" android:id="@+id/repeat_status"
android:textSize="15dp" android:textSize="15dp"
android:textColor="@color/abc_secondary_text_material_dark" android:textColor="@color/abc_secondary_text_material_dark"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
......
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