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