mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 12:20:51 +01:00
add reminder calculation at importing events
This commit is contained in:
parent
a6c54e0b7a
commit
7e8bc89eeb
@ -162,13 +162,13 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun saveReminder() {
|
private fun saveReminder() {
|
||||||
val value = custom_reminder_value.value
|
|
||||||
val multiplier = when (custom_reminder_other_period.selectedItemPosition) {
|
val multiplier = when (custom_reminder_other_period.selectedItemPosition) {
|
||||||
1 -> HOUR_MINS
|
1 -> HOUR_MINS
|
||||||
2 -> DAY_MINS
|
2 -> DAY_MINS
|
||||||
else -> 1
|
else -> 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val value = custom_reminder_value.value
|
||||||
config.defaultReminderMinutes = Integer.valueOf(if (value.isEmpty()) "0" else value) * multiplier
|
config.defaultReminderMinutes = Integer.valueOf(if (value.isEmpty()) "0" else value) * multiplier
|
||||||
config.defaultReminderType = REMINDER_CUSTOM
|
config.defaultReminderType = REMINDER_CUSTOM
|
||||||
toast(R.string.reminder_saved)
|
toast(R.string.reminder_saved)
|
||||||
|
@ -8,10 +8,14 @@ import android.widget.AdapterView
|
|||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.extensions.getDefaultReminderTypeIndex
|
import com.simplemobiletools.calendar.extensions.getDefaultReminderTypeIndex
|
||||||
import com.simplemobiletools.calendar.extensions.setupReminderPeriod
|
import com.simplemobiletools.calendar.extensions.setupReminderPeriod
|
||||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
import com.simplemobiletools.calendar.helpers.DAY_MINS
|
||||||
|
import com.simplemobiletools.calendar.helpers.HOUR_MINS
|
||||||
|
import com.simplemobiletools.calendar.helpers.REMINDER_AT_START
|
||||||
|
import com.simplemobiletools.calendar.helpers.REMINDER_OFF
|
||||||
import com.simplemobiletools.commons.extensions.humanizePath
|
import com.simplemobiletools.commons.extensions.humanizePath
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.extensions.showKeyboard
|
import com.simplemobiletools.commons.extensions.showKeyboard
|
||||||
|
import com.simplemobiletools.commons.extensions.value
|
||||||
import kotlinx.android.synthetic.main.dialog_import_events.view.*
|
import kotlinx.android.synthetic.main.dialog_import_events.view.*
|
||||||
|
|
||||||
class ImportEventsDialog(val activity: Activity, val path: String, val callback: () -> Unit) : AlertDialog.Builder(activity) {
|
class ImportEventsDialog(val activity: Activity, val path: String, val callback: () -> Unit) : AlertDialog.Builder(activity) {
|
||||||
@ -27,12 +31,12 @@ class ImportEventsDialog(val activity: Activity, val path: String, val callback:
|
|||||||
import_events_custom_reminder_holder.visibility = View.VISIBLE
|
import_events_custom_reminder_holder.visibility = View.VISIBLE
|
||||||
activity.showKeyboard(import_events_custom_reminder_value)
|
activity.showKeyboard(import_events_custom_reminder_value)
|
||||||
} else {
|
} else {
|
||||||
activity.hideKeyboard()
|
|
||||||
import_events_custom_reminder_holder.visibility = View.GONE
|
import_events_custom_reminder_holder.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNothingSelected(p0: AdapterView<*>?) {
|
override fun onNothingSelected(p0: AdapterView<*>?) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,9 +46,24 @@ class ImportEventsDialog(val activity: Activity, val path: String, val callback:
|
|||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.create().apply {
|
.create().apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.import_events)
|
activity.setupDialogStuff(view, this, R.string.import_events)
|
||||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
||||||
|
val minutes = when (view.import_events_reminder.selectedItemPosition) {
|
||||||
|
0 -> REMINDER_OFF
|
||||||
|
1 -> REMINDER_AT_START
|
||||||
|
else -> getReminderMinutes(view)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getReminderMinutes(view: View): Int {
|
||||||
|
val multiplier = when (view.import_events_custom_reminder_other_period.selectedItemPosition) {
|
||||||
|
1 -> HOUR_MINS
|
||||||
|
2 -> DAY_MINS
|
||||||
|
else -> 1
|
||||||
|
}
|
||||||
|
|
||||||
|
val value = view.import_events_custom_reminder_value.value
|
||||||
|
return Integer.valueOf(if (value.isEmpty()) "0" else value) * multiplier
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,11 +230,11 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="@dimen/activity_margin"
|
android:layout_marginBottom="@dimen/activity_margin"
|
||||||
android:layout_marginLeft="@dimen/activity_margin"
|
android:layout_marginLeft="@dimen/activity_margin"
|
||||||
android:layout_marginStart="@dimen/activity_margin"
|
android:layout_marginRight="@dimen/activity_margin"
|
||||||
android:digits="0123456789"
|
android:digits="0123456789"
|
||||||
|
android:ems="3"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:maxLength="10"
|
android:maxLength="4"
|
||||||
android:minEms="3"
|
|
||||||
android:textCursorDrawable="@null"
|
android:textCursorDrawable="@null"
|
||||||
android:textSize="@dimen/day_text_size"/>
|
android:textSize="@dimen/day_text_size"/>
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
android:id="@+id/import_events_reminder"
|
android:id="@+id/import_events_reminder"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/activity_margin"
|
||||||
android:layout_marginTop="@dimen/medium_margin"
|
android:layout_marginTop="@dimen/medium_margin"
|
||||||
android:entries="@array/reminders"/>
|
android:entries="@array/reminders"/>
|
||||||
|
|
||||||
@ -54,11 +55,11 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="@dimen/activity_margin"
|
android:layout_marginBottom="@dimen/activity_margin"
|
||||||
android:layout_marginLeft="@dimen/activity_margin"
|
android:layout_marginLeft="@dimen/activity_margin"
|
||||||
android:layout_marginStart="@dimen/activity_margin"
|
android:layout_marginRight="@dimen/activity_margin"
|
||||||
android:digits="0123456789"
|
android:digits="0123456789"
|
||||||
|
android:ems="3"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:maxLength="10"
|
android:maxLength="4"
|
||||||
android:minEms="3"
|
|
||||||
android:textCursorDrawable="@null"
|
android:textCursorDrawable="@null"
|
||||||
android:textSize="@dimen/day_text_size"/>
|
android:textSize="@dimen/day_text_size"/>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user