add a Save button and save the custom reminder value

This commit is contained in:
tibbi 2016-11-01 23:49:14 +01:00
parent 3a3fac2a48
commit f026c5230b
10 changed files with 44 additions and 11 deletions

View File

@ -240,9 +240,6 @@ class EventActivity : SimpleActivity(), DBHelper.EventsListener {
1 -> 0
else -> {
val value = custom_reminder_value.value
if (value.isEmpty())
0
val multiplier = when (custom_reminder_other_period.selectedItemPosition) {
1 -> Constants.HOUR_MINS
2 -> Constants.DAY_MINS

View File

@ -6,9 +6,7 @@ import android.view.View
import android.widget.AdapterView
import com.simplemobiletools.calendar.Constants
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.extensions.beVisibleIf
import com.simplemobiletools.calendar.extensions.hideKeyboard
import com.simplemobiletools.calendar.extensions.showKeyboard
import com.simplemobiletools.calendar.extensions.*
import kotlinx.android.synthetic.main.activity_settings.*
class SettingsActivity : SimpleActivity() {
@ -55,19 +53,23 @@ class SettingsActivity : SimpleActivity() {
Constants.REMINDER_AT_START -> 1
else -> 2
})
custom_reminder_save.setTextColor(custom_reminder_other_val.currentTextColor)
setupReminderPeriod(reminderMinutes)
settings_custom_reminder_holder.beVisibleIf(reminderType == 2)
custom_reminder_save.setOnClickListener { saveReminder() }
settings_default_reminder.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onNothingSelected(p0: AdapterView<*>?) {
}
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, itemIndex: Int, p3: Long) {
settings_custom_reminder_holder.beVisibleIf(itemIndex == 2)
if (itemIndex == 2)
if (itemIndex == 2) {
settings_custom_reminder_holder.visibility = View.VISIBLE
showKeyboard(custom_reminder_value)
else
} else {
hideKeyboard()
settings_custom_reminder_holder.visibility = View.GONE
}
mConfig.defaultReminderType = when (itemIndex) {
0 -> Constants.REMINDER_OFF
@ -78,6 +80,17 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun saveReminder() {
val value = custom_reminder_value.value
val multiplier = when (custom_reminder_other_period.selectedItemPosition) {
1 -> Constants.HOUR_MINS
2 -> Constants.DAY_MINS
else -> 1
}
mConfig.defaultReminderMinutes = Integer.valueOf(value) * multiplier
toast(R.string.reminder_saved)
}
private fun setupReminderPeriod(mins: Int) {
var value = mins
if (mins == 0) {

View File

@ -4,6 +4,7 @@ import android.appwidget.AppWidgetManager
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.widget.Toast
import com.simplemobiletools.calendar.MyWidgetProvider
import com.simplemobiletools.calendar.R
@ -18,3 +19,7 @@ fun Context.updateWidget() {
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
sendBroadcast(intent)
}
fun Context.toast(id: Int) = Toast.makeText(this, resources.getString(id), Toast.LENGTH_SHORT).show()
fun Context.toast(message: String) = Toast.makeText(this, message, Toast.LENGTH_SHORT).show()

View File

@ -119,6 +119,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/settings_padding"
android:layout_marginRight="@dimen/activity_margin"
android:layout_marginTop="@dimen/settings_padding"
android:visibility="gone">
@ -129,7 +130,7 @@
android:layout_marginLeft="@dimen/activity_margin"
android:digits="0123456789"
android:inputType="number"
android:minEms="5"
android:minEms="3"
android:textSize="@dimen/day_text_size"/>
<android.support.v7.widget.AppCompatSpinner
@ -141,7 +142,7 @@
android:layout_toRightOf="@+id/custom_reminder_value"
android:entries="@array/custom_reminders"
android:gravity="center_vertical"
android:paddingLeft="@dimen/activity_margin"/>
android:paddingLeft="@dimen/settings_padding"/>
<TextView
android:id="@+id/custom_reminder_other_val"
@ -153,6 +154,17 @@
android:gravity="center_vertical"
android:text="@string/before"/>
<Button
android:id="@+id/custom_reminder_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/custom_reminder_value"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/custom_reminder_value"
android:background="?android:attr/selectableItemBackground"
android:textSize="@dimen/day_text_size"
android:text="@string/save"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>

View File

@ -65,6 +65,7 @@
<string name="sunday_first">Sonntag als erster Wochentag</string>
<string name="week_numbers">Zeige Kalenderwoche an</string>
<string name="default_event_reminder">Default event reminder</string>
<string name="reminder_saved">Reminder saved</string>
<!-- License -->
<string name="notice">Diese App nutzt die folgenden Drittanbieterbibliotheken, die mein Leben einfacher machen. Danke.</string>

View File

@ -65,6 +65,7 @@
<string name="sunday_first">Sunday as first day</string>
<string name="week_numbers">Display week numbers</string>
<string name="default_event_reminder">Default event reminder</string>
<string name="reminder_saved">Reminder saved</string>
<!-- License -->
<string name="notice">Questa app usa le seguenti librerie di terze parti per semplificarmi la vita. Grazie.</string>

View File

@ -65,6 +65,7 @@
<string name="sunday_first">Sunday as first day</string>
<string name="week_numbers">Display week numbers</string>
<string name="default_event_reminder">Default event reminder</string>
<string name="reminder_saved">Reminder saved</string>
<!-- License -->
<string name="notice">このアプリは、私の人生を容易にするために、次のサードパーティのライブラリーを使用しています。 ありがとうございます。</string>

View File

@ -65,6 +65,7 @@
<string name="sunday_first">Domingo como primeiro dia</string>
<string name="week_numbers">Display week numbers</string>
<string name="default_event_reminder">Default event reminder</string>
<string name="reminder_saved">Reminder saved</string>
<!-- License -->
<string name="notice">Esta aplicação usa as seguintes bibliotecas de terceiros para facilitar a minha vida. Obrigado.</string>

View File

@ -65,6 +65,7 @@
<string name="sunday_first">Sunday as first day</string>
<string name="week_numbers">Display week numbers</string>
<string name="default_event_reminder">Default event reminder</string>
<string name="reminder_saved">Reminder saved</string>
<!-- License -->
<string name="notice">Denna app använder följande tredjepartsbibliotek för att göra mitt liv enklare. Tack.</string>

View File

@ -66,6 +66,7 @@
<string name="sunday_first">Sunday as first day</string>
<string name="week_numbers">Display week numbers</string>
<string name="default_event_reminder">Default event reminder</string>
<string name="reminder_saved">Reminder saved</string>
<!-- License -->
<string name="notice">This app uses the following third party libraries to make my life easier. Thank you.</string>