[Dialog/GenerateBlockTimetable] Make better dialog layout.

This commit is contained in:
Kacper Ziubryniewicz 2020-02-29 00:43:25 +01:00
parent 1bfb3781ab
commit 1354faf8c7
2 changed files with 50 additions and 89 deletions

View File

@ -77,34 +77,25 @@ class GenerateBlockTimetableDialog(
b = DialogGenerateBlockTimetableBinding.inflate(activity.layoutInflater) 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.showProfileNameCheckbox.setOnCheckedChangeListener { _, isChecked -> showProfileName = isChecked }
b.showTeachersNamesItem.onClick { b.showTeachersNamesCheckbox.trigger() }
b.showTeachersNamesCheckbox.setOnCheckedChangeListener { _, isChecked -> showTeachersNames = isChecked } b.showTeachersNamesCheckbox.setOnCheckedChangeListener { _, isChecked -> showTeachersNames = isChecked }
b.noColorsItem.onClick { b.noColorsCheckbox.trigger() }
b.noColorsCheckbox.setOnCheckedChangeListener { _, isChecked -> noColors = isChecked } b.noColorsCheckbox.setOnCheckedChangeListener { _, isChecked -> noColors = isChecked }
dialog = MaterialAlertDialogBuilder(activity) dialog = MaterialAlertDialogBuilder(activity)
.setTitle(R.string.timetable_generate_range) .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) .setView(b.root)
.setNeutralButton(R.string.cancel) { dialog, _ -> dialog.dismiss() } .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) } .setOnDismissListener { onDismissListener?.invoke(TAG) }
.show() .show()
}} }}

View File

@ -2,87 +2,57 @@
~ Copyright (c) Kacper Ziubryniewicz 2020-1-5 ~ Copyright (c) Kacper Ziubryniewicz 2020-1-5
--> -->
<layout xmlns:android="http://schemas.android.com/apk/res/android"> <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical"
android:paddingHorizontal="20dp">
<LinearLayout <RadioGroup
android:id="@+id/showProfileNameItem" android:id="@+id/weekSelectionRadioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/withChangesCurrentWeekRadio"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectableItemBackground" android:checked="true"
android:clickable="true" tools:text="@string/timetable_generate_current_week_format" />
android:focusable="true"
android:orientation="horizontal"> <RadioButton
android:id="@+id/withChangesNextWeekRadio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="@string/timetable_generate_next_week_format" />
<RadioButton
android:id="@+id/forSelectedWeekRadio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/timetable_generate_selected_week" />
</RadioGroup>
<CheckBox <CheckBox
android:id="@+id/showProfileNameCheckbox" android:id="@+id/showProfileNameCheckbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/timetable_generate_show_profile_name" />
</LinearLayout>
<LinearLayout
android:id="@+id/showTeachersNamesItem"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectableItemBackground" android:text="@string/timetable_generate_show_profile_name" />
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<CheckBox <CheckBox
android:id="@+id/showTeachersNamesCheckbox" android:id="@+id/showTeachersNamesCheckbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:checked="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/timetable_generate_show_teachers_names" />
</LinearLayout>
<LinearLayout
android:id="@+id/noColorsItem"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectableItemBackground" android:checked="true"
android:clickable="true" android:text="@string/timetable_generate_show_teachers_names" />
android:focusable="true"
android:orientation="horizontal">
<CheckBox <CheckBox
android:id="@+id/noColorsCheckbox" android:id="@+id/noColorsCheckbox"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/timetable_generate_no_colors" /> android:text="@string/timetable_generate_no_colors" />
</LinearLayout> </LinearLayout>
</LinearLayout>
</layout> </layout>