Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #1043

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Dev #1043

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Custom ViewPager that allows swiping to be disabled.
*/
class CalendarPager extends ViewPager {
public class CalendarPager extends ViewPager {

private boolean pagingEnabled = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Pager adapter backing the calendar view
*/
abstract class CalendarPagerAdapter<V extends CalendarPagerView> extends PagerAdapter {
public abstract class CalendarPagerAdapter<V extends CalendarPagerView> extends PagerAdapter {

private final ArrayDeque<V> currentViews;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@

import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.SHOW_DEFAULTS;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.showOtherMonths;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.DEFAULT_MAX_WEEKS;

abstract class CalendarPagerView extends ViewGroup
implements View.OnClickListener, View.OnLongClickListener {

protected static final int DEFAULT_DAYS_IN_WEEK = 7;
protected static final int DEFAULT_MAX_WEEKS = 6;
public static int DEFAULT_MAX_WEEKS = DEFAULT_MAX_WEEKS;
protected static final int DAY_NAMES_ROW = 1;

private final ArrayList<WeekDayView> weekDayViews = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Display one day of a {@linkplain MaterialCalendarView}
*/
@SuppressLint("ViewConstructor") class DayView extends AppCompatCheckedTextView {
@SuppressLint("ViewConstructor") public class DayView extends AppCompatCheckedTextView {

private CalendarDay date;
private int selectionColor = Color.GRAY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public class MaterialCalendarView extends ViewGroup {
*/
public static final int DEFAULT_TILE_SIZE_DP = 44;
private static final int DEFAULT_DAYS_IN_WEEK = 7;
private static final int DEFAULT_MAX_WEEKS = 6;
public static int DEFAULT_MAX_WEEKS = 6;
private static final int DAY_NAMES_ROW = 1;

private final TitleChanger titleChanger;
Expand Down Expand Up @@ -490,6 +490,14 @@ public void goToPrevious() {
pager.setCurrentItem(pager.getCurrentItem() - 1, true);
}
}

public void setDefaultMaxWeeks(int num) {
DEFAULT_MAX_WEEKS = num;
}

public int geDefaultMaxWeeks() {
return DEFAULT_MAX_WEEKS;
}

/**
* Go to next month or week without using the button {@link #buttonFuture}. Should only go to
Expand Down Expand Up @@ -637,7 +645,7 @@ public boolean onTouchEvent(MotionEvent event) {
public int getSelectionColor() {
return accentColor;
}

/**
* @param color The selection color
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Pager adapter backing the calendar view
*/
class MonthPagerAdapter extends CalendarPagerAdapter<MonthView> {
public class MonthPagerAdapter extends CalendarPagerAdapter<MonthView> {

MonthPagerAdapter(MaterialCalendarView mcv) {
super(mcv);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Display a month of {@linkplain DayView}s and
* seven {@linkplain WeekDayView}s.
*/
@SuppressLint("ViewConstructor") class MonthView extends CalendarPagerView {
@SuppressLint("ViewConstructor") public class MonthView extends CalendarPagerView {

public MonthView(
@NonNull final MaterialCalendarView view,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import android.widget.TextView;
import com.prolificinteractive.materialcalendarview.format.TitleFormatter;

class TitleChanger {
public class TitleChanger {

public static final int DEFAULT_ANIMATION_DELAY = 400;
public static final int DEFAULT_Y_TRANSLATION_DP = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public MonthArrayTitleFormatter(CharSequence[] monthLabels) {
@Override
public CharSequence format(CalendarDay day) {
return new SpannableStringBuilder()
.append(monthLabels[day.getMonth() - 1])
.append(" ")
.append(String.valueOf(day.getYear()));
.append(monthLabels[day.getMonth() - 1]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
public interface TitleFormatter {

String DEFAULT_FORMAT = "LLLL yyyy";
String DEFAULT_FORMAT = "LLLL";

TitleFormatter DEFAULT = new DateFormatTitleFormatter();

Expand Down
57 changes: 33 additions & 24 deletions library/src/main/res/layout/calendar_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,46 @@
android:orientation="horizontal"
>

<ImageButton
android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/mcv_arrow_margin"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/previous"
android:padding="@dimen/mcv_arrow_padding"
app:srcCompat="@drawable/mcv_action_previous"
/>

<TextView
android:id="@+id/month_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:gravity="start"
android:paddingHorizontal="@dimen/mcv_arrow_padding"
android:layout_marginHorizontal="@dimen/mcv_arrow_margin"
tools:text="August 2018"
style="?android:attr/textAppearanceMedium"
/>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageButton
android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/mcv_arrow_margin"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/previous"
android:padding="@dimen/mcv_arrow_padding"
app:srcCompat="@drawable/mcv_action_previous"
/>

<ImageButton
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/mcv_arrow_margin"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/next"
android:padding="@dimen/mcv_arrow_padding"
app:srcCompat="@drawable/mcv_action_next"
/>

</LinearLayout>

<ImageButton
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/mcv_arrow_margin"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/next"
android:padding="@dimen/mcv_arrow_padding"
app:srcCompat="@drawable/mcv_action_next"
/>

</LinearLayout>
</LinearLayout>