diff --git a/CHANGELOG.md b/CHANGELOG.md
index d6a5ea5..40cd49a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,8 @@
# Change Log
+## Version 1.3 *(15.2.2021)*
+
+ * Adding number of days to display functionality
+ * Fix bug in selectDay
## Version 1.2 *(11.6.2016)*
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index ecec41b..79d3b45 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -8,5 +8,6 @@
In chronological order:
-* [Your name or handle] <[email or website]>
- * [Brief summary of your changes]
+* Tony Awino <[tonyawino](https://github.com\/tonyawino)>
+ * Adding number of days to display functionality
+ * Fix bug in selectDay
diff --git a/build.gradle b/build.gradle
index aff4f41..81a3c06 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,10 +2,11 @@
buildscript {
repositories {
+ google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.2'
+ classpath 'com.android.tools.build:gradle:4.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -14,6 +15,7 @@ buildscript {
allprojects {
repositories {
+ google()
jcenter()
}
}
diff --git a/example/build.gradle b/example/build.gradle
index c64e3e4..49f003e 100644
--- a/example/build.gradle
+++ b/example/build.gradle
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 'Google Inc.:Google APIs:23'
- buildToolsVersion "23.0.3"
+ compileSdkVersion 30
+ buildToolsVersion "30.0.3"
defaultConfig {
applicationId "solar.blaz.date.week.example"
minSdkVersion 15
- targetSdkVersion 23
+ targetSdkVersion 30
versionCode 1
versionName "1.0"
}
@@ -20,8 +20,9 @@ android {
}
dependencies {
- compile 'com.android.support:appcompat-v7:23.4.0'
- compile project(':week-date-picker')
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation 'org.threeten:threetenbp:1.3.1'
+ implementation project(':week-date-picker')
- testCompile 'junit:junit:4.12'
+ testImplementation 'junit:junit:4.12'
}
diff --git a/example/src/main/res/layout/activity_main.xml b/example/src/main/res/layout/activity_main.xml
index 15b3cfd..bf5fe00 100644
--- a/example/src/main/res/layout/activity_main.xml
+++ b/example/src/main/res/layout/activity_main.xml
@@ -17,6 +17,7 @@
app:wdp_labelPadding="5dp"
app:wdp_dayBackground="@drawable/date_picker_day_bg"
app:wdp_indicatorDrawable="@drawable/date_picker_indicator"
- app:wdp_firstDayOfWeek="monday"/>
+ app:wdp_firstDayOfWeek="monday"
+ app:wdp_numDaysToDisplay="7"/>
diff --git a/gradle.properties b/gradle.properties
index 89e0d99..915f0e6 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -16,3 +16,5 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
+android.enableJetifier=true
+android.useAndroidX=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index dc6eab7..649f762 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
\ No newline at end of file
diff --git a/library/build.gradle b/library/build.gradle
index 011b891..121ba77 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -4,7 +4,7 @@ buildscript {
}
dependencies {
- classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
+ classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
}
}
@@ -14,15 +14,15 @@ apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
group = 'solar.blaz'
-version = '1.2'
+version = '1.3'
android {
- compileSdkVersion 'Google Inc.:Google APIs:23'
- buildToolsVersion "23.0.3"
+ compileSdkVersion 30
+ buildToolsVersion "30.0.3"
defaultConfig {
minSdkVersion 15
- targetSdkVersion 23
+ targetSdkVersion 30
versionCode 3
versionName project.version
}
@@ -36,13 +36,13 @@ android {
}
dependencies {
- compile 'com.android.support:appcompat-v7:23.4.0'
- compile 'org.threeten:threetenbp:1.3.1'
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation 'org.threeten:threetenbp:1.3.1'
}
bintray {
- user = bintrayUser
- key = bintrayKey
+ //user = bintrayUser
+ //key = bintrayKey
publish = true
diff --git a/library/src/main/java/solar/blaz/date/week/WeekDatePicker.java b/library/src/main/java/solar/blaz/date/week/WeekDatePicker.java
index 898587e..6f108e3 100644
--- a/library/src/main/java/solar/blaz/date/week/WeekDatePicker.java
+++ b/library/src/main/java/solar/blaz/date/week/WeekDatePicker.java
@@ -14,10 +14,10 @@
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.text.TextDirectionHeuristicCompat;
-import android.support.v4.text.TextDirectionHeuristicsCompat;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.text.TextDirectionHeuristicCompat;
+import androidx.core.text.TextDirectionHeuristicsCompat;
import android.text.BoringLayout;
import android.text.Layout;
import android.text.TextPaint;
@@ -81,6 +81,7 @@ public class WeekDatePicker extends View {
private final DayOfWeek firstDayOfWeek;
private final BoringLayout[] layouts = new BoringLayout[3 * 7]; // we are drawing 3 weeks at a time on screen
private final BoringLayout[] dayLabelLayouts = new BoringLayout[7];
+ private final int numDaysToDisplay;
@Nullable private final CharSequence[] labelNames;
@@ -198,6 +199,13 @@ public WeekDatePicker(Context context, AttributeSet attrs, int defStyle) {
int dayOfWeek = a.getInt(R.styleable.WeekDatePicker_wdp_firstDayOfWeek, DayOfWeek.SUNDAY.getValue());
firstDayOfWeek = DayOfWeek.of(dayOfWeek);
+ int numDays = a.getInt(R.styleable.WeekDatePicker_wdp_numDaysToDisplay, 7);
+ if (numDays<=7 && numDays>0) {
+ numDaysToDisplay = numDays;
+ }
+ else {
+ numDaysToDisplay=7;
+ }
} finally {
a.recycle();
@@ -271,7 +279,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
measuredWidth = width;
}
- int totalHeight = (int) (labelTextHeight + measuredWidth / 7 / 3 * 2 + labelPadding);
+ int totalHeight = (int) (labelTextHeight + measuredWidth / numDaysToDisplay / 3 * 2 + labelPadding);
if (heightMode == MeasureSpec.AT_MOST) {
height = Math.min(heightSize, totalHeight);
@@ -316,7 +324,7 @@ private void drawWeek(Canvas canvas, int layoutIndex, int weekOffset) {
int centerY = layouts[0].getHeight() / 2;
float dateLineOffset = circleRadius - centerY;
- for (int i = 0; i < 7; i++) {
+ for (int i = 0; i < numDaysToDisplay; i++) {
int itemIndex = weekOffset * 7 + i;
BoringLayout layout = layouts[layoutIndex + i];
@@ -817,7 +825,7 @@ public void setDateIndicator(@NonNull LocalDate date, boolean enabled) {
}
private int getDayForDate(@NonNull LocalDate date) {
- return firstDay.until(date).getDays();
+ return (int) (date.toEpochDay() - firstDay.toEpochDay());
}
@Override
@@ -837,7 +845,7 @@ private int getDayPositionFromTouch(float x) {
int weekPositionFromTouch = getWeekPositionFromTouch(x);
int position = weekPositionFromTouch * 7 + getRelativeDayPositionFromTouch(x);
if (weekPositionFromTouch < 0) {
- position += 6;
+ position += (numDaysToDisplay-1);
}
return position;
}
@@ -945,7 +953,7 @@ private void calculateItemSize(int w, int h) {
int items = 1;
int totalPadding = ((int) dividerSize * (items - 1));
weekWidth = (w - totalPadding) / items;
- dayWidth = weekWidth / 7;
+ dayWidth = weekWidth / numDaysToDisplay;
scrollToItem(selectedWeek);
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
index b784517..7ad6a56 100644
--- a/library/src/main/res/values/attrs.xml
+++ b/library/src/main/res/values/attrs.xml
@@ -17,6 +17,7 @@
+