[UI/Agenda] Add FAB to add events and make the dialog open with the selected date.

This commit is contained in:
Kacper Ziubryniewicz 2019-12-15 00:42:28 +01:00
parent 7ce4acc687
commit cf77623e9c
2 changed files with 32 additions and 8 deletions

View File

@ -72,6 +72,7 @@ public class AgendaFragment extends Fragment {
private FragmentAgendaDefaultBinding b_default = null; private FragmentAgendaDefaultBinding b_default = null;
private FragmentAgendaCalendarBinding b_calendar = null; private FragmentAgendaCalendarBinding b_calendar = null;
private int viewType = AGENDA_DEFAULT; private int viewType = AGENDA_DEFAULT;
private Date actualDate = null;
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -110,7 +111,7 @@ public class AgendaFragment extends Fragment {
activity, activity,
App.profileId, App.profileId,
null, null,
null, actualDate,
null, null,
null, null,
null, null,
@ -137,7 +138,24 @@ public class AgendaFragment extends Fragment {
Toast.makeText(activity, R.string.main_menu_mark_as_read_success, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.main_menu_mark_as_read_success, Toast.LENGTH_SHORT).show();
}) })
); );
activity.getNavView().bottomBar.setFabEnable(true);
activity.getNavView().bottomBar.setFabExtendedText(getString(R.string.add));
activity.getNavView().bottomBar.setFabIcon(CommunityMaterial.Icon2.cmd_plus);
activity.getNavView().setFabOnClickListener(v -> new EventManualDialog(
activity,
App.profileId,
null,
actualDate,
null,
null,
null,
null,
null
));
activity.gainAttention(); activity.gainAttention();
activity.gainAttentionFAB();
if (viewType == AGENDA_DEFAULT) { if (viewType == AGENDA_DEFAULT) {
createDefaultAgendaView(); createDefaultAgendaView();
@ -303,7 +321,8 @@ public class AgendaFragment extends Fragment {
@Override @Override
public void onScrollToDate(Calendar calendar) { public void onScrollToDate(Calendar calendar) {
int scrolledDate = Date.fromCalendar(calendar).getValue(); actualDate = Date.fromCalendar(calendar);
int scrolledDate = actualDate.getValue();
if (unreadEventDates.contains(scrolledDate)) { if (unreadEventDates.contains(scrolledDate)) {
AsyncTask.execute(() -> app.db.eventDao().setSeenByDate(App.profileId, Date.fromYmd(intToStr(scrolledDate)), true)); AsyncTask.execute(() -> app.db.eventDao().setSeenByDate(App.profileId, Date.fromYmd(intToStr(scrolledDate)), true));
unreadEventDates.remove((Integer) scrolledDate); unreadEventDates.remove((Integer) scrolledDate);

View File

@ -99,12 +99,17 @@ class HomeworkFragment : Fragment() {
b.tabLayout.setupWithViewPager(b.viewPager) b.tabLayout.setupWithViewPager(b.viewPager)
activity.navView.bottomBar.fabEnable = true activity.navView.apply {
activity.navView.bottomBar.fabExtendedText = getString(R.string.add) bottomBar.apply {
activity.navView.bottomBar.fabIcon = CommunityMaterial.Icon2.cmd_plus fabEnable = true
activity.navView.setFabOnClickListener(View.OnClickListener { fabExtendedText = getString(R.string.add)
EventManualDialog(activity, App.profileId, defaultType = Event.TYPE_HOMEWORK) fabIcon = CommunityMaterial.Icon2.cmd_plus
}) }
setFabOnClickListener(View.OnClickListener {
EventManualDialog(activity, App.profileId, defaultType = Event.TYPE_HOMEWORK)
})
}
activity.gainAttention() activity.gainAttention()
activity.gainAttentionFAB() activity.gainAttentionFAB()