create the custom repeat interval dialog
This commit is contained in:
parent
d205c0a5ec
commit
08c921d0c9
|
@ -0,0 +1,45 @@
|
|||
package com.simplemobiletools.calendar.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import kotlinx.android.synthetic.main.dialog_custom_event_repeat_interval.view.*
|
||||
|
||||
class CustomEventRepeatIntervalDialog(val activity: Activity, val callback: (seconds: Int) -> Unit) : AlertDialog.Builder(activity) {
|
||||
var dialog: AlertDialog
|
||||
var view: ViewGroup = LayoutInflater.from(activity).inflate(R.layout.dialog_custom_event_repeat_interval, null) as ViewGroup
|
||||
|
||||
init {
|
||||
view.dialog_radio_view.check(R.id.dialog_radio_days)
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, { dialogInterface, i -> confirmRepeatInterval() })
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
activity.setupDialogStuff(view, this, R.string.select_repeat_interval)
|
||||
}
|
||||
}
|
||||
|
||||
private fun confirmRepeatInterval() {
|
||||
val value = view.dialog_custom_repeat_interval_value.value
|
||||
val multiplier = getMultiplier(view.dialog_radio_view.checkedRadioButtonId)
|
||||
val days = Integer.valueOf(if (value.isEmpty()) "0" else value)
|
||||
callback.invoke(days * multiplier * 24 * 60 * 60)
|
||||
activity.hideKeyboard()
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
private fun getMultiplier(id: Int) = when (id) {
|
||||
R.id.dialog_radio_weeks -> 7
|
||||
R.id.dialog_radio_months -> 30
|
||||
R.id.dialog_radio_years -> 365
|
||||
else -> 1
|
||||
}
|
||||
}
|
|
@ -61,7 +61,10 @@ class EventRepeatIntervalDialog(val activity: Activity, val repeatSeconds: Int,
|
|||
return
|
||||
|
||||
if (checkedId == seconds.size) {
|
||||
|
||||
CustomEventRepeatIntervalDialog(activity) {
|
||||
callback.invoke(it)
|
||||
dialog?.dismiss()
|
||||
}
|
||||
} else {
|
||||
callback.invoke(seconds.elementAt(checkedId))
|
||||
dialog?.dismiss()
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/dialog_custom_repeat_interval_scrollview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_custom_repeat_interval_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/dialog_custom_repeat_interval_value"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:digits="0123456789"
|
||||
android:ems="3"
|
||||
android:inputType="number"
|
||||
android:maxLength="4"
|
||||
android:textCursorDrawable="@null"/>
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/dialog_radio_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||
android:id="@+id/dialog_radio_days"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/days_raw"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||
android:id="@+id/dialog_radio_weeks"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/weeks_raw"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||
android:id="@+id/dialog_radio_months"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/months_raw"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||
android:id="@+id/dialog_radio_years"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/years_raw"/>
|
||||
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Quincenal</string>
|
||||
<string name="monthly">Mensual</string>
|
||||
<string name="yearly">Anual</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repeat till:</string>
|
||||
<string name="forever">Forever</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Zweiwöchentlich</string>
|
||||
<string name="monthly">Monatlich</string>
|
||||
<string name="yearly">Jährlich</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Wiederholen bis:</string>
|
||||
<string name="forever">unendlich</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Quincenal</string>
|
||||
<string name="monthly">Mensual</string>
|
||||
<string name="yearly">Anual</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repeat till:</string>
|
||||
<string name="forever">Forever</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Bihebdomadaire</string>
|
||||
<string name="monthly">Mensuelle</string>
|
||||
<string name="yearly">Annuelle</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repeat till:</string>
|
||||
<string name="forever">Forever</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Quincenal</string>
|
||||
<string name="monthly">Mensual</string>
|
||||
<string name="yearly">Anual</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repeat till:</string>
|
||||
<string name="forever">Forever</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">हर दो सफ्ताह</string>
|
||||
<string name="monthly">मासिक</string>
|
||||
<string name="yearly">वार्षिक</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repeat till:</string>
|
||||
<string name="forever">Forever</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Kéthetente</string>
|
||||
<string name="monthly">Havonta</string>
|
||||
<string name="yearly">Évente</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repeat till:</string>
|
||||
<string name="forever">Forever</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Biweekly</string>
|
||||
<string name="monthly">Monthly</string>
|
||||
<string name="yearly">Yearly</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repeat till:</string>
|
||||
<string name="forever">Forever</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">דו-שבועית</string>
|
||||
<string name="monthly">חודשית</string>
|
||||
<string name="yearly">שנתית</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repeat till:</string>
|
||||
<string name="forever">Forever</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">隔週</string>
|
||||
<string name="monthly">毎月</string>
|
||||
<string name="yearly">毎年</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repeat till:</string>
|
||||
<string name="forever">Forever</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Bissemanal</string>
|
||||
<string name="monthly">Mensal</string>
|
||||
<string name="yearly">Anual</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repetir até:</string>
|
||||
<string name="forever">Eternamente</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Раз в две недели</string>
|
||||
<string name="monthly">Ежемесячно</string>
|
||||
<string name="yearly">Ежегодно</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Повторять до:</string>
|
||||
<string name="forever">Бесконечно</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Dvojtýždenne</string>
|
||||
<string name="monthly">Mesačne</string>
|
||||
<string name="yearly">Ročne</string>
|
||||
<string name="weeks_raw">týždňov</string>
|
||||
<string name="months_raw">mesiacov</string>
|
||||
<string name="years_raw">rokov</string>
|
||||
<string name="repeat_till">Opakovať do:</string>
|
||||
<string name="forever">Navždy</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Varannan vecka</string>
|
||||
<string name="monthly">Månadsvis</string>
|
||||
<string name="yearly">Årligen</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repeat till:</string>
|
||||
<string name="forever">Forever</string>
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<string name="biweekly">Biweekly</string>
|
||||
<string name="monthly">Monthly</string>
|
||||
<string name="yearly">Yearly</string>
|
||||
<string name="weeks_raw">weeks</string>
|
||||
<string name="months_raw">months</string>
|
||||
<string name="years_raw">years</string>
|
||||
<string name="repeat_till">Repeat till:</string>
|
||||
<string name="forever">Forever</string>
|
||||
|
||||
|
|
Loading…
Reference in New Issue