more tweaks to import events dialog

This commit is contained in:
tibbi 2017-01-25 23:23:19 +01:00
parent 7e491869bc
commit ae14690294
3 changed files with 29 additions and 3 deletions

View File

@ -136,10 +136,9 @@ class SettingsActivity : SimpleActivity() {
private fun setupEventReminder() {
val reminderType = config.defaultReminderType
val reminderMinutes = config.defaultReminderMinutes
settings_default_reminder.setSelection(getDefaultReminderTypeIndex())
custom_reminder_save.setTextColor(custom_reminder_other_val.currentTextColor)
setupReminderPeriod(reminderMinutes, custom_reminder_other_period, custom_reminder_value)
setupReminderPeriod(custom_reminder_other_period, custom_reminder_value)
settings_custom_reminder_holder.beVisibleIf(reminderType == REMINDER_CUSTOM)
custom_reminder_save.setOnClickListener { saveReminder() }

View File

@ -3,15 +3,38 @@ package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.support.v7.app.AlertDialog
import android.view.LayoutInflater
import android.view.View
import android.widget.AdapterView
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.extensions.getDefaultReminderTypeIndex
import com.simplemobiletools.calendar.extensions.setupReminderPeriod
import com.simplemobiletools.commons.extensions.hideKeyboard
import com.simplemobiletools.commons.extensions.humanizePath
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.showKeyboard
import kotlinx.android.synthetic.main.dialog_import_events.view.*
class ImportEventsDialog(val activity: Activity, val path: String, val callback: () -> Unit) : AlertDialog.Builder(activity) {
init {
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_import_events, null).apply {
import_events_filename.text = activity.humanizePath(path)
import_events_reminder.setSelection(context.getDefaultReminderTypeIndex())
context.setupReminderPeriod(import_events_custom_reminder_other_period, import_events_custom_reminder_value)
import_events_reminder.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, itemIndex: Int, p3: Long) {
if (itemIndex == 2) {
import_events_custom_reminder_holder.visibility = View.VISIBLE
activity.showKeyboard(import_events_custom_reminder_value)
} else {
activity.hideKeyboard()
import_events_custom_reminder_holder.visibility = View.GONE
}
}
override fun onNothingSelected(p0: AdapterView<*>?) {
}
}
}
AlertDialog.Builder(activity)
@ -19,6 +42,9 @@ class ImportEventsDialog(val activity: Activity, val path: String, val callback:
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this, R.string.import_events)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
})
}
}
}

View File

@ -117,7 +117,8 @@ fun Context.getDefaultReminderValue(index: Int): Int {
}
}
fun Context.setupReminderPeriod(mins: Int, otherPeriod: AppCompatSpinner, otherValue: EditText) {
fun Context.setupReminderPeriod(otherPeriod: AppCompatSpinner, otherValue: EditText) {
val mins = config.defaultReminderMinutes
var value = mins
if (mins == 0) {
otherPeriod.setSelection(0)