hide the event End date and time by default
This commit is contained in:
parent
6c783bead1
commit
272bb121e4
|
@ -11,6 +11,7 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
@ -30,6 +31,7 @@ import java.util.List;
|
|||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnCheckedChanged;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.OnItemSelected;
|
||||
|
||||
|
@ -43,6 +45,7 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
|
|||
@BindView(R.id.event_reminder_other) EditText mReminderOtherET;
|
||||
@BindView(R.id.event_reminder) AppCompatSpinner mReminder;
|
||||
@BindView(R.id.event_repetition) AppCompatSpinner mRepetition;
|
||||
@BindView(R.id.event_end_checkbox) CheckBox mEndCheckbox;
|
||||
|
||||
private static DateTime mEventStartDateTime;
|
||||
private static DateTime mEventEndDateTime;
|
||||
|
@ -81,6 +84,7 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
|
|||
updateEndTime();
|
||||
setupReminder();
|
||||
setupRepetition();
|
||||
setupEndCheckbox();
|
||||
|
||||
mWasEndDateSet = (event != null);
|
||||
mWasEndTimeSet = (event != null);
|
||||
|
@ -90,6 +94,7 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
|
|||
setTitle(getResources().getString(R.string.edit_event));
|
||||
mEventStartDateTime = Formatter.getDateTimeFromTS(mEvent.getStartTS());
|
||||
mEventEndDateTime = Formatter.getDateTimeFromTS(mEvent.getEndTS());
|
||||
mEndCheckbox.setChecked(!mEventStartDateTime.equals(mEventEndDateTime));
|
||||
mTitleET.setText(mEvent.getTitle());
|
||||
mDescriptionET.setText(mEvent.getDescription());
|
||||
hideKeyboard();
|
||||
|
@ -146,6 +151,16 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
|
|||
}
|
||||
}
|
||||
|
||||
private void setupEndCheckbox() {
|
||||
mEndCheckbox.setTextColor(mStartDate.getCurrentTextColor());
|
||||
}
|
||||
|
||||
@OnCheckedChanged(R.id.event_end_checkbox)
|
||||
public void checkChanged(boolean isChecked) {
|
||||
mEndDate.setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
mEndTime.setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@OnItemSelected(R.id.event_reminder)
|
||||
public void handleReminder() {
|
||||
if (!mWasReminderInit) {
|
||||
|
@ -205,7 +220,7 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
|
|||
final int startTS = (int) (mEventStartDateTime.getMillis() / 1000);
|
||||
final int endTS = (int) (mEventEndDateTime.getMillis() / 1000);
|
||||
|
||||
if (startTS > endTS) {
|
||||
if (mEndCheckbox.isChecked() && startTS > endTS) {
|
||||
Utils.showToast(getApplicationContext(), R.string.end_before_start);
|
||||
return;
|
||||
}
|
||||
|
@ -213,7 +228,7 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
|
|||
final DBHelper dbHelper = DBHelper.newInstance(getApplicationContext(), this);
|
||||
final String description = mDescriptionET.getText().toString().trim();
|
||||
mEvent.setStartTS(startTS);
|
||||
mEvent.setEndTS(endTS);
|
||||
mEvent.setEndTS(mEndCheckbox.isChecked() ? endTS : startTS);
|
||||
mEvent.setTitle(title);
|
||||
mEvent.setDescription(description);
|
||||
mEvent.setReminderMinutes(getReminderMinutes());
|
||||
|
|
|
@ -76,12 +76,13 @@
|
|||
android:text="00:00"
|
||||
android:textSize="@dimen/day_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/event_end_label"
|
||||
android:layout_width="wrap_content"
|
||||
<CheckBox
|
||||
android:id="@+id/event_end_checkbox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/event_start_date"
|
||||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/end"
|
||||
android:textSize="@dimen/day_text_size"/>
|
||||
|
||||
|
@ -89,20 +90,26 @@
|
|||
android:id="@+id/event_end_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/event_end_label"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:layout_below="@+id/event_end_checkbox"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:text="January 1 1970"
|
||||
android:textSize="@dimen/day_text_size"/>
|
||||
android:textSize="@dimen/day_text_size"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/event_end_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/event_end_label"
|
||||
android:layout_below="@+id/event_end_checkbox"
|
||||
android:layout_toRightOf="@id/event_end_date"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:text="00:00"
|
||||
android:textSize="@dimen/day_text_size"/>
|
||||
android:textSize="@dimen/day_text_size"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/event_reminder_label"
|
||||
|
|
Loading…
Reference in New Issue