add some views related to custom reminder interval

This commit is contained in:
tibbi 2016-11-01 20:12:03 +01:00
parent 315c17ef85
commit 053111112a
2 changed files with 53 additions and 24 deletions

View File

@ -9,7 +9,6 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
import android.widget.AdapterView
import android.widget.EditText
@ -99,7 +98,8 @@ class EventActivity : SimpleActivity(), DBHelper.EventsListener {
}
private fun hideKeyboard() {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow((currentFocus ?: View(this)).windowToken, 0)
}
private fun showKeyboard(et: EditText) {
@ -113,7 +113,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventsListener {
0 -> event_reminder.setSelection(1)
else -> {
event_reminder.setSelection(2)
event_reminder_other.visibility = View.VISIBLE
toggleCustomReminderVisibility(true)
event_reminder_other.setText(mEvent.reminderMinutes.toString())
}
}
@ -146,15 +146,21 @@ class EventActivity : SimpleActivity(), DBHelper.EventsListener {
}
if (event_reminder.selectedItemPosition == event_reminder.count - 1) {
event_reminder_other.visibility = View.VISIBLE
toggleCustomReminderVisibility(true)
event_reminder_other.requestFocus()
showKeyboard(event_reminder_other)
} else {
event_reminder_other.visibility = View.GONE
hideKeyboard()
toggleCustomReminderVisibility(false)
}
}
fun toggleCustomReminderVisibility(show: Boolean) {
event_reminder_other_period.beVisibleIf(show)
event_reminder_other_val.beVisibleIf(show)
event_reminder_other.beVisibleIf(show)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_event, menu)
val item = menu.findItem(R.id.delete)

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/event_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:id="@+id/event_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/event_holder"
@ -24,7 +24,7 @@
android:maxLength="30"
android:maxLines="1"
android:minEms="20"
android:textSize="@dimen/day_text_size" />
android:textSize="@dimen/day_text_size"/>
</android.support.design.widget.TextInputLayout>
@ -44,7 +44,7 @@
android:hint="@string/description"
android:inputType="textCapSentences|textMultiLine"
android:minEms="20"
android:textSize="@dimen/day_text_size" />
android:textSize="@dimen/day_text_size"/>
</android.support.design.widget.TextInputLayout>
<TextView
@ -54,7 +54,7 @@
android:layout_below="@+id/event_description_label"
android:layout_marginTop="@dimen/activity_margin"
android:text="@string/start"
android:textSize="@dimen/day_text_size" />
android:textSize="@dimen/day_text_size"/>
<TextView
android:id="@+id/event_start_date"
@ -63,7 +63,7 @@
android:layout_below="@+id/event_start_label"
android:padding="@dimen/activity_margin"
android:text="January 1 1970"
android:textSize="@dimen/day_text_size" />
android:textSize="@dimen/day_text_size"/>
<TextView
android:id="@+id/event_start_time"
@ -73,7 +73,7 @@
android:layout_toRightOf="@id/event_start_date"
android:padding="@dimen/activity_margin"
android:text="00:00"
android:textSize="@dimen/day_text_size" />
android:textSize="@dimen/day_text_size"/>
<CheckBox
android:id="@+id/event_end_checkbox"
@ -83,7 +83,7 @@
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/end"
android:textSize="@dimen/day_text_size" />
android:textSize="@dimen/day_text_size"/>
<TextView
android:id="@+id/event_end_date"
@ -95,7 +95,7 @@
android:paddingRight="@dimen/activity_margin"
android:text="January 1 1970"
android:textSize="@dimen/day_text_size"
android:visibility="gone" />
android:visibility="gone"/>
<TextView
android:id="@+id/event_end_time"
@ -108,7 +108,7 @@
android:paddingRight="@dimen/activity_margin"
android:text="00:00"
android:textSize="@dimen/day_text_size"
android:visibility="gone" />
android:visibility="gone"/>
<TextView
android:id="@+id/event_reminder_label"
@ -117,7 +117,7 @@
android:layout_below="@+id/event_end_time"
android:layout_marginTop="@dimen/activity_margin"
android:text="@string/reminder"
android:textSize="@dimen/day_text_size" />
android:textSize="@dimen/day_text_size"/>
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/event_reminder"
@ -125,28 +125,51 @@
android:layout_height="wrap_content"
android:layout_below="@+id/event_reminder_label"
android:entries="@array/reminders"
android:padding="@dimen/activity_margin" />
android:padding="@dimen/activity_margin"/>
<EditText
android:id="@+id/event_reminder_other"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_reminder_label"
android:layout_toRightOf="@+id/event_reminder"
android:layout_below="@+id/event_reminder"
android:layout_marginLeft="@dimen/activity_margin"
android:digits="0123456789"
android:inputType="number"
android:minEms="5"
android:textSize="@dimen/day_text_size"
android:visibility="invisible" />
android:visibility="gone"/>
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/event_reminder_other_period"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/event_reminder_other"
android:layout_alignTop="@+id/event_reminder_other"
android:layout_toRightOf="@+id/event_reminder_other"
android:entries="@array/custom_reminders"
android:gravity="center_vertical"
android:paddingLeft="@dimen/activity_margin"
android:visibility="gone"/>
<TextView
android:id="@+id/event_reminder_other_val"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/event_reminder_other"
android:layout_alignTop="@+id/event_reminder_other"
android:layout_toRightOf="@+id/event_reminder_other_period"
android:gravity="center_vertical"
android:text="@string/before"
android:visibility="gone"/>
<TextView
android:id="@+id/event_repetition_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_reminder"
android:layout_below="@+id/event_reminder_other"
android:layout_marginTop="@dimen/activity_margin"
android:text="@string/repetition"
android:textSize="@dimen/day_text_size" />
android:textSize="@dimen/day_text_size"/>
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/event_repetition"
@ -154,7 +177,7 @@
android:layout_height="wrap_content"
android:layout_below="@+id/event_repetition_label"
android:entries="@array/repetition"
android:padding="@dimen/activity_margin" />
android:padding="@dimen/activity_margin"/>
</RelativeLayout>
</ScrollView>