[Dialog/BellSync] Implement bell sync dialog.

This commit is contained in:
Kacper Ziubryniewicz 2019-12-20 00:40:00 +01:00
parent 38fc9e97bb
commit 2cf204ff79
10 changed files with 451 additions and 4 deletions

View File

@ -0,0 +1,79 @@
/*
* Copyright (c) Kacper Ziubryniewicz 2019-12-20
*/
package pl.szczodrzynski.edziennik.ui.dialogs.bell
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import pl.szczodrzynski.edziennik.App
import pl.szczodrzynski.edziennik.MainActivity
import pl.szczodrzynski.edziennik.R
import pl.szczodrzynski.edziennik.databinding.DialogBellSyncBinding
import pl.szczodrzynski.edziennik.utils.models.Time
import kotlin.coroutines.CoroutineContext
class BellSyncDialog(
val activity: AppCompatActivity,
private val bellTime: Time,
val onShowListener: ((tag: String) -> Unit)? = null,
val onDismissListener: ((tag: String) -> Unit)? = null
) : CoroutineScope {
companion object {
const val TAG = "BellSyncDialog"
}
private lateinit var job: Job
override val coroutineContext: CoroutineContext
get() = job + Dispatchers.Main
private lateinit var dialog: AlertDialog
private lateinit var b: DialogBellSyncBinding
private val app by lazy { activity.application as App }
init { apply {
if (activity.isFinishing)
return@apply
job = Job()
b = DialogBellSyncBinding.inflate(activity.layoutInflater)
onShowListener?.invoke(TAG)
dialog = MaterialAlertDialogBuilder(activity)
.setTitle(R.string.bell_sync_title)
.setView(b.root)
.setNeutralButton(R.string.cancel) { dialog, _ -> dialog.dismiss() }
.show()
initView()
}}
private fun initView() {
b.bellSyncHowto.text = app.getString(R.string.bell_sync_howto, bellTime.stringHM)
b.bellSyncButton.setOnClickListener {
val now = Time.getNow()
val bellDiff = Time.diff(now, bellTime)
val multiplier = if (bellTime > now) -1 else 1
app.config.timetable.bellSyncDiff = bellDiff
app.config.timetable.bellSyncMultiplier = multiplier
MaterialAlertDialogBuilder(activity)
.setTitle(R.string.bell_sync_title)
.setMessage(app.getString(R.string.bell_sync_results, if (multiplier == -1) '-' else '+', bellDiff.stringHMS))
.setPositiveButton(R.string.ok) { resultsDialog, _ ->
resultsDialog.dismiss()
dialog.dismiss()
if (activity is MainActivity) activity.reloadTarget()
}
.show()
}
if (Time.diff(Time.getNow(), bellTime) > Time(0, 10, 0)) { // Easter egg ^^
b.bellSyncButton.setImageDrawable(app.resources.getDrawable(R.drawable.ic_bell_wtf)) // wtf
}
}
}

View File

@ -0,0 +1,138 @@
/*
* Copyright (c) Kacper Ziubryniewicz 2019-12-20
*/
package pl.szczodrzynski.edziennik.ui.dialogs.bell
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.*
import pl.szczodrzynski.edziennik.App
import pl.szczodrzynski.edziennik.MainActivity
import pl.szczodrzynski.edziennik.R
import pl.szczodrzynski.edziennik.databinding.DialogBellSyncTimeChooseBinding
import pl.szczodrzynski.edziennik.onClick
import pl.szczodrzynski.edziennik.utils.TextInputDropDown
import pl.szczodrzynski.edziennik.utils.models.Date
import pl.szczodrzynski.edziennik.utils.models.Time
import kotlin.coroutines.CoroutineContext
class BellSyncTimeChooseDialog(
val activity: AppCompatActivity,
val onShowListener: ((tag: String) -> Unit)? = null,
val onDismissListener: ((tag: String) -> Unit)? = null
) : CoroutineScope {
companion object {
const val TAG = "BellSyncTimeChooseDialog"
}
private lateinit var job: Job
override val coroutineContext: CoroutineContext
get() = job + Dispatchers.Main
private lateinit var dialog: AlertDialog
private lateinit var b: DialogBellSyncTimeChooseBinding
private val app by lazy { activity.application as App }
private val today = Date.getToday()
private val selectedTime: Time?
get() = b.timeDropdown.selected?.id?.let { Time.fromValue(it.toInt()) }
init { apply {
if (activity.isFinishing)
return@apply
job = Job()
b = DialogBellSyncTimeChooseBinding.inflate(activity.layoutInflater)
onShowListener?.invoke(TAG)
dialog = MaterialAlertDialogBuilder(activity)
.setTitle(R.string.bell_sync_title)
.setView(b.root)
.setPositiveButton(R.string.ok) { dialog, _ ->
dialog.dismiss()
selectedTime?.let {
BellSyncDialog(activity, it)
}
}
.setNegativeButton(R.string.cancel) { dialog, _ -> dialog.dismiss() }
.setNeutralButton(R.string.reset, null)
.setOnDismissListener {
onDismissListener?.invoke(TAG)
}
.show()
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).onClick {
showResetDialog()
}
initView()
}}
private fun initView() {
b.bellSyncHowto.text = app.getString(R.string.bell_sync_choose_howto)
app.config.timetable.bellSyncDiff?.let { bellDiff ->
val multiplier = app.config.timetable.bellSyncMultiplier
val bellDiffText = (if (multiplier == -1) '-' else '+') + bellDiff.stringHMS
b.bellSyncHowto.text = app.getString(R.string.concat_2_strings,
app.getString(R.string.bell_sync_choose_howto),
app.getString(R.string.bell_sync_current_dialog, bellDiffText)
)
}
loadTimeList()
}
private fun loadTimeList() { launch {
val timeItems = withContext(Dispatchers.Default) {
val lessons = app.db.timetableDao().getForDateNow(App.profileId, today)
val items = mutableListOf<TextInputDropDown.Item>()
lessons.forEach {
items += TextInputDropDown.Item(
it.startTime?.value?.toLong() ?: return@forEach,
app.getString(R.string.bell_sync_lesson_item, it.displaySubjectName, it.startTime?.stringHM),
tag = it
)
items += TextInputDropDown.Item(
it.endTime?.value?.toLong() ?: return@forEach,
app.getString(R.string.bell_sync_break_item, it.endTime?.stringHM),
tag = it
)
}
items
}
b.timeDropdown.clear()
b.timeDropdown.append(timeItems)
timeItems.forEachIndexed { index, item ->
val time = Time.fromValue(item.id.toInt())
if (time < Time.getNow()) {
b.timeDropdown.select(if (timeItems.size > index + 1) timeItems[index + 1] else item)
}
}
b.timeDropdown.isEnabled = true
// TODO Fix popup cutting off
}}
private fun showResetDialog() {
MaterialAlertDialogBuilder(activity)
.setTitle(R.string.bell_sync_title)
.setMessage(R.string.bell_sync_reset_confirm)
.setPositiveButton(R.string.yes) { confirmDialog, _ ->
app.config.timetable.bellSyncDiff = null
app.config.timetable.bellSyncMultiplier = 0
confirmDialog.dismiss()
dialog.dismiss()
if (activity is MainActivity) activity.reloadTarget()
}
.setNegativeButton(R.string.no) { dialog, _ -> dialog.dismiss() }
.show()
}
}

View File

@ -22,6 +22,7 @@ import pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile
import pl.szczodrzynski.edziennik.data.db.modules.timetable.Lesson
import pl.szczodrzynski.edziennik.data.db.modules.timetable.LessonFull
import pl.szczodrzynski.edziennik.databinding.CardHomeTimetableBinding
import pl.szczodrzynski.edziennik.ui.dialogs.bell.BellSyncTimeChooseDialog
import pl.szczodrzynski.edziennik.ui.modules.home.HomeCard
import pl.szczodrzynski.edziennik.ui.modules.home.HomeCardAdapter
import pl.szczodrzynski.edziennik.ui.modules.home.HomeFragmentV2
@ -79,6 +80,16 @@ class HomeTimetableCard(
.colorAttr(activity, R.attr.colorIcon)
.sizeDp(20))
b.bellSync.setImageDrawable(IconicsDrawable(activity, CommunityMaterial.Icon.cmd_alarm_bell)
.colorAttr(activity, R.attr.colorIcon)
.sizeDp(20))
b.bellSync.setOnClickListener {
BellSyncTimeChooseDialog(
activity
)
}
// get current bell-sync params
app.config.timetable.bellSyncDiff?.let {
bellSyncDiffMillis = (it.hour * 60 * 60 * 1000 + it.minute * 60 * 1000 + it.second * 1000).toLong()

View File

@ -0,0 +1,54 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportWidth="64"
android:viewportHeight="64">
<path
android:pathData="M48.3984,50.668L34.668,50.668L34.668,48L48.3984,48C50.3984,48 52,46.3984 52,44.3984L52,26.668L54.668,26.668L54.668,44.3984C54.668,47.8672 51.8672,50.668 48.3984,50.668Z"
android:fillColor="#C5CAE9"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M34.668,56L18.668,56C16.5352,56 14.668,54.2656 14.668,52L14.668,42.668C14.668,40.5352 16.5352,38.668 18.668,38.668L34.668,38.668C36.8008,38.668 38.668,40.5352 38.668,42.668L38.668,52C38.668,54.2656 36.8008,56 34.668,56Z"
android:fillColor="#546E7A"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M46.668,28C46.668,39.0664 37.7344,48 26.668,48C15.6016,48 6.668,39.0664 6.668,28C6.668,16.9336 15.6016,8 26.668,8C37.7344,8 46.668,16.9336 46.668,28Z"
android:fillColor="#FF3D00"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M26.668,42.668C16,42.668 7.332,34.9336 6.668,26.9336C6.668,27.332 6.668,27.7344 6.668,28C6.668,39.0664 15.6016,48 26.668,48C37.7344,48 46.668,39.0664 46.668,28C46.668,27.6016 46.668,27.1992 46.668,26.9336C46,34.9336 37.332,42.668 26.668,42.668Z"
android:fillColor="#DD2C00"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M14.668,44L14.668,47.1992C18.1328,49.332 22.2656,50.668 26.668,50.668C31.0664,50.668 35.1992,49.332 38.668,47.1992L38.668,44C35.332,46.5352 31.1992,48 26.668,48C22.1328,48 18,46.5352 14.668,44Z"
android:fillColor="#37474F"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M34.668,28C34.668,32.3984 31.0664,36 26.668,36C22.2656,36 18.668,32.3984 18.668,28C18.668,23.6016 22.2656,20 26.668,20C31.0664,20 34.668,23.6016 34.668,28Z"
android:fillColor="#C5CAE9"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M29.332,28C29.332,29.4648 28.1328,30.668 26.668,30.668C25.1992,30.668 24,29.4648 24,28C24,26.5352 25.1992,25.332 26.668,25.332C28.1328,25.332 29.332,26.5352 29.332,28Z"
android:fillColor="#7986CB"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M57.332,26.668C57.332,28.9336 55.6016,30.668 53.332,30.668C51.0664,30.668 49.332,28.9336 49.332,26.668C49.332,24.3984 51.0664,22.668 53.332,22.668C55.6016,22.668 57.332,24.3984 57.332,26.668Z"
android:fillColor="#9FA8DA"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
</vector>

View File

@ -0,0 +1,78 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportWidth="64"
android:viewportHeight="64">
<path
android:pathData="M45.5508,36.1758C44.8242,32.8359 43.625,29.5391 43.3516,26.125C43.1641,23.7617 43.0859,21.375 42.6016,19.0508C42.1758,16.9883 41.3516,14.6016 39.4258,13.4883C38.0391,12.6875 36.4375,12.6641 34.8633,12.7109C33.0117,12.7734 31.1875,12.8008 29.3359,12.75C26.1367,12.6758 22.7617,12.7617 20.6484,15.5234C19.0234,17.6484 18.4883,20.4258 18.1758,23.0234C17.8242,25.9141 17.6992,28.8125 17.1484,31.6758C16.4766,35.1875 15.5625,38.7734 15.9375,42.375C17.7617,41.6641 19.8984,41.5234 21.8008,41.4609C25.4141,41.3359 29.0234,41.1875 32.6484,41.2734C34.6641,41.3242 36.6992,41.3359 38.6992,41.5859C39.6875,41.7109 40.6875,41.8984 41.6875,41.9766C42.5859,42.0391 43.4883,41.9766 44.3867,41.9883C44.9766,42 45.5742,42.0234 46.1641,42.125C46.2383,40.1367 45.9766,38.1367 45.5508,36.1758ZM27.3984,36.5859C27.3984,36.8867 27.25,37.1992 26.9375,37.2891C24.3633,38.0508 21.6758,37.8984 19.0742,37.3125C18.2383,37.125 18.4609,35.8359 19.2734,35.9492C19.2891,34.875 19.3359,33.8008 19.7109,32.7617C19.7891,32.5742 19.8984,32.4609 20.0391,32.3984C20.1367,32.2891 20.2734,32.2109 20.4609,32.1875C21.7383,32.0234 23.0234,31.8359 24.3125,31.8125C25.125,31.8008 26.1875,31.8516 26.8125,32.4883C27.875,33.5859 27.4141,35.2383 27.3984,36.5859ZM27.5742,27.8359C27.5117,29 27.0508,29.9141 25.8867,30.2891C24.2383,30.8125 22.4609,30.6875 20.7734,30.9492C20.4375,31 20.2109,30.8359 20.125,30.6016C20.0742,30.5625 20.0117,30.5234 19.9766,30.4609C19.5234,29.9492 19.6133,29.0508 19.6758,28.4258C19.7617,27.5117 19.9609,26.625 20.1641,25.7383C20.4883,24.3008 20.6875,22.8867 20.8867,21.4375C21.1016,19.8633 21.375,18.1133 22.25,16.7383C23.1875,15.2734 24.5742,14.5859 26.3125,14.7891C26.5859,14.8125 26.875,15.125 26.8633,15.4141C26.6484,19.5742 27.7891,23.6758 27.5742,27.8359Z"
android:fillColor="#EF4823"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M25.8242,33.4766C25.2266,33.0234 24.1992,33.1992 23.5117,33.25C22.6367,33.3125 21.7734,33.4258 20.8984,33.5391C20.625,34.3867 20.6484,35.3359 20.6484,36.2109C20.6484,36.2109 20.6484,36.2109 20.6484,36.2266C22.4492,36.5117 24.2734,36.5625 26.0508,36.1133C26.0742,35.625 26.125,35.1484 26.125,34.6641C26.1367,34.2891 26.1758,33.7383 25.8242,33.4766Z"
android:fillColor="#D6E5E5"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M18.1758,11.0234C18.1758,11.0391 18.1875,11.0508 18.1992,11.0625C18.3633,11.2266 18.5234,11.25 18.6367,11.2266C18.4609,11.2109 18.3008,11.1484 18.1758,11.0234Z"
android:fillColor="#D6E5E5"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M26.2266,27.0234C26.2109,23.375 25.3867,19.7617 25.4492,16.125C22.8242,16.3125 22.3984,20.1016 22.1484,22.1992C22,23.5 21.7734,24.7383 21.4883,26.0117C21.3125,26.8125 21.125,27.625 21.0391,28.4375C21,28.7266 20.9766,29.0234 21,29.3125C21.0117,29.4258 21.0117,29.4883 21.0234,29.5391C22.4883,29.3633 24.0625,29.4766 25.4375,28.9883C26.3242,28.6758 26.2266,27.8867 26.2266,27.0234Z"
android:fillColor="#D6E5E5"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M49.6641,45.9883C49.0625,45.0859 48.25,44.1484 47.1875,43.8008C46.8984,43.9766 46.4492,43.8633 46.2383,43.5625C44.7891,43.3008 43.3242,43.4375 41.8359,43.3633C39.875,43.2617 37.9375,42.8633 35.9609,42.7617C33.9141,42.6641 31.8633,42.6133 29.8125,42.625C27.8242,42.625 25.8516,42.6992 23.875,42.7734C22.5859,42.8242 21.2891,42.8359 20,42.9492C18.6992,43.0625 17.375,43.25 16.1758,43.7891C15.0234,44.3008 14.1992,45.1133 13.5742,46.1992C12.8867,47.3867 12.4258,48.7109 12.1133,50.0508C11.8359,51.2109 11.5859,52.5117 11.7617,53.7266C12.2734,53.5625 12.875,53.5234 13.3008,53.4883C14.8984,53.3125 16.5117,53.2383 18.125,53.1758C29.3633,52.7109 40.6133,52.6641 51.8633,52.6484C51.5508,50.3516 50.9492,47.9258 49.6641,45.9883Z"
android:fillColor="#EF4823"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M53.25,52.875C52.9609,50.3984 52.3359,47.9258 51.125,45.7383C50.5234,44.6641 49.7109,43.6758 48.6641,43.0117C48.3008,42.7891 47.9141,42.6016 47.5117,42.4609C47.6758,38.9492 46.8516,35.5391 45.9883,32.1484C45.5391,30.4258 44.9883,28.6484 44.8008,26.875C44.6875,25.7891 44.625,24.6875 44.5508,23.6016C44.2383,19.2617 43.625,13.2734 38.75,11.6875C37.0625,11.1367 35.125,11.3242 33.3867,11.3984C31.6016,11.4766 29.8242,11.3867 28.0391,11.3633C26.3125,11.3359 24.5859,11.4766 22.9766,12.1016C21.6484,12.6133 20.5117,13.5234 19.6367,14.6367C17.9609,16.75 17.3125,19.5117 16.9375,22.125C16.5391,24.9375 16.4766,27.7734 15.9883,30.5742C15.2891,34.5742 14.1367,38.6133 14.6133,42.7109C14.625,42.8359 14.6641,42.9375 14.7266,43.0117C14.0234,43.4492 13.3867,44.0117 12.8867,44.75C11.9375,46.125 11.3359,47.6641 10.8984,49.2734C10.4375,50.9492 10.1641,52.7891 10.5234,54.5117C10.5742,54.7617 10.7266,54.8984 10.8867,54.9492C11.0508,55.3242 11.6367,55.4375 11.9883,55.1484C12.0234,55.1367 12.1133,55.1016 12.1367,55.0859C12.3984,55.0117 12.4141,55.0117 12.7617,54.9609C13.5234,54.8516 14.2891,54.7891 15.0508,54.7266C17.1641,54.5742 19.2891,54.5117 21.3984,54.4492C25.6992,54.3242 30.0117,54.1758 34.3125,54.1016C40.4883,54 46.6484,54.0391 52.8242,54.0391C53.4883,54.0117 53.6016,53.2617 53.25,52.875ZM17.1484,31.6875C17.6992,28.8125 17.8242,25.9258 18.1758,23.0391C18.4883,20.4375 19.0234,17.6641 20.6484,15.5391C22.7617,12.7617 26.1367,12.6875 29.3359,12.7617C31.1875,12.8008 33.0117,12.7734 34.8633,12.7266C36.4258,12.6758 38.0234,12.6992 39.4258,13.5C41.3516,14.6133 42.1758,17.0117 42.6016,19.0625C43.0742,21.3867 43.1484,23.7734 43.3516,26.1367C43.625,29.5508 44.8359,32.8516 45.5508,36.1875C45.9766,38.1367 46.2383,40.1484 46.1641,42.1484C45.5742,42.0625 44.9766,42.0234 44.3867,42.0117C43.4883,42 42.5859,42.0508 41.6875,42C40.6875,41.9375 39.6992,41.7383 38.6992,41.6133C36.6992,41.3516 34.6641,41.3359 32.6484,41.3008C29.0234,41.2109 25.4141,41.3633 21.8008,41.4883C19.9141,41.5508 17.7734,41.6875 15.9375,42.3984C15.5742,38.7891 16.4883,35.1992 17.1484,31.6875ZM18.1016,53.1641C16.4883,53.2266 14.875,53.3008 13.2734,53.4766C12.8516,53.5234 12.25,53.5508 11.7383,53.7109C11.5625,52.5 11.8125,51.1992 12.0859,50.0391C12.3984,48.6992 12.8633,47.375 13.5508,46.1875C14.1758,45.1016 15,44.2891 16.1484,43.7734C17.3516,43.2383 18.6758,43.0508 19.9766,42.9375C21.2617,42.8242 22.5625,42.8242 23.8516,42.7617C25.8242,42.6758 27.8125,42.6133 29.7891,42.6133C31.8359,42.6133 33.8867,42.6641 35.9375,42.75C37.9141,42.8359 39.8516,43.25 41.8125,43.3516C43.3008,43.4258 44.7617,43.2891 46.2109,43.5508C46.4375,43.8516 46.875,43.9492 47.1641,43.7891C48.2266,44.1367 49.0508,45.0742 49.6367,45.9766C50.9258,47.9141 51.5234,50.3359 51.8125,52.6367C40.5859,52.6484 29.3359,52.7109 18.1016,53.1641Z"
android:fillColor="#010101"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M26.8359,15.4141C26.8516,15.125 26.5625,14.8242 26.2891,14.7891C24.5508,14.5859 23.1641,15.2734 22.2266,16.7383C21.3516,18.1016 21.0742,19.8516 20.8633,21.4375C20.6641,22.8984 20.4609,24.3008 20.1367,25.7383C19.9375,26.625 19.75,27.5234 19.6484,28.4258C19.5859,29.0508 19.5,29.9492 19.9492,30.4609C20,30.5117 20.0508,30.5625 20.1016,30.6016C20.1992,30.8359 20.4141,31 20.75,30.9492C22.4492,30.6875 24.2109,30.8008 25.8633,30.2891C27.0234,29.9258 27.4883,29 27.5508,27.8359C27.7891,23.6758 26.6484,19.5742 26.8359,15.4141ZM25.4375,28.9883C24.0508,29.4766 22.4766,29.3633 21.0234,29.5391C21.0117,29.4883 21.0117,29.4141 21,29.3125C20.9766,29.0234 21.0117,28.7266 21.0391,28.4375C21.1367,27.625 21.3125,26.8125 21.4883,26.0117C21.7734,24.7383 21.9883,23.5 22.1484,22.1992C22.3984,20.1016 22.8242,16.3125 25.4492,16.125C25.3867,19.7734 26.1992,23.375 26.2266,27.0234C26.2266,27.8867 26.3242,28.6758 25.4375,28.9883Z"
android:fillColor="#010101"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M26.8125,32.5117C26.1875,31.8867 25.1367,31.8242 24.3125,31.8359C23.0234,31.8633 21.75,32.0508 20.4609,32.2109C20.2734,32.2383 20.1367,32.3125 20.0391,32.4258C19.8984,32.4766 19.7734,32.5859 19.7109,32.7891C19.3359,33.8125 19.2734,34.8867 19.2734,35.9766C18.4609,35.8633 18.2383,37.1484 19.0742,37.3359C21.6758,37.9258 24.3633,38.0742 26.9375,37.3125C27.25,37.2266 27.3867,36.9141 27.3984,36.6133C27.4141,35.2383 27.875,33.5859 26.8125,32.5117ZM26.125,34.6758C26.1133,35.1641 26.0742,35.6367 26.0508,36.125C24.2734,36.5625 22.4492,36.5234 20.6484,36.2383C20.6484,36.2383 20.6484,36.2383 20.6484,36.2266C20.6484,35.3359 20.625,34.3984 20.8984,33.5508C21.7734,33.4375 22.6367,33.3359 23.5117,33.2617C24.1992,33.2109 25.2266,33.0391 25.8242,33.4883C26.1758,33.7383 26.1367,34.2891 26.125,34.6758Z"
android:fillColor="#010101"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M50.9883,18.2383C50.125,16.3359 49.875,14.1875 49.0859,12.25C48.2383,10.1875 46.75,8.2266 44.2891,8.3984C43.3984,8.4609 43.5117,9.8359 44.3867,9.7734C46.3867,9.6367 47.3633,11.5859 47.9766,13.1992C48.6484,14.9883 48.8984,16.9492 49.6875,18.6992C50.0508,19.4883 51.3516,19.0391 50.9883,18.2383Z"
android:fillColor="#010101"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M56.875,15.8125C56.5508,14.0625 56.1641,12.2734 55.6641,10.5742C55.3359,9.4609 54.875,8.3984 54.3125,7.3984C53.9609,6.7891 53.3984,6.3359 52.8633,5.8867C52.1133,5.2617 50.25,3.7734 49.5234,5.2266C49.1758,5.9375 50.1367,6.5117 50.625,6.0234C50.8633,6.125 51.0859,6.2617 51.3008,6.4141C51.7617,6.7383 52.1875,7.1133 52.6133,7.4883C53.125,7.9492 53.3984,8.5391 53.6875,9.1758C54.1133,10.1016 54.3984,11.0859 54.6484,12.0742C54.9766,13.3984 55.2891,14.7383 55.5391,16.0742C55.75,17.1992 56.0859,18.75 55.5391,19.8359C55.125,20.625 56.3633,21.2383 56.7734,20.4492C57.4883,19.0742 57.1484,17.2617 56.875,15.8125Z"
android:fillColor="#010101"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M19.3359,10.5391C19.1758,9.6758 18.3867,9.7734 17.8242,10.1758C17.5117,10.4141 17.2109,10.6758 16.9141,10.9375C16.6484,11.1641 16.2891,11.375 16.0625,11.6367C15.3125,12.5117 14.6992,13.5 14.3008,14.5742C14.0859,15.1484 13.9375,15.7383 13.8633,16.3516C13.8008,16.8516 13.7109,17.5391 13.8984,18.0117C14.0234,18.3359 14.4258,18.5859 14.7734,18.4375C15.125,18.2734 15.3008,18.0391 15.375,17.6484C15.4375,17.3633 15.3359,17.1484 15.1641,17.0117C15.1758,16.8633 15.1992,16.7266 15.2109,16.6133C15.25,16.1992 15.3516,15.8008 15.4609,15.4141C15.6875,14.6133 16.1133,13.8516 16.6016,13.1758C16.9375,12.6992 17.3516,12.375 17.7891,11.9883C17.9883,11.8125 18.1992,11.6367 18.4141,11.4609C18.5,11.3867 18.5859,11.3242 18.6758,11.2617C18.6875,11.25 18.6875,11.25 18.6992,11.25C19.0742,11.2383 19.4258,11 19.3359,10.5391ZM18.1875,11.0625C18.1758,11.0508 18.1758,11.0391 18.1641,11.0234C18.2891,11.1484 18.4492,11.2109 18.625,11.2266C18.5117,11.25 18.3516,11.2266 18.1875,11.0625Z"
android:fillColor="#010101"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M15.9883,5.8125C9.875,8.7266 7.8984,16.4609 7.2891,22.6367C7.1992,23.5117 8.4375,23.7734 8.6367,22.8984C8.6992,22.8125 8.7734,22.7383 8.8516,22.6641C9.1758,22.3359 9.0508,21.9258 8.7617,21.7109C9.1016,19.0625 9.6875,16.4375 10.6992,13.9609C11.8359,11.1758 13.6367,8.4492 16.4375,7.1133C17.2383,6.7383 16.7891,5.4258 15.9883,5.8125Z"
android:fillColor="#010101"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
</vector>

View File

@ -48,9 +48,15 @@
android:visibility="gone"
tools:src="@sample/settings" />
<ImageView
android:id="@+id/bellSync"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="10dp"
android:background="?selectableItemBackgroundBorderless"
tools:src="@sample/settings" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Kacper Ziubryniewicz 2019-12-20
-->
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="24dp">
<TextView
android:id="@+id/bellSyncHowto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="@string/bell_sync_howto" />
<ImageView
android:id="@+id/bellSyncButton"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_gravity="center"
android:layout_margin="32dp"
android:background="?android:attr/selectableItemBackground"
app:srcCompat="@drawable/ic_bell" />
</LinearLayout>
</layout>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Kacper Ziubryniewicz 2019-12-20
-->
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="24dp">
<TextView
android:id="@+id/bellSyncHowto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
tools:text="@string/bell_sync_choose_howto" />
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/bell_sync_time_title">
<pl.szczodrzynski.edziennik.utils.TextInputDropDown
android:id="@+id/timeDropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
tools:text="lekcja matematyka (8:00)"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</ScrollView>
</layout>

View File

@ -76,10 +76,13 @@
<string name="bell_sync_adjust_error">Incorrect format</string>
<string name="bell_sync_cannot_now">Calibration is impossible, because there are no lessons now. Try again, i.e. in the end of the lesson or break. Remember that you should run this even before planned bell time.</string>
<string name="bell_sync_current_dialog">\n\nCurrent calibration: %s</string>
<string name="bell_sync_howto">Click OK, when the lesson ends. The counter\'s time will be calibrated to the bell time.\n\nPlanned bell time is %s</string>
<string name="bell_sync_howto">Click OK, when the bell rings. The counter\'s time will be calibrated to the bell time.\n\nPlanned bell time is %s</string>
<string name="bell_sync_reset_confirm">Do you want to reset the calibration?</string>
<string name="bell_sync_results">The bell is inexact by %s%s</string>
<string name="bell_sync_title">Calibrate with the school bell</string>
<string name="bell_sync_time_title">Time of the bell to synchronize</string>
<string name="bell_sync_lesson_item">lesson %s (%s)</string>
<string name="bell_sync_break_item">break (%s)</string>
<string name="cancel">Cancel</string>
<string name="card_grades_button">Go to grades</string>
<string name="card_grades_header_title">Grades - last 7 days</string>

View File

@ -98,10 +98,14 @@
<string name="bell_sync_adjust_error">Nieprawidłowy format</string>
<string name="bell_sync_cannot_now">Synchronizacja jest niemożliwa, ponieważ teraz nie ma żadnych lekcji. Spróbuj jeszcze raz np. pod koniec lekcji albo przerwy. Pamiętaj, że powinieneś to uruchomić jeszcze przed planowanym czasem dzwonka.</string>
<string name="bell_sync_current_dialog">"\n\nAktualna kalibracja to %s"</string>
<string name="bell_sync_howto">Kliknij OK, kiedy lekcja się skończy. Licznik czasu zostanie zsynchronizowany z czasem dzwonka.\n\nCzas według planu to %s</string>
<string name="bell_sync_howto">Kliknij OK, kiedy dzwonek zadzwoni. Licznik czasu zostanie zsynchronizowany z czasem dzwonka.\n\nCzas według planu to %s</string>
<string name="bell_sync_choose_howto">Wybierz najbliższy dzwonek, abyś mógł go zsynchronizować z aplikacją.</string>
<string name="bell_sync_reset_confirm">Czy na pewno zresetować synchronizację?</string>
<string name="bell_sync_results">Dzwonek jest niedokładny o %s%s</string>
<string name="bell_sync_title">Synchronizacja z dzwonkiem</string>
<string name="bell_sync_time_title">Godzina dzwonka do synchronizacji</string>
<string name="bell_sync_lesson_item">lekcja %s (%s)</string>
<string name="bell_sync_break_item">przerwa (%s)</string>
<string name="cancel">Anuluj</string>
<string name="card_grades_button">Przejdź do ocen</string>
<string name="card_grades_header_title">Oceny - ostatnie 7 dni</string>