From 13cdaadcf73512ed6d27e4ba050e83e49bebdc5f Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Tue, 10 Dec 2019 22:31:33 +0100 Subject: [PATCH] [Dialog/EventManual] Add default type support and remove old dialog from the agenda fragment. --- .../ui/dialogs/event/EventManualDialog.kt | 6 ++++ .../ui/modules/agenda/AgendaFragment.java | 28 ++++++++----------- .../ui/modules/homework/HomeworkFragment.kt | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventManualDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventManualDialog.kt index 7bee8519..07e801ac 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventManualDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventManualDialog.kt @@ -177,6 +177,10 @@ class EventManualDialog( b.teacherDropdown.isEnabled = true b.typeDropdown.isEnabled = true + defaultType?.let { + b.typeDropdown.select(it.toLong()) + } + b.typeDropdown.selected?.let { item -> customColor = (item.tag as EventType).color } @@ -207,9 +211,11 @@ class EventManualDialog( customColor = null return@setOnChangeListener true } + (customColor ?: Event.COLOR_DEFAULT).let { b.typeColor.background.colorFilter = PorterDuffColorFilter(it, PorterDuff.Mode.SRC_ATOP) } + b.typeColor.onClick { val currentColor = (b.typeDropdown?.selected?.tag as EventType?)?.color ?: Event.COLOR_DEFAULT val colorPickerDialog = ColorPickerDialog.newBuilder() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.java b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.java index bc49c3c4..da0956f8 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.java @@ -16,7 +16,6 @@ import androidx.annotation.Nullable; import androidx.databinding.DataBindingUtil; import androidx.fragment.app.Fragment; -import com.afollestad.materialdialogs.MaterialDialog; import com.applandeo.materialcalendarview.CalendarView; import com.applandeo.materialcalendarview.EventDay; import com.github.tibolte.agendacalendarview.AgendaCalendarView; @@ -44,7 +43,7 @@ import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsenceFull; import pl.szczodrzynski.edziennik.databinding.FragmentAgendaCalendarBinding; import pl.szczodrzynski.edziennik.databinding.FragmentAgendaDefaultBinding; import pl.szczodrzynski.edziennik.ui.dialogs.event.EventListDialog; -import pl.szczodrzynski.edziennik.ui.dialogs.event.EventManualDialogOld; +import pl.szczodrzynski.edziennik.ui.dialogs.event.EventManualDialog; import pl.szczodrzynski.edziennik.ui.dialogs.lessonchange.LessonChangeDialog; import pl.szczodrzynski.edziennik.ui.dialogs.teacherabsence.TeacherAbsenceDialog; import pl.szczodrzynski.edziennik.ui.modules.agenda.lessonchange.LessonChangeCounter; @@ -107,20 +106,17 @@ public class AgendaFragment extends Fragment { .withIcon(SzkolnyFont.Icon.szf_calendar_plus_outline) .withOnClickListener(v3 -> { activity.getBottomSheet().close(); - new MaterialDialog.Builder(activity) - .title(R.string.main_menu_add) - .items(R.array.main_menu_add_options) - .itemsCallback((dialog, itemView, position, text) -> { - switch (position) { - case 0: - new EventManualDialogOld(activity).show(app, null, null, null, EventManualDialogOld.DIALOG_EVENT); - break; - case 1: - new EventManualDialogOld(activity).show(app, null, null, null, EventManualDialogOld.DIALOG_HOMEWORK); - break; - } - }) - .show(); + new EventManualDialog( + activity, + App.profileId, + null, + null, + null, + null, + null, + null, + null + ); }), new BottomSheetPrimaryItem(true) .withTitle(R.string.menu_agenda_change_view) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt index 34f62beb..01a2d705 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt @@ -103,7 +103,7 @@ class HomeworkFragment : Fragment() { activity.navView.bottomBar.fabExtendedText = getString(R.string.add) activity.navView.bottomBar.fabIcon = CommunityMaterial.Icon2.cmd_plus activity.navView.setFabOnClickListener(View.OnClickListener { - EventManualDialog(activity, App.profileId) + EventManualDialog(activity, App.profileId, defaultType = Event.TYPE_HOMEWORK) }) activity.gainAttention()