|
| 1 | +package xyz.aprildown.timer.app.timer.edit |
| 2 | + |
| 3 | +import android.content.Context |
| 4 | +import androidx.annotation.StringRes |
| 5 | +import xyz.aprildown.timer.domain.entities.BehaviourEntity |
| 6 | +import xyz.aprildown.timer.domain.entities.BehaviourType |
| 7 | +import xyz.aprildown.timer.domain.entities.StepEntity |
| 8 | +import xyz.aprildown.timer.domain.entities.StepType |
| 9 | +import xyz.aprildown.timer.domain.entities.TimerEntity |
| 10 | +import xyz.aprildown.timer.app.base.R as RBase |
| 11 | + |
| 12 | +internal fun Context.getOneStageTimer(): TimerEntity = TimerEntity( |
| 13 | + id = TimerEntity.NEW_ID, |
| 14 | + name = getString(RBase.string.sample_timer_template_1_stage_name), |
| 15 | + loop = 3, |
| 16 | + steps = listOf( |
| 17 | + StepEntity.Step( |
| 18 | + label = getString(RBase.string.sample_timer_template_1_stage_work), |
| 19 | + length = 90_000L |
| 20 | + ), |
| 21 | + getTemplateNotifierStep() |
| 22 | + ), |
| 23 | + startStep = getTemplateStartStep(), |
| 24 | + endStep = getTemplateEndStep() |
| 25 | +) |
| 26 | + |
| 27 | +internal fun Context.getTwoStagesTimer(): TimerEntity = TimerEntity( |
| 28 | + id = TimerEntity.NEW_ID, |
| 29 | + name = getString(RBase.string.sample_timer_template_2_stages_name), |
| 30 | + loop = 3, |
| 31 | + steps = listOf( |
| 32 | + StepEntity.Step( |
| 33 | + label = getString(RBase.string.sample_timer_template_2_stages_high), |
| 34 | + length = 90_000L |
| 35 | + ), |
| 36 | + getTemplateNotifierStep(), |
| 37 | + StepEntity.Step( |
| 38 | + label = getString(RBase.string.sample_timer_template_2_stages_low), |
| 39 | + length = 30_000L |
| 40 | + ), |
| 41 | + getTemplateNotifierStep() |
| 42 | + ), |
| 43 | + startStep = getTemplateStartStep(RBase.string.sample_timer_template_2_stages_start), |
| 44 | + endStep = getTemplateEndStep(RBase.string.sample_timer_template_2_stages_end) |
| 45 | +) |
| 46 | + |
| 47 | +internal fun Context.getThreeStagesTimer(): TimerEntity = TimerEntity( |
| 48 | + id = TimerEntity.NEW_ID, |
| 49 | + name = getString(RBase.string.sample_timer_template_3_stages_name), |
| 50 | + loop = 3, |
| 51 | + steps = listOf( |
| 52 | + StepEntity.Step( |
| 53 | + label = getString(RBase.string.sample_timer_template_3_stages_1), |
| 54 | + length = 60_000L |
| 55 | + ), |
| 56 | + getTemplateNotifierStep(), |
| 57 | + StepEntity.Step( |
| 58 | + label = getString(RBase.string.sample_timer_template_3_stages_2), |
| 59 | + length = 60_000L |
| 60 | + ), |
| 61 | + getTemplateNotifierStep(), |
| 62 | + StepEntity.Step( |
| 63 | + label = getString(RBase.string.sample_timer_template_3_stages_3), |
| 64 | + length = 60_000L |
| 65 | + ), |
| 66 | + getTemplateNotifierStep() |
| 67 | + ), |
| 68 | + startStep = getTemplateStartStep(), |
| 69 | + endStep = getTemplateEndStep() |
| 70 | +) |
| 71 | + |
| 72 | +private fun Context.getTemplateNotifierStep(): StepEntity.Step = StepEntity.Step( |
| 73 | + label = getString(RBase.string.sample_timer_template_done), |
| 74 | + length = 5_000L, |
| 75 | + behaviour = listOf( |
| 76 | + BehaviourEntity(BehaviourType.MUSIC), |
| 77 | + BehaviourEntity(BehaviourType.SCREEN) |
| 78 | + ), |
| 79 | + type = StepType.NOTIFIER |
| 80 | +) |
| 81 | + |
| 82 | +private fun Context.getTemplateStartStep( |
| 83 | + @StringRes labelRes: Int = RBase.string.sample_timer_template_prepare |
| 84 | +): StepEntity.Step = StepEntity.Step( |
| 85 | + label = getString(labelRes), |
| 86 | + length = 10_000L, |
| 87 | + behaviour = listOf(BehaviourEntity(BehaviourType.BEEP)), |
| 88 | + type = StepType.START |
| 89 | +) |
| 90 | + |
| 91 | +private fun Context.getTemplateEndStep( |
| 92 | + @StringRes labelRes: Int = RBase.string.sample_timer_template_finish |
| 93 | +): StepEntity.Step = StepEntity.Step( |
| 94 | + label = getString(labelRes), |
| 95 | + length = 10_000L, |
| 96 | + behaviour = listOf(BehaviourEntity(BehaviourType.VOICE)), |
| 97 | + type = StepType.END |
| 98 | +) |
0 commit comments