From 1354faf8c7feabed6c5f8d002178b4c2384d7815 Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Sat, 29 Feb 2020 00:43:25 +0100 Subject: [PATCH] [Dialog/GenerateBlockTimetable] Make better dialog layout. --- .../timetable/GenerateBlockTimetableDialog.kt | 31 ++--- .../dialog_generate_block_timetable.xml | 108 +++++++----------- 2 files changed, 50 insertions(+), 89 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/timetable/GenerateBlockTimetableDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/timetable/GenerateBlockTimetableDialog.kt index 3f947761..0cfa9e36 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/timetable/GenerateBlockTimetableDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/timetable/GenerateBlockTimetableDialog.kt @@ -77,34 +77,25 @@ class GenerateBlockTimetableDialog( b = DialogGenerateBlockTimetableBinding.inflate(activity.layoutInflater) - b.showProfileNameItem.onClick { b.showProfileNameCheckbox.trigger() } + b.withChangesCurrentWeekRadio.setText(R.string.timetable_generate_current_week_format, weekCurrentStart.formattedStringShort, weekCurrentEnd.formattedStringShort) + b.withChangesNextWeekRadio.setText(R.string.timetable_generate_next_week_format, weekNextStart.formattedStringShort, weekCurrentEnd.formattedStringShort) + b.showProfileNameCheckbox.setOnCheckedChangeListener { _, isChecked -> showProfileName = isChecked } - - b.showTeachersNamesItem.onClick { b.showTeachersNamesCheckbox.trigger() } b.showTeachersNamesCheckbox.setOnCheckedChangeListener { _, isChecked -> showTeachersNames = isChecked } - - b.noColorsItem.onClick { b.noColorsCheckbox.trigger() } b.noColorsCheckbox.setOnCheckedChangeListener { _, isChecked -> noColors = isChecked } dialog = MaterialAlertDialogBuilder(activity) .setTitle(R.string.timetable_generate_range) - .setItems(arrayOf( - activity.getString(R.string.timetable_generate_current_week_format, weekCurrentStart.formattedStringShort, weekCurrentEnd.formattedStringShort) - .asColoredSpannable(android.R.attr.textColorPrimary.resolveAttr(activity)), - activity.getString(R.string.timetable_generate_next_week_format, weekNextStart.formattedStringShort, weekNextEnd.formattedStringShort) - .asColoredSpannable(android.R.attr.textColorPrimary.resolveAttr(activity)), - activity.getString(R.string.timetable_generate_selected_week) - .asColoredSpannable(android.R.attr.textColorPrimary.resolveAttr(activity)) - )) { dialog, which -> - dialog.dismiss() - when (which) { - 0 -> generateBlockTimetable(weekCurrentStart, weekCurrentEnd) - 1 -> generateBlockTimetable(weekNextStart, weekNextEnd) - 2 -> selectDate() - } - } .setView(b.root) .setNeutralButton(R.string.cancel) { dialog, _ -> dialog.dismiss() } + .setPositiveButton(R.string.save) { dialog, _ -> + dialog.dismiss() + when (b.weekSelectionRadioGroup.checkedRadioButtonId) { + R.id.withChangesCurrentWeekRadio -> generateBlockTimetable(weekCurrentStart, weekCurrentEnd) + R.id.withChangesNextWeekRadio -> generateBlockTimetable(weekNextStart, weekNextEnd) + R.id.forSelectedWeekRadio -> selectDate() + } + } .setOnDismissListener { onDismissListener?.invoke(TAG) } .show() }} diff --git a/app/src/main/res/layout/dialog_generate_block_timetable.xml b/app/src/main/res/layout/dialog_generate_block_timetable.xml index e4f2d01b..0a4164c9 100644 --- a/app/src/main/res/layout/dialog_generate_block_timetable.xml +++ b/app/src/main/res/layout/dialog_generate_block_timetable.xml @@ -2,87 +2,57 @@ ~ Copyright (c) Kacper Ziubryniewicz 2020-1-5 --> - + + android:orientation="vertical" + android:paddingHorizontal="20dp"> - + + + + + + + + + + android:text="@string/timetable_generate_show_profile_name" /> - - - - - - + android:checked="true" + android:text="@string/timetable_generate_show_teachers_names" /> - - - - - - - - - - - + android:text="@string/timetable_generate_no_colors" />