forked from github/szkolny
Merge pull request #3 from szkolny-eu/feature/module-refactor
Refactor Gradle dependencies and project modules
This commit is contained in:
commit
07561c6484
1
agendacalendarview/.gitignore
vendored
1
agendacalendarview/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
/build
|
|
@ -1,54 +0,0 @@
|
|||||||
apply plugin: 'com.android.library'
|
|
||||||
//apply plugin: 'me.tatarka.retrolambda'
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion setup.compileSdk
|
|
||||||
|
|
||||||
android {
|
|
||||||
lintOptions {
|
|
||||||
abortOnError false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
minSdkVersion 14
|
|
||||||
targetSdkVersion setup.targetSdk
|
|
||||||
versionCode 1
|
|
||||||
versionName "1.0"
|
|
||||||
}
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
debugMinify {
|
|
||||||
debuggable = true
|
|
||||||
minifyEnabled = true
|
|
||||||
proguardFiles 'proguard-android.txt'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sourceSets {
|
|
||||||
main {
|
|
||||||
assets.srcDirs = ['assets']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
||||||
// Google libraries
|
|
||||||
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
|
|
||||||
implementation "androidx.recyclerview:recyclerview:${versions.recyclerView}"
|
|
||||||
implementation "com.google.android.material:material:${versions.material}"
|
|
||||||
|
|
||||||
// other libraries
|
|
||||||
//implementation 'se.emilsjolander:stickylistheaders:2.7.0'
|
|
||||||
implementation 'com.github.edisonw:StickyListHeaders:master-SNAPSHOT@aar'
|
|
||||||
implementation 'io.reactivex:rxjava:1.1.1'
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="com.github.tibolte.agendacalendarview">
|
|
||||||
</manifest>
|
|
@ -1,264 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview;
|
|
||||||
|
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.ObjectAnimator;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.ColorStateList;
|
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.os.Handler;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.AbsListView;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.agenda.AgendaAdapter;
|
|
||||||
import com.github.tibolte.agendacalendarview.agenda.AgendaView;
|
|
||||||
import com.github.tibolte.agendacalendarview.calendar.CalendarView;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.BaseCalendarEvent;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.DayItem;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.IWeekItem;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.WeekItem;
|
|
||||||
import com.github.tibolte.agendacalendarview.render.DefaultEventRenderer;
|
|
||||||
import com.github.tibolte.agendacalendarview.render.EventRenderer;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.BusProvider;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.Events;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.ListViewScrollTracker;
|
|
||||||
import com.github.tibolte.agendacalendarview.widgets.FloatingActionButton;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* View holding the agenda and calendar view together.
|
|
||||||
*/
|
|
||||||
public class AgendaCalendarView extends FrameLayout implements StickyListHeadersListView.OnStickyHeaderChangedListener {
|
|
||||||
|
|
||||||
private static final String LOG_TAG = AgendaCalendarView.class.getSimpleName();
|
|
||||||
|
|
||||||
private CalendarView mCalendarView;
|
|
||||||
private AgendaView mAgendaView;
|
|
||||||
private FloatingActionButton mFloatingActionButton;
|
|
||||||
|
|
||||||
private int mAgendaCurrentDayTextColor, mCalendarHeaderColor, mCalendarHeaderTextColor, mCalendarBackgroundColor, mCalendarDayTextColor, mCalendarPastDayTextColor, mCalendarCurrentDayColor, mFabColor;
|
|
||||||
private CalendarPickerController mCalendarPickerController;
|
|
||||||
|
|
||||||
public AgendaView getAgendaView() {
|
|
||||||
return mAgendaView;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ListViewScrollTracker mAgendaListViewScrollTracker;
|
|
||||||
private AbsListView.OnScrollListener mAgendaScrollListener = new AbsListView.OnScrollListener() {
|
|
||||||
int mCurrentAngle;
|
|
||||||
int mMaxAngle = 85;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
|
||||||
int scrollY = mAgendaListViewScrollTracker.calculateScrollY(firstVisibleItem, visibleItemCount);
|
|
||||||
if (scrollY != 0) {
|
|
||||||
mFloatingActionButton.show();
|
|
||||||
}
|
|
||||||
//Log.d(LOG_TAG, String.format("Agenda listView scrollY: %d", scrollY));
|
|
||||||
/*int toAngle = scrollY / 100;
|
|
||||||
if (toAngle > mMaxAngle) {
|
|
||||||
toAngle = mMaxAngle;
|
|
||||||
} else if (toAngle < -mMaxAngle) {
|
|
||||||
toAngle = -mMaxAngle;
|
|
||||||
}
|
|
||||||
RotateAnimation rotate = new RotateAnimation(mCurrentAngle, toAngle, mFloatingActionButton.getWidth() / 2, mFloatingActionButton.getHeight() / 2);
|
|
||||||
rotate.setFillAfter(true);
|
|
||||||
mCurrentAngle = toAngle;
|
|
||||||
mFloatingActionButton.startAnimation(rotate);*/
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// region Constructors
|
|
||||||
|
|
||||||
public AgendaCalendarView(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AgendaCalendarView(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
|
|
||||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ColorOptionsView, 0, 0);
|
|
||||||
mAgendaCurrentDayTextColor = a.getColor(R.styleable.ColorOptionsView_agendaCurrentDayTextColor, getResources().getColor(R.color.theme_primary));
|
|
||||||
mCalendarHeaderColor = a.getColor(R.styleable.ColorOptionsView_calendarHeaderColor, getResources().getColor(R.color.theme_primary_dark));
|
|
||||||
mCalendarHeaderTextColor = a.getColor(R.styleable.ColorOptionsView_calendarHeaderTextColor, getResources().getColor(R.color.theme_text_icons));
|
|
||||||
mCalendarBackgroundColor = a.getColor(R.styleable.ColorOptionsView_calendarColor, getResources().getColor(R.color.theme_primary));
|
|
||||||
mCalendarDayTextColor = a.getColor(R.styleable.ColorOptionsView_calendarDayTextColor, getResources().getColor(R.color.theme_text_icons));
|
|
||||||
mCalendarCurrentDayColor = a.getColor(R.styleable.ColorOptionsView_calendarCurrentDayTextColor, getResources().getColor(R.color.calendar_text_current_day));
|
|
||||||
mCalendarPastDayTextColor = a.getColor(R.styleable.ColorOptionsView_calendarPastDayTextColor, getResources().getColor(R.color.theme_light_primary));
|
|
||||||
mFabColor = a.getColor(R.styleable.ColorOptionsView_fabColor, getResources().getColor(R.color.theme_accent));
|
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) context
|
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
inflater.inflate(R.layout.view_agendacalendar, this, true);
|
|
||||||
|
|
||||||
setAlpha(0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Class - View
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onFinishInflate() {
|
|
||||||
super.onFinishInflate();
|
|
||||||
mCalendarView = (CalendarView) findViewById(R.id.calendar_view);
|
|
||||||
mAgendaView = (AgendaView) findViewById(R.id.agenda_view);
|
|
||||||
mFloatingActionButton = (FloatingActionButton) findViewById(R.id.floating_action_button);
|
|
||||||
ColorStateList csl = new ColorStateList(new int[][]{new int[0]}, new int[]{mFabColor});
|
|
||||||
mFloatingActionButton.setBackgroundTintList(csl);
|
|
||||||
|
|
||||||
LinearLayout mDayNamesHeader = mCalendarView.findViewById(R.id.cal_day_names);
|
|
||||||
mDayNamesHeader.setBackgroundColor(mCalendarHeaderColor);
|
|
||||||
for (int i = 0; i < mDayNamesHeader.getChildCount(); i++) {
|
|
||||||
TextView txtDay = (TextView) mDayNamesHeader.getChildAt(i);
|
|
||||||
txtDay.setTextColor(mCalendarHeaderTextColor);
|
|
||||||
}
|
|
||||||
mCalendarView.findViewById(R.id.list_week).setBackgroundColor(mCalendarBackgroundColor);
|
|
||||||
|
|
||||||
mAgendaView.getAgendaListView().setOnItemClickListener((AdapterView<?> parent, View view, int position, long id) -> {
|
|
||||||
mCalendarPickerController.onEventSelected(CalendarManager.getInstance().getEvents().get(position));
|
|
||||||
});
|
|
||||||
|
|
||||||
BusProvider.getInstance().toObserverable()
|
|
||||||
.subscribe(event -> {
|
|
||||||
if (event instanceof Events.DayClickedEvent) {
|
|
||||||
if (mCalendarPickerController != null)
|
|
||||||
mCalendarPickerController.onDaySelected(((Events.DayClickedEvent) event).getDay());
|
|
||||||
} else if (event instanceof Events.EventsFetched) {
|
|
||||||
ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), 1f).setDuration(500);
|
|
||||||
alphaAnimation.addListener(new Animator.AnimatorListener() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationStart(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
long fabAnimationDelay = 500;
|
|
||||||
// Just after setting the alpha from this view to 1, we hide the fab.
|
|
||||||
// It will reappear as soon as the user is scrolling the Agenda view.
|
|
||||||
new Handler().postDelayed(() -> {
|
|
||||||
mFloatingActionButton.hide();
|
|
||||||
mAgendaListViewScrollTracker = new ListViewScrollTracker(mAgendaView.getAgendaListView());
|
|
||||||
mAgendaView.getAgendaListView().setOnScrollListener(mAgendaScrollListener);
|
|
||||||
mFloatingActionButton.setOnClickListener((v) -> {
|
|
||||||
mAgendaView.translateList(0);
|
|
||||||
mAgendaView.getAgendaListView().smoothScrollBy(0, 0);
|
|
||||||
//mAgendaView.getAgendaListView().getWrappedList().smoothScrollBy(0, 0);
|
|
||||||
mAgendaView.getAgendaListView().scrollToCurrentDate(CalendarManager.getInstance().getToday());
|
|
||||||
new Handler().postDelayed(() -> mFloatingActionButton.hide(), fabAnimationDelay);
|
|
||||||
});
|
|
||||||
}, fabAnimationDelay);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationCancel(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationRepeat(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
alphaAnimation.start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Interface - StickyListHeadersListView.OnStickyHeaderChangedListener
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStickyHeaderChanged(StickyListHeadersListView stickyListHeadersListView, View header, int position, long headerId) {
|
|
||||||
//Log.d(LOG_TAG, String.format("onStickyHeaderChanged, position = %d, headerId = %d", position, headerId));
|
|
||||||
|
|
||||||
if (CalendarManager.getInstance().getEvents().size() > 0) {
|
|
||||||
CalendarEvent event = CalendarManager.getInstance().getEvents().get(position);
|
|
||||||
if (event != null) {
|
|
||||||
mCalendarView.scrollToDate(event);
|
|
||||||
mCalendarPickerController.onScrollToDate(event.getInstanceDay());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
public void init(List<CalendarEvent> eventList, Calendar minDate, Calendar maxDate, Locale locale, CalendarPickerController calendarPickerController, EventRenderer<?> ... renderers) {
|
|
||||||
mCalendarPickerController = calendarPickerController;
|
|
||||||
|
|
||||||
CalendarManager.getInstance(getContext()).buildCal(minDate, maxDate, locale, new DayItem(), new WeekItem());
|
|
||||||
|
|
||||||
// Feed our views with weeks list and events
|
|
||||||
mCalendarView.init(CalendarManager.getInstance(getContext()), mCalendarDayTextColor, mCalendarCurrentDayColor, mCalendarPastDayTextColor, eventList);
|
|
||||||
|
|
||||||
// Load agenda events and scroll to current day
|
|
||||||
AgendaAdapter agendaAdapter = new AgendaAdapter(mAgendaCurrentDayTextColor);
|
|
||||||
mAgendaView.getAgendaListView().setAdapter(agendaAdapter);
|
|
||||||
mAgendaView.getAgendaListView().setOnStickyHeaderChangedListener(this);
|
|
||||||
|
|
||||||
CalendarManager.getInstance().loadEvents(eventList, new BaseCalendarEvent());
|
|
||||||
BusProvider.getInstance().send(new Events.EventsFetched());
|
|
||||||
Log.d(LOG_TAG, "CalendarEventTask finished, event count "+eventList.size());
|
|
||||||
|
|
||||||
// add default event renderer
|
|
||||||
addEventRenderer(new DefaultEventRenderer());
|
|
||||||
for (EventRenderer<?> renderer: renderers) {
|
|
||||||
addEventRenderer(renderer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(Locale locale, List<IWeekItem> lWeeks, List<IDayItem> lDays, List<CalendarEvent> lEvents, CalendarPickerController calendarPickerController) {
|
|
||||||
mCalendarPickerController = calendarPickerController;
|
|
||||||
|
|
||||||
CalendarManager.getInstance(getContext()).loadCal(locale, lWeeks, lDays, lEvents);
|
|
||||||
|
|
||||||
// Feed our views with weeks list and events
|
|
||||||
mCalendarView.init(CalendarManager.getInstance(getContext()), mCalendarDayTextColor, mCalendarCurrentDayColor, mCalendarPastDayTextColor, lEvents);
|
|
||||||
|
|
||||||
// Load agenda events and scroll to current day
|
|
||||||
AgendaAdapter agendaAdapter = new AgendaAdapter(mAgendaCurrentDayTextColor);
|
|
||||||
mAgendaView.getAgendaListView().setAdapter(agendaAdapter);
|
|
||||||
mAgendaView.getAgendaListView().setOnStickyHeaderChangedListener(this);
|
|
||||||
|
|
||||||
// notify that actually everything is loaded
|
|
||||||
BusProvider.getInstance().send(new Events.EventsFetched());
|
|
||||||
Log.d(LOG_TAG, "CalendarEventTask finished");
|
|
||||||
|
|
||||||
// add default event renderer
|
|
||||||
addEventRenderer(new DefaultEventRenderer());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addEventRenderer(@NonNull final EventRenderer<?> renderer) {
|
|
||||||
AgendaAdapter adapter = (AgendaAdapter) mAgendaView.getAgendaListView().getAdapter();
|
|
||||||
adapter.addEventRenderer(renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableFloatingIndicator(boolean enable) {
|
|
||||||
mFloatingActionButton.setVisibility(enable ? VISIBLE : GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,267 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.IWeekItem;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class manages information about the calendar. (Events, weather info...)
|
|
||||||
* Holds reference to the days list of the calendar.
|
|
||||||
* As the app is using several views, we want to keep everything in one place.
|
|
||||||
*/
|
|
||||||
public class CalendarManager {
|
|
||||||
|
|
||||||
private static final String LOG_TAG = CalendarManager.class.getSimpleName();
|
|
||||||
|
|
||||||
private static CalendarManager mInstance;
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private Locale mLocale;
|
|
||||||
private Calendar mToday = Calendar.getInstance();
|
|
||||||
private SimpleDateFormat mWeekdayFormatter;
|
|
||||||
private SimpleDateFormat mMonthHalfNameFormat;
|
|
||||||
|
|
||||||
/// instances of classes provided from outside
|
|
||||||
private IDayItem mCleanDay;
|
|
||||||
private IWeekItem mCleanWeek;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of days used by the calendar
|
|
||||||
*/
|
|
||||||
private List<IDayItem> mDays = new ArrayList<>();
|
|
||||||
/**
|
|
||||||
* List of weeks used by the calendar
|
|
||||||
*/
|
|
||||||
private List<IWeekItem> mWeeks = new ArrayList<>();
|
|
||||||
/**
|
|
||||||
* List of events instances
|
|
||||||
*/
|
|
||||||
private List<CalendarEvent> mEvents = new ArrayList<>();
|
|
||||||
|
|
||||||
// region Constructors
|
|
||||||
|
|
||||||
public CalendarManager(Context context) {
|
|
||||||
this.mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CalendarManager getInstance(Context context) {
|
|
||||||
if (mInstance == null) {
|
|
||||||
mInstance = new CalendarManager(context);
|
|
||||||
}
|
|
||||||
return mInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CalendarManager getInstance() {
|
|
||||||
return mInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Getters/Setters
|
|
||||||
|
|
||||||
public Locale getLocale() {
|
|
||||||
return mLocale;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Context getContext() {
|
|
||||||
return mContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Calendar getToday() {
|
|
||||||
return mToday;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToday(Calendar today) {
|
|
||||||
this.mToday = today;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<IWeekItem> getWeeks() {
|
|
||||||
return mWeeks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CalendarEvent> getEvents() {
|
|
||||||
return mEvents;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<IDayItem> getDays() {
|
|
||||||
return mDays;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleDateFormat getWeekdayFormatter() {
|
|
||||||
return mWeekdayFormatter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleDateFormat getMonthHalfNameFormat() {
|
|
||||||
return mMonthHalfNameFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
public void buildCal(Calendar minDate, Calendar maxDate, Locale locale, IDayItem cleanDay, IWeekItem cleanWeek) {
|
|
||||||
if (minDate == null || maxDate == null) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"minDate and maxDate must be non-null.");
|
|
||||||
}
|
|
||||||
if (minDate.after(maxDate)) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"minDate must be before maxDate.");
|
|
||||||
}
|
|
||||||
if (locale == null) {
|
|
||||||
throw new IllegalArgumentException("Locale is null.");
|
|
||||||
}
|
|
||||||
|
|
||||||
setLocale(locale);
|
|
||||||
|
|
||||||
mDays.clear();
|
|
||||||
mWeeks.clear();
|
|
||||||
mEvents.clear();
|
|
||||||
|
|
||||||
mCleanDay = cleanDay;
|
|
||||||
mCleanWeek = cleanWeek;
|
|
||||||
|
|
||||||
Calendar mMinCal = Calendar.getInstance(mLocale);
|
|
||||||
Calendar mMaxCal = Calendar.getInstance(mLocale);
|
|
||||||
Calendar mWeekCounter = Calendar.getInstance(mLocale);
|
|
||||||
|
|
||||||
mMinCal.setTime(minDate.getTime());
|
|
||||||
mMaxCal.setTime(maxDate.getTime());
|
|
||||||
|
|
||||||
// maxDate is exclusive, here we bump back to the previous day, as maxDate if December 1st, 2020,
|
|
||||||
// we don't include that month in our list
|
|
||||||
mMaxCal.add(Calendar.MINUTE, -1);
|
|
||||||
|
|
||||||
// Now iterate we iterate between mMinCal and mMaxCal so we build our list of weeks
|
|
||||||
mWeekCounter.setTime(mMinCal.getTime());
|
|
||||||
int maxMonth = mMaxCal.get(Calendar.MONTH);
|
|
||||||
int maxYear = mMaxCal.get(Calendar.YEAR);
|
|
||||||
|
|
||||||
int currentMonth = mWeekCounter.get(Calendar.MONTH);
|
|
||||||
int currentYear = mWeekCounter.get(Calendar.YEAR);
|
|
||||||
|
|
||||||
// Loop through the weeks
|
|
||||||
while ((currentMonth <= maxMonth // Up to, including the month.
|
|
||||||
|| currentYear < maxYear) // Up to the year.
|
|
||||||
&& currentYear < maxYear + 1) { // But not > next yr.
|
|
||||||
|
|
||||||
Date date = mWeekCounter.getTime();
|
|
||||||
// Build our week list
|
|
||||||
int currentWeekOfYear = mWeekCounter.get(Calendar.WEEK_OF_YEAR);
|
|
||||||
|
|
||||||
IWeekItem weekItem = cleanWeek.copy();
|
|
||||||
weekItem.setWeekInYear(currentWeekOfYear);
|
|
||||||
weekItem.setYear(currentYear);
|
|
||||||
weekItem.setDate(date);
|
|
||||||
weekItem.setMonth(currentMonth);
|
|
||||||
weekItem.setLabel(mMonthHalfNameFormat.format(date));
|
|
||||||
List<IDayItem> dayItems = getDayCells(mWeekCounter); // gather days for the built week
|
|
||||||
weekItem.setDayItems(dayItems);
|
|
||||||
mWeeks.add(weekItem);
|
|
||||||
|
|
||||||
//Log.d(LOG_TAG, String.format("Adding week: %s", weekItem));
|
|
||||||
|
|
||||||
mWeekCounter.add(Calendar.WEEK_OF_YEAR, 1);
|
|
||||||
|
|
||||||
currentMonth = mWeekCounter.get(Calendar.MONTH);
|
|
||||||
currentYear = mWeekCounter.get(Calendar.YEAR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadEvents(List<CalendarEvent> eventList, CalendarEvent noEvent) {
|
|
||||||
|
|
||||||
for (IWeekItem weekItem : getWeeks()) {
|
|
||||||
for (IDayItem dayItem : weekItem.getDayItems()) {
|
|
||||||
boolean isEventForDay = false;
|
|
||||||
boolean isShowBadgeForDay = false;
|
|
||||||
for (CalendarEvent event : eventList) {
|
|
||||||
if (DateHelper.isBetweenInclusive(dayItem.getDate(), event.getStartTime(), event.getEndTime())) {
|
|
||||||
CalendarEvent copy = event.copy();
|
|
||||||
|
|
||||||
if (copy.getShowBadge()) {
|
|
||||||
isShowBadgeForDay = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Calendar dayInstance = Calendar.getInstance();
|
|
||||||
dayInstance.setTime(dayItem.getDate());
|
|
||||||
copy.setInstanceDay(dayInstance);
|
|
||||||
copy.setDayReference(dayItem);
|
|
||||||
copy.setWeekReference(weekItem);
|
|
||||||
// add instances in chronological order
|
|
||||||
getEvents().add(copy);
|
|
||||||
isEventForDay = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isEventForDay) {
|
|
||||||
Calendar dayInstance = Calendar.getInstance();
|
|
||||||
dayInstance.setTime(dayItem.getDate());
|
|
||||||
CalendarEvent copy = noEvent.copy();
|
|
||||||
|
|
||||||
copy.setInstanceDay(dayInstance);
|
|
||||||
copy.setDayReference(dayItem);
|
|
||||||
copy.setWeekReference(weekItem);
|
|
||||||
copy.setLocation("");
|
|
||||||
copy.setTitle(getContext().getResources().getString(R.string.agenda_event_no_events));
|
|
||||||
copy.setPlaceholder(true);
|
|
||||||
getEvents().add(copy);
|
|
||||||
}
|
|
||||||
dayItem.setShowBadge(isShowBadgeForDay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadCal (Locale locale, List<IWeekItem> lWeeks, List<IDayItem> lDays, List<CalendarEvent> lEvents) {
|
|
||||||
mWeeks = lWeeks;
|
|
||||||
mDays = lDays;
|
|
||||||
mEvents = lEvents;
|
|
||||||
setLocale(locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Private methods
|
|
||||||
|
|
||||||
private List<IDayItem> getDayCells(Calendar startCal) {
|
|
||||||
Calendar cal = Calendar.getInstance(mLocale);
|
|
||||||
cal.setTime(startCal.getTime());
|
|
||||||
List<IDayItem> dayItems = new ArrayList<>();
|
|
||||||
|
|
||||||
int firstDayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
|
|
||||||
int offset = cal.getFirstDayOfWeek() - firstDayOfWeek;
|
|
||||||
if (offset > 0) {
|
|
||||||
offset -= 7;
|
|
||||||
}
|
|
||||||
cal.add(Calendar.DATE, offset);
|
|
||||||
|
|
||||||
//Log.d(LOG_TAG, String.format("Buiding row week starting at %s", cal.getTime()));
|
|
||||||
for (int c = 0; c < 7; c++) {
|
|
||||||
IDayItem dayItem = mCleanDay.copy();
|
|
||||||
dayItem.buildDayItemFromCal(cal);
|
|
||||||
dayItems.add(dayItem);
|
|
||||||
cal.add(Calendar.DATE, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
mDays.addAll(dayItems);
|
|
||||||
return dayItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setLocale(Locale locale) {
|
|
||||||
this.mLocale = locale;
|
|
||||||
setToday(Calendar.getInstance(mLocale));
|
|
||||||
mWeekdayFormatter = new SimpleDateFormat(getContext().getString(R.string.day_name_format), mLocale);
|
|
||||||
mMonthHalfNameFormat = new SimpleDateFormat(getContext().getString(R.string.month_half_name_format), locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
public interface CalendarPickerController {
|
|
||||||
void onDaySelected(IDayItem dayItem);
|
|
||||||
|
|
||||||
void onEventSelected(CalendarEvent event);
|
|
||||||
|
|
||||||
void onScrollToDate(Calendar calendar);
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.agenda;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
|
||||||
import com.github.tibolte.agendacalendarview.render.DefaultEventRenderer;
|
|
||||||
import com.github.tibolte.agendacalendarview.render.EventRenderer;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adapter for the agenda, implements StickyListHeadersAdapter.
|
|
||||||
* Days as sections and CalendarEvents as list items.
|
|
||||||
*/
|
|
||||||
public class AgendaAdapter extends BaseAdapter implements StickyListHeadersAdapter {
|
|
||||||
|
|
||||||
private List<CalendarEvent> mEvents = new ArrayList<>();
|
|
||||||
private List<EventRenderer<?>> mRenderers = new ArrayList<>();
|
|
||||||
private int mCurrentDayColor;
|
|
||||||
|
|
||||||
// region Constructor
|
|
||||||
|
|
||||||
public AgendaAdapter(int currentDayTextColor) {
|
|
||||||
this.mCurrentDayColor = currentDayTextColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
public void updateEvents(List<CalendarEvent> events) {
|
|
||||||
this.mEvents.clear();
|
|
||||||
this.mEvents.addAll(events);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Interface - StickyListHeadersAdapter
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getHeaderView(int position, View convertView, ViewGroup parent) {
|
|
||||||
AgendaHeaderView agendaHeaderView = (AgendaHeaderView) convertView;
|
|
||||||
if (agendaHeaderView == null) {
|
|
||||||
agendaHeaderView = AgendaHeaderView.inflate(parent);
|
|
||||||
}
|
|
||||||
agendaHeaderView.setDay(getItem(position).getInstanceDay(), mCurrentDayColor, getItem(position).getDayReference().getShowBadge());
|
|
||||||
return agendaHeaderView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getHeaderId(int position) {
|
|
||||||
return mEvents.get(position).getInstanceDay().getTimeInMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Class - BaseAdapter
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
return mEvents.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CalendarEvent getItem(int position) {
|
|
||||||
return mEvents.get(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getItemId(int position) {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
|
||||||
EventRenderer eventRenderer = new DefaultEventRenderer();
|
|
||||||
final CalendarEvent event = getItem(position);
|
|
||||||
|
|
||||||
// Search for the correct event renderer
|
|
||||||
for (EventRenderer renderer : mRenderers) {
|
|
||||||
if(event.getClass().isAssignableFrom(renderer.getRenderType())) {
|
|
||||||
eventRenderer = renderer;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
convertView = LayoutInflater.from(parent.getContext())
|
|
||||||
.inflate(eventRenderer.getEventLayout(), parent, false);
|
|
||||||
eventRenderer.render(convertView, event);
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addEventRenderer(@NonNull final EventRenderer<?> renderer) {
|
|
||||||
mRenderers.add(renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.agenda;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.R;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List item view for the StickyHeaderListView of the agenda view
|
|
||||||
*/
|
|
||||||
public class AgendaEventView extends LinearLayout {
|
|
||||||
public static AgendaEventView inflate(ViewGroup parent) {
|
|
||||||
return (AgendaEventView) LayoutInflater.from(parent.getContext()).inflate(R.layout.view_agenda_event, parent, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// region Constructors
|
|
||||||
|
|
||||||
public AgendaEventView(Context context) {
|
|
||||||
this(context, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AgendaEventView(Context context, AttributeSet attrs) {
|
|
||||||
this(context, attrs, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AgendaEventView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
setPadding(getResources().getDimensionPixelSize(R.dimen.agenda_event_view_padding_left),
|
|
||||||
getResources().getDimensionPixelSize(R.dimen.agenda_event_view_padding_top),
|
|
||||||
getResources().getDimensionPixelSize(R.dimen.agenda_event_view_padding_right),
|
|
||||||
getResources().getDimensionPixelSize(R.dimen.agenda_event_view_padding_bottom));
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.agenda;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
|
||||||
import com.github.tibolte.agendacalendarview.R;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.drawable.GradientDrawable;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Header view for the StickyHeaderListView of the agenda view
|
|
||||||
*/
|
|
||||||
public class AgendaHeaderView extends LinearLayout {
|
|
||||||
|
|
||||||
public static AgendaHeaderView inflate(ViewGroup parent) {
|
|
||||||
return (AgendaHeaderView) LayoutInflater.from(parent.getContext()).inflate(R.layout.view_agenda_header, parent, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// region Constructors
|
|
||||||
|
|
||||||
public AgendaHeaderView(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AgendaHeaderView(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AgendaHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
public void setDay(Calendar day, int currentDayTextColor, boolean showBadge) {
|
|
||||||
TextView txtDayOfMonth = (TextView) findViewById(R.id.view_agenda_day_of_month);
|
|
||||||
TextView txtDayOfWeek = (TextView) findViewById(R.id.view_agenda_day_of_week);
|
|
||||||
TextView txtDay = (TextView) findViewById(R.id.view_agenda_day_text);
|
|
||||||
View circleView = findViewById(R.id.view_day_circle_selected);
|
|
||||||
|
|
||||||
Calendar today = CalendarManager.getInstance().getToday();
|
|
||||||
|
|
||||||
SimpleDateFormat dayWeekFormatter = new SimpleDateFormat(getContext().getString(R.string.day_name_format), CalendarManager.getInstance().getLocale());
|
|
||||||
SimpleDateFormat dayWeekLongFormatter = new SimpleDateFormat("EEEE", CalendarManager.getInstance().getLocale());
|
|
||||||
|
|
||||||
txtDayOfMonth.setTextColor(getResources().getColor(R.color.calendar_text_default));
|
|
||||||
txtDayOfWeek.setTextColor(getResources().getColor(R.color.calendar_text_default));
|
|
||||||
|
|
||||||
if (DateHelper.sameDate(day, today)) {
|
|
||||||
txtDayOfMonth.setTextColor(currentDayTextColor);
|
|
||||||
circleView.setVisibility(VISIBLE);
|
|
||||||
GradientDrawable drawable = (GradientDrawable) circleView.getBackground();
|
|
||||||
drawable.setStroke((int) (2 * Resources.getSystem().getDisplayMetrics().density), currentDayTextColor);
|
|
||||||
} else if (showBadge) {
|
|
||||||
circleView.setVisibility(VISIBLE);
|
|
||||||
GradientDrawable drawable = (GradientDrawable) circleView.getBackground();
|
|
||||||
drawable.setStroke((int) (2 * Resources.getSystem().getDisplayMetrics().density), 0xffff0000);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
circleView.setVisibility(INVISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
txtDayOfMonth.setText(String.valueOf(day.get(Calendar.DAY_OF_MONTH)));
|
|
||||||
txtDayOfWeek.setText(dayWeekFormatter.format(day.getTime()));
|
|
||||||
//txtDay.setText(dayWeekLongFormatter.format(day.getTime()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.agenda;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StickyListHeadersListView to scroll chronologically through events.
|
|
||||||
*/
|
|
||||||
public class AgendaListView extends StickyListHeadersListView {
|
|
||||||
|
|
||||||
// region Constructors
|
|
||||||
|
|
||||||
public AgendaListView(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AgendaListView(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AgendaListView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
public void scrollToCurrentDate(Calendar today) {
|
|
||||||
List<CalendarEvent> events = CalendarManager.getInstance().getEvents();
|
|
||||||
|
|
||||||
int toIndex = 0;
|
|
||||||
for (int i = 0; i < events.size(); i++) {
|
|
||||||
if (DateHelper.sameDate(today, events.get(i).getInstanceDay())) {
|
|
||||||
toIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final int finalToIndex = toIndex;
|
|
||||||
post(()->setSelection(finalToIndex));
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,145 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.agenda;
|
|
||||||
|
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.ObjectAnimator;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
|
||||||
import com.github.tibolte.agendacalendarview.R;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.BusProvider;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.Events;
|
|
||||||
|
|
||||||
public class AgendaView extends FrameLayout {
|
|
||||||
|
|
||||||
private AgendaListView mAgendaListView;
|
|
||||||
private View mShadowView;
|
|
||||||
|
|
||||||
// region Constructors
|
|
||||||
|
|
||||||
public AgendaView(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AgendaView(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) context
|
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
inflater.inflate(R.layout.view_agenda, this, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Class - View
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onFinishInflate() {
|
|
||||||
super.onFinishInflate();
|
|
||||||
|
|
||||||
mAgendaListView = (AgendaListView) findViewById(R.id.agenda_listview);
|
|
||||||
mShadowView = findViewById(R.id.view_shadow);
|
|
||||||
|
|
||||||
BusProvider.getInstance().toObserverable()
|
|
||||||
.subscribe(event -> {
|
|
||||||
if (event instanceof Events.DayClickedEvent) {
|
|
||||||
Events.DayClickedEvent clickedEvent = (Events.DayClickedEvent) event;
|
|
||||||
getAgendaListView().scrollToCurrentDate(clickedEvent.getCalendar());
|
|
||||||
} else if (event instanceof Events.CalendarScrolledEvent) {
|
|
||||||
int offset = (int) (3 * getResources().getDimension(R.dimen.day_cell_height));
|
|
||||||
translateList(offset);
|
|
||||||
} else if (event instanceof Events.EventsFetched) {
|
|
||||||
if (getAgendaListView().getAdapter() != null)
|
|
||||||
((AgendaAdapter) getAgendaListView().getAdapter()).updateEvents(CalendarManager.getInstance().getEvents());
|
|
||||||
|
|
||||||
getViewTreeObserver().addOnGlobalLayoutListener(
|
|
||||||
new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
if (getWidth() != 0 && getHeight() != 0) {
|
|
||||||
// display only two visible rows on the calendar view
|
|
||||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getLayoutParams();
|
|
||||||
int height = getHeight();
|
|
||||||
int margin = (int) (getContext().getResources().getDimension(R.dimen.calendar_header_height) + 2 * getContext().getResources().getDimension(R.dimen.day_cell_height));
|
|
||||||
layoutParams.height = height;
|
|
||||||
layoutParams.setMargins(0, margin, 0, 0);
|
|
||||||
setLayoutParams(layoutParams);
|
|
||||||
|
|
||||||
getAgendaListView().scrollToCurrentDate(CalendarManager.getInstance().getToday());
|
|
||||||
|
|
||||||
getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
);
|
|
||||||
} else if (event instanceof Events.ForecastFetched) {
|
|
||||||
((AgendaAdapter) getAgendaListView().getAdapter()).updateEvents(CalendarManager.getInstance().getEvents());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
|
||||||
int eventaction = event.getAction();
|
|
||||||
|
|
||||||
switch (eventaction) {
|
|
||||||
case MotionEvent.ACTION_DOWN:
|
|
||||||
// if the user touches the listView, we put it back to the top
|
|
||||||
translateList(0);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.dispatchTouchEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
public AgendaListView getAgendaListView() {
|
|
||||||
return mAgendaListView;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void translateList(int targetY) {
|
|
||||||
if (targetY != getTranslationY()) {
|
|
||||||
ObjectAnimator mover = ObjectAnimator.ofFloat(this, "translationY", targetY);
|
|
||||||
mover.setDuration(150);
|
|
||||||
mover.addListener(new Animator.AnimatorListener() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationStart(Animator animation) {
|
|
||||||
//mShadowView.setVisibility(GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
if (targetY == 0) {
|
|
||||||
BusProvider.getInstance().send(new Events.AgendaListViewTouchedEvent());
|
|
||||||
}
|
|
||||||
//mShadowView.setVisibility(VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationCancel(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationRepeat(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mover.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,279 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.calendar;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
|
||||||
import com.github.tibolte.agendacalendarview.R;
|
|
||||||
import com.github.tibolte.agendacalendarview.calendar.weekslist.WeekListView;
|
|
||||||
import com.github.tibolte.agendacalendarview.calendar.weekslist.WeeksAdapter;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.IWeekItem;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.BusProvider;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.Events;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The calendar view is a freely scrolling view that allows the user to browse between days of the
|
|
||||||
* year.
|
|
||||||
*/
|
|
||||||
public class CalendarView extends LinearLayout {
|
|
||||||
|
|
||||||
private static final String LOG_TAG = CalendarView.class.getSimpleName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Top of the calendar view layout, the week days list
|
|
||||||
*/
|
|
||||||
private LinearLayout mDayNamesHeader;
|
|
||||||
/**
|
|
||||||
* Part of the calendar view layout always visible, the weeks list
|
|
||||||
*/
|
|
||||||
private WeekListView mListViewWeeks;
|
|
||||||
/**
|
|
||||||
* The adapter for the weeks list
|
|
||||||
*/
|
|
||||||
private WeeksAdapter mWeeksAdapter;
|
|
||||||
/**
|
|
||||||
* The current highlighted day in blue
|
|
||||||
*/
|
|
||||||
private IDayItem mSelectedDay;
|
|
||||||
/**
|
|
||||||
* The current row displayed at top of the list
|
|
||||||
*/
|
|
||||||
private int mCurrentListPosition;
|
|
||||||
|
|
||||||
// region Constructors
|
|
||||||
|
|
||||||
public CalendarView(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CalendarView(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) context
|
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
inflater.inflate(R.layout.view_calendar, this, true);
|
|
||||||
|
|
||||||
setOrientation(VERTICAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
public IDayItem getSelectedDay() {
|
|
||||||
return mSelectedDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectedDay(IDayItem mSelectedDay) {
|
|
||||||
this.mSelectedDay = mSelectedDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WeekListView getListViewWeeks() {
|
|
||||||
return mListViewWeeks;
|
|
||||||
}
|
|
||||||
|
|
||||||
// region Class - View
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onFinishInflate() {
|
|
||||||
super.onFinishInflate();
|
|
||||||
|
|
||||||
mDayNamesHeader = (LinearLayout) findViewById(R.id.cal_day_names);
|
|
||||||
mListViewWeeks = (WeekListView) findViewById(R.id.list_week);
|
|
||||||
mListViewWeeks.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
||||||
mListViewWeeks.setHasFixedSize(true);
|
|
||||||
mListViewWeeks.setItemAnimator(null);
|
|
||||||
mListViewWeeks.setSnapEnabled(true);
|
|
||||||
|
|
||||||
// display only two visible rows on the calendar view
|
|
||||||
getViewTreeObserver().addOnGlobalLayoutListener(
|
|
||||||
new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
if (getWidth() != 0 && getHeight() != 0) {
|
|
||||||
collapseCalendarView();
|
|
||||||
getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onAttachedToWindow() {
|
|
||||||
super.onAttachedToWindow();
|
|
||||||
|
|
||||||
BusProvider.getInstance().toObserverable()
|
|
||||||
.subscribe(event -> {
|
|
||||||
if (event instanceof Events.CalendarScrolledEvent) {
|
|
||||||
expandCalendarView();
|
|
||||||
} else if (event instanceof Events.AgendaListViewTouchedEvent) {
|
|
||||||
collapseCalendarView();
|
|
||||||
} else if (event instanceof Events.DayClickedEvent) {
|
|
||||||
Events.DayClickedEvent clickedEvent = (Events.DayClickedEvent) event;
|
|
||||||
updateSelectedDay(clickedEvent.getCalendar(), clickedEvent.getDay());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
public void init(CalendarManager calendarManager, int dayTextColor, int currentDayTextColor, int pastDayTextColor, List<CalendarEvent> eventList) {
|
|
||||||
Calendar today = calendarManager.getToday();
|
|
||||||
Locale locale = calendarManager.getLocale();
|
|
||||||
SimpleDateFormat weekDayFormatter = calendarManager.getWeekdayFormatter();
|
|
||||||
List<IWeekItem> weeks = calendarManager.getWeeks();
|
|
||||||
|
|
||||||
setUpHeader(today, weekDayFormatter, locale);
|
|
||||||
setUpAdapter(today, weeks, dayTextColor, currentDayTextColor, pastDayTextColor, eventList);
|
|
||||||
scrollToDate(today, weeks);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fired when the Agenda list view changes section.
|
|
||||||
*
|
|
||||||
* @param calendarEvent The event for the selected position in the agenda listview.
|
|
||||||
*/
|
|
||||||
public void scrollToDate(final CalendarEvent calendarEvent) {
|
|
||||||
mListViewWeeks.post(()->scrollToPosition(updateSelectedDay(calendarEvent.getInstanceDay(), calendarEvent.getDayReference())));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void scrollToDate(Calendar today, List<IWeekItem> weeks) {
|
|
||||||
Integer currentWeekIndex = null;
|
|
||||||
|
|
||||||
for (int c = 0; c < weeks.size(); c++) {
|
|
||||||
if (DateHelper.sameWeek(today, weeks.get(c))) {
|
|
||||||
currentWeekIndex = c;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentWeekIndex != null) {
|
|
||||||
final Integer finalCurrentWeekIndex = currentWeekIndex;
|
|
||||||
mListViewWeeks.post(() -> scrollToPosition(finalCurrentWeekIndex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBackgroundColor(int color) {
|
|
||||||
mListViewWeeks.setBackgroundColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Private methods
|
|
||||||
|
|
||||||
private void scrollToPosition(int targetPosition) {
|
|
||||||
LinearLayoutManager layoutManager = ((LinearLayoutManager) mListViewWeeks.getLayoutManager());
|
|
||||||
layoutManager.scrollToPosition(targetPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateItemAtPosition(int position) {
|
|
||||||
WeeksAdapter weeksAdapter = (WeeksAdapter) mListViewWeeks.getAdapter();
|
|
||||||
weeksAdapter.notifyItemChanged(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new adapter if necessary and sets up its parameters.
|
|
||||||
*/
|
|
||||||
private void setUpAdapter(Calendar today, List<IWeekItem> weeks, int dayTextColor, int currentDayTextColor, int pastDayTextColor, List<CalendarEvent> events) {
|
|
||||||
BusProvider.getInstance().toObserverable()
|
|
||||||
.subscribe(event -> {
|
|
||||||
if (event instanceof Events.EventsFetched) {
|
|
||||||
//Log.d("CalendarView", "events size "+events.size());
|
|
||||||
if (mWeeksAdapter == null) {
|
|
||||||
//Log.d(LOG_TAG, "Setting adapter with today's calendar: " + today.toString());
|
|
||||||
mWeeksAdapter = new WeeksAdapter(getContext(), today, dayTextColor, currentDayTextColor, pastDayTextColor, events);
|
|
||||||
mListViewWeeks.setAdapter(mWeeksAdapter);
|
|
||||||
}
|
|
||||||
mWeeksAdapter.updateWeeksItems(weeks);
|
|
||||||
}});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpHeader(Calendar today, SimpleDateFormat weekDayFormatter, Locale locale) {
|
|
||||||
int daysPerWeek = 7;
|
|
||||||
String[] dayLabels = new String[daysPerWeek];
|
|
||||||
Calendar cal = Calendar.getInstance(CalendarManager.getInstance(getContext()).getLocale());
|
|
||||||
cal.setTime(today.getTime());
|
|
||||||
int firstDayOfWeek = cal.getFirstDayOfWeek();
|
|
||||||
for (int count = 0; count < 7; count++) {
|
|
||||||
cal.set(Calendar.DAY_OF_WEEK, firstDayOfWeek + count);
|
|
||||||
if (locale.getLanguage().equals("en")) {
|
|
||||||
dayLabels[count] = weekDayFormatter.format(cal.getTime()).toUpperCase(locale);
|
|
||||||
} else {
|
|
||||||
dayLabels[count] = weekDayFormatter.format(cal.getTime());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < mDayNamesHeader.getChildCount(); i++) {
|
|
||||||
TextView txtDay = (TextView) mDayNamesHeader.getChildAt(i);
|
|
||||||
txtDay.setText(dayLabels[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void expandCalendarView() {
|
|
||||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getLayoutParams();
|
|
||||||
layoutParams.height = (int) (getResources().getDimension(R.dimen.calendar_header_height) + 5 * getResources().getDimension(R.dimen.day_cell_height));
|
|
||||||
setLayoutParams(layoutParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void collapseCalendarView() {
|
|
||||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getLayoutParams();
|
|
||||||
layoutParams.height = (int) (getResources().getDimension(R.dimen.calendar_header_height) + 2 * getResources().getDimension(R.dimen.day_cell_height));
|
|
||||||
setLayoutParams(layoutParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a selected cell day item.
|
|
||||||
*
|
|
||||||
* @param calendar The Calendar instance of the day selected.
|
|
||||||
* @param dayItem The DayItem information held by the cell item.
|
|
||||||
* @return The selected row of the weeks list, to be updated.
|
|
||||||
*/
|
|
||||||
private int updateSelectedDay(Calendar calendar, IDayItem dayItem) {
|
|
||||||
Integer currentWeekIndex = null;
|
|
||||||
|
|
||||||
// update highlighted/selected day
|
|
||||||
if (!dayItem.equals(getSelectedDay())) {
|
|
||||||
dayItem.setSelected(true);
|
|
||||||
if (getSelectedDay() != null) {
|
|
||||||
getSelectedDay().setSelected(false);
|
|
||||||
}
|
|
||||||
setSelectedDay(dayItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int c = 0; c < CalendarManager.getInstance().getWeeks().size(); c++) {
|
|
||||||
if (DateHelper.sameWeek(calendar, CalendarManager.getInstance().getWeeks().get(c))) {
|
|
||||||
currentWeekIndex = c;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentWeekIndex != null) {
|
|
||||||
// highlighted day has changed, update the rows concerned
|
|
||||||
if (currentWeekIndex != mCurrentListPosition) {
|
|
||||||
updateItemAtPosition(mCurrentListPosition);
|
|
||||||
}
|
|
||||||
mCurrentListPosition = currentWeekIndex;
|
|
||||||
updateItemAtPosition(currentWeekIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mCurrentListPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.calendar.weekslist;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.BusProvider;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.Events;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
public class WeekListView extends RecyclerView {
|
|
||||||
private boolean mUserScrolling = false;
|
|
||||||
private boolean mScrolling = false;
|
|
||||||
|
|
||||||
// region Constructors
|
|
||||||
|
|
||||||
public WeekListView(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WeekListView(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WeekListView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable snapping behaviour for this recyclerView
|
|
||||||
*
|
|
||||||
* @param enabled enable or disable the snapping behaviour
|
|
||||||
*/
|
|
||||||
public void setSnapEnabled(boolean enabled) {
|
|
||||||
if (enabled) {
|
|
||||||
addOnScrollListener(mScrollListener);
|
|
||||||
} else {
|
|
||||||
removeOnScrollListener(mScrollListener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Private methods
|
|
||||||
|
|
||||||
private OnScrollListener mScrollListener = new OnScrollListener() {
|
|
||||||
@Override
|
|
||||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
|
||||||
super.onScrolled(recyclerView, dx, dy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
|
||||||
super.onScrollStateChanged(recyclerView, newState);
|
|
||||||
final WeeksAdapter weeksAdapter = (WeeksAdapter) getAdapter();
|
|
||||||
|
|
||||||
switch (newState) {
|
|
||||||
case SCROLL_STATE_IDLE:
|
|
||||||
if (mUserScrolling) {
|
|
||||||
scrollToView(getCenterView());
|
|
||||||
postDelayed(() -> weeksAdapter.setDragging(false), 700); // Wait for recyclerView to settle
|
|
||||||
}
|
|
||||||
|
|
||||||
mUserScrolling = false;
|
|
||||||
mScrolling = false;
|
|
||||||
break;
|
|
||||||
// If scroll is caused by a touch (scroll touch, not any touch)
|
|
||||||
case SCROLL_STATE_DRAGGING:
|
|
||||||
BusProvider.getInstance().send(new Events.CalendarScrolledEvent());
|
|
||||||
// If scroll was initiated already, this is not a user scrolling, but probably a tap, else set userScrolling
|
|
||||||
if (!mScrolling) {
|
|
||||||
mUserScrolling = true;
|
|
||||||
}
|
|
||||||
weeksAdapter.setDragging(true);
|
|
||||||
break;
|
|
||||||
case SCROLL_STATE_SETTLING:
|
|
||||||
// The user's finger is not touching the list anymore, no need
|
|
||||||
// for any alpha animation then
|
|
||||||
weeksAdapter.setAlphaSet(true);
|
|
||||||
mScrolling = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private View getChildClosestToPosition(int y) {
|
|
||||||
if (getChildCount() <= 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
int itemHeight = getChildAt(0).getMeasuredHeight();
|
|
||||||
|
|
||||||
int closestY = 9999;
|
|
||||||
View closestChild = null;
|
|
||||||
|
|
||||||
for (int i = 0; i < getChildCount(); i++) {
|
|
||||||
View child = getChildAt(i);
|
|
||||||
|
|
||||||
int childCenterY = ((int) child.getY() + (itemHeight / 2));
|
|
||||||
int yDistance = childCenterY - y;
|
|
||||||
|
|
||||||
// If child center is closer than previous closest, set it as closest
|
|
||||||
if (Math.abs(yDistance) < Math.abs(closestY)) {
|
|
||||||
closestY = yDistance;
|
|
||||||
closestChild = child;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return closestChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
private View getCenterView() {
|
|
||||||
return getChildClosestToPosition(getMeasuredHeight() / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scrollToView(View child) {
|
|
||||||
if (child == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stopScroll();
|
|
||||||
|
|
||||||
int scrollDistance = getScrollDistance(child);
|
|
||||||
|
|
||||||
if (scrollDistance != 0) {
|
|
||||||
smoothScrollBy(0, scrollDistance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getScrollDistance(View child) {
|
|
||||||
int itemHeight = getChildAt(0).getMeasuredHeight();
|
|
||||||
int centerY = getMeasuredHeight() / 2;
|
|
||||||
|
|
||||||
int childCenterY = ((int) child.getY() + (itemHeight / 2));
|
|
||||||
|
|
||||||
return childCenterY - centerY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,321 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.calendar.weekslist;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
|
||||||
import com.github.tibolte.agendacalendarview.R;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.IWeekItem;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.BusProvider;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.Events;
|
|
||||||
|
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.AnimatorSet;
|
|
||||||
import android.animation.ObjectAnimator;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.graphics.PorterDuffColorFilter;
|
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.graphics.drawable.GradientDrawable;
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class WeeksAdapter extends RecyclerView.Adapter<WeeksAdapter.WeekViewHolder> {
|
|
||||||
|
|
||||||
public static final long FADE_DURATION = 250;
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private Calendar mToday;
|
|
||||||
private List<IWeekItem> mWeeksList = new ArrayList<>();
|
|
||||||
private List<CalendarEvent> mEventList = new ArrayList<>();
|
|
||||||
private boolean mDragging;
|
|
||||||
private boolean mAlphaSet;
|
|
||||||
private int mDayTextColor, mPastDayTextColor, mCurrentDayColor;
|
|
||||||
|
|
||||||
// region Constructor
|
|
||||||
|
|
||||||
public WeeksAdapter(Context context, Calendar today, int dayTextColor, int currentDayTextColor, int pastDayTextColor, List<CalendarEvent> events) {
|
|
||||||
this.mToday = today;
|
|
||||||
this.mContext = context;
|
|
||||||
this.mDayTextColor = dayTextColor;
|
|
||||||
this.mCurrentDayColor = currentDayTextColor;
|
|
||||||
this.mPastDayTextColor = pastDayTextColor;
|
|
||||||
this.mEventList = events;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
public void updateWeeksItems(List<IWeekItem> weekItems) {
|
|
||||||
this.mWeeksList.clear();
|
|
||||||
this.mWeeksList.addAll(weekItems);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
// region Getters/setters
|
|
||||||
|
|
||||||
public List<IWeekItem> getWeeksList() {
|
|
||||||
return mWeeksList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDragging() {
|
|
||||||
return mDragging;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDragging(boolean dragging) {
|
|
||||||
if (dragging != this.mDragging) {
|
|
||||||
this.mDragging = dragging;
|
|
||||||
notifyItemRangeChanged(0, mWeeksList.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAlphaSet() {
|
|
||||||
return mAlphaSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlphaSet(boolean alphaSet) {
|
|
||||||
mAlphaSet = alphaSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region RecyclerView.Adapter<WeeksAdapter.WeekViewHolder> methods
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WeekViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
|
||||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_week, parent, false);
|
|
||||||
return new WeekViewHolder(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(WeekViewHolder weekViewHolder, int position) {
|
|
||||||
IWeekItem weekItem = mWeeksList.get(position);
|
|
||||||
weekViewHolder.bindWeek(weekItem, mToday);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return mWeeksList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Class - WeekViewHolder
|
|
||||||
|
|
||||||
public class WeekViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of layout containers for each day
|
|
||||||
*/
|
|
||||||
private List<LinearLayout> mCells;
|
|
||||||
private TextView mTxtMonth;
|
|
||||||
private FrameLayout mMonthBackground;
|
|
||||||
|
|
||||||
public WeekViewHolder(View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
mTxtMonth = (TextView) itemView.findViewById(R.id.month_label);
|
|
||||||
mMonthBackground = (FrameLayout) itemView.findViewById(R.id.month_background);
|
|
||||||
LinearLayout daysContainer = (LinearLayout) itemView.findViewById(R.id.week_days_container);
|
|
||||||
setUpChildren(daysContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void bindWeek(IWeekItem weekItem, Calendar today) {
|
|
||||||
setUpMonthOverlay();
|
|
||||||
|
|
||||||
List<IDayItem> dayItems = weekItem.getDayItems();
|
|
||||||
|
|
||||||
for (int c = 0; c < dayItems.size(); c++) {
|
|
||||||
final IDayItem dayItem = dayItems.get(c);
|
|
||||||
LinearLayout cellItem = mCells.get(c);
|
|
||||||
TextView txtDay = (TextView) cellItem.findViewById(R.id.view_day_day_label);
|
|
||||||
TextView txtMonth = (TextView) cellItem.findViewById(R.id.view_day_month_label);
|
|
||||||
View circleView = cellItem.findViewById(R.id.view_day_circle_selected);
|
|
||||||
View eventIndicator1 = cellItem.findViewById(R.id.view_day_event_indicator1);
|
|
||||||
View eventIndicator2 = cellItem.findViewById(R.id.view_day_event_indicator2);
|
|
||||||
View eventIndicator3 = cellItem.findViewById(R.id.view_day_event_indicator3);
|
|
||||||
cellItem.setOnClickListener(v->BusProvider.getInstance().send(new Events.DayClickedEvent(dayItem)));
|
|
||||||
|
|
||||||
eventIndicator1.setVisibility(View.INVISIBLE);
|
|
||||||
eventIndicator2.setVisibility(View.INVISIBLE);
|
|
||||||
eventIndicator3.setVisibility(View.INVISIBLE);
|
|
||||||
|
|
||||||
Calendar dayItemCalendar = Calendar.getInstance();
|
|
||||||
dayItemCalendar.setTime(dayItem.getDate());
|
|
||||||
int eventCount = 0;
|
|
||||||
for (CalendarEvent event: mEventList) {
|
|
||||||
if (event.getStartTime().get(Calendar.YEAR) == dayItemCalendar.get(Calendar.YEAR)
|
|
||||||
&& event.getStartTime().get(Calendar.MONTH) == dayItemCalendar.get(Calendar.MONTH)
|
|
||||||
&& event.getStartTime().get(Calendar.DAY_OF_MONTH) == dayItemCalendar.get(Calendar.DAY_OF_MONTH)) {
|
|
||||||
eventCount++;
|
|
||||||
if (eventCount == 1) {
|
|
||||||
eventIndicator1.setVisibility(View.VISIBLE);
|
|
||||||
eventIndicator1.getBackground().setColorFilter(new PorterDuffColorFilter(event.getColor(),PorterDuff.Mode.MULTIPLY));
|
|
||||||
}
|
|
||||||
if (eventCount == 2) {
|
|
||||||
eventIndicator2.setVisibility(View.VISIBLE);
|
|
||||||
eventIndicator2.getBackground().setColorFilter(new PorterDuffColorFilter(event.getColor(),PorterDuff.Mode.MULTIPLY));
|
|
||||||
}
|
|
||||||
if (eventCount == 3) {
|
|
||||||
eventIndicator3.setVisibility(View.VISIBLE);
|
|
||||||
eventIndicator3.getBackground().setColorFilter(new PorterDuffColorFilter(event.getColor(),PorterDuff.Mode.MULTIPLY));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Log.d("CalendarView", "Event count for day "+dayItem.getValue()+" is "+eventCount);
|
|
||||||
|
|
||||||
txtMonth.setVisibility(View.GONE);
|
|
||||||
txtDay.setTextColor(mDayTextColor);
|
|
||||||
txtMonth.setTextColor(mDayTextColor);
|
|
||||||
circleView.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
txtDay.setTypeface(null, Typeface.NORMAL);
|
|
||||||
txtMonth.setTypeface(null, Typeface.NORMAL);
|
|
||||||
|
|
||||||
// Display the day
|
|
||||||
txtDay.setText(Integer.toString(dayItem.getValue()));
|
|
||||||
|
|
||||||
// Highlight first day of the month
|
|
||||||
if (dayItem.isFirstDayOfTheMonth() && !dayItem.isSelected()) {
|
|
||||||
txtMonth.setVisibility(View.VISIBLE);
|
|
||||||
txtMonth.setText(dayItem.getMonth());
|
|
||||||
txtDay.setTypeface(null, Typeface.BOLD);
|
|
||||||
txtMonth.setTypeface(null, Typeface.BOLD);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if this day is in the past
|
|
||||||
if (today.getTime().after(dayItem.getDate()) && !DateHelper.sameDate(today, dayItem.getDate())) {
|
|
||||||
txtDay.setTextColor(mPastDayTextColor);
|
|
||||||
txtMonth.setTextColor(mPastDayTextColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Highlight the cell if this day is today
|
|
||||||
if (dayItem.isToday() && !dayItem.isSelected()) {
|
|
||||||
txtDay.setTextColor(mCurrentDayColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dayItem.getShowBadge()) {
|
|
||||||
circleView.setVisibility(View.VISIBLE);
|
|
||||||
GradientDrawable drawable = (GradientDrawable) circleView.getBackground();
|
|
||||||
drawable.setStroke((int) (2 * Resources.getSystem().getDisplayMetrics().density), 0xffff0000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show a circle if the day is selected
|
|
||||||
if (dayItem.isSelected()) {
|
|
||||||
txtDay.setTextColor(mDayTextColor);
|
|
||||||
circleView.setVisibility(View.VISIBLE);
|
|
||||||
GradientDrawable drawable = (GradientDrawable) circleView.getBackground();
|
|
||||||
drawable.setStroke((int) (1 * Resources.getSystem().getDisplayMetrics().density), mDayTextColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the month label has to be displayed
|
|
||||||
if (dayItem.getValue() == 15) {
|
|
||||||
mTxtMonth.setVisibility(View.VISIBLE);
|
|
||||||
SimpleDateFormat monthDateFormat = new SimpleDateFormat(mContext.getResources().getString(R.string.month_name_format), CalendarManager.getInstance().getLocale());
|
|
||||||
String month = monthDateFormat.format(weekItem.getDate()).toUpperCase();
|
|
||||||
if (today.get(Calendar.YEAR) != weekItem.getYear()) {
|
|
||||||
month = month + String.format(" %d", weekItem.getYear());
|
|
||||||
}
|
|
||||||
mTxtMonth.setText(month);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpChildren(LinearLayout daysContainer) {
|
|
||||||
mCells = new ArrayList<>();
|
|
||||||
for (int i = 0; i < daysContainer.getChildCount(); i++) {
|
|
||||||
mCells.add((LinearLayout) daysContainer.getChildAt(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpMonthOverlay() {
|
|
||||||
mTxtMonth.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
if (isDragging()) {
|
|
||||||
AnimatorSet animatorSetFadeIn = new AnimatorSet();
|
|
||||||
animatorSetFadeIn.setDuration(FADE_DURATION);
|
|
||||||
ObjectAnimator animatorTxtAlphaIn = ObjectAnimator.ofFloat(mTxtMonth, "alpha", mTxtMonth.getAlpha(), 1f);
|
|
||||||
ObjectAnimator animatorBackgroundAlphaIn = ObjectAnimator.ofFloat(mMonthBackground, "alpha", mMonthBackground.getAlpha(), 1f);
|
|
||||||
animatorSetFadeIn.playTogether(
|
|
||||||
animatorTxtAlphaIn
|
|
||||||
//animatorBackgroundAlphaIn
|
|
||||||
);
|
|
||||||
animatorSetFadeIn.addListener(new Animator.AnimatorListener() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationStart(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
setAlphaSet(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationCancel(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationRepeat(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
animatorSetFadeIn.start();
|
|
||||||
} else {
|
|
||||||
AnimatorSet animatorSetFadeOut = new AnimatorSet();
|
|
||||||
animatorSetFadeOut.setDuration(FADE_DURATION);
|
|
||||||
ObjectAnimator animatorTxtAlphaOut = ObjectAnimator.ofFloat(mTxtMonth, "alpha", mTxtMonth.getAlpha(), 0f);
|
|
||||||
ObjectAnimator animatorBackgroundAlphaOut = ObjectAnimator.ofFloat(mMonthBackground, "alpha", mMonthBackground.getAlpha(), 0f);
|
|
||||||
animatorSetFadeOut.playTogether(
|
|
||||||
animatorTxtAlphaOut
|
|
||||||
//animatorBackgroundAlphaOut
|
|
||||||
);
|
|
||||||
animatorSetFadeOut.addListener(new Animator.AnimatorListener() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationStart(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
setAlphaSet(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationCancel(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationRepeat(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
animatorSetFadeOut.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isAlphaSet()) {
|
|
||||||
//mMonthBackground.setAlpha(1f);
|
|
||||||
mTxtMonth.setAlpha(1f);
|
|
||||||
} else {
|
|
||||||
//mMonthBackground.setAlpha(0f);
|
|
||||||
mTxtMonth.setAlpha(0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,345 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.models;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Event model class containing the information to be displayed on the agenda view.
|
|
||||||
*/
|
|
||||||
public class BaseCalendarEvent implements CalendarEvent {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Id of the event.
|
|
||||||
*/
|
|
||||||
private long mId;
|
|
||||||
/**
|
|
||||||
* Color to be displayed in the agenda view.
|
|
||||||
*/
|
|
||||||
private int mColor;
|
|
||||||
/**
|
|
||||||
* Text color displayed on the background color
|
|
||||||
*/
|
|
||||||
private int mTextColor;
|
|
||||||
/**
|
|
||||||
* Title of the event.
|
|
||||||
*/
|
|
||||||
private String mTitle;
|
|
||||||
/**
|
|
||||||
* Description of the event.
|
|
||||||
*/
|
|
||||||
private String mDescription;
|
|
||||||
/**
|
|
||||||
* Where the event takes place.
|
|
||||||
*/
|
|
||||||
private String mLocation;
|
|
||||||
/**
|
|
||||||
* Calendar instance helping sorting the events per section in the agenda view.
|
|
||||||
*/
|
|
||||||
private Calendar mInstanceDay;
|
|
||||||
/**
|
|
||||||
* Start time of the event.
|
|
||||||
*/
|
|
||||||
private Calendar mStartTime;
|
|
||||||
/**
|
|
||||||
* End time of the event.
|
|
||||||
*/
|
|
||||||
private Calendar mEndTime;
|
|
||||||
/**
|
|
||||||
* Indicates if the event lasts all day.
|
|
||||||
*/
|
|
||||||
private boolean mAllDay;
|
|
||||||
/**
|
|
||||||
* Tells if this BaseCalendarEvent instance is used as a placeholder in the agenda view, if there's
|
|
||||||
* no event for that day.
|
|
||||||
*/
|
|
||||||
private boolean mPlaceHolder;
|
|
||||||
/**
|
|
||||||
* Tells if this BaseCalendarEvent instance is used as a forecast information holder in the agenda
|
|
||||||
* view.
|
|
||||||
*/
|
|
||||||
private boolean mWeather;
|
|
||||||
/**
|
|
||||||
* Duration of the event.
|
|
||||||
*/
|
|
||||||
private String mDuration;
|
|
||||||
/**
|
|
||||||
* References to a DayItem instance for that event, used to link interaction between the
|
|
||||||
* calendar view and the agenda view.
|
|
||||||
*/
|
|
||||||
private IDayItem mDayReference;
|
|
||||||
/**
|
|
||||||
* References to a WeekItem instance for that event, used to link interaction between the
|
|
||||||
* calendar view and the agenda view.
|
|
||||||
*/
|
|
||||||
private IWeekItem mWeekReference;
|
|
||||||
/**
|
|
||||||
* Weather icon string returned by the Dark Sky API.
|
|
||||||
*/
|
|
||||||
private String mWeatherIcon;
|
|
||||||
/**
|
|
||||||
* Temperature value returned by the Dark Sky API.
|
|
||||||
*/
|
|
||||||
private double mTemperature;
|
|
||||||
|
|
||||||
private boolean mShowBadge;
|
|
||||||
|
|
||||||
// region Constructor
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the event
|
|
||||||
*
|
|
||||||
* @param id The id of the event.
|
|
||||||
* @param color The color of the event.
|
|
||||||
* @param textColor The color of the event description text.
|
|
||||||
* @param title The title of the event.
|
|
||||||
* @param description The description of the event.
|
|
||||||
* @param location The location of the event.
|
|
||||||
* @param dateStart The start date of the event.
|
|
||||||
* @param dateEnd The end date of the event.
|
|
||||||
* @param allDay Int that can be equal to 0 or 1.
|
|
||||||
* @param duration The duration of the event in RFC2445 format.
|
|
||||||
*/
|
|
||||||
public BaseCalendarEvent(long id, int color, int textColor, String title, String description, String location, long dateStart, long dateEnd, int allDay, String duration) {
|
|
||||||
this.mId = id;
|
|
||||||
this.mColor = color;
|
|
||||||
this.mTextColor = textColor;
|
|
||||||
this.mAllDay = (allDay == 1);
|
|
||||||
this.mDuration = duration;
|
|
||||||
this.mTitle = title;
|
|
||||||
this.mDescription = description;
|
|
||||||
this.mLocation = location;
|
|
||||||
|
|
||||||
this.mStartTime = Calendar.getInstance();
|
|
||||||
this.mStartTime.setTimeInMillis(dateStart);
|
|
||||||
this.mEndTime = Calendar.getInstance();
|
|
||||||
this.mEndTime.setTimeInMillis(dateEnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseCalendarEvent() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the event
|
|
||||||
* @param title The title of the event.
|
|
||||||
* @param description The description of the event.
|
|
||||||
* @param location The location of the event.
|
|
||||||
* @param color The color of the event (for display in the app).
|
|
||||||
* @param textColor The color of the event description text.
|
|
||||||
* @param startTime The start time of the event.
|
|
||||||
* @param endTime The end time of the event.
|
|
||||||
* @param allDay Indicates if the event lasts the whole day.
|
|
||||||
*/
|
|
||||||
public BaseCalendarEvent(String title, String description, String location, int color, int textColor, Calendar startTime, Calendar endTime, boolean allDay) {
|
|
||||||
this.mTitle = title;
|
|
||||||
this.mDescription = description;
|
|
||||||
this.mLocation = location;
|
|
||||||
this.mColor = color;
|
|
||||||
this.mTextColor = textColor;
|
|
||||||
this.mStartTime = startTime;
|
|
||||||
this.mEndTime = endTime;
|
|
||||||
this.mAllDay = allDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseCalendarEvent(String title, String description, String location, int color, int textColor, Calendar startTime, Calendar endTime, boolean allDay, long id, boolean showBadge) {
|
|
||||||
this.mTitle = title;
|
|
||||||
this.mDescription = description;
|
|
||||||
this.mLocation = location;
|
|
||||||
this.mColor = color;
|
|
||||||
this.mTextColor = textColor;
|
|
||||||
this.mStartTime = startTime;
|
|
||||||
this.mEndTime = endTime;
|
|
||||||
this.mAllDay = allDay;
|
|
||||||
this.mId = id;
|
|
||||||
this.mShowBadge = showBadge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseCalendarEvent(BaseCalendarEvent calendarEvent) {
|
|
||||||
this.mId = calendarEvent.getId();
|
|
||||||
this.mColor = calendarEvent.getColor();
|
|
||||||
this.mTextColor = calendarEvent.getTextColor();
|
|
||||||
this.mAllDay = calendarEvent.isAllDay();
|
|
||||||
this.mDuration = calendarEvent.getDuration();
|
|
||||||
this.mTitle = calendarEvent.getTitle();
|
|
||||||
this.mDescription = calendarEvent.getDescription();
|
|
||||||
this.mLocation = calendarEvent.getLocation();
|
|
||||||
this.mStartTime = calendarEvent.getStartTime();
|
|
||||||
this.mEndTime = calendarEvent.getEndTime();
|
|
||||||
this.mShowBadge = calendarEvent.getShowBadge();
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Getters/Setters
|
|
||||||
|
|
||||||
public int getColor() {
|
|
||||||
return mColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColor(int mColor) {
|
|
||||||
this.mColor = mColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTextColor() {
|
|
||||||
return mTextColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTextColor(int mTextColor) {
|
|
||||||
this.mTextColor = mTextColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return mDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAllDay() {
|
|
||||||
return mAllDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAllDay(boolean allDay) {
|
|
||||||
this.mAllDay = allDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String mDescription) {
|
|
||||||
this.mDescription = mDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Calendar getInstanceDay() {
|
|
||||||
return mInstanceDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInstanceDay(Calendar mInstanceDay) {
|
|
||||||
this.mInstanceDay = mInstanceDay;
|
|
||||||
this.mInstanceDay.set(Calendar.HOUR, 0);
|
|
||||||
this.mInstanceDay.set(Calendar.MINUTE, 0);
|
|
||||||
this.mInstanceDay.set(Calendar.SECOND, 0);
|
|
||||||
this.mInstanceDay.set(Calendar.MILLISECOND, 0);
|
|
||||||
this.mInstanceDay.set(Calendar.AM_PM, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Calendar getEndTime() {
|
|
||||||
return mEndTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndTime(Calendar mEndTime) {
|
|
||||||
this.mEndTime = mEndTime;
|
|
||||||
}
|
|
||||||
public void setPlaceholder(boolean placeholder) {
|
|
||||||
mPlaceHolder = placeholder;
|
|
||||||
}
|
|
||||||
public boolean isPlaceholder() {
|
|
||||||
return mPlaceHolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getId() {
|
|
||||||
return mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long mId) {
|
|
||||||
this.mId = mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getShowBadge() {
|
|
||||||
return mShowBadge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShowBadge(boolean mShowBadge) {
|
|
||||||
this.mShowBadge = mShowBadge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLocation() {
|
|
||||||
return mLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocation(String mLocation) {
|
|
||||||
this.mLocation = mLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Calendar getStartTime() {
|
|
||||||
return mStartTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartTime(Calendar mStartTime) {
|
|
||||||
this.mStartTime = mStartTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return mTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String mTitle) {
|
|
||||||
this.mTitle = mTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDuration() {
|
|
||||||
return mDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDuration(String duration) {
|
|
||||||
this.mDuration = duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPlaceHolder() {
|
|
||||||
return mPlaceHolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlaceHolder(boolean mPlaceHolder) {
|
|
||||||
this.mPlaceHolder = mPlaceHolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWeather() {
|
|
||||||
return mWeather;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWeather(boolean mWeather) {
|
|
||||||
this.mWeather = mWeather;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IDayItem getDayReference() {
|
|
||||||
return mDayReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDayReference(IDayItem mDayReference) {
|
|
||||||
this.mDayReference = mDayReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IWeekItem getWeekReference() {
|
|
||||||
return mWeekReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWeekReference(IWeekItem mWeekReference) {
|
|
||||||
this.mWeekReference = mWeekReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWeatherIcon() {
|
|
||||||
return mWeatherIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWeatherIcon(String mWeatherIcon) {
|
|
||||||
this.mWeatherIcon = mWeatherIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTemperature() {
|
|
||||||
return mTemperature;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTemperature(double mTemperature) {
|
|
||||||
this.mTemperature = mTemperature;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CalendarEvent copy() {
|
|
||||||
return new BaseCalendarEvent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "BaseCalendarEvent{"
|
|
||||||
+ "title='"
|
|
||||||
+ mTitle
|
|
||||||
+ ", instanceDay= "
|
|
||||||
+ mInstanceDay.getTime()
|
|
||||||
+ "}";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.models;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
public interface CalendarEvent {
|
|
||||||
|
|
||||||
|
|
||||||
void setPlaceholder(boolean placeholder);
|
|
||||||
|
|
||||||
boolean isPlaceholder();
|
|
||||||
|
|
||||||
public String getLocation();
|
|
||||||
|
|
||||||
public void setLocation(String mLocation);
|
|
||||||
|
|
||||||
long getId();
|
|
||||||
|
|
||||||
void setId(long mId);
|
|
||||||
|
|
||||||
boolean getShowBadge();
|
|
||||||
|
|
||||||
void setShowBadge(boolean mShowBadge);
|
|
||||||
|
|
||||||
int getTextColor();
|
|
||||||
|
|
||||||
void setTextColor(int mTextColor);
|
|
||||||
|
|
||||||
String getDescription();
|
|
||||||
|
|
||||||
void setDescription(String mDescription);
|
|
||||||
|
|
||||||
boolean isAllDay();
|
|
||||||
|
|
||||||
void setAllDay(boolean allDay);
|
|
||||||
|
|
||||||
Calendar getStartTime();
|
|
||||||
|
|
||||||
void setStartTime(Calendar mStartTime);
|
|
||||||
|
|
||||||
Calendar getEndTime();
|
|
||||||
|
|
||||||
void setEndTime(Calendar mEndTime);
|
|
||||||
|
|
||||||
String getTitle();
|
|
||||||
|
|
||||||
void setTitle(String mTitle);
|
|
||||||
|
|
||||||
Calendar getInstanceDay();
|
|
||||||
|
|
||||||
void setInstanceDay(Calendar mInstanceDay);
|
|
||||||
|
|
||||||
IDayItem getDayReference();
|
|
||||||
|
|
||||||
void setDayReference(IDayItem mDayReference);
|
|
||||||
|
|
||||||
IWeekItem getWeekReference();
|
|
||||||
|
|
||||||
void setWeekReference(IWeekItem mWeekReference);
|
|
||||||
|
|
||||||
CalendarEvent copy();
|
|
||||||
|
|
||||||
int getColor();
|
|
||||||
}
|
|
@ -1,145 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.models;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
|
||||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Day model class.
|
|
||||||
*/
|
|
||||||
public class DayItem implements IDayItem {
|
|
||||||
private Date mDate;
|
|
||||||
private int mValue;
|
|
||||||
private int mDayOfTheWeek;
|
|
||||||
private boolean mToday;
|
|
||||||
private boolean mFirstDayOfTheMonth;
|
|
||||||
private boolean mSelected;
|
|
||||||
private String mMonth;
|
|
||||||
private boolean mShowBadge;
|
|
||||||
|
|
||||||
// region Constructor
|
|
||||||
|
|
||||||
public DayItem(Date date, int value, boolean today, String month) {
|
|
||||||
this.mDate = date;
|
|
||||||
this.mValue = value;
|
|
||||||
this.mToday = today;
|
|
||||||
this.mMonth = month;
|
|
||||||
}
|
|
||||||
// only for cleanDay
|
|
||||||
public DayItem() {
|
|
||||||
|
|
||||||
}
|
|
||||||
public DayItem(DayItem original) {
|
|
||||||
|
|
||||||
this.mDate = original.getDate();
|
|
||||||
this.mValue = original.getValue();
|
|
||||||
this.mToday = original.isToday();
|
|
||||||
this.mDayOfTheWeek = original.getDayOftheWeek();
|
|
||||||
this.mFirstDayOfTheMonth = original.isFirstDayOfTheMonth();
|
|
||||||
this.mSelected = original.isSelected();
|
|
||||||
this.mMonth = original.getMonth();
|
|
||||||
this.mShowBadge = original.mShowBadge;
|
|
||||||
}
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Getters/Setters
|
|
||||||
|
|
||||||
public Date getDate() {
|
|
||||||
return mDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDate(Date date) {
|
|
||||||
this.mDate = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getValue() {
|
|
||||||
return mValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(int value) {
|
|
||||||
this.mValue = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isToday() {
|
|
||||||
return mToday;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToday(boolean today) {
|
|
||||||
this.mToday = today;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSelected() {
|
|
||||||
return mSelected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelected(boolean selected) {
|
|
||||||
this.mSelected = selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFirstDayOfTheMonth() {
|
|
||||||
return mFirstDayOfTheMonth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFirstDayOfTheMonth(boolean firstDayOfTheMonth) {
|
|
||||||
this.mFirstDayOfTheMonth = firstDayOfTheMonth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMonth() {
|
|
||||||
return mMonth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMonth(String month) {
|
|
||||||
this.mMonth = month;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDayOftheWeek() {
|
|
||||||
return mDayOfTheWeek;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDayOftheWeek(int mDayOftheWeek) {
|
|
||||||
this.mDayOfTheWeek = mDayOftheWeek;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShowBadge(boolean showBadge) {
|
|
||||||
this.mShowBadge = showBadge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getShowBadge() {
|
|
||||||
return this.mShowBadge;
|
|
||||||
}
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
public void buildDayItemFromCal(Calendar calendar) {
|
|
||||||
Date date = calendar.getTime();
|
|
||||||
this.mDate = date;
|
|
||||||
|
|
||||||
this.mValue = calendar.get(Calendar.DAY_OF_MONTH);
|
|
||||||
this.mToday = DateHelper.sameDate(calendar, CalendarManager.getInstance().getToday());
|
|
||||||
this.mMonth = CalendarManager.getInstance().getMonthHalfNameFormat().format(date);
|
|
||||||
if (this.mValue == 1) {
|
|
||||||
this.mFirstDayOfTheMonth = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "DayItem{"
|
|
||||||
+ "Date='"
|
|
||||||
+ mDate.toString()
|
|
||||||
+ ", value="
|
|
||||||
+ mValue
|
|
||||||
+ '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IDayItem copy() {
|
|
||||||
return new DayItem(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.models;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public interface IDayItem {
|
|
||||||
|
|
||||||
// region Getters/Setters
|
|
||||||
|
|
||||||
Date getDate();
|
|
||||||
|
|
||||||
void setDate(Date date);
|
|
||||||
|
|
||||||
int getValue();
|
|
||||||
|
|
||||||
void setValue(int value);
|
|
||||||
|
|
||||||
boolean isToday();
|
|
||||||
|
|
||||||
void setToday(boolean today);
|
|
||||||
|
|
||||||
boolean isSelected();
|
|
||||||
|
|
||||||
void setSelected(boolean selected);
|
|
||||||
|
|
||||||
boolean isFirstDayOfTheMonth();
|
|
||||||
|
|
||||||
void setFirstDayOfTheMonth(boolean firstDayOfTheMonth);
|
|
||||||
|
|
||||||
String getMonth();
|
|
||||||
|
|
||||||
void setMonth(String month);
|
|
||||||
|
|
||||||
int getDayOftheWeek();
|
|
||||||
|
|
||||||
void setDayOftheWeek(int mDayOftheWeek);
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
void buildDayItemFromCal(Calendar calendar);
|
|
||||||
|
|
||||||
String toString();
|
|
||||||
|
|
||||||
IDayItem copy();
|
|
||||||
|
|
||||||
void setShowBadge(boolean showBadge);
|
|
||||||
|
|
||||||
boolean getShowBadge();
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.models;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface IWeekItem {
|
|
||||||
|
|
||||||
|
|
||||||
int getWeekInYear();
|
|
||||||
|
|
||||||
void setWeekInYear(int weekInYear);
|
|
||||||
|
|
||||||
int getYear();
|
|
||||||
|
|
||||||
void setYear(int year);
|
|
||||||
|
|
||||||
int getMonth();
|
|
||||||
|
|
||||||
void setMonth(int month);
|
|
||||||
|
|
||||||
Date getDate();
|
|
||||||
|
|
||||||
void setDate(Date date);
|
|
||||||
|
|
||||||
String getLabel();
|
|
||||||
|
|
||||||
void setLabel(String label);
|
|
||||||
|
|
||||||
List<IDayItem> getDayItems();
|
|
||||||
|
|
||||||
void setDayItems(List<IDayItem> dayItems);
|
|
||||||
|
|
||||||
IWeekItem copy();
|
|
||||||
}
|
|
@ -1,110 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.models;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Week model class.
|
|
||||||
*/
|
|
||||||
public class WeekItem implements IWeekItem {
|
|
||||||
private int mWeekInYear;
|
|
||||||
private int mYear;
|
|
||||||
private int mMonth;
|
|
||||||
private Date mDate;
|
|
||||||
private String mLabel;
|
|
||||||
private List<IDayItem> mDayItems;
|
|
||||||
|
|
||||||
// region Constructor
|
|
||||||
|
|
||||||
public WeekItem(int weekInYear, int year, Date date, String label, int month) {
|
|
||||||
this.mWeekInYear = weekInYear;
|
|
||||||
this.mYear = year;
|
|
||||||
this.mDate = date;
|
|
||||||
this.mLabel = label;
|
|
||||||
this.mMonth = month;
|
|
||||||
}
|
|
||||||
public WeekItem(WeekItem original) {
|
|
||||||
this.mWeekInYear = original.getWeekInYear();
|
|
||||||
this.mYear = original.getYear();
|
|
||||||
this.mMonth = original.getMonth();
|
|
||||||
this.mDate = original.getDate();
|
|
||||||
this.mLabel = original.getLabel();
|
|
||||||
this.mDayItems = original.getDayItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
public WeekItem(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Getters/Setters
|
|
||||||
|
|
||||||
public int getWeekInYear() {
|
|
||||||
return mWeekInYear;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWeekInYear(int weekInYear) {
|
|
||||||
this.mWeekInYear = weekInYear;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getYear() {
|
|
||||||
return mYear;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setYear(int year) {
|
|
||||||
this.mYear = year;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMonth() {
|
|
||||||
return mMonth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMonth(int month) {
|
|
||||||
this.mMonth = month;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDate() {
|
|
||||||
return mDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDate(Date date) {
|
|
||||||
this.mDate = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return mLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.mLabel = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<IDayItem> getDayItems() {
|
|
||||||
return mDayItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDayItems(List<IDayItem> dayItems) {
|
|
||||||
this.mDayItems = dayItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IWeekItem copy() {
|
|
||||||
return new WeekItem(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "WeekItem{"
|
|
||||||
+ "label='"
|
|
||||||
+ mLabel
|
|
||||||
+ '\''
|
|
||||||
+ ", weekInYear="
|
|
||||||
+ mWeekInYear
|
|
||||||
+ ", year="
|
|
||||||
+ mYear
|
|
||||||
+ '}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.render;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.cardview.widget.CardView;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.R;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.BaseCalendarEvent;
|
|
||||||
import com.google.android.material.internal.ViewUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class helping to inflate our default layout in the AgendaAdapter
|
|
||||||
*/
|
|
||||||
public class DefaultEventRenderer extends EventRenderer<BaseCalendarEvent> {
|
|
||||||
|
|
||||||
public static int themeAttributeToColor(int themeAttributeId,
|
|
||||||
Context context,
|
|
||||||
int fallbackColorId) {
|
|
||||||
TypedValue outValue = new TypedValue();
|
|
||||||
Resources.Theme theme = context.getTheme();
|
|
||||||
boolean wasResolved =
|
|
||||||
theme.resolveAttribute(
|
|
||||||
themeAttributeId, outValue, true);
|
|
||||||
if (wasResolved) {
|
|
||||||
return ContextCompat.getColor(
|
|
||||||
context, outValue.resourceId);
|
|
||||||
} else {
|
|
||||||
// fallback colour handling
|
|
||||||
return fallbackColorId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// region class - EventRenderer
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(@NonNull View view, @NonNull BaseCalendarEvent event) {
|
|
||||||
CardView card = view.findViewById(R.id.view_agenda_event_card_view);
|
|
||||||
TextView txtTitle = view.findViewById(R.id.view_agenda_event_title);
|
|
||||||
TextView txtLocation = view.findViewById(R.id.view_agenda_event_location);
|
|
||||||
LinearLayout descriptionContainer = view.findViewById(R.id.view_agenda_event_description_container);
|
|
||||||
LinearLayout locationContainer = view.findViewById(R.id.view_agenda_event_location_container);
|
|
||||||
|
|
||||||
descriptionContainer.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
txtTitle.setText(event.getTitle());
|
|
||||||
txtLocation.setText(event.getLocation());
|
|
||||||
if (event.getLocation().length() > 0) {
|
|
||||||
locationContainer.setVisibility(View.VISIBLE);
|
|
||||||
txtLocation.setText(event.getLocation());
|
|
||||||
} else {
|
|
||||||
locationContainer.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event.isPlaceholder()/*!event.getTitle().equals(view.getResources().getString(R.string.agenda_event_no_events))*/) {
|
|
||||||
txtTitle.setTextColor(event.getTextColor());
|
|
||||||
card.setCardBackgroundColor(event.getColor());
|
|
||||||
txtLocation.setTextColor(event.getTextColor());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
card.setCardBackgroundColor(Color.TRANSPARENT);
|
|
||||||
card.setCardElevation(0);
|
|
||||||
card.setBackgroundColor(Color.TRANSPARENT);
|
|
||||||
card.setRadius(0);
|
|
||||||
card.setBackgroundDrawable(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEventLayout() {
|
|
||||||
return R.layout.view_agenda_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.render;
|
|
||||||
|
|
||||||
import androidx.annotation.LayoutRes;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
|
||||||
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class for helping layout rendering
|
|
||||||
*/
|
|
||||||
public abstract class EventRenderer<T extends CalendarEvent> {
|
|
||||||
public abstract void render(final View view, final T event);
|
|
||||||
|
|
||||||
@LayoutRes
|
|
||||||
public abstract int getEventLayout();
|
|
||||||
|
|
||||||
public Class<T> getRenderType() {
|
|
||||||
ParameterizedType type = (ParameterizedType) getClass().getGenericSuperclass();
|
|
||||||
return (Class<T>) type.getActualTypeArguments()[0];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.utils;
|
|
||||||
|
|
||||||
import rx.Observable;
|
|
||||||
import rx.subjects.PublishSubject;
|
|
||||||
import rx.subjects.SerializedSubject;
|
|
||||||
import rx.subjects.Subject;
|
|
||||||
|
|
||||||
public class BusProvider {
|
|
||||||
|
|
||||||
public static BusProvider mInstance;
|
|
||||||
|
|
||||||
private final Subject<Object, Object> mBus = new SerializedSubject<>(PublishSubject.create());
|
|
||||||
|
|
||||||
// region Constructors
|
|
||||||
|
|
||||||
public static BusProvider getInstance() {
|
|
||||||
if (mInstance == null) {
|
|
||||||
mInstance = new BusProvider();
|
|
||||||
}
|
|
||||||
return mInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
public void send(Object object) {
|
|
||||||
mBus.onNext(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Observable<Object> toObserverable() {
|
|
||||||
return mBus;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,135 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.utils;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
|
||||||
import com.github.tibolte.agendacalendarview.R;
|
|
||||||
import com.github.tibolte.agendacalendarview.models.IWeekItem;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class containing helper functions for dates
|
|
||||||
*/
|
|
||||||
public class DateHelper {
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if two Calendar instances have the same time (by month, year and day of month)
|
|
||||||
*
|
|
||||||
* @param cal The first Calendar instance.
|
|
||||||
* @param selectedDate The second Calendar instance.
|
|
||||||
* @return True if both instances have the same time.
|
|
||||||
*/
|
|
||||||
public static boolean sameDate(Calendar cal, Calendar selectedDate) {
|
|
||||||
return cal.get(Calendar.MONTH) == selectedDate.get(Calendar.MONTH)
|
|
||||||
&& cal.get(Calendar.YEAR) == selectedDate.get(Calendar.YEAR)
|
|
||||||
&& cal.get(Calendar.DAY_OF_MONTH) == selectedDate.get(Calendar.DAY_OF_MONTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a Date instance and a Calendar instance have the same time (by month, year and day
|
|
||||||
* of month)
|
|
||||||
*
|
|
||||||
* @param cal The Calendar instance.
|
|
||||||
* @param selectedDate The Date instance.
|
|
||||||
* @return True if both have the same time.
|
|
||||||
*/
|
|
||||||
public static boolean sameDate(Calendar cal, Date selectedDate) {
|
|
||||||
Calendar selectedCal = Calendar.getInstance();
|
|
||||||
selectedCal.setTime(selectedDate);
|
|
||||||
return cal.get(Calendar.MONTH) == selectedCal.get(Calendar.MONTH)
|
|
||||||
&& cal.get(Calendar.YEAR) == selectedCal.get(Calendar.YEAR)
|
|
||||||
&& cal.get(Calendar.DAY_OF_MONTH) == selectedCal.get(Calendar.DAY_OF_MONTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a Date instance is between two Calendar instances' dates (inclusively) in time.
|
|
||||||
*
|
|
||||||
* @param selectedDate The date to verify.
|
|
||||||
* @param startCal The start time.
|
|
||||||
* @param endCal The end time.
|
|
||||||
* @return True if the verified date is between the two specified dates.
|
|
||||||
*/
|
|
||||||
public static boolean isBetweenInclusive(Date selectedDate, Calendar startCal, Calendar endCal) {
|
|
||||||
Calendar selectedCal = Calendar.getInstance();
|
|
||||||
selectedCal.setTime(selectedDate);
|
|
||||||
// Check if we deal with the same day regarding startCal and endCal
|
|
||||||
return sameDate(selectedCal, startCal) || selectedCal.after(startCal) && selectedCal.before(endCal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if Calendar instance's date is in the same week, as the WeekItem instance.
|
|
||||||
*
|
|
||||||
* @param cal The Calendar instance to verify.
|
|
||||||
* @param week The WeekItem instance to compare to.
|
|
||||||
* @return True if both instances are in the same week.
|
|
||||||
*/
|
|
||||||
public static boolean sameWeek(Calendar cal, IWeekItem week) {
|
|
||||||
return (cal.get(Calendar.WEEK_OF_YEAR) == week.getWeekInYear() && cal.get(Calendar.YEAR) == week.getYear());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a millisecond duration to a string format
|
|
||||||
*
|
|
||||||
* @param millis A duration to convert to a string form
|
|
||||||
* @return A string of the form "Xd" or either "XhXm".
|
|
||||||
*/
|
|
||||||
public static String getDuration(Context context, long millis) {
|
|
||||||
if (millis < 0) {
|
|
||||||
throw new IllegalArgumentException("Duration must be greater than zero!");
|
|
||||||
}
|
|
||||||
|
|
||||||
long days = TimeUnit.MILLISECONDS.toDays(millis);
|
|
||||||
millis -= TimeUnit.DAYS.toMillis(days);
|
|
||||||
long hours = TimeUnit.MILLISECONDS.toHours(millis);
|
|
||||||
millis -= TimeUnit.HOURS.toMillis(hours);
|
|
||||||
long minutes = TimeUnit.MILLISECONDS.toMinutes(millis);
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder(64);
|
|
||||||
if (days > 0) {
|
|
||||||
sb.append(days);
|
|
||||||
sb.append(context.getResources().getString(R.string.agenda_event_day_duration));
|
|
||||||
return (sb.toString());
|
|
||||||
} else {
|
|
||||||
if (hours > 0) {
|
|
||||||
sb.append(hours);
|
|
||||||
sb.append("h");
|
|
||||||
}
|
|
||||||
if (minutes > 0) {
|
|
||||||
sb.append(minutes);
|
|
||||||
sb.append("m");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (sb.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for displaying the date in any section of the agenda view.
|
|
||||||
*
|
|
||||||
* @param calendar The date of the section.
|
|
||||||
* @param locale The locale used by the Sunrise calendar.
|
|
||||||
* @return The formatted date without the year included.
|
|
||||||
*/
|
|
||||||
public static String getYearLessLocalizedDate(Calendar calendar, Locale locale) {
|
|
||||||
SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat.getDateInstance(DateFormat.FULL, CalendarManager.getInstance().getLocale());
|
|
||||||
String pattern = sdf.toPattern();
|
|
||||||
|
|
||||||
String yearLessPattern = pattern.replaceAll("\\W?[Yy]+\\W?", "");
|
|
||||||
SimpleDateFormat yearLessSDF = new SimpleDateFormat(yearLessPattern, locale);
|
|
||||||
String yearLessDate = yearLessSDF.format(calendar.getTime()).toUpperCase();
|
|
||||||
if (yearLessDate.endsWith(",")) {
|
|
||||||
yearLessDate = yearLessDate.substring(0, yearLessDate.length() - 1);
|
|
||||||
}
|
|
||||||
return yearLessDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.utils;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Events emitted by the bus provider.
|
|
||||||
*/
|
|
||||||
public class Events {
|
|
||||||
|
|
||||||
public static class DayClickedEvent {
|
|
||||||
|
|
||||||
public Calendar mCalendar;
|
|
||||||
public IDayItem mDayItem;
|
|
||||||
|
|
||||||
public DayClickedEvent(IDayItem dayItem) {
|
|
||||||
this.mCalendar = Calendar.getInstance();
|
|
||||||
this.mCalendar.setTime(dayItem.getDate());
|
|
||||||
this.mDayItem = dayItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Calendar getCalendar() {
|
|
||||||
return mCalendar;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IDayItem getDay() {
|
|
||||||
return mDayItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CalendarScrolledEvent {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class AgendaListViewTouchedEvent {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class EventsFetched {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ForecastFetched {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.utils;
|
|
||||||
|
|
||||||
import com.github.tibolte.agendacalendarview.agenda.AgendaListView;
|
|
||||||
|
|
||||||
import android.util.SparseArray;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper class calculating the scrolling distance in the AgendaListView.
|
|
||||||
*/
|
|
||||||
public class ListViewScrollTracker {
|
|
||||||
private AgendaListView mListView;
|
|
||||||
private SparseArray<Integer> mPositions;
|
|
||||||
private SparseArray<Integer> mListViewItemHeights = new SparseArray<>();
|
|
||||||
private int mFirstVisiblePosition;
|
|
||||||
private int mReferencePosition = -1; // Position of the current date in the Agenda listView
|
|
||||||
|
|
||||||
// region Constructor and Accessor(s)
|
|
||||||
|
|
||||||
public ListViewScrollTracker(AgendaListView listView) {
|
|
||||||
mListView = listView;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getReferencePosition() {
|
|
||||||
return mReferencePosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call from an AbsListView.OnScrollListener to calculate the incremental offset (change in
|
|
||||||
* scroll offset
|
|
||||||
* since the last calculation).
|
|
||||||
*
|
|
||||||
* @param firstVisiblePosition First visible item position in the list.
|
|
||||||
* @param visibleItemCount Number of visible items in the list.
|
|
||||||
* @return The incremental offset, or 0 if it wasn't possible to calculate the offset.
|
|
||||||
*/
|
|
||||||
public int calculateIncrementalOffset(int firstVisiblePosition, int visibleItemCount) {
|
|
||||||
// Remember previous positions, if any
|
|
||||||
SparseArray<Integer> previousPositions = mPositions;
|
|
||||||
|
|
||||||
// Store new positions
|
|
||||||
mPositions = new SparseArray<>();
|
|
||||||
for (int i = 0; i < visibleItemCount; i++) {
|
|
||||||
mPositions.put(firstVisiblePosition + i, mListView.getListChildAt(i).getTop());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (previousPositions != null) {
|
|
||||||
// Find position which exists in both mPositions and previousPositions, then return the difference
|
|
||||||
// of the new and old Y values.
|
|
||||||
for (int i = 0; i < previousPositions.size(); i++) {
|
|
||||||
int previousPosition = previousPositions.keyAt(i);
|
|
||||||
int previousTop = previousPositions.get(previousPosition);
|
|
||||||
Integer newTop = mPositions.get(previousPosition);
|
|
||||||
if (newTop != null) {
|
|
||||||
return newTop - previousTop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // No view's position was in both previousPositions and mPositions
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call from an AbsListView.OnScrollListener to calculate the scrollY (Here
|
|
||||||
* we definite as the distance in pixels compared to the position representing the current
|
|
||||||
* date).
|
|
||||||
*
|
|
||||||
* @param firstVisiblePosition First visible item position in the list.
|
|
||||||
* @param visibleItemCount Number of visible items in the list.
|
|
||||||
* @return Distance in pixels compared to current day position (negative if firstVisiblePosition less than mReferencePosition)
|
|
||||||
*/
|
|
||||||
public int calculateScrollY(int firstVisiblePosition, int visibleItemCount) {
|
|
||||||
mFirstVisiblePosition = firstVisiblePosition;
|
|
||||||
if (mReferencePosition < 0) {
|
|
||||||
mReferencePosition = mFirstVisiblePosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (visibleItemCount > 0) {
|
|
||||||
View c = mListView.getListChildAt(0); // this is the first visible row
|
|
||||||
int scrollY = -c.getTop();
|
|
||||||
mListViewItemHeights.put(firstVisiblePosition, c.getMeasuredHeight());
|
|
||||||
|
|
||||||
if (mFirstVisiblePosition >= mReferencePosition) {
|
|
||||||
for (int i = mReferencePosition; i < firstVisiblePosition; ++i) {
|
|
||||||
if (mListViewItemHeights.get(i) == null) {
|
|
||||||
mListViewItemHeights.put(i, c.getMeasuredHeight());
|
|
||||||
}
|
|
||||||
scrollY += mListViewItemHeights.get(i); // add all heights of the views that are gone
|
|
||||||
}
|
|
||||||
return scrollY;
|
|
||||||
} else {
|
|
||||||
for (int i = mReferencePosition - 1; i >= firstVisiblePosition; --i) {
|
|
||||||
if (mListViewItemHeights.get(i) == null) {
|
|
||||||
mListViewItemHeights.put(i, c.getMeasuredHeight());
|
|
||||||
}
|
|
||||||
scrollY -= mListViewItemHeights.get(i);
|
|
||||||
}
|
|
||||||
return scrollY;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
mPositions = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,110 +0,0 @@
|
|||||||
package com.github.tibolte.agendacalendarview.widgets;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
|
||||||
import android.view.animation.Interpolator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Floating action button helping to scroll back to the current date.
|
|
||||||
*/
|
|
||||||
public class FloatingActionButton extends com.google.android.material.floatingactionbutton.FloatingActionButton {
|
|
||||||
private static final int TRANSLATE_DURATION_MILLIS = 200;
|
|
||||||
|
|
||||||
private boolean mVisible = true;
|
|
||||||
|
|
||||||
private final Interpolator mInterpolator = new AccelerateDecelerateInterpolator();
|
|
||||||
|
|
||||||
// region Constructors
|
|
||||||
|
|
||||||
public FloatingActionButton(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FloatingActionButton(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Overrides
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
show(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
hide(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Public methods
|
|
||||||
|
|
||||||
public void show(boolean animate) {
|
|
||||||
toggle(true, animate, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hide(boolean animate) {
|
|
||||||
toggle(false, animate, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isVisible() {
|
|
||||||
return mVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Private methods
|
|
||||||
|
|
||||||
private void toggle(final boolean visible, final boolean animate, boolean force) {
|
|
||||||
if (mVisible != visible || force) {
|
|
||||||
mVisible = visible;
|
|
||||||
int height = getHeight();
|
|
||||||
if (height == 0 && !force) {
|
|
||||||
ViewTreeObserver vto = getViewTreeObserver();
|
|
||||||
if (vto.isAlive()) {
|
|
||||||
vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreDraw() {
|
|
||||||
ViewTreeObserver currentVto = getViewTreeObserver();
|
|
||||||
if (currentVto.isAlive()) {
|
|
||||||
currentVto.removeOnPreDrawListener(this);
|
|
||||||
}
|
|
||||||
toggle(visible, animate, true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int translationY = visible ? 0 : height + getMarginBottom();
|
|
||||||
if (animate) {
|
|
||||||
animate().setInterpolator(mInterpolator)
|
|
||||||
.setDuration(TRANSLATE_DURATION_MILLIS)
|
|
||||||
.translationY(translationY);
|
|
||||||
} else {
|
|
||||||
setTranslationY(translationY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getMarginBottom() {
|
|
||||||
int marginBottom = 0;
|
|
||||||
final ViewGroup.LayoutParams layoutParams = getLayoutParams();
|
|
||||||
if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
|
|
||||||
marginBottom = ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin;
|
|
||||||
}
|
|
||||||
return marginBottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="oval">
|
|
||||||
|
|
||||||
<stroke android:width="2dp" android:color="@color/theme_primary"/>
|
|
||||||
|
|
||||||
<solid android:color="@android:color/transparent" />
|
|
||||||
|
|
||||||
</shape>
|
|
@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="oval">
|
|
||||||
<solid android:color="#ffffff" />
|
|
||||||
</shape>
|
|
@ -1,7 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:height="24dp"
|
|
||||||
android:width="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path android:fillColor="#fff" android:pathData="M7,10H12V15H7M19,19H5V8H19M19,3H18V1H16V3H8V1H6V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3Z" />
|
|
||||||
</vector>
|
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="oval">
|
|
||||||
|
|
||||||
<stroke android:width="1dp" android:color="@color/theme_text_icons"/>
|
|
||||||
|
|
||||||
<solid android:color="@android:color/transparent" />
|
|
||||||
</shape>
|
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<gradient
|
|
||||||
android:angle="270"
|
|
||||||
android:startColor="#88444444"
|
|
||||||
android:endColor="#00000000" />
|
|
||||||
</shape>
|
|
@ -1,48 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/week_days_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_cell" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_cell" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_cell" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_cell" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_cell" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_cell" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_cell" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/month_background"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/day_cell_height"
|
|
||||||
android:alpha="0"
|
|
||||||
android:background="@color/calendar_month_transparent_background" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/month_label"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:alpha="0"
|
|
||||||
tools:alpha="1"
|
|
||||||
android:textColor="@android:color/black"
|
|
||||||
android:textSize="17sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
tools:text="MAJ" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/view_shadow"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="5dp"
|
|
||||||
android:background="@drawable/shadow"
|
|
||||||
android:visibility="visible"/>
|
|
||||||
|
|
||||||
<com.github.tibolte.agendacalendarview.agenda.AgendaListView
|
|
||||||
android:id="@+id/agenda_listview"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:animationCache="false"
|
|
||||||
android:divider="@color/agenda_list_header_divider"
|
|
||||||
android:dividerHeight="1dp"
|
|
||||||
android:overScrollMode="never"
|
|
||||||
android:scrollbars="none"
|
|
||||||
android:scrollingCache="false" />
|
|
||||||
|
|
||||||
</merge>
|
|
@ -1,53 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<com.github.tibolte.agendacalendarview.agenda.AgendaEventView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:id="@+id/view_agenda_event_card_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
tools:cardBackgroundColor="@color/blue_selected"
|
|
||||||
app:cardCornerRadius="5dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/view_agenda_event_description_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="10dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/view_agenda_event_title"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:textSize="16sp"
|
|
||||||
tools:text="sprawdzian - Biotechnologia" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/view_agenda_event_location_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/view_agenda_event_location"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="@color/calendar_text_default"
|
|
||||||
android:textSize="12sp"
|
|
||||||
tools:text="9:05, biologia, Beata Pudełko, 1B3T" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
</com.github.tibolte.agendacalendarview.agenda.AgendaEventView>
|
|
@ -1,64 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<com.github.tibolte.agendacalendarview.agenda.AgendaHeaderView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/view_agenda_day_text"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:visibility="visible" />
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="5dp">
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/view_day_circle_selected"
|
|
||||||
android:layout_width="@dimen/circle_day_size"
|
|
||||||
android:layout_height="@dimen/circle_day_size"
|
|
||||||
android:background="@drawable/agenda_day_circle"
|
|
||||||
android:visibility="invisible"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:paddingBottom="5dp"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/view_agenda_day_of_month"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:textSize="20sp"
|
|
||||||
tools:text="24" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/view_agenda_day_of_week"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:visibility="visible"
|
|
||||||
tools:text="śr." />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</com.github.tibolte.agendacalendarview.agenda.AgendaHeaderView>
|
|
@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<merge 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">
|
|
||||||
|
|
||||||
<com.github.tibolte.agendacalendarview.calendar.CalendarView
|
|
||||||
android:id="@+id/calendar_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
|
|
||||||
<com.github.tibolte.agendacalendarview.agenda.AgendaView
|
|
||||||
android:id="@+id/agenda_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
</com.github.tibolte.agendacalendarview.agenda.AgendaView>
|
|
||||||
|
|
||||||
<com.github.tibolte.agendacalendarview.widgets.FloatingActionButton
|
|
||||||
android:id="@+id/floating_action_button"
|
|
||||||
style="@style/fab"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:scaleType="center" />
|
|
||||||
|
|
||||||
</merge>
|
|
@ -1,48 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:parentTag="LinearLayout"
|
|
||||||
tools:orientation="vertical">
|
|
||||||
|
|
||||||
<!-- Day names labels -->
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/cal_day_names"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/calendar_header_height"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_calendar_header" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_calendar_header" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_calendar_header" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_calendar_header" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_calendar_header" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_calendar_header" />
|
|
||||||
|
|
||||||
<include layout="@layout/view_day_calendar_header" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0.5dp"
|
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
android:background="#ff7f7f7f" />
|
|
||||||
|
|
||||||
<com.github.tibolte.agendacalendarview.calendar.weekslist.WeekListView
|
|
||||||
android:id="@+id/list_week"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:cacheColorHint="@android:color/transparent"
|
|
||||||
android:divider="@color/calendar_divider_color"
|
|
||||||
android:dividerHeight="1dp"
|
|
||||||
android:drawSelectorOnTop="false"
|
|
||||||
android:listSelector="@android:color/transparent"
|
|
||||||
android:overScrollMode="never"
|
|
||||||
android:scrollbars="none" />
|
|
||||||
|
|
||||||
</merge>
|
|
@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="0dip"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
tools:text="pon." />
|
|
@ -1,85 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="0dip"
|
|
||||||
android:layout_height="@dimen/day_cell_height"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/view_day_month_label"
|
|
||||||
style="@style/CalendarCellText"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:text="maj" />
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/view_day_circle_selected"
|
|
||||||
android:layout_width="@dimen/circle_selected_size"
|
|
||||||
android:layout_height="@dimen/circle_selected_size"
|
|
||||||
android:background="@drawable/selected_day_color_circle"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/view_day_day_label"
|
|
||||||
style="@style/CalendarCellText"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
tools:text="1" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="10dp"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/view_day_event_indicator3"
|
|
||||||
android:layout_width="10dp"
|
|
||||||
android:layout_height="10dp"
|
|
||||||
android:layout_marginStart="3dp"
|
|
||||||
android:layout_marginLeft="3dp"
|
|
||||||
android:background="@drawable/event_color_circle"
|
|
||||||
android:visibility="invisible" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/view_day_event_indicator2"
|
|
||||||
android:layout_width="10dp"
|
|
||||||
android:layout_height="10dp"
|
|
||||||
android:layout_marginStart="3dp"
|
|
||||||
android:layout_marginLeft="3dp"
|
|
||||||
android:background="@drawable/event_color_circle"
|
|
||||||
android:visibility="invisible" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/view_day_event_indicator1"
|
|
||||||
android:layout_width="10dp"
|
|
||||||
android:layout_height="10dp"
|
|
||||||
android:layout_marginStart="3dp"
|
|
||||||
android:layout_marginLeft="3dp"
|
|
||||||
android:background="@drawable/event_color_circle"
|
|
||||||
android:visibility="invisible" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,12 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<!-- Agenda -->
|
|
||||||
<string name="today">Today</string>
|
|
||||||
<string name="tomorrow">Tomorrow</string>
|
|
||||||
<string name="agenda_event_day_duration">d</string>
|
|
||||||
<string name="agenda_event_all_day">All day</string>
|
|
||||||
<string name="agenda_event_no_events">No events</string>
|
|
||||||
|
|
||||||
<!-- Weather -->
|
|
||||||
<string name="month_name_format">LLLL</string>
|
|
||||||
<string name="month_half_name_format">MMM</string>
|
|
||||||
</resources>
|
|
@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<declare-styleable name="ColorOptionsView">
|
|
||||||
<attr name="agendaCurrentDayTextColor" format="color" />
|
|
||||||
<attr name="calendarHeaderColor" format="color" />
|
|
||||||
<attr name="calendarHeaderTextColor" format="color" />
|
|
||||||
<attr name="calendarColor" format="color" />
|
|
||||||
<attr name="calendarDayTextColor" format="color" />
|
|
||||||
<attr name="calendarPastDayTextColor" format="color" />
|
|
||||||
<attr name="calendarCurrentDayTextColor" format="color" />
|
|
||||||
<attr name="fabColor" format="color" />
|
|
||||||
</declare-styleable>
|
|
||||||
</resources>
|
|
@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<!-- Colors for Calendar view -->
|
|
||||||
<color name="calendar_text_current_day">#000000</color>
|
|
||||||
<color name="calendar_text_default">#9C9CA0</color>
|
|
||||||
<color name="calendar_month_transparent_background">#CCFFFFFF</color>
|
|
||||||
<color name="calendar_divider_color">#F3F3F3</color>
|
|
||||||
|
|
||||||
<!-- Colors for Agenda view -->
|
|
||||||
<!--<color name="agenda_list_header_divider">#666666</color>-->
|
|
||||||
<color name="agenda_list_header_divider">#00000000</color>
|
|
||||||
|
|
||||||
<!-- General -->
|
|
||||||
<color name="blue_selected">#2196F3</color>
|
|
||||||
<color name="theme_primary_dark">#1976D2</color>
|
|
||||||
<color name="theme_primary">#2196F3</color>
|
|
||||||
<color name="theme_light_primary">#BBDEFB</color>
|
|
||||||
<color name="theme_accent">#4caf50</color>
|
|
||||||
<color name="theme_text_icons">#FFFFFF</color>
|
|
||||||
|
|
||||||
</resources>
|
|
@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<!-- Calendar values -->
|
|
||||||
<dimen name="calendar_header_height">20dp</dimen>
|
|
||||||
<dimen name="day_cell_height">52dp</dimen>
|
|
||||||
<dimen name="text_day_size">14dp</dimen>
|
|
||||||
<dimen name="circle_selected_size">32dp</dimen>
|
|
||||||
|
|
||||||
<!-- Agenda values -->
|
|
||||||
<dimen name="circle_day_size">60dp</dimen>
|
|
||||||
|
|
||||||
<!-- Floating action button values -->
|
|
||||||
<!--<dimen name="fab_size">56dp</dimen>-->
|
|
||||||
|
|
||||||
<dimen name="agenda_event_view_padding_left">70dp</dimen>
|
|
||||||
<dimen name="agenda_event_view_padding_top">5dp</dimen>
|
|
||||||
<dimen name="agenda_event_view_padding_right">15dp</dimen>
|
|
||||||
<dimen name="agenda_event_view_padding_bottom">5dp</dimen>
|
|
||||||
</resources>
|
|
@ -1,14 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<!-- Calendar -->
|
|
||||||
<string name="month_name_format">LLLL</string>
|
|
||||||
<string name="day_name_format" translatable="false">E</string>
|
|
||||||
|
|
||||||
<!-- Agenda -->
|
|
||||||
<string name="today">Dziś</string>
|
|
||||||
<string name="tomorrow">Jutro</string>
|
|
||||||
<string name="agenda_event_day_duration">d</string>
|
|
||||||
<string name="agenda_event_all_day">Cały dzień</string>
|
|
||||||
<string name="agenda_event_no_events">Brak wydarzeń</string>
|
|
||||||
|
|
||||||
<string name="month_half_name_format">MMM</string>
|
|
||||||
</resources>
|
|
@ -1,25 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<!-- Calendar styles -->
|
|
||||||
<style name="CalendarCellText">
|
|
||||||
<item name="android:layout_height">wrap_content</item>
|
|
||||||
<item name="android:layout_width">wrap_content</item>
|
|
||||||
<item name="android:textColor">@color/calendar_text_default</item>
|
|
||||||
<item name="android:textStyle">normal</item>
|
|
||||||
<item name="android:textSize">@dimen/text_day_size</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<!-- Agenda styles -->
|
|
||||||
|
|
||||||
<!-- FAB -->
|
|
||||||
<style name="fab">
|
|
||||||
<item name="android:src">@drawable/fab_arrow</item>
|
|
||||||
<item name="android:layout_height">wrap_content</item>
|
|
||||||
<item name="android:layout_width">wrap_content</item>
|
|
||||||
<item name="android:layout_gravity">bottom|start</item>
|
|
||||||
<item name="android:layout_margin">16dp</item>
|
|
||||||
<item name="elevation">8dp</item>
|
|
||||||
<item name="fabSize">normal</item>
|
|
||||||
<item name="pressedTranslationZ">6dp</item>
|
|
||||||
</style>
|
|
||||||
</resources>
|
|
1
annotation/.gitignore
vendored
1
annotation/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
/build
|
|
@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Kuba Szczodrzyński 2020-3-28.
|
|
||||||
*/
|
|
||||||
|
|
||||||
apply plugin: 'java-library'
|
|
||||||
apply plugin: 'kotlin'
|
|
||||||
apply plugin: 'kotlin-kapt'
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceCompatibility = "7"
|
|
||||||
targetCompatibility = "7"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
compileKotlin {
|
|
||||||
kotlinOptions {
|
|
||||||
jvmTarget = "1.8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compileTestKotlin {
|
|
||||||
kotlinOptions {
|
|
||||||
jvmTarget = "1.8"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Kuba Szczodrzyński 2020-3-28.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package pl.szczodrzynski.edziennik.annotation
|
|
||||||
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
|
||||||
@MustBeDocumented
|
|
||||||
annotation class SelectiveDao(
|
|
||||||
val db: KClass<*>
|
|
||||||
)
|
|
@ -1,13 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Kuba Szczodrzyński 2020-3-28.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package pl.szczodrzynski.edziennik.annotation
|
|
||||||
|
|
||||||
@Target(AnnotationTarget.FUNCTION)
|
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
|
||||||
@MustBeDocumented
|
|
||||||
annotation class UpdateSelective(
|
|
||||||
val primaryKeys: Array<String>,
|
|
||||||
val skippedColumns: Array<String> = []
|
|
||||||
)
|
|
220
app/build.gradle
220
app/build.gradle
@ -1,21 +1,21 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
apply plugin: 'kotlin-kapt'
|
apply plugin: 'kotlin-kapt'
|
||||||
apply plugin: 'kotlin-android-extensions'
|
|
||||||
apply plugin: 'com.google.gms.google-services'
|
apply plugin: 'com.google.gms.google-services'
|
||||||
apply plugin: 'com.google.firebase.crashlytics'
|
apply plugin: 'com.google.firebase.crashlytics'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
signingConfigs {
|
|
||||||
}
|
|
||||||
compileSdkVersion setup.compileSdk
|
compileSdkVersion setup.compileSdk
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId 'pl.szczodrzynski.edziennik'
|
applicationId 'pl.szczodrzynski.edziennik'
|
||||||
minSdkVersion setup.minSdk
|
minSdkVersion setup.minSdk
|
||||||
targetSdkVersion setup.targetSdk
|
targetSdkVersion setup.targetSdk
|
||||||
|
|
||||||
versionCode release.versionCode
|
versionCode release.versionCode
|
||||||
versionName release.versionName
|
versionName release.versionName
|
||||||
multiDexEnabled true
|
|
||||||
|
multiDexEnabled = true
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
@ -28,41 +28,35 @@ android {
|
|||||||
variant.outputs.all {
|
variant.outputs.all {
|
||||||
if (variant.buildType.name == "release") {
|
if (variant.buildType.name == "release") {
|
||||||
outputFileName = "Edziennik_" + defaultConfig.versionName + ".apk"
|
outputFileName = "Edziennik_" + defaultConfig.versionName + ".apk"
|
||||||
} else if (variant.buildType.name == "debugMinify") {
|
|
||||||
outputFileName = "Edziennik_" + defaultConfig.versionName + "_debugMinify.apk"
|
|
||||||
} else {
|
} else {
|
||||||
outputFileName = "Edziennik_" + defaultConfig.versionName + "_debug.apk"
|
outputFileName = "Edziennik_" + defaultConfig.versionName + "_debug.apk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug {
|
debug {
|
||||||
minifyEnabled false
|
minifyEnabled = false
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled = true
|
||||||
shrinkResources true
|
shrinkResources = true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt')
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
proguardFiles fileTree('proguard').asList().toArray()
|
proguardFiles fileTree('proguard').asList().toArray()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
|
||||||
implementation "com.google.firebase:firebase-core:${versions.firebase}"
|
|
||||||
}
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
}
|
}
|
||||||
lintOptions {
|
lintOptions {
|
||||||
checkReleaseBuilds false
|
checkReleaseBuilds = false
|
||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
dataBinding = true
|
dataBinding = true
|
||||||
|
viewBinding = true
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
coreLibraryDesugaringEnabled true
|
coreLibraryDesugaringEnabled = true
|
||||||
sourceCompatibility '1.8'
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility '1.8'
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
}
|
|
||||||
productFlavors {
|
|
||||||
}
|
}
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
@ -76,145 +70,93 @@ android {
|
|||||||
version "3.10.2"
|
version "3.10.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ndkVersion '21.3.6528147'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*task finalizeBundleDebug(type: Copy) {
|
|
||||||
from("debug/debug")
|
|
||||||
include "app.aab"
|
|
||||||
destinationDir file("debug/debug")
|
|
||||||
rename "app.aab", "Edziennik_debug.aab"
|
|
||||||
}
|
|
||||||
|
|
||||||
// it finalizes :bundleRelease
|
|
||||||
task finalizeBundleRelease(type: Copy) {
|
|
||||||
from("release/release")
|
|
||||||
include "app.aab"
|
|
||||||
destinationDir file("release/release")
|
|
||||||
rename "app.aab", "Edziennik_${android.defaultConfig.versionCode}.aab"
|
|
||||||
}*/
|
|
||||||
/*
|
|
||||||
// this adds the above two tasks
|
|
||||||
tasks.whenTaskAdded { task ->
|
|
||||||
if (task.name == "bundleDebug") {
|
|
||||||
task.finalizedBy finalizeBundleDebug
|
|
||||||
} else if (task.name == "bundleRelease") {
|
|
||||||
task.finalizedBy finalizeBundleRelease
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
|
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
|
// Language cores
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
|
||||||
|
|
||||||
kapt "androidx.room:room-compiler:${versions.room}"
|
// Android Jetpack
|
||||||
debugImplementation "com.amitshekhar.android:debug-db:1.0.5"
|
implementation "androidx.appcompat:appcompat:1.2.0"
|
||||||
|
implementation "androidx.cardview:cardview:1.0.0"
|
||||||
|
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
|
||||||
|
implementation "androidx.core:core-ktx:1.3.2"
|
||||||
|
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.0"
|
||||||
|
implementation "androidx.navigation:navigation-fragment-ktx:2.3.4"
|
||||||
|
implementation "androidx.recyclerview:recyclerview:1.1.0"
|
||||||
|
implementation "androidx.room:room-runtime:2.2.6"
|
||||||
|
implementation "androidx.work:work-runtime-ktx:2.5.0"
|
||||||
|
kapt "androidx.room:room-compiler:2.2.6"
|
||||||
|
|
||||||
implementation "android.arch.navigation:navigation-fragment-ktx:${versions.navigationFragment}"
|
// Google design libs
|
||||||
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
|
implementation "com.google.android.material:material:1.3.0"
|
||||||
implementation "androidx.cardview:cardview:${versions.cardView}"
|
implementation "com.google.android:flexbox:2.0.1"
|
||||||
implementation "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}"
|
|
||||||
implementation "androidx.core:core-ktx:${versions.ktx}"
|
|
||||||
implementation "androidx.gridlayout:gridlayout:${versions.gridLayout}"
|
|
||||||
implementation "androidx.legacy:legacy-support-v4:${versions.legacy}"
|
|
||||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:${versions.lifecycle}"
|
|
||||||
implementation "androidx.recyclerview:recyclerview:${versions.recyclerView}"
|
|
||||||
implementation "androidx.room:room-runtime:${versions.room}"
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
|
|
||||||
|
|
||||||
implementation "com.google.android.gms:play-services-wearable:${versions.play_services}"
|
// Play Services/Firebase
|
||||||
implementation "com.google.android.material:material:${versions.material}"
|
implementation "com.google.android.gms:play-services-wearable:17.0.0"
|
||||||
implementation "com.google.firebase:firebase-messaging:${versions.firebasemessaging}"
|
implementation "com.google.firebase:firebase-core:18.0.2"
|
||||||
|
implementation "com.google.firebase:firebase-crashlytics:17.4.0"
|
||||||
|
implementation("com.google.firebase:firebase-messaging") { version { strictly "20.1.3" } }
|
||||||
|
|
||||||
//implementation "com.github.kuba2k2.MaterialDrawer:library:e603091449"
|
// OkHttp, Retrofit, Gson, Jsoup
|
||||||
implementation "com.mikepenz:crossfader:1.6.0" // do not update
|
implementation("com.squareup.okhttp3:okhttp") { version { strictly "3.12.13" } }
|
||||||
implementation "com.mikepenz:iconics-core:${versions.iconics}"
|
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
||||||
implementation "com.mikepenz:iconics-views:${versions.iconics}"
|
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
|
||||||
implementation "com.mikepenz:community-material-typeface:${versions.font_cmd}@aar"
|
implementation "com.squareup.retrofit2:converter-scalars:2.9.0"
|
||||||
implementation "com.mikepenz:materialize:1.2.1"
|
implementation 'com.google.code.gson:gson:2.8.6'
|
||||||
|
implementation "org.jsoup:jsoup:1.13.1"
|
||||||
|
implementation "pl.droidsonroids:jspoon:1.3.2"
|
||||||
|
implementation "pl.droidsonroids.retrofit2:converter-jspoon:1.3.2"
|
||||||
|
|
||||||
implementation "com.github.kuba2k2:NavLib:${versions.navlib}"
|
// Szkolny.eu libraries/forks
|
||||||
|
implementation "eu.szkolny:agendacalendarview:1799f8ef47"
|
||||||
|
implementation "eu.szkolny:cafebar:5bf0c618de"
|
||||||
|
implementation "eu.szkolny.fslogin:lib:2.0.0"
|
||||||
|
implementation "eu.szkolny:material-about-library:0534abf316"
|
||||||
|
implementation "eu.szkolny:mhttp:af4b62e6e9"
|
||||||
|
implementation "eu.szkolny:nachos:0e5dfcaceb"
|
||||||
|
implementation "eu.szkolny.selective-dao:annotation:27f8f3f194"
|
||||||
|
implementation "pl.szczodrzynski:navlib:0.7.2"
|
||||||
|
implementation "pl.szczodrzynski:numberslidingpicker:2921225f76"
|
||||||
|
implementation "pl.szczodrzynski:recyclertablayout:700f980584"
|
||||||
|
implementation "pl.szczodrzynski:tachyon:551943a6b5"
|
||||||
|
kapt "eu.szkolny.selective-dao:codegen:27f8f3f194"
|
||||||
|
|
||||||
implementation "com.afollestad.material-dialogs:commons:${versions.materialdialogs}"
|
// Iconics & related
|
||||||
implementation "com.afollestad.material-dialogs:core:${versions.materialdialogs}"
|
implementation "com.mikepenz:iconics-core:5.2.8"
|
||||||
|
implementation "com.mikepenz:iconics-views:5.2.8"
|
||||||
|
implementation "com.mikepenz:community-material-typeface:5.8.55.0-kotlin@aar"
|
||||||
|
implementation "eu.szkolny:szkolny-font:1dab7d64ed"
|
||||||
|
|
||||||
implementation "cat.ereza:customactivityoncrash:2.2.0"
|
// Other dependencies
|
||||||
|
implementation "cat.ereza:customactivityoncrash:2.3.0"
|
||||||
|
implementation "com.afollestad.material-dialogs:commons:0.9.6.0"
|
||||||
|
implementation "com.afollestad.material-dialogs:core:0.9.6.0"
|
||||||
implementation "com.applandeo:material-calendar-view:1.5.0"
|
implementation "com.applandeo:material-calendar-view:1.5.0"
|
||||||
implementation 'com.google.firebase:firebase-crashlytics:17.3.1'
|
|
||||||
implementation "com.daimajia.swipelayout:library:1.2.0@aar"
|
implementation "com.daimajia.swipelayout:library:1.2.0@aar"
|
||||||
implementation "com.evernote:android-job:1.2.6"
|
|
||||||
implementation "com.github.antonKozyriatskyi:CircularProgressIndicator:1.2.2"
|
implementation "com.github.antonKozyriatskyi:CircularProgressIndicator:1.2.2"
|
||||||
implementation "com.github.bassaer:chatmessageview:2.0.1"
|
implementation "com.github.bassaer:chatmessageview:2.0.1"
|
||||||
implementation("com.github.ozodrukh:CircularReveal:2.0.1@aar") {transitive = true}
|
implementation "com.github.ChuckerTeam.Chucker:library:3.0.1"
|
||||||
implementation "com.heinrichreimersoftware:material-intro:1.5.8" // do not update
|
implementation "com.github.jetradarmobile:android-snowfall:1.2.0"
|
||||||
implementation "com.jaredrummler:colorpicker:1.0.2"
|
implementation "com.github.wulkanowy.uonet-request-signer:hebe-jvm:a99ca50a31"
|
||||||
implementation("com.squareup.okhttp3:okhttp") {
|
implementation("com.heinrichreimersoftware:material-intro") { version { strictly "1.5.8" } }
|
||||||
version {
|
implementation "com.hypertrack:hyperlog:0.0.10"
|
||||||
strictly "3.12.13"
|
implementation "com.jaredrummler:colorpicker:1.1.0"
|
||||||
}
|
implementation "com.qifan.powerpermission:powerpermission-coroutines:1.3.0"
|
||||||
}
|
implementation "com.qifan.powerpermission:powerpermission:1.3.0"
|
||||||
implementation "com.theartofdev.edmodo:android-image-cropper:2.8.0" // do not update
|
implementation "com.theartofdev.edmodo:android-image-cropper:2.8.0"
|
||||||
implementation "com.wdullaer:materialdatetimepicker:4.1.2"
|
implementation "com.wdullaer:materialdatetimepicker:4.2.3"
|
||||||
implementation "com.yuyh.json:jsonviewer:1.0.6"
|
implementation "com.yuyh.json:jsonviewer:1.0.6"
|
||||||
|
implementation "io.coil-kt:coil:1.1.1"
|
||||||
implementation "me.dm7.barcodescanner:zxing:1.9.8"
|
implementation "me.dm7.barcodescanner:zxing:1.9.8"
|
||||||
implementation "me.grantland:autofittextview:0.2.1"
|
implementation "me.grantland:autofittextview:0.2.1"
|
||||||
implementation "me.leolin:ShortcutBadger:1.1.22@aar"
|
implementation "me.leolin:ShortcutBadger:1.1.22@aar"
|
||||||
implementation "org.greenrobot:eventbus:3.1.1"
|
implementation "org.greenrobot:eventbus:3.2.0"
|
||||||
implementation "org.jsoup:jsoup:1.12.1"
|
implementation("pl.droidsonroids.gif:android-gif-drawable") { version { strictly "1.2.15" } }
|
||||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.15"
|
|
||||||
//implementation "se.emilsjolander:stickylistheaders:2.7.0"
|
|
||||||
implementation 'com.github.edisonw:StickyListHeaders:master-SNAPSHOT@aar'
|
|
||||||
implementation "uk.co.samuelwall:material-tap-target-prompt:2.14.0"
|
|
||||||
|
|
||||||
implementation project(":agendacalendarview")
|
// Debug-only dependencies
|
||||||
implementation project(":cafebar")
|
debugImplementation "com.amitshekhar.android:debug-db:1.0.5"
|
||||||
implementation project(":material-about-library")
|
|
||||||
implementation project(":mhttp")
|
|
||||||
implementation project(":nachos")
|
|
||||||
//implementation project(":Navigation")
|
|
||||||
implementation project(":szkolny-font")
|
|
||||||
|
|
||||||
implementation "com.github.ChuckerTeam.Chucker:library:3.0.1"
|
|
||||||
//releaseImplementation "com.github.ChuckerTeam.Chucker:library-no-op:3.0.1"
|
|
||||||
|
|
||||||
//implementation 'com.github.wulkanowy:uonet-request-signer:master-SNAPSHOT'
|
|
||||||
//implementation 'com.github.kuba2k2.uonet-request-signer:android:master-63f094b14a-1'
|
|
||||||
|
|
||||||
//implementation "org.redundent:kotlin-xml-builder:1.5.3"
|
|
||||||
|
|
||||||
implementation 'com.github.wulkanowy.uonet-request-signer:hebe-jvm:a99ca50a31'
|
|
||||||
|
|
||||||
implementation "androidx.work:work-runtime-ktx:${versions.work}"
|
|
||||||
|
|
||||||
implementation 'com.hypertrack:hyperlog:0.0.10'
|
|
||||||
|
|
||||||
implementation 'com.github.kuba2k2:RecyclerTabLayout:700f980584'
|
|
||||||
|
|
||||||
implementation 'com.github.kuba2k2:Tachyon:551943a6b5'
|
|
||||||
|
|
||||||
implementation "com.squareup.retrofit2:retrofit:${versions.retrofit}"
|
|
||||||
implementation "com.squareup.retrofit2:converter-gson:${versions.retrofit}"
|
|
||||||
|
|
||||||
implementation 'com.github.jetradarmobile:android-snowfall:1.2.0'
|
|
||||||
|
|
||||||
implementation "io.coil-kt:coil:0.9.2"
|
|
||||||
|
|
||||||
implementation 'com.github.kuba2k2:NumberSlidingPicker:2921225f76'
|
|
||||||
|
|
||||||
implementation project(":annotation")
|
|
||||||
kapt project(":codegen")
|
|
||||||
|
|
||||||
implementation 'com.google.android:flexbox:2.0.1'
|
|
||||||
|
|
||||||
implementation 'com.qifan.powerpermission:powerpermission:1.3.0'
|
|
||||||
implementation 'com.qifan.powerpermission:powerpermission-coroutines:1.3.0'
|
|
||||||
|
|
||||||
implementation 'com.github.kuba2k2.FSLogin:lib:2.0.0'
|
|
||||||
implementation 'pl.droidsonroids:jspoon:1.3.2'
|
|
||||||
implementation "com.squareup.retrofit2:converter-scalars:2.8.1"
|
|
||||||
implementation "pl.droidsonroids.retrofit2:converter-jspoon:1.3.2"
|
|
||||||
}
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
-dontwarn com.evernote.android.job.gcm.**
|
|
||||||
-dontwarn com.evernote.android.job.GcmAvailableHelper
|
|
||||||
-dontwarn com.evernote.android.job.work.**
|
|
||||||
-dontwarn com.evernote.android.job.WorkManagerAvailableHelper
|
|
||||||
|
|
||||||
-keep public class com.evernote.android.job.v21.PlatformJobService
|
|
||||||
-keep public class com.evernote.android.job.v14.PlatformAlarmService
|
|
||||||
-keep public class com.evernote.android.job.v14.PlatformAlarmReceiver
|
|
||||||
-keep public class com.evernote.android.job.JobBootReceiver
|
|
||||||
-keep public class com.evernote.android.job.JobRescheduleService
|
|
||||||
-keep public class com.evernote.android.job.gcm.PlatformGcmService
|
|
||||||
-keep public class com.evernote.android.job.work.PlatformWorker
|
|
||||||
|
|
||||||
-keep class com.evernote.android.job.** { *; }
|
|
@ -1 +0,0 @@
|
|||||||
-keep class android.support.v8.renderscript.** { *; }
|
|
@ -1,25 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# By default, the flags in this file are appended to flags specified
|
|
||||||
# in D:\AndroidSDK/tools/proguard/proguard-android.txt
|
|
||||||
# You can edit the include path and order by changing the proguardFiles
|
|
||||||
# directive in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
|
|
||||||
-keep class android.support.v7.graphics.** { *; }
|
|
||||||
-dontwarn android.support.v7.graphics.**
|
|
||||||
|
|
||||||
-keep class android.support.design.widget.** { *; }
|
|
||||||
-keep interface android.support.design.widget.** { *; }
|
|
||||||
-dontwarn android.support.design.**
|
|
@ -1,14 +0,0 @@
|
|||||||
# Android iconics library - https://github.com/mikepenz/Android-Iconics
|
|
||||||
# Warning: works ONLY with iconics > 1.0.0
|
|
||||||
#
|
|
||||||
# Tested on gradle config:
|
|
||||||
#
|
|
||||||
# compile 'com.mikepenz:iconics-core:1.7.1@aar'
|
|
||||||
#
|
|
||||||
|
|
||||||
-keep class com.mikepenz.iconics.** { *; }
|
|
||||||
-keep class com.mikepenz.community_material_typeface_library.CommunityMaterial
|
|
||||||
-keep class com.mikepenz.fontawesome_typeface_library.FontAwesome
|
|
||||||
-keep class com.mikepenz.google_material_typeface_library.GoogleMaterial
|
|
||||||
-keep class com.mikepenz.meteocons_typeface_library.Meteoconcs
|
|
||||||
-keep class com.mikepenz.octicons_typeface_library.Octicons
|
|
@ -1,48 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# By default, the flags in this file are appended to flags specified
|
|
||||||
# in /Users/wangchao/Work/android-sdk/sdk/tools/proguard/proguard-android.txt
|
|
||||||
# You can edit the include path and order by changing the proguardFiles
|
|
||||||
# directive in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
-dontwarn im.wangchao.**
|
|
||||||
-dontwarn okio.**
|
|
||||||
-dontwarn javax.annotation.Nullable
|
|
||||||
-dontwarn javax.annotation.ParametersAreNonnullByDefault
|
|
||||||
-keep class im.wangchao.** { *; }
|
|
||||||
-keep class **_HttpBinder { *; }
|
|
||||||
-keepclasseswithmembernames class * {
|
|
||||||
@im.wangchao.* <fields>;
|
|
||||||
}
|
|
||||||
-keepclasseswithmembernames class * {
|
|
||||||
@im.wangchao.* <methods>;
|
|
||||||
}
|
|
||||||
-keepclassmembers class * implements java.io.Serializable {
|
|
||||||
static final long serialVersionUID;
|
|
||||||
private static final java.io.ObjectStreamField[] serialPersistentFields;
|
|
||||||
!static !transient <fields>;
|
|
||||||
private void writeObject(java.io.ObjectOutputStream);
|
|
||||||
private void readObject(java.io.ObjectInputStream);
|
|
||||||
java.lang.Object writeReplace();
|
|
||||||
java.lang.Object readResolve();
|
|
||||||
}
|
|
||||||
# okhttp
|
|
||||||
-dontwarn okhttp3.**
|
|
||||||
-dontwarn okio.**
|
|
||||||
-dontwarn javax.annotation.**
|
|
||||||
-dontwarn org.conscrypt.**
|
|
||||||
# A resource is loaded with a relative path so the package of this class must be preserved.
|
|
||||||
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
|
|
||||||
|
|
||||||
# If you do not use Rx:
|
|
||||||
-dontwarn rx.**
|
|
@ -1 +0,0 @@
|
|||||||
-keep class com.mikepenz.szkolny_font_typeface_library.SzkolnyFont { *; }
|
|
@ -1,21 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# You can control the set of applied configuration files using the
|
|
||||||
# proguardFiles setting in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
@ -26,7 +26,6 @@ import com.google.firebase.messaging.FirebaseMessaging
|
|||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.hypertrack.hyperlog.HyperLog
|
import com.hypertrack.hyperlog.HyperLog
|
||||||
import com.mikepenz.iconics.Iconics
|
import com.mikepenz.iconics.Iconics
|
||||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
|
||||||
import im.wangchao.mhttp.MHttp
|
import im.wangchao.mhttp.MHttp
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import me.leolin.shortcutbadger.ShortcutBadger
|
import me.leolin.shortcutbadger.ShortcutBadger
|
||||||
@ -159,7 +158,6 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
|||||||
.errorActivity(CrashActivity::class.java)
|
.errorActivity(CrashActivity::class.java)
|
||||||
.apply()
|
.apply()
|
||||||
Iconics.init(applicationContext)
|
Iconics.init(applicationContext)
|
||||||
Iconics.registerFont(SzkolnyFont)
|
|
||||||
App.db = AppDb(this)
|
App.db = AppDb(this)
|
||||||
Themes.themeInt = config.ui.theme
|
Themes.themeInt = config.ui.theme
|
||||||
devMode = config.debugMode
|
devMode = config.debugMode
|
||||||
|
@ -23,16 +23,16 @@ import androidx.lifecycle.Observer
|
|||||||
import androidx.navigation.NavOptions
|
import androidx.navigation.NavOptions
|
||||||
import com.danimahardhika.cafebar.CafeBar
|
import com.danimahardhika.cafebar.CafeBar
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.mikepenz.iconics.IconicsColor
|
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.IconicsSize
|
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
import com.mikepenz.iconics.utils.colorInt
|
||||||
|
import com.mikepenz.iconics.utils.sizeDp
|
||||||
import com.mikepenz.materialdrawer.model.DividerDrawerItem
|
import com.mikepenz.materialdrawer.model.DividerDrawerItem
|
||||||
import com.mikepenz.materialdrawer.model.ProfileDrawerItem
|
import com.mikepenz.materialdrawer.model.ProfileDrawerItem
|
||||||
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem
|
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.*
|
import com.mikepenz.materialdrawer.model.interfaces.*
|
||||||
import com.mikepenz.materialdrawer.model.utils.withIsHiddenInMiniDrawer
|
import com.mikepenz.materialdrawer.model.utils.withIsHiddenInMiniDrawer
|
||||||
|
import eu.szkolny.font.SzkolnyFont
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
@ -152,7 +152,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
.withPopToHome(false)
|
.withPopToHome(false)
|
||||||
|
|
||||||
list += NavTarget(DRAWER_ITEM_TIMETABLE, R.string.menu_timetable, TimetableFragment::class)
|
list += NavTarget(DRAWER_ITEM_TIMETABLE, R.string.menu_timetable, TimetableFragment::class)
|
||||||
.withIcon(CommunityMaterial.Icon2.cmd_timetable)
|
.withIcon(CommunityMaterial.Icon3.cmd_timetable)
|
||||||
.withBadgeTypeId(TYPE_LESSON_CHANGE)
|
.withBadgeTypeId(TYPE_LESSON_CHANGE)
|
||||||
.isInDrawer(true)
|
.isInDrawer(true)
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
.isInDrawer(true)
|
.isInDrawer(true)
|
||||||
|
|
||||||
list += NavTarget(DRAWER_ITEM_GRADES, R.string.menu_grades, GradesListFragment::class)
|
list += NavTarget(DRAWER_ITEM_GRADES, R.string.menu_grades, GradesListFragment::class)
|
||||||
.withIcon(CommunityMaterial.Icon2.cmd_numeric_5_box_outline)
|
.withIcon(CommunityMaterial.Icon3.cmd_numeric_5_box_outline)
|
||||||
.withBadgeTypeId(TYPE_GRADE)
|
.withBadgeTypeId(TYPE_GRADE)
|
||||||
.isInDrawer(true)
|
.isInDrawer(true)
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
.isBelowSeparator(true)
|
.isBelowSeparator(true)
|
||||||
|
|
||||||
list += NavTarget(DRAWER_ITEM_SETTINGS, R.string.menu_settings, SettingsNewFragment::class)
|
list += NavTarget(DRAWER_ITEM_SETTINGS, R.string.menu_settings, SettingsNewFragment::class)
|
||||||
.withIcon(CommunityMaterial.Icon2.cmd_settings_outline)
|
.withIcon(CommunityMaterial.Icon.cmd_cog_outline)
|
||||||
.isInDrawer(true)
|
.isInDrawer(true)
|
||||||
.isStatic(true)
|
.isStatic(true)
|
||||||
.isBelowSeparator(true)
|
.isBelowSeparator(true)
|
||||||
@ -208,7 +208,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
|
|
||||||
// profile settings items
|
// profile settings items
|
||||||
list += NavTarget(DRAWER_PROFILE_ADD_NEW, R.string.menu_add_new_profile, null)
|
list += NavTarget(DRAWER_PROFILE_ADD_NEW, R.string.menu_add_new_profile, null)
|
||||||
.withIcon(CommunityMaterial.Icon2.cmd_plus)
|
.withIcon(CommunityMaterial.Icon3.cmd_plus)
|
||||||
.withDescription(R.string.drawer_add_new_profile_desc)
|
.withDescription(R.string.drawer_add_new_profile_desc)
|
||||||
.isInProfileList(true)
|
.isInProfileList(true)
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
if (App.devMode) {
|
if (App.devMode) {
|
||||||
list += NavTarget(DRAWER_ITEM_DEBUG, R.string.menu_debug, DebugFragment::class)
|
list += NavTarget(DRAWER_ITEM_DEBUG, R.string.menu_debug, DebugFragment::class)
|
||||||
list += NavTarget(TARGET_LAB, R.string.menu_lab, LabFragment::class)
|
list += NavTarget(TARGET_LAB, R.string.menu_lab, LabFragment::class)
|
||||||
.withIcon(CommunityMaterial.Icon.cmd_flask_outline)
|
.withIcon(CommunityMaterial.Icon2.cmd_flask_outline)
|
||||||
.isInDrawer(true)
|
.isInDrawer(true)
|
||||||
.isBelowSeparator(true)
|
.isBelowSeparator(true)
|
||||||
.isStatic(true)
|
.isStatic(true)
|
||||||
@ -519,7 +519,11 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
navView.coordinator.postDelayed({
|
navView.coordinator.postDelayed({
|
||||||
CafeBar.builder(this)
|
CafeBar.builder(this)
|
||||||
.content(R.string.rate_snackbar_text)
|
.content(R.string.rate_snackbar_text)
|
||||||
.icon(IconicsDrawable(this).icon(CommunityMaterial.Icon2.cmd_star_outline).size(IconicsSize.dp(20)).color(IconicsColor.colorInt(Themes.getPrimaryTextColor(this))))
|
.icon(IconicsDrawable(this).apply {
|
||||||
|
icon = CommunityMaterial.Icon3.cmd_star_outline
|
||||||
|
sizeDp = 20
|
||||||
|
colorInt = Themes.getPrimaryTextColor(this@MainActivity)
|
||||||
|
})
|
||||||
.positiveText(R.string.rate_snackbar_positive)
|
.positiveText(R.string.rate_snackbar_positive)
|
||||||
.positiveColor(-0xb350b0)
|
.positiveColor(-0xb350b0)
|
||||||
.negativeText(R.string.rate_snackbar_negative)
|
.negativeText(R.string.rate_snackbar_negative)
|
||||||
@ -532,12 +536,12 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
app.config.appRateSnackbarTime = 0
|
app.config.appRateSnackbarTime = 0
|
||||||
}
|
}
|
||||||
.onNegative { cafeBar ->
|
.onNegative { cafeBar ->
|
||||||
Toast.makeText(this, "Szkoda, opinie innych pomagają mi rozwijać aplikację.", Toast.LENGTH_LONG).show()
|
Toast.makeText(this, R.string.rate_snackbar_negative_message, Toast.LENGTH_LONG).show()
|
||||||
cafeBar.dismiss()
|
cafeBar.dismiss()
|
||||||
app.config.appRateSnackbarTime = 0
|
app.config.appRateSnackbarTime = 0
|
||||||
}
|
}
|
||||||
.onNeutral { cafeBar ->
|
.onNeutral { cafeBar ->
|
||||||
Toast.makeText(this, "OK", Toast.LENGTH_LONG).show()
|
Toast.makeText(this, R.string.ok, Toast.LENGTH_LONG).show()
|
||||||
cafeBar.dismiss()
|
cafeBar.dismiss()
|
||||||
app.config.appRateSnackbarTime = System.currentTimeMillis() + 7 * 24 * 60 * 60 * 1000
|
app.config.appRateSnackbarTime = System.currentTimeMillis() + 7 * 24 * 60 * 60 * 1000
|
||||||
}
|
}
|
||||||
@ -561,7 +565,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
BottomSheetSeparatorItem(false),
|
BottomSheetSeparatorItem(false),
|
||||||
BottomSheetPrimaryItem(false)
|
BottomSheetPrimaryItem(false)
|
||||||
.withTitle(R.string.menu_settings)
|
.withTitle(R.string.menu_settings)
|
||||||
.withIcon(CommunityMaterial.Icon2.cmd_settings_outline)
|
.withIcon(CommunityMaterial.Icon.cmd_cog_outline)
|
||||||
.withOnClickListener(View.OnClickListener { loadTarget(DRAWER_ITEM_SETTINGS) }),
|
.withOnClickListener(View.OnClickListener { loadTarget(DRAWER_ITEM_SETTINGS) }),
|
||||||
BottomSheetPrimaryItem(false)
|
BottomSheetPrimaryItem(false)
|
||||||
.withTitle(R.string.menu_feedback)
|
.withTitle(R.string.menu_feedback)
|
||||||
|
@ -8,9 +8,9 @@ import androidx.room.Dao
|
|||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.RawQuery
|
import androidx.room.RawQuery
|
||||||
import androidx.sqlite.db.SupportSQLiteQuery
|
import androidx.sqlite.db.SupportSQLiteQuery
|
||||||
|
import eu.szkolny.selectivedao.annotation.SelectiveDao
|
||||||
|
import eu.szkolny.selectivedao.annotation.UpdateSelective
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.annotation.SelectiveDao
|
|
||||||
import pl.szczodrzynski.edziennik.annotation.UpdateSelective
|
|
||||||
import pl.szczodrzynski.edziennik.data.db.AppDb
|
import pl.szczodrzynski.edziennik.data.db.AppDb
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Announcement
|
import pl.szczodrzynski.edziennik.data.db.entity.Announcement
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
|
@ -8,9 +8,9 @@ import androidx.room.Dao
|
|||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.RawQuery
|
import androidx.room.RawQuery
|
||||||
import androidx.sqlite.db.SupportSQLiteQuery
|
import androidx.sqlite.db.SupportSQLiteQuery
|
||||||
|
import eu.szkolny.selectivedao.annotation.SelectiveDao
|
||||||
|
import eu.szkolny.selectivedao.annotation.UpdateSelective
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.annotation.SelectiveDao
|
|
||||||
import pl.szczodrzynski.edziennik.annotation.UpdateSelective
|
|
||||||
import pl.szczodrzynski.edziennik.data.db.AppDb
|
import pl.szczodrzynski.edziennik.data.db.AppDb
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Attendance
|
import pl.szczodrzynski.edziennik.data.db.entity.Attendance
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
|
@ -10,9 +10,9 @@ import androidx.room.RawQuery
|
|||||||
import androidx.room.Transaction
|
import androidx.room.Transaction
|
||||||
import androidx.sqlite.db.SimpleSQLiteQuery
|
import androidx.sqlite.db.SimpleSQLiteQuery
|
||||||
import androidx.sqlite.db.SupportSQLiteQuery
|
import androidx.sqlite.db.SupportSQLiteQuery
|
||||||
|
import eu.szkolny.selectivedao.annotation.SelectiveDao
|
||||||
|
import eu.szkolny.selectivedao.annotation.UpdateSelective
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.annotation.SelectiveDao
|
|
||||||
import pl.szczodrzynski.edziennik.annotation.UpdateSelective
|
|
||||||
import pl.szczodrzynski.edziennik.data.db.AppDb
|
import pl.szczodrzynski.edziennik.data.db.AppDb
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
|
@ -9,9 +9,9 @@ import androidx.room.Query
|
|||||||
import androidx.room.RawQuery
|
import androidx.room.RawQuery
|
||||||
import androidx.room.Transaction
|
import androidx.room.Transaction
|
||||||
import androidx.sqlite.db.SupportSQLiteQuery
|
import androidx.sqlite.db.SupportSQLiteQuery
|
||||||
|
import eu.szkolny.selectivedao.annotation.SelectiveDao
|
||||||
|
import eu.szkolny.selectivedao.annotation.UpdateSelective
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.annotation.SelectiveDao
|
|
||||||
import pl.szczodrzynski.edziennik.annotation.UpdateSelective
|
|
||||||
import pl.szczodrzynski.edziennik.data.db.AppDb
|
import pl.szczodrzynski.edziennik.data.db.AppDb
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Grade
|
import pl.szczodrzynski.edziennik.data.db.entity.Grade
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
|
@ -8,9 +8,9 @@ import androidx.room.Dao
|
|||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.RawQuery
|
import androidx.room.RawQuery
|
||||||
import androidx.sqlite.db.SupportSQLiteQuery
|
import androidx.sqlite.db.SupportSQLiteQuery
|
||||||
|
import eu.szkolny.selectivedao.annotation.SelectiveDao
|
||||||
|
import eu.szkolny.selectivedao.annotation.UpdateSelective
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.annotation.SelectiveDao
|
|
||||||
import pl.szczodrzynski.edziennik.annotation.UpdateSelective
|
|
||||||
import pl.szczodrzynski.edziennik.data.db.AppDb
|
import pl.szczodrzynski.edziennik.data.db.AppDb
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.LuckyNumber
|
import pl.szczodrzynski.edziennik.data.db.entity.LuckyNumber
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
|
@ -8,9 +8,9 @@ import androidx.room.Dao
|
|||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.RawQuery
|
import androidx.room.RawQuery
|
||||||
import androidx.sqlite.db.SupportSQLiteQuery
|
import androidx.sqlite.db.SupportSQLiteQuery
|
||||||
|
import eu.szkolny.selectivedao.annotation.SelectiveDao
|
||||||
|
import eu.szkolny.selectivedao.annotation.UpdateSelective
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.annotation.SelectiveDao
|
|
||||||
import pl.szczodrzynski.edziennik.annotation.UpdateSelective
|
|
||||||
import pl.szczodrzynski.edziennik.data.db.AppDb
|
import pl.szczodrzynski.edziennik.data.db.AppDb
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Message
|
import pl.szczodrzynski.edziennik.data.db.entity.Message
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
|
@ -8,9 +8,9 @@ import androidx.room.Dao
|
|||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.RawQuery
|
import androidx.room.RawQuery
|
||||||
import androidx.sqlite.db.SupportSQLiteQuery
|
import androidx.sqlite.db.SupportSQLiteQuery
|
||||||
|
import eu.szkolny.selectivedao.annotation.SelectiveDao
|
||||||
|
import eu.szkolny.selectivedao.annotation.UpdateSelective
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.annotation.SelectiveDao
|
|
||||||
import pl.szczodrzynski.edziennik.annotation.UpdateSelective
|
|
||||||
import pl.szczodrzynski.edziennik.data.db.AppDb
|
import pl.szczodrzynski.edziennik.data.db.AppDb
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Notice
|
import pl.szczodrzynski.edziennik.data.db.entity.Notice
|
||||||
|
@ -8,9 +8,9 @@ import androidx.room.Dao
|
|||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.RawQuery
|
import androidx.room.RawQuery
|
||||||
import androidx.sqlite.db.SupportSQLiteQuery
|
import androidx.sqlite.db.SupportSQLiteQuery
|
||||||
|
import eu.szkolny.selectivedao.annotation.SelectiveDao
|
||||||
|
import eu.szkolny.selectivedao.annotation.UpdateSelective
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.annotation.SelectiveDao
|
|
||||||
import pl.szczodrzynski.edziennik.annotation.UpdateSelective
|
|
||||||
import pl.szczodrzynski.edziennik.data.db.AppDb
|
import pl.szczodrzynski.edziennik.data.db.AppDb
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.TeacherAbsence
|
import pl.szczodrzynski.edziennik.data.db.entity.TeacherAbsence
|
||||||
|
@ -8,9 +8,9 @@ import androidx.room.Dao
|
|||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.RawQuery
|
import androidx.room.RawQuery
|
||||||
import androidx.sqlite.db.SupportSQLiteQuery
|
import androidx.sqlite.db.SupportSQLiteQuery
|
||||||
|
import eu.szkolny.selectivedao.annotation.SelectiveDao
|
||||||
|
import eu.szkolny.selectivedao.annotation.UpdateSelective
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.annotation.SelectiveDao
|
|
||||||
import pl.szczodrzynski.edziennik.annotation.UpdateSelective
|
|
||||||
import pl.szczodrzynski.edziennik.data.db.AppDb
|
import pl.szczodrzynski.edziennik.data.db.AppDb
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
|
@ -8,7 +8,7 @@ import android.text.method.LinkMovementMethod
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import coil.api.load
|
import coil.load
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -10,8 +10,6 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import kotlinx.android.synthetic.main.row_lesson_change_item.view.*
|
|
||||||
import kotlinx.android.synthetic.main.row_teacher_absence_item.view.*
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import pl.szczodrzynski.edziennik.*
|
import pl.szczodrzynski.edziennik.*
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
||||||
@ -111,7 +109,7 @@ class DayDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
lessonChanges.ifNotEmpty {
|
lessonChanges.ifNotEmpty {
|
||||||
b.lessonChangeContainer.visibility = View.VISIBLE
|
b.lessonChangeContainer.root.visibility = View.VISIBLE
|
||||||
b.lessonChangeContainer.lessonChangeCount.text = it.size.toString()
|
b.lessonChangeContainer.lessonChangeCount.text = it.size.toString()
|
||||||
|
|
||||||
b.lessonChangeLayout.onClick {
|
b.lessonChangeLayout.onClick {
|
||||||
@ -130,7 +128,7 @@ class DayDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
teacherAbsences.ifNotEmpty {
|
teacherAbsences.ifNotEmpty {
|
||||||
b.teacherAbsenceContainer.visibility = View.VISIBLE
|
b.teacherAbsenceContainer.root.visibility = View.VISIBLE
|
||||||
b.teacherAbsenceContainer.teacherAbsenceCount.text = it.size.toString()
|
b.teacherAbsenceContainer.teacherAbsenceCount.text = it.size.toString()
|
||||||
|
|
||||||
b.teacherAbsenceLayout.onClick {
|
b.teacherAbsenceLayout.onClick {
|
||||||
|
@ -378,7 +378,7 @@ class EventManualDialog(
|
|||||||
customColor = color
|
customColor = color
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
colorPickerDialog.show(activity.fragmentManager, "color-picker-dialog")
|
colorPickerDialog.show(activity.supportFragmentManager, "color-picker-dialog")
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -16,12 +16,11 @@ import com.github.tibolte.agendacalendarview.CalendarPickerController
|
|||||||
import com.github.tibolte.agendacalendarview.models.BaseCalendarEvent
|
import com.github.tibolte.agendacalendarview.models.BaseCalendarEvent
|
||||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent
|
import com.github.tibolte.agendacalendarview.models.CalendarEvent
|
||||||
import com.github.tibolte.agendacalendarview.models.IDayItem
|
import com.github.tibolte.agendacalendarview.models.IDayItem
|
||||||
import com.mikepenz.iconics.IconicsColor
|
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.IconicsSize
|
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial.Icon2
|
import com.mikepenz.iconics.utils.colorInt
|
||||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
import com.mikepenz.iconics.utils.sizeDp
|
||||||
|
import eu.szkolny.font.SzkolnyFont
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.MainActivity
|
import pl.szczodrzynski.edziennik.MainActivity
|
||||||
@ -89,7 +88,7 @@ class AgendaFragment : Fragment(), CoroutineScope {
|
|||||||
}),
|
}),
|
||||||
BottomSheetPrimaryItem(true)
|
BottomSheetPrimaryItem(true)
|
||||||
.withTitle(R.string.menu_agenda_change_view)
|
.withTitle(R.string.menu_agenda_change_view)
|
||||||
.withIcon(if (type == Profile.AGENDA_DEFAULT) CommunityMaterial.Icon.cmd_calendar_outline else CommunityMaterial.Icon.cmd_format_list_bulleted_square)
|
.withIcon(if (type == Profile.AGENDA_DEFAULT) CommunityMaterial.Icon.cmd_calendar_outline else CommunityMaterial.Icon2.cmd_format_list_bulleted_square)
|
||||||
.withOnClickListener(View.OnClickListener {
|
.withOnClickListener(View.OnClickListener {
|
||||||
activity.bottomSheet.close()
|
activity.bottomSheet.close()
|
||||||
type = if (type == Profile.AGENDA_DEFAULT) Profile.AGENDA_CALENDAR else Profile.AGENDA_DEFAULT
|
type = if (type == Profile.AGENDA_DEFAULT) Profile.AGENDA_CALENDAR else Profile.AGENDA_DEFAULT
|
||||||
@ -111,7 +110,7 @@ class AgendaFragment : Fragment(), CoroutineScope {
|
|||||||
|
|
||||||
activity.navView.bottomBar.fabEnable = true
|
activity.navView.bottomBar.fabEnable = true
|
||||||
activity.navView.bottomBar.fabExtendedText = getString(R.string.add)
|
activity.navView.bottomBar.fabExtendedText = getString(R.string.add)
|
||||||
activity.navView.bottomBar.fabIcon = Icon2.cmd_plus
|
activity.navView.bottomBar.fabIcon = CommunityMaterial.Icon3.cmd_plus
|
||||||
activity.navView.setFabOnClickListener(View.OnClickListener {
|
activity.navView.setFabOnClickListener(View.OnClickListener {
|
||||||
EventManualDialog(activity, app.profileId, defaultDate = actualDate)
|
EventManualDialog(activity, app.profileId, defaultDate = actualDate)
|
||||||
})
|
})
|
||||||
@ -278,10 +277,11 @@ class AgendaFragment : Fragment(), CoroutineScope {
|
|||||||
val unreadEventDates = mutableSetOf<Int>()
|
val unreadEventDates = mutableSetOf<Int>()
|
||||||
|
|
||||||
events.forEach { event ->
|
events.forEach { event ->
|
||||||
val eventIcon = IconicsDrawable(activity)
|
val eventIcon = IconicsDrawable(activity).apply {
|
||||||
.icon(CommunityMaterial.Icon.cmd_checkbox_blank_circle)
|
icon = CommunityMaterial.Icon.cmd_checkbox_blank_circle
|
||||||
.size(IconicsSize.dp(10))
|
sizeDp = 10
|
||||||
.color(IconicsColor.colorInt(event.eventColor))
|
colorInt = event.eventColor
|
||||||
|
}
|
||||||
|
|
||||||
dayList.add(EventDay(event.startTimeCalendar, eventIcon))
|
dayList.add(EventDay(event.startTimeCalendar, eventIcon))
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class AttendanceFragment : Fragment(), CoroutineScope {
|
|||||||
activity.bottomSheet.prependItems(
|
activity.bottomSheet.prependItems(
|
||||||
BottomSheetPrimaryItem(true)
|
BottomSheetPrimaryItem(true)
|
||||||
.withTitle(R.string.menu_attendance_config)
|
.withTitle(R.string.menu_attendance_config)
|
||||||
.withIcon(CommunityMaterial.Icon2.cmd_settings_outline)
|
.withIcon(CommunityMaterial.Icon.cmd_cog_outline)
|
||||||
.withOnClickListener(View.OnClickListener {
|
.withOnClickListener(View.OnClickListener {
|
||||||
activity.bottomSheet.close()
|
activity.bottomSheet.close()
|
||||||
AttendanceConfigDialog(activity, true, null, null)
|
AttendanceConfigDialog(activity, true, null, null)
|
||||||
|
@ -13,9 +13,9 @@ import androidx.cardview.widget.CardView
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
|
||||||
import com.mikepenz.iconics.utils.colorRes
|
import com.mikepenz.iconics.utils.colorRes
|
||||||
import com.mikepenz.iconics.utils.sizeDp
|
import com.mikepenz.iconics.utils.sizeDp
|
||||||
|
import eu.szkolny.font.SzkolnyFont
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.R
|
import pl.szczodrzynski.edziennik.R
|
||||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_MOBIDZIENNIK
|
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_MOBIDZIENNIK
|
||||||
@ -49,17 +49,26 @@ class NoticesAdapter//getting the context and product list with constructor
|
|||||||
holder.noticesItemAddedDate.text = Date.fromMillis(notice.addedDate).formattedString
|
holder.noticesItemAddedDate.text = Date.fromMillis(notice.addedDate).formattedString
|
||||||
|
|
||||||
if (notice.type == Notice.TYPE_POSITIVE) {
|
if (notice.type == Notice.TYPE_POSITIVE) {
|
||||||
holder.noticesItemType.setImageDrawable(IconicsDrawable(context, CommunityMaterial.Icon2.cmd_plus_circle_outline)
|
holder.noticesItemType.setImageDrawable(
|
||||||
.colorRes(R.color.md_green_600)
|
IconicsDrawable(context, CommunityMaterial.Icon3.cmd_plus_circle_outline).apply {
|
||||||
.sizeDp(36))
|
colorRes = R.color.md_green_600
|
||||||
|
sizeDp = 36
|
||||||
|
}
|
||||||
|
)
|
||||||
} else if (notice.type == Notice.TYPE_NEGATIVE) {
|
} else if (notice.type == Notice.TYPE_NEGATIVE) {
|
||||||
holder.noticesItemType.setImageDrawable(IconicsDrawable(context, CommunityMaterial.Icon.cmd_alert_decagram_outline)
|
holder.noticesItemType.setImageDrawable(
|
||||||
.colorRes(R.color.md_red_600)
|
IconicsDrawable(context, CommunityMaterial.Icon.cmd_alert_decagram_outline).apply {
|
||||||
.sizeDp(36))
|
colorRes = R.color.md_red_600
|
||||||
|
sizeDp = 36
|
||||||
|
}
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
holder.noticesItemType.setImageDrawable(IconicsDrawable(context, SzkolnyFont.Icon.szf_message_processing_outline)
|
holder.noticesItemType.setImageDrawable(
|
||||||
.colorRes(R.color.md_blue_500)
|
IconicsDrawable(context, SzkolnyFont.Icon.szf_message_processing_outline).apply {
|
||||||
.sizeDp(36))
|
colorRes = R.color.md_blue_500
|
||||||
|
sizeDp = 36
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!notice.seen) {
|
if (!notice.seen) {
|
||||||
|
@ -14,8 +14,8 @@ import android.widget.PopupMenu
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import coil.Coil
|
import coil.imageLoader
|
||||||
import coil.api.load
|
import coil.request.ImageRequest
|
||||||
import com.github.bassaer.chatmessageview.model.IChatUser
|
import com.github.bassaer.chatmessageview.model.IChatUser
|
||||||
import com.github.bassaer.chatmessageview.model.Message
|
import com.github.bassaer.chatmessageview.model.Message
|
||||||
import com.github.bassaer.chatmessageview.view.ChatView
|
import com.github.bassaer.chatmessageview.view.ChatView
|
||||||
@ -34,14 +34,6 @@ import pl.szczodrzynski.edziennik.onClick
|
|||||||
import pl.szczodrzynski.edziennik.utils.Utils
|
import pl.szczodrzynski.edziennik.utils.Utils
|
||||||
import pl.szczodrzynski.edziennik.utils.Utils.openUrl
|
import pl.szczodrzynski.edziennik.utils.Utils.openUrl
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.List
|
|
||||||
import kotlin.collections.any
|
|
||||||
import kotlin.collections.filter
|
|
||||||
import kotlin.collections.firstOrNull
|
|
||||||
import kotlin.collections.forEach
|
|
||||||
import kotlin.collections.forEachIndexed
|
|
||||||
import kotlin.collections.isNotEmpty
|
|
||||||
import kotlin.collections.mutableMapOf
|
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
|
||||||
@ -221,13 +213,15 @@ class FeedbackFragment : Fragment(), CoroutineScope {
|
|||||||
Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888).also { bmp ->
|
Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888).also { bmp ->
|
||||||
launch {
|
launch {
|
||||||
Log.d(TAG, "Created image for $userName")
|
Log.d(TAG, "Created image for $userName")
|
||||||
Coil.load(activity, image) {
|
val request = ImageRequest.Builder(activity)
|
||||||
target {
|
.data(image)
|
||||||
|
.target {
|
||||||
val canvas = Canvas(bmp)
|
val canvas = Canvas(bmp)
|
||||||
it.setBounds(0, 0, bmp.width, bmp.height)
|
it.setBounds(0, 0, bmp.width, bmp.height)
|
||||||
it.draw(canvas)
|
it.draw(canvas)
|
||||||
}
|
}
|
||||||
}
|
.build()
|
||||||
|
activity.imageLoader.enqueue(request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import androidx.fragment.app.Fragment
|
|||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial.Icon2
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import pl.szczodrzynski.edziennik.*
|
import pl.szczodrzynski.edziennik.*
|
||||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.TARGET_GRADES_EDITOR
|
import pl.szczodrzynski.edziennik.MainActivity.Companion.TARGET_GRADES_EDITOR
|
||||||
@ -71,7 +70,7 @@ class GradesListFragment : Fragment(), CoroutineScope {
|
|||||||
val adapter = GradesAdapter(activity)
|
val adapter = GradesAdapter(activity)
|
||||||
var firstRun = true
|
var firstRun = true
|
||||||
|
|
||||||
app.db.gradeDao().getAllOrderBy(App.profileId, app.gradesManager.getOrderByString()).observe(this@GradesListFragment, Observer { grades -> this@GradesListFragment.launch {
|
app.db.gradeDao().getAllOrderBy(App.profileId, app.gradesManager.getOrderByString()).observe(viewLifecycleOwner, Observer { grades -> this@GradesListFragment.launch {
|
||||||
if (!isAdded) return@launch
|
if (!isAdded) return@launch
|
||||||
|
|
||||||
val items = when {
|
val items = when {
|
||||||
@ -135,7 +134,7 @@ class GradesListFragment : Fragment(), CoroutineScope {
|
|||||||
activity.bottomSheet.prependItems(
|
activity.bottomSheet.prependItems(
|
||||||
BottomSheetPrimaryItem(true)
|
BottomSheetPrimaryItem(true)
|
||||||
.withTitle(R.string.menu_grades_config)
|
.withTitle(R.string.menu_grades_config)
|
||||||
.withIcon(Icon2.cmd_settings_outline)
|
.withIcon(CommunityMaterial.Icon.cmd_cog_outline)
|
||||||
.withOnClickListener(View.OnClickListener {
|
.withOnClickListener(View.OnClickListener {
|
||||||
activity.bottomSheet.close()
|
activity.bottomSheet.close()
|
||||||
GradesConfigDialog(activity, true, null, null)
|
GradesConfigDialog(activity, true, null, null)
|
||||||
|
@ -7,9 +7,9 @@ package pl.szczodrzynski.edziennik.ui.modules.home
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
|
||||||
import com.mikepenz.iconics.utils.colorInt
|
import com.mikepenz.iconics.utils.colorInt
|
||||||
import com.mikepenz.iconics.utils.sizeDp
|
import com.mikepenz.iconics.utils.sizeDp
|
||||||
|
import eu.szkolny.font.SzkolnyFont
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import pl.szczodrzynski.edziennik.*
|
import pl.szczodrzynski.edziennik.*
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
||||||
@ -59,9 +59,12 @@ class CounterActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b.bellSync.setImageDrawable(IconicsDrawable(this@CounterActivity, SzkolnyFont.Icon.szf_alarm_bell_outline)
|
b.bellSync.setImageDrawable(
|
||||||
.colorInt(0xff404040.toInt())
|
IconicsDrawable(this@CounterActivity, SzkolnyFont.Icon.szf_alarm_bell_outline).apply {
|
||||||
.sizeDp(36))
|
colorInt = 0xff404040.toInt()
|
||||||
|
sizeDp = 36
|
||||||
|
}
|
||||||
|
)
|
||||||
b.bellSync.onClick {
|
b.bellSync.onClick {
|
||||||
BellSyncTimeChooseDialog(activity = this@CounterActivity)
|
BellSyncTimeChooseDialog(activity = this@CounterActivity)
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,13 @@ import androidx.recyclerview.widget.ItemTouchHelper
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate
|
import androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial.Icon
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial.Icon
|
||||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
import eu.szkolny.font.SzkolnyFont
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import pl.szczodrzynski.edziennik.*
|
import pl.szczodrzynski.edziennik.*
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||||
import pl.szczodrzynski.edziennik.databinding.FragmentHomeBinding
|
import pl.szczodrzynski.edziennik.databinding.FragmentHomeBinding
|
||||||
import pl.szczodrzynski.edziennik.ui.dialogs.home.StudentNumberDialog
|
import pl.szczodrzynski.edziennik.ui.dialogs.home.StudentNumberDialog
|
||||||
import pl.szczodrzynski.edziennik.ui.modules.home.cards.*
|
import pl.szczodrzynski.edziennik.ui.modules.home.cards.*
|
||||||
import pl.szczodrzynski.edziennik.utils.Themes
|
|
||||||
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem
|
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem
|
||||||
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem
|
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
@ -75,7 +74,7 @@ class HomeFragment : Fragment(), CoroutineScope {
|
|||||||
private lateinit var activity: MainActivity
|
private lateinit var activity: MainActivity
|
||||||
private lateinit var b: FragmentHomeBinding
|
private lateinit var b: FragmentHomeBinding
|
||||||
|
|
||||||
private lateinit var job: Job
|
private val job: Job = Job()
|
||||||
override val coroutineContext: CoroutineContext
|
override val coroutineContext: CoroutineContext
|
||||||
get() = job + Dispatchers.Main
|
get() = job + Dispatchers.Main
|
||||||
|
|
||||||
@ -83,10 +82,8 @@ class HomeFragment : Fragment(), CoroutineScope {
|
|||||||
activity = (getActivity() as MainActivity?) ?: return null
|
activity = (getActivity() as MainActivity?) ?: return null
|
||||||
context ?: return null
|
context ?: return null
|
||||||
app = activity.application as App
|
app = activity.application as App
|
||||||
context!!.theme.applyStyle(Themes.appTheme, true)
|
|
||||||
b = FragmentHomeBinding.inflate(inflater)
|
b = FragmentHomeBinding.inflate(inflater)
|
||||||
b.refreshLayout.setParent(activity.swipeRefreshLayout)
|
b.refreshLayout.setParent(activity.swipeRefreshLayout)
|
||||||
job = Job()
|
|
||||||
return b.root
|
return b.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import androidx.core.text.HtmlCompat
|
|||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.plusAssign
|
import androidx.core.view.plusAssign
|
||||||
import androidx.core.view.setMargins
|
import androidx.core.view.setMargins
|
||||||
import coil.api.load
|
import coil.load
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
|
@ -15,8 +15,8 @@ import androidx.core.view.setMargins
|
|||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
|
||||||
import com.mikepenz.iconics.utils.sizeDp
|
import com.mikepenz.iconics.utils.sizeDp
|
||||||
|
import eu.szkolny.font.SzkolnyFont
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
@ -87,17 +87,26 @@ class HomeTimetableCard(
|
|||||||
}
|
}
|
||||||
holder.root += b.root
|
holder.root += b.root
|
||||||
|
|
||||||
b.settings.setImageDrawable(IconicsDrawable(activity, CommunityMaterial.Icon2.cmd_settings_outline)
|
b.settings.setImageDrawable(
|
||||||
.colorAttr(activity, R.attr.colorIcon)
|
IconicsDrawable(activity, CommunityMaterial.Icon.cmd_cog_outline).apply {
|
||||||
.sizeDp(20))
|
colorAttr(activity, R.attr.colorIcon)
|
||||||
|
sizeDp = 20
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
b.bellSync.setImageDrawable(IconicsDrawable(activity, SzkolnyFont.Icon.szf_alarm_bell_outline)
|
b.bellSync.setImageDrawable(
|
||||||
.colorAttr(activity, R.attr.colorIcon)
|
IconicsDrawable(activity, SzkolnyFont.Icon.szf_alarm_bell_outline).apply {
|
||||||
.sizeDp(20))
|
colorAttr(activity, R.attr.colorIcon)
|
||||||
|
sizeDp = 20
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
b.showCounter.setImageDrawable(IconicsDrawable(activity, CommunityMaterial.Icon.cmd_fullscreen)
|
b.showCounter.setImageDrawable(
|
||||||
.colorAttr(activity, R.attr.colorIcon)
|
IconicsDrawable(activity, CommunityMaterial.Icon2.cmd_fullscreen).apply {
|
||||||
.sizeDp(20))
|
colorAttr(activity, R.attr.colorIcon)
|
||||||
|
sizeDp = 20
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
b.bellSync.setOnClickListener {
|
b.bellSync.setOnClickListener {
|
||||||
BellSyncTimeChooseDialog(
|
BellSyncTimeChooseDialog(
|
||||||
|
@ -12,7 +12,7 @@ import android.view.ViewGroup
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
import eu.szkolny.font.SzkolnyFont
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
@ -100,7 +100,7 @@ class HomeworkFragment : Fragment(), CoroutineScope {
|
|||||||
bottomBar.apply {
|
bottomBar.apply {
|
||||||
fabEnable = true
|
fabEnable = true
|
||||||
fabExtendedText = getString(R.string.add)
|
fabExtendedText = getString(R.string.add)
|
||||||
fabIcon = CommunityMaterial.Icon2.cmd_plus
|
fabIcon = CommunityMaterial.Icon3.cmd_plus
|
||||||
}
|
}
|
||||||
|
|
||||||
setFabOnClickListener(View.OnClickListener {
|
setFabOnClickListener(View.OnClickListener {
|
||||||
|
@ -97,11 +97,12 @@ class LoginFormFragment : Fragment(), CoroutineScope {
|
|||||||
b.textEdit.id = credential.name
|
b.textEdit.id = credential.name
|
||||||
|
|
||||||
b.textEdit.setText(arguments?.getString(credential.keyName) ?: "")
|
b.textEdit.setText(arguments?.getString(credential.keyName) ?: "")
|
||||||
b.textLayout.startIconDrawable = IconicsDrawable(activity)
|
b.textLayout.startIconDrawable = IconicsDrawable(activity).apply {
|
||||||
.icon(credential.icon)
|
icon = credential.icon
|
||||||
.sizeDp(24)
|
sizeDp = 24
|
||||||
.paddingDp(2)
|
paddingDp = 2
|
||||||
.colorAttr(activity, R.attr.colorOnBackground)
|
colorAttr(activity, R.attr.colorOnBackground)
|
||||||
|
}
|
||||||
|
|
||||||
this.b.formContainer.addView(b.root)
|
this.b.formContainer.addView(b.root)
|
||||||
credentials[credential] = b
|
credentials[credential] = b
|
||||||
|
@ -110,7 +110,7 @@ object LoginInfo {
|
|||||||
FormField(
|
FormField(
|
||||||
keyName = "accountPin",
|
keyName = "accountPin",
|
||||||
name = R.string.login_hint_pin,
|
name = R.string.login_hint_pin,
|
||||||
icon = CommunityMaterial.Icon2.cmd_lock,
|
icon = CommunityMaterial.Icon2.cmd_lock_outline,
|
||||||
emptyText = R.string.login_error_no_pin,
|
emptyText = R.string.login_error_no_pin,
|
||||||
invalidText = R.string.login_error_incorrect_pin,
|
invalidText = R.string.login_error_incorrect_pin,
|
||||||
errorCodes = mapOf(),
|
errorCodes = mapOf(),
|
||||||
@ -157,7 +157,7 @@ object LoginInfo {
|
|||||||
FormField(
|
FormField(
|
||||||
keyName = "symbol",
|
keyName = "symbol",
|
||||||
name = R.string.login_hint_symbol,
|
name = R.string.login_hint_symbol,
|
||||||
icon = CommunityMaterial.Icon2.cmd_school,
|
icon = CommunityMaterial.Icon3.cmd_school_outline,
|
||||||
emptyText = R.string.login_error_no_symbol,
|
emptyText = R.string.login_error_no_symbol,
|
||||||
invalidText = R.string.login_error_incorrect_symbol,
|
invalidText = R.string.login_error_incorrect_symbol,
|
||||||
errorCodes = mapOf(
|
errorCodes = mapOf(
|
||||||
@ -170,7 +170,7 @@ object LoginInfo {
|
|||||||
FormField(
|
FormField(
|
||||||
keyName = "devicePin",
|
keyName = "devicePin",
|
||||||
name = R.string.login_hint_pin,
|
name = R.string.login_hint_pin,
|
||||||
icon = CommunityMaterial.Icon2.cmd_lock,
|
icon = CommunityMaterial.Icon2.cmd_lock_outline,
|
||||||
emptyText = R.string.login_error_no_pin,
|
emptyText = R.string.login_error_no_pin,
|
||||||
invalidText = R.string.login_error_incorrect_pin,
|
invalidText = R.string.login_error_incorrect_pin,
|
||||||
errorCodes = mapOf(
|
errorCodes = mapOf(
|
||||||
@ -252,7 +252,7 @@ object LoginInfo {
|
|||||||
FormField(
|
FormField(
|
||||||
keyName = "serverName",
|
keyName = "serverName",
|
||||||
name = R.string.login_hint_address,
|
name = R.string.login_hint_address,
|
||||||
icon = CommunityMaterial.Icon2.cmd_web,
|
icon = CommunityMaterial.Icon3.cmd_web,
|
||||||
emptyText = R.string.login_error_no_address,
|
emptyText = R.string.login_error_no_address,
|
||||||
invalidText = R.string.login_error_incorrect_address,
|
invalidText = R.string.login_error_incorrect_address,
|
||||||
errorCodes = mapOf(
|
errorCodes = mapOf(
|
||||||
|
@ -10,7 +10,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import coil.api.load
|
import coil.load
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -9,7 +9,7 @@ import android.view.ViewGroup
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import coil.api.load
|
import coil.load
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.databinding.LoginPlatformItemBinding
|
import pl.szczodrzynski.edziennik.databinding.LoginPlatformItemBinding
|
||||||
import pl.szczodrzynski.edziennik.ui.modules.grades.viewholder.BindableViewHolder
|
import pl.szczodrzynski.edziennik.ui.modules.grades.viewholder.BindableViewHolder
|
||||||
|
@ -65,9 +65,10 @@ class MessageFragment : Fragment(), CoroutineScope {
|
|||||||
if (!isAdded) return
|
if (!isAdded) return
|
||||||
|
|
||||||
b.closeButton.setImageDrawable(
|
b.closeButton.setImageDrawable(
|
||||||
IconicsDrawable(activity, CommunityMaterial.Icon2.cmd_window_close)
|
IconicsDrawable(activity, CommunityMaterial.Icon3.cmd_window_close).apply {
|
||||||
.colorAttr(activity, android.R.attr.textColorSecondary)
|
colorAttr(activity, android.R.attr.textColorSecondary)
|
||||||
.sizeDp(12)
|
sizeDp = 12
|
||||||
|
}
|
||||||
)
|
)
|
||||||
b.closeButton.setOnClickListener { activity.navigateUp() }
|
b.closeButton.setOnClickListener { activity.navigateUp() }
|
||||||
|
|
||||||
@ -230,7 +231,7 @@ class MessageFragment : Fragment(), CoroutineScope {
|
|||||||
bottomBar.apply {
|
bottomBar.apply {
|
||||||
fabEnable = true
|
fabEnable = true
|
||||||
fabExtendedText = getString(R.string.messages_reply)
|
fabExtendedText = getString(R.string.messages_reply)
|
||||||
fabIcon = CommunityMaterial.Icon2.cmd_reply
|
fabIcon = CommunityMaterial.Icon3.cmd_reply_outline
|
||||||
}
|
}
|
||||||
|
|
||||||
setFabOnClickListener(View.OnClickListener {
|
setFabOnClickListener(View.OnClickListener {
|
||||||
|
@ -97,7 +97,7 @@ class MessagesFragment : Fragment(), CoroutineScope {
|
|||||||
bottomBar.apply {
|
bottomBar.apply {
|
||||||
fabEnable = true
|
fabEnable = true
|
||||||
fabExtendedText = getString(R.string.compose)
|
fabExtendedText = getString(R.string.compose)
|
||||||
fabIcon = CommunityMaterial.Icon2.cmd_pencil_outline
|
fabIcon = CommunityMaterial.Icon3.cmd_pencil_outline
|
||||||
}
|
}
|
||||||
|
|
||||||
setFabOnClickListener(View.OnClickListener {
|
setFabOnClickListener(View.OnClickListener {
|
||||||
|
@ -316,7 +316,7 @@ class MessagesComposeFragment : Fragment(), CoroutineScope {
|
|||||||
activity.navView.bottomBar.apply {
|
activity.navView.bottomBar.apply {
|
||||||
fabEnable = true
|
fabEnable = true
|
||||||
fabExtendedText = getString(R.string.messages_compose_send)
|
fabExtendedText = getString(R.string.messages_compose_send)
|
||||||
fabIcon = CommunityMaterial.Icon2.cmd_send
|
fabIcon = CommunityMaterial.Icon3.cmd_send_outline
|
||||||
|
|
||||||
setFabOnClickListener(View.OnClickListener {
|
setFabOnClickListener(View.OnClickListener {
|
||||||
sendMessage()
|
sendMessage()
|
||||||
|
@ -38,10 +38,11 @@ class SettingsLicenseActivity : MaterialAboutActivity() {
|
|||||||
license: OpenSourceLicense,
|
license: OpenSourceLicense,
|
||||||
libraryUrl: String): MaterialAboutCard {
|
libraryUrl: String): MaterialAboutCard {
|
||||||
val licenseItem = MaterialAboutActionItem.Builder()
|
val licenseItem = MaterialAboutActionItem.Builder()
|
||||||
.icon(IconicsDrawable(this)
|
.icon(IconicsDrawable(this).apply {
|
||||||
.icon(CommunityMaterial.Icon.cmd_book_outline)
|
icon = CommunityMaterial.Icon.cmd_book_outline
|
||||||
.colorInt(foregroundColor)
|
colorInt = foregroundColor
|
||||||
.sizeDp(18))
|
sizeDp = 18
|
||||||
|
})
|
||||||
.setIconGravity(MaterialAboutActionItem.GRAVITY_TOP)
|
.setIconGravity(MaterialAboutActionItem.GRAVITY_TOP)
|
||||||
.text(libraryTitle)
|
.text(libraryTitle)
|
||||||
.subText(String.format(getString(license.resourceId), copyrightYear, copyrightName))
|
.subText(String.format(getString(license.resourceId), copyrightYear, copyrightName))
|
||||||
@ -78,12 +79,6 @@ class SettingsLicenseActivity : MaterialAboutActivity() {
|
|||||||
"Applandeo sp. z o.o.",
|
"Applandeo sp. z o.o.",
|
||||||
OpenSourceLicense.APACHE_2,
|
OpenSourceLicense.APACHE_2,
|
||||||
"https://github.com/Applandeo/Material-Calendar-View/"),
|
"https://github.com/Applandeo/Material-Calendar-View/"),
|
||||||
createLicenseCard(this,
|
|
||||||
"Android-Job",
|
|
||||||
"2007-2017",
|
|
||||||
"Evernote Corporation",
|
|
||||||
OpenSourceLicense.APACHE_2,
|
|
||||||
"https://github.com/evernote/android-job/"),
|
|
||||||
createLicenseCard(this,
|
createLicenseCard(this,
|
||||||
"Custom Activity On Crash",
|
"Custom Activity On Crash",
|
||||||
"",
|
"",
|
||||||
@ -150,12 +145,6 @@ class SettingsLicenseActivity : MaterialAboutActivity() {
|
|||||||
"Arthur Teplitzki, 2013 Edmodo, Inc.",
|
"Arthur Teplitzki, 2013 Edmodo, Inc.",
|
||||||
OpenSourceLicense.APACHE_2,
|
OpenSourceLicense.APACHE_2,
|
||||||
"https://github.com/ArthurHub/Android-Image-Cropper/"),
|
"https://github.com/ArthurHub/Android-Image-Cropper/"),
|
||||||
createLicenseCard(this,
|
|
||||||
"Material Tap Target Prompt",
|
|
||||||
"2016-2018",
|
|
||||||
"Samuel Wall",
|
|
||||||
OpenSourceLicense.APACHE_2,
|
|
||||||
"https://github.com/sjwall/MaterialTapTargetPrompt/"),
|
|
||||||
createLicenseCard(this,
|
createLicenseCard(this,
|
||||||
"Android Swipe Layout",
|
"Android Swipe Layout",
|
||||||
"2014",
|
"2014",
|
||||||
|
@ -21,16 +21,15 @@ import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem;
|
|||||||
import com.danielstone.materialaboutlibrary.items.MaterialAboutActionSwitchItem;
|
import com.danielstone.materialaboutlibrary.items.MaterialAboutActionSwitchItem;
|
||||||
import com.danielstone.materialaboutlibrary.items.MaterialAboutItem;
|
import com.danielstone.materialaboutlibrary.items.MaterialAboutItem;
|
||||||
import com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction;
|
import com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction;
|
||||||
import com.danielstone.materialaboutlibrary.items.MaterialAboutProfileItem;
|
|
||||||
import com.danielstone.materialaboutlibrary.items.MaterialAboutSwitchItem;
|
import com.danielstone.materialaboutlibrary.items.MaterialAboutSwitchItem;
|
||||||
import com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem;
|
import com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem;
|
||||||
import com.danielstone.materialaboutlibrary.model.MaterialAboutCard;
|
import com.danielstone.materialaboutlibrary.model.MaterialAboutCard;
|
||||||
import com.danielstone.materialaboutlibrary.model.MaterialAboutList;
|
import com.danielstone.materialaboutlibrary.model.MaterialAboutList;
|
||||||
import com.mikepenz.iconics.IconicsColor;
|
|
||||||
import com.mikepenz.iconics.IconicsDrawable;
|
import com.mikepenz.iconics.IconicsDrawable;
|
||||||
import com.mikepenz.iconics.IconicsSize;
|
import com.mikepenz.iconics.typeface.IIcon;
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial;
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial;
|
||||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont;
|
import com.mikepenz.iconics.utils.IconicsConvertersKt;
|
||||||
|
import com.mikepenz.iconics.utils.IconicsDrawableExtensionsKt;
|
||||||
import com.theartofdev.edmodo.cropper.CropImage;
|
import com.theartofdev.edmodo.cropper.CropImage;
|
||||||
import com.theartofdev.edmodo.cropper.CropImageView;
|
import com.theartofdev.edmodo.cropper.CropImageView;
|
||||||
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
|
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
|
||||||
@ -41,6 +40,8 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.szkolny.font.SzkolnyFont;
|
||||||
|
import kotlin.Unit;
|
||||||
import pl.szczodrzynski.edziennik.App;
|
import pl.szczodrzynski.edziennik.App;
|
||||||
import pl.szczodrzynski.edziennik.BuildConfig;
|
import pl.szczodrzynski.edziennik.BuildConfig;
|
||||||
import pl.szczodrzynski.edziennik.ExtensionsKt;
|
import pl.szczodrzynski.edziennik.ExtensionsKt;
|
||||||
@ -91,6 +92,15 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
private int secondaryTextOnPrimaryBg = -1;
|
private int secondaryTextOnPrimaryBg = -1;
|
||||||
private int iconSizeDp = 20;
|
private int iconSizeDp = 20;
|
||||||
|
|
||||||
|
private IconicsDrawable icon(IIcon icon, int sizeDp, int color) {
|
||||||
|
return new IconicsDrawable(activity).apply((drawable) -> {
|
||||||
|
drawable.setIcon(icon);
|
||||||
|
IconicsConvertersKt.setSizeDp(drawable, sizeDp);
|
||||||
|
IconicsDrawableExtensionsKt.setColorInt(drawable, color);
|
||||||
|
return Unit.INSTANCE;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private MaterialAboutCard getCardWithItems(CharSequence title, ArrayList<MaterialAboutItem> items, boolean primaryColor) {
|
private MaterialAboutCard getCardWithItems(CharSequence title, ArrayList<MaterialAboutItem> items, boolean primaryColor) {
|
||||||
MaterialAboutCard card = new MaterialAboutCard.Builder().title(title).cardColor(0xff1976D2).build();
|
MaterialAboutCard card = new MaterialAboutCard.Builder().title(title).cardColor(0xff1976D2).build();
|
||||||
card.getItems().addAll(items);
|
card.getItems().addAll(items);
|
||||||
@ -121,10 +131,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
return new MaterialAboutActionItem(
|
return new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_more_text),
|
getString(R.string.settings_more_text),
|
||||||
null,
|
null,
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon.cmd_chevron_down, 14, iconColor),
|
||||||
.icon(CommunityMaterial.Icon.cmd_chevron_down)
|
|
||||||
.size(IconicsSize.dp(14))
|
|
||||||
.color(IconicsColor.colorInt(iconColor)),
|
|
||||||
onClickAction
|
onClickAction
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -156,12 +163,12 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
roundDrawable.setCircular(true);
|
roundDrawable.setCircular(true);
|
||||||
return roundDrawable;*/
|
return roundDrawable;*/
|
||||||
}
|
}
|
||||||
private MaterialAboutProfileItem profileCardTitleItem;
|
private MaterialAboutTitleItem profileCardTitleItem;
|
||||||
private ArrayList<MaterialAboutItem> getProfileCard(boolean expandedOnly) {
|
private ArrayList<MaterialAboutItem> getProfileCard(boolean expandedOnly) {
|
||||||
ArrayList<MaterialAboutItem> items = new ArrayList<>();
|
ArrayList<MaterialAboutItem> items = new ArrayList<>();
|
||||||
if (!expandedOnly) {
|
if (!expandedOnly) {
|
||||||
|
|
||||||
profileCardTitleItem = new MaterialAboutProfileItem(
|
profileCardTitleItem = new MaterialAboutTitleItem(
|
||||||
app.getProfile().getName(),
|
app.getProfile().getName(),
|
||||||
app.getProfile().getSubname(),
|
app.getProfile().getSubname(),
|
||||||
getProfileDrawable()
|
getProfileDrawable()
|
||||||
@ -210,10 +217,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutActionItem(
|
new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_profile_change_password_text),
|
getString(R.string.settings_profile_change_password_text),
|
||||||
getString(R.string.settings_profile_change_password_subtext),
|
getString(R.string.settings_profile_change_password_subtext),
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon2.cmd_key_variant, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon2.cmd_key_variant)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
|
|
||||||
@ -224,10 +228,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutActionItem(
|
new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_add_student_text),
|
getString(R.string.settings_add_student_text),
|
||||||
getString(R.string.settings_add_student_subtext),
|
getString(R.string.settings_add_student_subtext),
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon.cmd_account_plus_outline, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon.cmd_account_plus_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
startActivity(new Intent(activity, LoginActivity.class));
|
startActivity(new Intent(activity, LoginActivity.class));
|
||||||
@ -238,10 +239,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutActionItem(
|
new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_profile_notifications_text),
|
getString(R.string.settings_profile_notifications_text),
|
||||||
getString(R.string.settings_profile_notifications_subtext),
|
getString(R.string.settings_profile_notifications_subtext),
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon2.cmd_filter_outline, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon.cmd_filter_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
new NotificationFilterDialog(activity, null, null);
|
new NotificationFilterDialog(activity, null, null);
|
||||||
@ -252,10 +250,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutActionItem(
|
new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_profile_remove_text),
|
getString(R.string.settings_profile_remove_text),
|
||||||
getString(R.string.settings_profile_remove_subtext),
|
getString(R.string.settings_profile_remove_subtext),
|
||||||
new IconicsDrawable(activity)
|
icon(SzkolnyFont.Icon.szf_delete_empty_outline, iconSizeDp, iconColor)
|
||||||
.icon(SzkolnyFont.Icon.szf_delete_empty_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
new ProfileRemoveDialog(activity, app.getProfile().getId(), app.getProfile().getName(), false);
|
new ProfileRemoveDialog(activity, app.getProfile().getId(), app.getProfile().getName(), false);
|
||||||
@ -267,20 +262,17 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
items.add(
|
items.add(
|
||||||
new MaterialAboutSwitchItem(
|
new MaterialAboutSwitchItem.Builder()
|
||||||
getString(R.string.settings_profile_sync_text),
|
.text(R.string.settings_profile_sync_text)
|
||||||
getString(R.string.settings_profile_sync_subtext),
|
.subText(R.string.settings_profile_sync_subtext)
|
||||||
new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon.cmd_account_convert, iconSizeDp, iconColor))
|
||||||
.icon(CommunityMaterial.Icon.cmd_account_convert)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
|
||||||
.setChecked(app.getProfile().getSyncEnabled())
|
.setChecked(app.getProfile().getSyncEnabled())
|
||||||
.setOnChangeAction(((isChecked, tag) -> {
|
.setOnCheckedChanged(((item, isChecked) -> {
|
||||||
app.getProfile().setSyncEnabled(isChecked);
|
app.getProfile().setSyncEnabled(isChecked);
|
||||||
app.profileSave();
|
app.profileSave();
|
||||||
return true;
|
return true;
|
||||||
}))
|
}))
|
||||||
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -300,20 +292,17 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
Date today = Date.getToday();
|
Date today = Date.getToday();
|
||||||
if (today.month == 12 || today.month == 1) {
|
if (today.month == 12 || today.month == 1) {
|
||||||
items.add(
|
items.add(
|
||||||
new MaterialAboutSwitchItem(
|
new MaterialAboutSwitchItem.Builder()
|
||||||
getString(R.string.settings_theme_snowfall_text),
|
.text(R.string.settings_theme_snowfall_text)
|
||||||
getString(R.string.settings_theme_snowfall_subtext),
|
.subText(R.string.settings_theme_snowfall_subtext)
|
||||||
new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon3.cmd_snowflake, iconSizeDp, iconColor))
|
||||||
.icon(CommunityMaterial.Icon2.cmd_snowflake)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
|
||||||
.setChecked(app.getConfig().getUi().getSnowfall())
|
.setChecked(app.getConfig().getUi().getSnowfall())
|
||||||
.setOnChangeAction((isChecked, tag) -> {
|
.setOnCheckedChanged((item, isChecked) -> {
|
||||||
app.getConfig().getUi().setSnowfall(isChecked);
|
app.getConfig().getUi().setSnowfall(isChecked);
|
||||||
activity.recreate();
|
activity.recreate();
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,10 +310,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutActionItem(
|
new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_theme_theme_text),
|
getString(R.string.settings_theme_theme_text),
|
||||||
Themes.INSTANCE.getThemeName(activity),
|
Themes.INSTANCE.getThemeName(activity),
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon3.cmd_palette_outline, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon2.cmd_palette_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
new MaterialDialog.Builder(activity)
|
new MaterialDialog.Builder(activity)
|
||||||
@ -343,16 +329,12 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
);
|
);
|
||||||
|
|
||||||
items.add(
|
items.add(
|
||||||
new MaterialAboutSwitchItem(
|
new MaterialAboutSwitchItem.Builder()
|
||||||
getString(R.string.settings_theme_mini_drawer_text),
|
.text(R.string.settings_theme_mini_drawer_text)
|
||||||
getString(R.string.settings_theme_mini_drawer_subtext),
|
.subText(R.string.settings_theme_mini_drawer_subtext)
|
||||||
new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon.cmd_dots_vertical, iconSizeDp, iconColor))
|
||||||
.icon(CommunityMaterial.Icon.cmd_dots_vertical)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
|
||||||
.setChecked(app.getConfig().getUi().getMiniMenuVisible())
|
.setChecked(app.getConfig().getUi().getMiniMenuVisible())
|
||||||
.setOnChangeAction((isChecked, tag) -> {
|
.setOnCheckedChanged((item, isChecked) -> {
|
||||||
// 0,1 1
|
// 0,1 1
|
||||||
// 0,0 0
|
// 0,0 0
|
||||||
// 1,1 0
|
// 1,1 0
|
||||||
@ -361,6 +343,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
activity.getNavView().drawer.setMiniDrawerVisiblePortrait(isChecked);
|
activity.getNavView().drawer.setMiniDrawerVisiblePortrait(isChecked);
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
items.add(getMoreItem(() -> addCardItems(CARD_THEME, getThemeCard(true))));
|
items.add(getMoreItem(() -> addCardItems(CARD_THEME, getThemeCard(true))));
|
||||||
@ -371,10 +354,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutActionItem(
|
new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_theme_mini_drawer_buttons_text),
|
getString(R.string.settings_theme_mini_drawer_buttons_text),
|
||||||
null,
|
null,
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon2.cmd_format_list_checks, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon.cmd_format_list_checks)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
List<Integer> buttonIds = new ArrayList<>();
|
List<Integer> buttonIds = new ArrayList<>();
|
||||||
@ -435,10 +415,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutActionItem(
|
new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_theme_drawer_header_text),
|
getString(R.string.settings_theme_drawer_header_text),
|
||||||
null,
|
null,
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon2.cmd_image_outline, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon2.cmd_image_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
if (app.getConfig().getUi().getHeaderBackground() != null) {
|
if (app.getConfig().getUi().getHeaderBackground() != null) {
|
||||||
@ -469,10 +446,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutActionItem(
|
new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_theme_app_background_text),
|
getString(R.string.settings_theme_app_background_text),
|
||||||
getString(R.string.settings_theme_app_background_subtext),
|
getString(R.string.settings_theme_app_background_subtext),
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon2.cmd_image_filter_hdr, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon2.cmd_image_filter_hdr)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
if (app.getConfig().getUi().getAppBackground() != null) {
|
if (app.getConfig().getUi().getAppBackground() != null) {
|
||||||
@ -496,19 +470,15 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
);
|
);
|
||||||
|
|
||||||
items.add(
|
items.add(
|
||||||
new MaterialAboutSwitchItem(
|
new MaterialAboutSwitchItem.Builder( )
|
||||||
getString(R.string.settings_theme_open_drawer_on_back_pressed_text),
|
.text(R.string.settings_theme_open_drawer_on_back_pressed_text)
|
||||||
null,
|
.icon(icon(CommunityMaterial.Icon3.cmd_menu_open, iconSizeDp, iconColor))
|
||||||
new IconicsDrawable(activity)
|
|
||||||
.icon(CommunityMaterial.Icon2.cmd_menu_open)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
|
||||||
.setChecked(app.getConfig().getUi().getOpenDrawerOnBackPressed())
|
.setChecked(app.getConfig().getUi().getOpenDrawerOnBackPressed())
|
||||||
.setOnChangeAction((isChecked, tag) -> {
|
.setOnCheckedChanged((item, isChecked) -> {
|
||||||
app.getConfig().getUi().setOpenDrawerOnBackPressed(isChecked);
|
app.getConfig().getUi().setOpenDrawerOnBackPressed(isChecked);
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
@ -548,20 +518,17 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
private MaterialAboutItem getSyncCardWifiItem() {
|
private MaterialAboutItem getSyncCardWifiItem() {
|
||||||
return new MaterialAboutSwitchItem(
|
return new MaterialAboutSwitchItem.Builder()
|
||||||
getString(R.string.settings_sync_wifi_text),
|
.text(R.string.settings_sync_wifi_text)
|
||||||
getString(R.string.settings_sync_wifi_subtext),
|
.subText(R.string.settings_sync_wifi_subtext)
|
||||||
new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon3.cmd_wifi_strength_2, iconSizeDp, iconColor))
|
||||||
.icon(CommunityMaterial.Icon2.cmd_wifi_strength_2)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
|
||||||
.setChecked(app.getConfig().getSync().getOnlyWifi())
|
.setChecked(app.getConfig().getSync().getOnlyWifi())
|
||||||
.setOnChangeAction((isChecked, tag) -> {
|
.setOnCheckedChanged((item, isChecked) -> {
|
||||||
app.getConfig().getSync().setOnlyWifi(isChecked);
|
app.getConfig().getSync().setOnlyWifi(isChecked);
|
||||||
SyncWorker.Companion.rescheduleNext(app);
|
SyncWorker.Companion.rescheduleNext(app);
|
||||||
return true;
|
return true;
|
||||||
});
|
})
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
private MaterialAboutActionSwitchItem syncCardIntervalItem;
|
private MaterialAboutActionSwitchItem syncCardIntervalItem;
|
||||||
private MaterialAboutActionSwitchItem syncCardQuietHoursItem;
|
private MaterialAboutActionSwitchItem syncCardQuietHoursItem;
|
||||||
@ -569,14 +536,11 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
ArrayList<MaterialAboutItem> items = new ArrayList<>();
|
ArrayList<MaterialAboutItem> items = new ArrayList<>();
|
||||||
if (!expandedOnly) {
|
if (!expandedOnly) {
|
||||||
|
|
||||||
syncCardIntervalItem = new MaterialAboutActionSwitchItem(
|
syncCardIntervalItem = new MaterialAboutActionSwitchItem.Builder()
|
||||||
getString(R.string.settings_sync_sync_interval_text),
|
.text(R.string.settings_sync_sync_interval_text)
|
||||||
getString(R.string.settings_sync_sync_interval_subtext_disabled),
|
.subText(R.string.settings_sync_sync_interval_subtext_disabled)
|
||||||
new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon.cmd_download_outline, iconSizeDp, iconColor))
|
||||||
.icon(CommunityMaterial.Icon.cmd_download_outline)
|
.build();
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
);
|
|
||||||
syncCardIntervalItem.setSubTextChecked(getSyncCardIntervalSubText());
|
syncCardIntervalItem.setSubTextChecked(getSyncCardIntervalSubText());
|
||||||
syncCardIntervalItem.setChecked(app.getConfig().getSync().getEnabled());
|
syncCardIntervalItem.setChecked(app.getConfig().getSync().getEnabled());
|
||||||
syncCardIntervalItem.setOnClickAction(() -> {
|
syncCardIntervalItem.setOnClickAction(() -> {
|
||||||
@ -625,7 +589,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
syncCardIntervalItem.setOnChangeAction((isChecked, tag) -> {
|
syncCardIntervalItem.setOnCheckedChangedAction((item, isChecked) -> {
|
||||||
if (isChecked && !app.getConfig().getSync().getEnabled()) {
|
if (isChecked && !app.getConfig().getSync().getEnabled()) {
|
||||||
addCardItem(CARD_SYNC, 1, getSyncCardWifiItem());
|
addCardItem(CARD_SYNC, 1, getSyncCardWifiItem());
|
||||||
}
|
}
|
||||||
@ -646,10 +610,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutSwitchItem(
|
new MaterialAboutSwitchItem(
|
||||||
"Cisza na lekcjach",
|
"Cisza na lekcjach",
|
||||||
"Nie odtwarzaj dźwięku powiadomień podczas lekcji",
|
"Nie odtwarzaj dźwięku powiadomień podczas lekcji",
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon2.cmd_volume_off, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon2.cmd_volume_off)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setChecked(app.appConfig.quietDuringLessons)
|
.setChecked(app.appConfig.quietDuringLessons)
|
||||||
.setOnChangeAction((isChecked) -> {
|
.setOnChangeAction((isChecked) -> {
|
||||||
@ -660,14 +621,11 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
);*/
|
);*/
|
||||||
|
|
||||||
|
|
||||||
syncCardQuietHoursItem = new MaterialAboutActionSwitchItem(
|
syncCardQuietHoursItem = new MaterialAboutActionSwitchItem.Builder()
|
||||||
getString(R.string.settings_sync_quiet_hours_text),
|
.text(R.string.settings_sync_quiet_hours_text)
|
||||||
getString(R.string.settings_sync_quiet_hours_subtext_disabled),
|
.subText(R.string.settings_sync_quiet_hours_subtext_disabled)
|
||||||
new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon.cmd_bell_sleep_outline, iconSizeDp, iconColor))
|
||||||
.icon(CommunityMaterial.Icon.cmd_bell_sleep_outline)
|
.build();
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
);
|
|
||||||
syncCardQuietHoursItem.setChecked(app.getConfig().getSync().getQuietHoursEnabled());
|
syncCardQuietHoursItem.setChecked(app.getConfig().getSync().getQuietHoursEnabled());
|
||||||
syncCardQuietHoursItem.setSubTextChecked(getSyncCardQuietHoursSubText());
|
syncCardQuietHoursItem.setSubTextChecked(getSyncCardQuietHoursSubText());
|
||||||
syncCardQuietHoursItem.setOnClickAction(() -> {
|
syncCardQuietHoursItem.setOnClickAction(() -> {
|
||||||
@ -707,7 +665,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
syncCardQuietHoursItem.setOnChangeAction((isChecked, tag) -> {
|
syncCardQuietHoursItem.setOnCheckedChangedAction((item, isChecked) -> {
|
||||||
app.getConfig().getSync().setQuietHoursEnabled(isChecked);
|
app.getConfig().getSync().setQuietHoursEnabled(isChecked);
|
||||||
if (isChecked && app.getConfig().getSync().getQuietHoursStart() == null) {
|
if (isChecked && app.getConfig().getSync().getQuietHoursStart() == null) {
|
||||||
app.getConfig().getSync().setQuietHoursStart(new Time(22, 30, 0));
|
app.getConfig().getSync().setQuietHoursStart(new Time(22, 30, 0));
|
||||||
@ -723,10 +681,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutActionItem(
|
new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_sync_web_push_text),
|
getString(R.string.settings_sync_web_push_text),
|
||||||
getString(R.string.settings_sync_web_push_subtext),
|
getString(R.string.settings_sync_web_push_subtext),
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon2.cmd_laptop, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon2.cmd_laptop)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
activity.loadTarget(MainActivity.TARGET_WEB_PUSH, null);
|
activity.loadTarget(MainActivity.TARGET_WEB_PUSH, null);
|
||||||
@ -741,10 +696,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutActionItem(
|
new MaterialAboutActionItem(
|
||||||
"Dźwięk powiadomień",
|
"Dźwięk powiadomień",
|
||||||
"Szkolny.eu",
|
"Szkolny.eu",
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon2.cmd_volume_high, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon2.cmd_volume_high)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
|
|
||||||
@ -752,20 +704,16 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
);*/
|
);*/
|
||||||
|
|
||||||
items.add(
|
items.add(
|
||||||
new MaterialAboutSwitchItem(
|
new MaterialAboutSwitchItem.Builder()
|
||||||
getString(R.string.settings_sync_updates_text),
|
.text(R.string.settings_sync_updates_text)
|
||||||
null,
|
.icon(icon(CommunityMaterial.Icon.cmd_cellphone_arrow_down, iconSizeDp, iconColor))
|
||||||
new IconicsDrawable(activity)
|
|
||||||
.icon(CommunityMaterial.Icon.cmd_cellphone_arrow_down)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
|
||||||
.setChecked(app.getConfig().getSync().getNotifyAboutUpdates())
|
.setChecked(app.getConfig().getSync().getNotifyAboutUpdates())
|
||||||
.setOnChangeAction((isChecked, tag) -> {
|
.setOnCheckedChanged((item, isChecked) -> {
|
||||||
app.getConfig().getSync().setNotifyAboutUpdates(isChecked);
|
app.getConfig().getSync().setNotifyAboutUpdates(isChecked);
|
||||||
UpdateWorker.Companion.rescheduleNext(app);
|
UpdateWorker.Companion.rescheduleNext(app);
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
@ -773,10 +721,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
new MaterialAboutActionItem(
|
new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_sync_notifications_settings_text),
|
getString(R.string.settings_sync_notifications_settings_text),
|
||||||
getString(R.string.settings_sync_notifications_settings_subtext),
|
getString(R.string.settings_sync_notifications_settings_subtext),
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon.cmd_cog_outline, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon2.cmd_settings_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
String channel = app.getNotificationChannelsManager().getData().getKey();
|
String channel = app.getNotificationChannelsManager().getData().getKey();
|
||||||
@ -846,16 +791,12 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
private MaterialAboutItem getRegisterCardSharedEventsItem() {
|
private MaterialAboutItem getRegisterCardSharedEventsItem() {
|
||||||
return new MaterialAboutSwitchItem(
|
return new MaterialAboutSwitchItem.Builder()
|
||||||
getString(R.string.settings_register_shared_events_text),
|
.text(R.string.settings_register_shared_events_text)
|
||||||
getString(R.string.settings_register_shared_events_subtext),
|
.subText(R.string.settings_register_shared_events_subtext)
|
||||||
new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon3.cmd_share_outline, iconSizeDp, iconColor))
|
||||||
.icon(CommunityMaterial.Icon2.cmd_share_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
|
||||||
.setChecked(app.getProfile().getEnableSharedEvents())
|
.setChecked(app.getProfile().getEnableSharedEvents())
|
||||||
.setOnChangeAction((isChecked, tag) -> {
|
.setOnCheckedChanged((item, isChecked) -> {
|
||||||
app.getProfile().setEnableSharedEvents(isChecked);
|
app.getProfile().setEnableSharedEvents(isChecked);
|
||||||
app.profileSave();
|
app.profileSave();
|
||||||
if (isChecked) new MaterialDialog.Builder(activity)
|
if (isChecked) new MaterialDialog.Builder(activity)
|
||||||
@ -869,7 +810,8 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
.positiveText(R.string.ok)
|
.positiveText(R.string.ok)
|
||||||
.show();
|
.show();
|
||||||
return true;
|
return true;
|
||||||
});
|
})
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaterialAboutSwitchItem registerCardAllowRegistrationItem;
|
private MaterialAboutSwitchItem registerCardAllowRegistrationItem;
|
||||||
@ -880,31 +822,22 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
items.add(new MaterialAboutActionItem(
|
items.add(new MaterialAboutActionItem(
|
||||||
getString(R.string.menu_grades_config),
|
getString(R.string.menu_grades_config),
|
||||||
null,
|
null,
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon3.cmd_numeric_5_box_outline, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon2.cmd_numeric_5_box_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
).setOnClickAction(() -> new GradesConfigDialog(activity, false, null, null)));
|
).setOnClickAction(() -> new GradesConfigDialog(activity, false, null, null)));
|
||||||
|
|
||||||
items.add(new MaterialAboutActionItem(
|
items.add(new MaterialAboutActionItem(
|
||||||
getString(R.string.menu_attendance_config),
|
getString(R.string.menu_attendance_config),
|
||||||
null,
|
null,
|
||||||
new IconicsDrawable(activity)
|
icon(CommunityMaterial.Icon.cmd_calendar_remove_outline, iconSizeDp, iconColor)
|
||||||
.icon(CommunityMaterial.Icon.cmd_calendar_remove_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
).setOnClickAction(() -> new AttendanceConfigDialog(activity, false, null, null)));
|
).setOnClickAction(() -> new AttendanceConfigDialog(activity, false, null, null)));
|
||||||
|
|
||||||
registerCardAllowRegistrationItem = new MaterialAboutSwitchItem(
|
registerCardAllowRegistrationItem = new MaterialAboutSwitchItem.Builder()
|
||||||
getString(R.string.settings_register_allow_registration_text),
|
.text(R.string.settings_register_allow_registration_text)
|
||||||
getString(R.string.settings_register_allow_registration_subtext),
|
.subText(R.string.settings_register_allow_registration_subtext)
|
||||||
new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon.cmd_account_circle_outline, iconSizeDp, iconColor))
|
||||||
.icon(CommunityMaterial.Icon.cmd_account_circle_outline)
|
.build();
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
);
|
|
||||||
registerCardAllowRegistrationItem.setChecked(app.getProfile().getRegistration() == REGISTRATION_ENABLED);
|
registerCardAllowRegistrationItem.setChecked(app.getProfile().getRegistration() == REGISTRATION_ENABLED);
|
||||||
registerCardAllowRegistrationItem.setOnChangeAction((isChecked, tag) -> {
|
registerCardAllowRegistrationItem.setOnCheckedChangedAction((item, isChecked) -> {
|
||||||
if (isChecked) new MaterialDialog.Builder(activity)
|
if (isChecked) new MaterialDialog.Builder(activity)
|
||||||
.title(getString(R.string.settings_register_allow_registration_dialog_enabled_title))
|
.title(getString(R.string.settings_register_allow_registration_dialog_enabled_title))
|
||||||
.content(getString(R.string.settings_register_allow_registration_dialog_enabled_text))
|
.content(getString(R.string.settings_register_allow_registration_dialog_enabled_text))
|
||||||
@ -958,10 +891,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
registerCardBellSyncItem = new MaterialAboutActionItem(
|
registerCardBellSyncItem = new MaterialAboutActionItem(
|
||||||
getString(R.string.settings_register_bell_sync_text),
|
getString(R.string.settings_register_bell_sync_text),
|
||||||
getRegisterCardBellSyncSubText(),
|
getRegisterCardBellSyncSubText(),
|
||||||
new IconicsDrawable(activity)
|
icon(SzkolnyFont.Icon.szf_alarm_bell_outline, iconSizeDp, iconColor)
|
||||||
.icon(SzkolnyFont.Icon.szf_alarm_bell_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
);
|
);
|
||||||
registerCardBellSyncItem.setOnClickAction(() -> {
|
registerCardBellSyncItem.setOnClickAction(() -> {
|
||||||
new MaterialDialog.Builder(activity)
|
new MaterialDialog.Builder(activity)
|
||||||
@ -1025,55 +955,44 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
items.add(registerCardBellSyncItem);
|
items.add(registerCardBellSyncItem);
|
||||||
|
|
||||||
items.add(
|
items.add(
|
||||||
new MaterialAboutSwitchItem(
|
new MaterialAboutSwitchItem.Builder()
|
||||||
getString(R.string.settings_register_count_in_seconds_text),
|
.text(R.string.settings_register_count_in_seconds_text)
|
||||||
getString(R.string.settings_register_count_in_seconds_subtext),
|
.subText(R.string.settings_register_count_in_seconds_subtext)
|
||||||
new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon3.cmd_timer, iconSizeDp, iconColor))
|
||||||
.icon(CommunityMaterial.Icon2.cmd_timer)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
|
||||||
.setChecked(app.getConfig().getTimetable().getCountInSeconds())
|
.setChecked(app.getConfig().getTimetable().getCountInSeconds())
|
||||||
.setOnChangeAction((isChecked, tag) -> {
|
.setOnCheckedChanged((item, isChecked) -> {
|
||||||
app.getConfig().getTimetable().setCountInSeconds(isChecked);
|
app.getConfig().getTimetable().setCountInSeconds(isChecked);
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (app.getProfile().getLoginStoreType() == LoginStore.LOGIN_TYPE_LIBRUS) {
|
if (app.getProfile().getLoginStoreType() == LoginStore.LOGIN_TYPE_LIBRUS) {
|
||||||
items.add(
|
items.add(
|
||||||
new MaterialAboutSwitchItem(
|
new MaterialAboutSwitchItem.Builder()
|
||||||
getString(R.string.settings_register_show_teacher_absences_text),
|
.text(R.string.settings_register_show_teacher_absences_text)
|
||||||
null,
|
.icon(icon(CommunityMaterial.Icon.cmd_account_arrow_right_outline, iconSizeDp, iconColor))
|
||||||
new IconicsDrawable(activity)
|
|
||||||
.icon(CommunityMaterial.Icon.cmd_account_arrow_right_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
|
||||||
.setChecked(app.getProfile().getStudentData("showTeacherAbsences", true))
|
.setChecked(app.getProfile().getStudentData("showTeacherAbsences", true))
|
||||||
.setOnChangeAction((isChecked, tag) -> {
|
.setOnCheckedChanged((item, isChecked) -> {
|
||||||
app.getProfile().putStudentData("showTeacherAbsences", isChecked);
|
app.getProfile().putStudentData("showTeacherAbsences", isChecked);
|
||||||
app.profileSave();
|
app.profileSave();
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App.Companion.getDevMode()) {
|
if (App.Companion.getDevMode()) {
|
||||||
items.add(
|
items.add(
|
||||||
new MaterialAboutSwitchItem(
|
new MaterialAboutSwitchItem.Builder()
|
||||||
getString(R.string.settings_register_hide_sticks_from_old),
|
.text(R.string.settings_register_hide_sticks_from_old)
|
||||||
null,
|
.icon(icon(CommunityMaterial.Icon3.cmd_numeric_1_box_outline, iconSizeDp, iconColor))
|
||||||
new IconicsDrawable(activity)
|
|
||||||
.icon(CommunityMaterial.Icon2.cmd_numeric_1_box_outline)
|
|
||||||
.size(IconicsSize.dp(iconSizeDp))
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
)
|
|
||||||
.setChecked(app.getConfig().forProfile().getGrades().getHideSticksFromOld())
|
.setChecked(app.getConfig().forProfile().getGrades().getHideSticksFromOld())
|
||||||
.setOnChangeAction((isChecked, tag) -> {
|
.setOnCheckedChanged((item, isChecked) -> {
|
||||||
app.getConfig().forProfile().getGrades().setHideSticksFromOld(isChecked);
|
app.getConfig().forProfile().getGrades().setHideSticksFromOld(isChecked);
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1097,20 +1016,13 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
items.add(new MaterialAboutTitleItem.Builder()
|
items.add(new MaterialAboutTitleItem.Builder()
|
||||||
.text(R.string.app_name)
|
.text(R.string.app_name)
|
||||||
.desc(R.string.settings_about_title_subtext)
|
.desc(R.string.settings_about_title_subtext)
|
||||||
.textColor(primaryTextOnPrimaryBg)
|
|
||||||
.descColor(secondaryTextOnPrimaryBg)
|
|
||||||
.icon(R.mipmap.ic_splash)
|
.icon(R.mipmap.ic_splash)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
pref_about_version = new MaterialAboutActionItem.Builder()
|
pref_about_version = new MaterialAboutActionItem.Builder()
|
||||||
.text(R.string.settings_about_version_text)
|
.text(R.string.settings_about_version_text)
|
||||||
.textColor(primaryTextOnPrimaryBg)
|
|
||||||
.subTextColor(secondaryTextOnPrimaryBg)
|
|
||||||
.subText(BuildConfig.VERSION_NAME + ", " + BuildConfig.BUILD_TYPE)
|
.subText(BuildConfig.VERSION_NAME + ", " + BuildConfig.BUILD_TYPE)
|
||||||
.icon(new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon2.cmd_information_outline, iconSizeDp, primaryTextOnPrimaryBg))
|
||||||
.icon(CommunityMaterial.Icon2.cmd_information_outline)
|
|
||||||
.color(IconicsColor.colorInt(primaryTextOnPrimaryBg))
|
|
||||||
.size(IconicsSize.dp(iconSizeDp)))
|
|
||||||
.build();
|
.build();
|
||||||
final int[] clickCounter = {0};
|
final int[] clickCounter = {0};
|
||||||
pref_about_version.setOnClickAction(() -> {
|
pref_about_version.setOnClickAction(() -> {
|
||||||
@ -1129,36 +1041,21 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
|
|
||||||
items.add(new MaterialAboutActionItem.Builder()
|
items.add(new MaterialAboutActionItem.Builder()
|
||||||
.text(R.string.settings_about_privacy_policy_text)
|
.text(R.string.settings_about_privacy_policy_text)
|
||||||
.textColor(primaryTextOnPrimaryBg)
|
.icon(icon(CommunityMaterial.Icon3.cmd_shield_outline, iconSizeDp, primaryTextOnPrimaryBg))
|
||||||
.subTextColor(secondaryTextOnPrimaryBg)
|
|
||||||
.icon(new IconicsDrawable(activity)
|
|
||||||
.icon(CommunityMaterial.Icon2.cmd_shield_outline)
|
|
||||||
.color(IconicsColor.colorInt(primaryTextOnPrimaryBg))
|
|
||||||
.size(IconicsSize.dp(iconSizeDp)))
|
|
||||||
.setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(activity, Uri.parse("https://szkolny.eu/privacy-policy")))
|
.setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(activity, Uri.parse("https://szkolny.eu/privacy-policy")))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
items.add(new MaterialAboutActionItem.Builder()
|
items.add(new MaterialAboutActionItem.Builder()
|
||||||
.text(R.string.settings_about_discord_text)
|
.text(R.string.settings_about_discord_text)
|
||||||
.textColor(primaryTextOnPrimaryBg)
|
|
||||||
.subTextColor(secondaryTextOnPrimaryBg)
|
|
||||||
.subText(R.string.settings_about_discord_subtext)
|
.subText(R.string.settings_about_discord_subtext)
|
||||||
.icon(new IconicsDrawable(activity)
|
.icon(icon(SzkolnyFont.Icon.szf_discord_outline, iconSizeDp, primaryTextOnPrimaryBg))
|
||||||
.icon(SzkolnyFont.Icon.szf_discord_outline)
|
|
||||||
.color(IconicsColor.colorInt(primaryTextOnPrimaryBg))
|
|
||||||
.size(IconicsSize.dp(iconSizeDp)))
|
|
||||||
.setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(activity, Uri.parse("https://szkolny.eu/discord")))
|
.setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(activity, Uri.parse("https://szkolny.eu/discord")))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
items.add(new MaterialAboutActionItem.Builder()
|
items.add(new MaterialAboutActionItem.Builder()
|
||||||
.text(R.string.settings_about_language_text)
|
.text(R.string.settings_about_language_text)
|
||||||
.textColor(primaryTextOnPrimaryBg)
|
|
||||||
.subTextColor(secondaryTextOnPrimaryBg)
|
|
||||||
.subText(R.string.settings_about_language_subtext)
|
.subText(R.string.settings_about_language_subtext)
|
||||||
.icon(new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon3.cmd_translate, iconSizeDp, primaryTextOnPrimaryBg))
|
||||||
.icon(CommunityMaterial.Icon2.cmd_translate)
|
|
||||||
.color(IconicsColor.colorInt(primaryTextOnPrimaryBg))
|
|
||||||
.size(IconicsSize.dp(iconSizeDp)))
|
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
new MaterialDialog.Builder(activity)
|
new MaterialDialog.Builder(activity)
|
||||||
.title(getString(R.string.settings_about_language_dialog_title))
|
.title(getString(R.string.settings_about_language_dialog_title))
|
||||||
@ -1193,12 +1090,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
items.add(new MaterialAboutActionItem.Builder()
|
items.add(new MaterialAboutActionItem.Builder()
|
||||||
.text(R.string.settings_about_update_text)
|
.text(R.string.settings_about_update_text)
|
||||||
.subText(R.string.settings_about_update_subtext)
|
.subText(R.string.settings_about_update_subtext)
|
||||||
.textColor(primaryTextOnPrimaryBg)
|
.icon(icon(CommunityMaterial.Icon3.cmd_update, iconSizeDp, primaryTextOnPrimaryBg))
|
||||||
.subTextColor(secondaryTextOnPrimaryBg)
|
|
||||||
.icon(new IconicsDrawable(activity)
|
|
||||||
.icon(CommunityMaterial.Icon2.cmd_update)
|
|
||||||
.color(IconicsColor.colorInt(primaryTextOnPrimaryBg))
|
|
||||||
.size(IconicsSize.dp(iconSizeDp)))
|
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
//open browser or intent here
|
//open browser or intent here
|
||||||
NetworkUtils net = new NetworkUtils(app);
|
NetworkUtils net = new NetworkUtils(app);
|
||||||
@ -1218,23 +1110,13 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
|
|
||||||
items.add(new MaterialAboutActionItem.Builder()
|
items.add(new MaterialAboutActionItem.Builder()
|
||||||
.text(R.string.settings_about_changelog_text)
|
.text(R.string.settings_about_changelog_text)
|
||||||
.textColor(primaryTextOnPrimaryBg)
|
.icon(icon(CommunityMaterial.Icon3.cmd_radar, iconSizeDp, primaryTextOnPrimaryBg))
|
||||||
.subTextColor(secondaryTextOnPrimaryBg)
|
|
||||||
.icon(new IconicsDrawable(activity)
|
|
||||||
.icon(CommunityMaterial.Icon2.cmd_radar)
|
|
||||||
.color(IconicsColor.colorInt(primaryTextOnPrimaryBg))
|
|
||||||
.size(IconicsSize.dp(iconSizeDp)))
|
|
||||||
.setOnClickAction(() -> new ChangelogDialog(activity, null, null))
|
.setOnClickAction(() -> new ChangelogDialog(activity, null, null))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
items.add(new MaterialAboutActionItem.Builder()
|
items.add(new MaterialAboutActionItem.Builder()
|
||||||
.text(R.string.settings_about_licenses_text)
|
.text(R.string.settings_about_licenses_text)
|
||||||
.textColor(primaryTextOnPrimaryBg)
|
.icon(icon(CommunityMaterial.Icon.cmd_code_braces, iconSizeDp, primaryTextOnPrimaryBg))
|
||||||
.subTextColor(secondaryTextOnPrimaryBg)
|
|
||||||
.icon(new IconicsDrawable(activity)
|
|
||||||
.icon(CommunityMaterial.Icon.cmd_code_braces)
|
|
||||||
.color(IconicsColor.colorInt(primaryTextOnPrimaryBg))
|
|
||||||
.size(IconicsSize.dp(iconSizeDp)))
|
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
Intent intent = new Intent(activity, SettingsLicenseActivity.class);
|
Intent intent = new Intent(activity, SettingsLicenseActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
@ -1243,10 +1125,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
|
|
||||||
/*items.add(new MaterialAboutActionItem.Builder()
|
/*items.add(new MaterialAboutActionItem.Builder()
|
||||||
.text(R.string.settings_about_intro_text)
|
.text(R.string.settings_about_intro_text)
|
||||||
.icon(new IconicsDrawable(activity)
|
.icon(icon(CommunityMaterial.Icon2.cmd_projector_screen, iconSizeDp, iconColor))
|
||||||
.icon(CommunityMaterial.Icon2.cmd_projector_screen)
|
|
||||||
.color(IconicsColor.colorInt(iconColor))
|
|
||||||
.size(IconicsSize.dp(iconSizeDp)))
|
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
if (tryingToDevMode[0]) {
|
if (tryingToDevMode[0]) {
|
||||||
if (getParentFragment() instanceof SettingsGeneralFragment) {
|
if (getParentFragment() instanceof SettingsGeneralFragment) {
|
||||||
@ -1267,12 +1146,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
items.add(new MaterialAboutActionItem.Builder()
|
items.add(new MaterialAboutActionItem.Builder()
|
||||||
.text(R.string.settings_about_crash_text)
|
.text(R.string.settings_about_crash_text)
|
||||||
.subText(R.string.settings_about_crash_subtext)
|
.subText(R.string.settings_about_crash_subtext)
|
||||||
.textColor(primaryTextOnPrimaryBg)
|
.icon(icon(CommunityMaterial.Icon.cmd_bug_outline, iconSizeDp, primaryTextOnPrimaryBg))
|
||||||
.subTextColor(secondaryTextOnPrimaryBg)
|
|
||||||
.icon(new IconicsDrawable(activity)
|
|
||||||
.icon(CommunityMaterial.Icon.cmd_bug_outline)
|
|
||||||
.color(IconicsColor.colorInt(primaryTextOnPrimaryBg))
|
|
||||||
.size(IconicsSize.dp(iconSizeDp)))
|
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
throw new RuntimeException("MANUAL CRASH");
|
throw new RuntimeException("MANUAL CRASH");
|
||||||
})
|
})
|
||||||
@ -1304,11 +1178,6 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
return materialAboutList;
|
return materialAboutList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getTheme() {
|
|
||||||
return Themes.INSTANCE.getAppTheme();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* _____ _ ____ _ _
|
/* _____ _ ____ _ _
|
||||||
/ ____| | | | _ \ | | | |
|
/ ____| | | | _ \ | | | |
|
||||||
| | _ _ ___| |_ ___ _ __ ___ | |_) | __ _ ___| | ____ _ _ __ ___ _ _ _ __ __| |___
|
| | _ _ ___| |_ ___ _ __ ___ | |_) | __ _ ___| | ____ _ _ __ ___ _ _ _ __ __| |___
|
||||||
|
@ -17,9 +17,8 @@ import android.widget.Toast
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial.Icon2
|
|
||||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
|
||||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog
|
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog
|
||||||
|
import eu.szkolny.font.SzkolnyFont
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.MainActivity
|
import pl.szczodrzynski.edziennik.MainActivity
|
||||||
@ -192,7 +191,7 @@ class TimetableFragment : Fragment(), CoroutineScope {
|
|||||||
BottomSheetPrimaryItem(true)
|
BottomSheetPrimaryItem(true)
|
||||||
.withTitle(R.string.menu_generate_block_timetable)
|
.withTitle(R.string.menu_generate_block_timetable)
|
||||||
.withDescription(R.string.menu_generate_block_timetable_desc)
|
.withDescription(R.string.menu_generate_block_timetable_desc)
|
||||||
.withIcon(Icon2.cmd_table_large)
|
.withIcon(CommunityMaterial.Icon3.cmd_table_large)
|
||||||
.withOnClickListener(View.OnClickListener {
|
.withOnClickListener(View.OnClickListener {
|
||||||
activity.bottomSheet.close()
|
activity.bottomSheet.close()
|
||||||
GenerateBlockTimetableDialog(activity)
|
GenerateBlockTimetableDialog(activity)
|
||||||
|
@ -11,11 +11,10 @@ import androidx.core.view.isVisible
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.typeface.IIcon
|
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
|
||||||
import com.mikepenz.iconics.utils.paddingDp
|
import com.mikepenz.iconics.utils.paddingDp
|
||||||
import com.mikepenz.iconics.utils.sizeDp
|
import com.mikepenz.iconics.utils.sizeDp
|
||||||
|
import eu.szkolny.font.SzkolnyFont
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
@ -60,7 +59,7 @@ class AttachmentAdapter(
|
|||||||
|
|
||||||
val fileName = item.name.substringBefore(":http")
|
val fileName = item.name.substringBefore(":http")
|
||||||
// create an icon for the attachment
|
// create an icon for the attachment
|
||||||
val icon: IIcon = when (Utils.getExtensionFromFileName(fileName)) {
|
val attachmentIcon = when (Utils.getExtensionFromFileName(fileName)) {
|
||||||
"doc", "docx", "odt", "rtf" -> SzkolnyFont.Icon.szf_file_word_outline
|
"doc", "docx", "odt", "rtf" -> SzkolnyFont.Icon.szf_file_word_outline
|
||||||
"xls", "xlsx", "ods" -> SzkolnyFont.Icon.szf_file_excel_outline
|
"xls", "xlsx", "ods" -> SzkolnyFont.Icon.szf_file_excel_outline
|
||||||
"ppt", "pptx", "odp" -> SzkolnyFont.Icon.szf_file_powerpoint_outline
|
"ppt", "pptx", "odp" -> SzkolnyFont.Icon.szf_file_powerpoint_outline
|
||||||
@ -70,7 +69,7 @@ class AttachmentAdapter(
|
|||||||
"jpg", "jpeg", "png", "bmp", "gif" -> SzkolnyFont.Icon.szf_file_image_outline
|
"jpg", "jpeg", "png", "bmp", "gif" -> SzkolnyFont.Icon.szf_file_image_outline
|
||||||
"zip", "rar", "tar", "7z" -> SzkolnyFont.Icon.szf_zip_box_outline
|
"zip", "rar", "tar", "7z" -> SzkolnyFont.Icon.szf_zip_box_outline
|
||||||
"html", "cpp", "c", "h", "css", "java", "py" -> SzkolnyFont.Icon.szf_file_code_outline
|
"html", "cpp", "c", "h", "css", "java", "py" -> SzkolnyFont.Icon.szf_file_code_outline
|
||||||
else -> CommunityMaterial.Icon.cmd_file_document_outline
|
else -> CommunityMaterial.Icon2.cmd_file_document_outline
|
||||||
}
|
}
|
||||||
|
|
||||||
b.chip.text = if (item.isDownloading) {
|
b.chip.text = if (item.isDownloading) {
|
||||||
@ -82,15 +81,17 @@ class AttachmentAdapter(
|
|||||||
} ?: fileName
|
} ?: fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
b.chip.chipIcon = IconicsDrawable(context)
|
b.chip.chipIcon = IconicsDrawable(context).apply {
|
||||||
.icon(icon)
|
icon = attachmentIcon
|
||||||
.colorAttr(context, R.attr.colorOnSurface)
|
colorAttr(context, R.attr.colorOnSurface)
|
||||||
.sizeDp(24)
|
sizeDp = 24
|
||||||
.paddingDp(2)
|
paddingDp = 2
|
||||||
b.chip.closeIcon = IconicsDrawable(context)
|
}
|
||||||
.icon(CommunityMaterial.Icon.cmd_check)
|
b.chip.closeIcon = IconicsDrawable(context).apply {
|
||||||
.colorAttr(context, R.attr.colorOnSurface)
|
icon = CommunityMaterial.Icon.cmd_check
|
||||||
.sizeDp(18)
|
colorAttr(context, R.attr.colorOnSurface)
|
||||||
|
sizeDp = 18
|
||||||
|
}
|
||||||
|
|
||||||
b.chip.isCloseIconVisible = item.isDownloaded && !item.isDownloading
|
b.chip.isCloseIconVisible = item.isDownloaded && !item.isDownloading
|
||||||
// prevent progress bar flickering
|
// prevent progress bar flickering
|
||||||
|
@ -48,10 +48,10 @@ class WidgetNotificationsProvider : AppWidgetProvider() {
|
|||||||
|
|
||||||
views.setImageViewBitmap(
|
views.setImageViewBitmap(
|
||||||
R.id.widgetNotificationsSync,
|
R.id.widgetNotificationsSync,
|
||||||
IconicsDrawable(context, CommunityMaterial.Icon.cmd_download_outline)
|
IconicsDrawable(context, CommunityMaterial.Icon.cmd_download_outline).apply {
|
||||||
.colorInt(Color.WHITE)
|
colorInt = Color.WHITE
|
||||||
.sizeDp(iconSize)
|
sizeDp = iconSize
|
||||||
.toBitmap()
|
}.toBitmap()
|
||||||
)
|
)
|
||||||
|
|
||||||
views.setViewVisibility(R.id.widgetNotificationsLoading, View.GONE)
|
views.setViewVisibility(R.id.widgetNotificationsLoading, View.GONE)
|
||||||
|
@ -24,13 +24,14 @@ import android.widget.RemoteViewsService;
|
|||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
|
|
||||||
import com.mikepenz.iconics.IconicsColor;
|
|
||||||
import com.mikepenz.iconics.IconicsDrawable;
|
import com.mikepenz.iconics.IconicsDrawable;
|
||||||
import com.mikepenz.iconics.IconicsSize;
|
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial;
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial;
|
||||||
|
import com.mikepenz.iconics.utils.IconicsConvertersKt;
|
||||||
|
import com.mikepenz.iconics.utils.IconicsDrawableExtensionsKt;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import kotlin.Unit;
|
||||||
import pl.szczodrzynski.edziennik.R;
|
import pl.szczodrzynski.edziennik.R;
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Date;
|
import pl.szczodrzynski.edziennik.utils.models.Date;
|
||||||
import pl.szczodrzynski.edziennik.utils.models.ItemWidgetTimetableModel;
|
import pl.szczodrzynski.edziennik.utils.models.ItemWidgetTimetableModel;
|
||||||
@ -126,6 +127,15 @@ public class WidgetTimetableFactory implements RemoteViewsService.RemoteViewsFac
|
|||||||
return resultBitmap;
|
return resultBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Bitmap homeIconBitmap() {
|
||||||
|
return new IconicsDrawable(context).apply((drawable) -> {
|
||||||
|
IconicsConvertersKt.setColorRes(drawable, R.color.md_red_500);
|
||||||
|
IconicsConvertersKt.setSizeDp(drawable, 10);
|
||||||
|
IconicsDrawableExtensionsKt.icon(drawable, CommunityMaterial.Icon2.cmd_home);
|
||||||
|
return Unit.INSTANCE;
|
||||||
|
}).toBitmap();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RemoteViews getViewAt(int i) {
|
public RemoteViews getViewAt(int i) {
|
||||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.row_widget_timetable_item);
|
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.row_widget_timetable_item);
|
||||||
@ -270,19 +280,19 @@ public class WidgetTimetableFactory implements RemoteViewsService.RemoteViewsFac
|
|||||||
if (lesson.eventColors.size() >= 1) {
|
if (lesson.eventColors.size() >= 1) {
|
||||||
views.setViewVisibility(R.id.widgetTimetableEvent1, View.VISIBLE);
|
views.setViewVisibility(R.id.widgetTimetableEvent1, View.VISIBLE);
|
||||||
if (lesson.eventColors.get(0) == -1)
|
if (lesson.eventColors.get(0) == -1)
|
||||||
views.setBitmap(R.id.widgetTimetableEvent1, "setImageBitmap", new IconicsDrawable(context).color(IconicsColor.colorRes(R.color.md_red_500)).size(IconicsSize.dp(10)).icon(CommunityMaterial.Icon2.cmd_home).toBitmap());
|
views.setBitmap(R.id.widgetTimetableEvent1, "setImageBitmap", homeIconBitmap());
|
||||||
else
|
else
|
||||||
views.setBitmap(R.id.widgetTimetableEvent1, "setImageBitmap", getColoredBitmap(context, R.drawable.event_color_circle, lesson.eventColors.get(0), eventIndicatorSize, eventIndicatorSize));
|
views.setBitmap(R.id.widgetTimetableEvent1, "setImageBitmap", getColoredBitmap(context, R.drawable.event_color_circle, lesson.eventColors.get(0), eventIndicatorSize, eventIndicatorSize));
|
||||||
if (lesson.eventColors.size() >= 2) {
|
if (lesson.eventColors.size() >= 2) {
|
||||||
views.setViewVisibility(R.id.widgetTimetableEvent2, View.VISIBLE);
|
views.setViewVisibility(R.id.widgetTimetableEvent2, View.VISIBLE);
|
||||||
if (lesson.eventColors.get(1) == -1)
|
if (lesson.eventColors.get(1) == -1)
|
||||||
views.setBitmap(R.id.widgetTimetableEvent2, "setImageBitmap", new IconicsDrawable(context).color(IconicsColor.colorRes(R.color.md_red_500)).size(IconicsSize.dp(10)).icon(CommunityMaterial.Icon2.cmd_home).toBitmap());
|
views.setBitmap(R.id.widgetTimetableEvent2, "setImageBitmap", homeIconBitmap());
|
||||||
else
|
else
|
||||||
views.setBitmap(R.id.widgetTimetableEvent2, "setImageBitmap", getColoredBitmap(context, R.drawable.event_color_circle, lesson.eventColors.get(1), eventIndicatorSize, eventIndicatorSize));
|
views.setBitmap(R.id.widgetTimetableEvent2, "setImageBitmap", getColoredBitmap(context, R.drawable.event_color_circle, lesson.eventColors.get(1), eventIndicatorSize, eventIndicatorSize));
|
||||||
if (lesson.eventColors.size() >= 3) {
|
if (lesson.eventColors.size() >= 3) {
|
||||||
views.setViewVisibility(R.id.widgetTimetableEvent3, View.VISIBLE);
|
views.setViewVisibility(R.id.widgetTimetableEvent3, View.VISIBLE);
|
||||||
if (lesson.eventColors.get(2) == -1)
|
if (lesson.eventColors.get(2) == -1)
|
||||||
views.setBitmap(R.id.widgetTimetableEvent3, "setImageBitmap", new IconicsDrawable(context).color(IconicsColor.colorRes(R.color.md_red_500)).size(IconicsSize.dp(10)).icon(CommunityMaterial.Icon2.cmd_home).toBitmap());
|
views.setBitmap(R.id.widgetTimetableEvent3, "setImageBitmap", homeIconBitmap());
|
||||||
else
|
else
|
||||||
views.setBitmap(R.id.widgetTimetableEvent3, "setImageBitmap", getColoredBitmap(context, R.drawable.event_color_circle, lesson.eventColors.get(2), eventIndicatorSize, eventIndicatorSize));
|
views.setBitmap(R.id.widgetTimetableEvent3, "setImageBitmap", getColoredBitmap(context, R.drawable.event_color_circle, lesson.eventColors.get(2), eventIndicatorSize, eventIndicatorSize));
|
||||||
}
|
}
|
||||||
|
@ -115,13 +115,21 @@ class WidgetTimetableProvider : AppWidgetProvider() {
|
|||||||
|
|
||||||
views.setOnClickPendingIntent(R.id.widgetTimetableSync, getPendingSelfIntent(context, ACTION_SYNC_DATA))
|
views.setOnClickPendingIntent(R.id.widgetTimetableSync, getPendingSelfIntent(context, ACTION_SYNC_DATA))
|
||||||
|
|
||||||
views.setImageViewBitmap(R.id.widgetTimetableRefresh, IconicsDrawable(context, CommunityMaterial.Icon2.cmd_refresh)
|
views.setImageViewBitmap(
|
||||||
.colorInt(Color.WHITE)
|
R.id.widgetTimetableRefresh,
|
||||||
.sizeDp(if (config.bigStyle) 24 else 16).toBitmap())
|
IconicsDrawable(context, CommunityMaterial.Icon3.cmd_refresh).apply {
|
||||||
|
colorInt = Color.WHITE
|
||||||
|
sizeDp = if (config.bigStyle) 24 else 16
|
||||||
|
}.toBitmap()
|
||||||
|
)
|
||||||
|
|
||||||
views.setImageViewBitmap(R.id.widgetTimetableSync, IconicsDrawable(context, CommunityMaterial.Icon.cmd_download_outline)
|
views.setImageViewBitmap(
|
||||||
.colorInt(Color.WHITE)
|
R.id.widgetTimetableSync,
|
||||||
.sizeDp(if (config.bigStyle) 24 else 16).toBitmap())
|
IconicsDrawable(context, CommunityMaterial.Icon.cmd_download_outline).apply {
|
||||||
|
colorInt = Color.WHITE
|
||||||
|
sizeDp = if (config.bigStyle) 24 else 16
|
||||||
|
}.toBitmap()
|
||||||
|
)
|
||||||
|
|
||||||
prepareAppWidget(app, appWidgetId, views, config, bellSyncDiffMillis)
|
prepareAppWidget(app, appWidgetId, views, config, bellSyncDiffMillis)
|
||||||
|
|
||||||
|
@ -0,0 +1,208 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SwipeRefreshLayout should be used whenever the user can refresh the
|
||||||
|
* contents of a view via a vertical swipe gesture. The activity that
|
||||||
|
* instantiates this view should add an OnRefreshListener to be notified
|
||||||
|
* whenever the swipe to refresh gesture is completed. The SwipeRefreshLayout
|
||||||
|
* will notify the listener each and every time the gesture is completed again;
|
||||||
|
* the listener is responsible for correctly determining when to actually
|
||||||
|
* initiate a refresh of its content. If the listener determines there should
|
||||||
|
* not be a refresh, it must call setRefreshing(false) to cancel any visual
|
||||||
|
* indication of a refresh. If an activity wishes to show just the progress
|
||||||
|
* animation, it should call setRefreshing(true). To disable the gesture and
|
||||||
|
* progress animation, call setEnabled(false) on the view.
|
||||||
|
* <p>
|
||||||
|
* This layout should be made the parent of the view that will be refreshed as a
|
||||||
|
* result of the gesture and can only support one direct child. This view will
|
||||||
|
* also be made the target of the gesture and will be forced to match both the
|
||||||
|
* width and the height supplied in this layout. The SwipeRefreshLayout does not
|
||||||
|
* provide accessibility events; instead, a menu item must be provided to allow
|
||||||
|
* refresh of the content wherever this gesture is used.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class SwipeRefreshLayoutNoIndicator extends SwipeRefreshLayout {
|
||||||
|
|
||||||
|
private SwipeRefreshLayoutNoTouch parent;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
if (parent == null)
|
||||||
|
return;
|
||||||
|
parent.setEnabled(enabled);
|
||||||
|
super.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(SwipeRefreshLayoutNoTouch parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple constructor to use when creating a SwipeRefreshLayout from code.
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
*/
|
||||||
|
public SwipeRefreshLayoutNoIndicator(@NonNull Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor that is called when inflating SwipeRefreshLayout from XML.
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param attrs
|
||||||
|
*/
|
||||||
|
public SwipeRefreshLayoutNoIndicator(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
|
ev.setSource(0x10000000);
|
||||||
|
boolean parentConsumed = parent.onInterceptTouchEvent(ev);
|
||||||
|
boolean superConsumed = super.onInterceptTouchEvent(ev);
|
||||||
|
return parentConsumed && superConsumed;
|
||||||
|
/*if (super.onInterceptTouchEvent(ev))
|
||||||
|
return parent.onInterceptTouchEvent(ev);
|
||||||
|
return false;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void requestDisallowInterceptTouchEvent(boolean b) {
|
||||||
|
parent.requestDisallowInterceptTouchEvent(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// NestedScrollingParent
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) {
|
||||||
|
parent.onStartNestedScroll(child, target, nestedScrollAxes);
|
||||||
|
return !parent.isRefreshing() && super.onStartNestedScroll(child, target, nestedScrollAxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNestedScrollAccepted(View child, View target, int axes) {
|
||||||
|
parent.onNestedScrollAccepted(child, target, axes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) {
|
||||||
|
parent.onNestedPreScroll(target, dx, dy, consumed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNestedScrollAxes() {
|
||||||
|
return parent.getNestedScrollAxes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopNestedScroll(View target) {
|
||||||
|
parent.onStopNestedScroll(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNestedScroll(final View target, final int dxConsumed, final int dyConsumed,
|
||||||
|
final int dxUnconsumed, final int dyUnconsumed) {
|
||||||
|
parent.onNestedScroll(target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
|
||||||
|
}
|
||||||
|
|
||||||
|
// NestedScrollingChild
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setNestedScrollingEnabled(boolean enabled) {
|
||||||
|
if (parent == null)
|
||||||
|
return;
|
||||||
|
//parent.setNestedScrollingEnabled(enabled);
|
||||||
|
super.setNestedScrollingEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNestedScrollingEnabled() {
|
||||||
|
return parent.isNestedScrollingEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean startNestedScroll(int axes) {
|
||||||
|
return parent.startNestedScroll(axes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopNestedScroll() {
|
||||||
|
parent.stopNestedScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNestedScrollingParent() {
|
||||||
|
return parent.hasNestedScrollingParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed,
|
||||||
|
int dyUnconsumed, int[] offsetInWindow) {
|
||||||
|
return super.dispatchNestedScroll(dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, offsetInWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow) {
|
||||||
|
return super.dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onNestedPreFling(View target, float velocityX,
|
||||||
|
float velocityY) {
|
||||||
|
return parent.onNestedPreFling(target, velocityX, velocityY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onNestedFling(View target, float velocityX, float velocityY,
|
||||||
|
boolean consumed) {
|
||||||
|
return parent.onNestedFling(target, velocityX, velocityY, consumed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed) {
|
||||||
|
return parent.dispatchNestedFling(velocityX, velocityY, consumed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dispatchNestedPreFling(float velocityX, float velocityY) {
|
||||||
|
return parent.dispatchNestedPreFling(velocityX, velocityY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onTouchEvent(MotionEvent ev) {
|
||||||
|
ev.setSource(0x10000000);
|
||||||
|
/*boolean consumed = super.onTouchEvent(ev);
|
||||||
|
if (consumed) {
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
return parent.onTouchEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package pl.szczodrzynski.edziennik.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
|
|
||||||
|
public class SwipeRefreshLayoutNoTouch extends SwipeRefreshLayout {
|
||||||
|
public SwipeRefreshLayoutNoTouch(@NonNull Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SwipeRefreshLayoutNoTouch(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
|
if (ev.getSource() == 0x10000000) {
|
||||||
|
// forward the event to super
|
||||||
|
return super.onInterceptTouchEvent(ev);
|
||||||
|
}
|
||||||
|
// discard all the other events
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/*if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL)
|
||||||
|
return false;
|
||||||
|
super.onInterceptTouchEvent(ev);
|
||||||
|
return false;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onTouchEvent(MotionEvent ev) {
|
||||||
|
if (ev.getSource() == 0x10000000) {
|
||||||
|
// forward the event to super
|
||||||
|
return super.onTouchEvent(ev);
|
||||||
|
}
|
||||||
|
// discard all the other events
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -206,6 +206,7 @@
|
|||||||
app:flexWrap="wrap"
|
app:flexWrap="wrap"
|
||||||
app:justifyContent="flex_end">
|
app:justifyContent="flex_end">
|
||||||
|
|
||||||
|
<!-- cmd_eye_check_outline -->
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/checkDoneButton"
|
android:id="@+id/checkDoneButton"
|
||||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||||
@ -213,53 +214,57 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
android:fontFamily="@font/community_material_font_v3_5_95_1"
|
android:fontFamily="@font/community_material_font_v5_8_55"
|
||||||
android:minWidth="0dp"
|
android:minWidth="0dp"
|
||||||
android:text="\uFCE1"
|
android:text="\uf4df"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
<!-- cmd_pencil_outline -->
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/editButton"
|
android:id="@+id/editButton"
|
||||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:fontFamily="@font/community_material_font_v3_5_95_1"
|
android:fontFamily="@font/community_material_font_v5_8_55"
|
||||||
android:minWidth="0dp"
|
android:minWidth="0dp"
|
||||||
android:text="\uFC92"
|
android:text="\uf2f4"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
<!-- cmd_calendar_export -->
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/saveInCalendarButton"
|
android:id="@+id/saveInCalendarButton"
|
||||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:fontFamily="@font/community_material_font_v3_5_95_1"
|
android:fontFamily="@font/community_material_font_v5_8_55"
|
||||||
android:minWidth="0dp"
|
android:minWidth="0dp"
|
||||||
android:text="\uFB09"
|
android:text="\uf97a"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
<!-- cmd_cursor_default_click_outline -->
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/goToTimetableButton"
|
android:id="@+id/goToTimetableButton"
|
||||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:fontFamily="@font/community_material_font_v3_5_95_1"
|
android:fontFamily="@font/community_material_font_v5_8_55"
|
||||||
android:minWidth="0dp"
|
android:minWidth="0dp"
|
||||||
android:text="\uFCDA"
|
android:text="\ufc90"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
<!-- cmd_download_outline -->
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/downloadButton"
|
android:id="@+id/downloadButton"
|
||||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:fontFamily="@font/community_material_font_v3_5_95_1"
|
android:fontFamily="@font/community_material_font_v5_8_55"
|
||||||
android:minWidth="0dp"
|
android:minWidth="0dp"
|
||||||
android:text="\uFB6B"
|
android:text="\uf436"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
</com.google.android.flexbox.FlexboxLayout>
|
</com.google.android.flexbox.FlexboxLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user