Add Custom Week Number Calculation Support#309
Open
PekingSpades wants to merge 4 commits intothellmund:mainfrom
Open
Add Custom Week Number Calculation Support#309PekingSpades wants to merge 4 commits intothellmund:mainfrom
PekingSpades wants to merge 4 commits intothellmund:mainfrom
Conversation
- Add beginWeekCalendar property to WeekView for custom week number calculation - Restore deprecated navigation methods (goToToday, goToCurrentTime, goToDate, goToHour) - Restore deprecated scrolling properties (xScrollingSpeed, isHorizontalFlingEnabled, etc.) - Remove drag-and-drop functionality from event handling - Simplify event click/long-click callbacks - Change rendering from hardware to software acceleration - Change onCreateEntity from abstract to open method with runtime exception BREAKING CHANGE: Removed drag-and-drop support for events BREAKING CHANGE: Removed stickToActualWeek property
- Add beginWeekCalendar parameter to HeaderRenderer constructor - Implement custom week number calculation based on beginWeekCalendar - Calculate week number from specified start date instead of default calendar week - Simplify date label drawing by removing single/multi-day view separation - Remove drawTimeColumnSeparatorExtension method (unused) - Add Java 8 time API dependencies for week calculation The week number calculation now supports custom start dates for academic or fiscal calendars.
- Add @publicapi annotation to beginWeekCalendar property - Add explicit getter for beginWeekCalendar - Remove unnecessary @RequiresApi(Build.VERSION_CODES.Q) annotations - Clean up Build version code references - Pass beginWeekCalendar to HeaderRenderer using 'this' reference This change allows external access to configure custom week start dates for week number calculation.
- Replace Java 8 time API (Instant, LocalDateTime, ChronoUnit) with Calendar API - Simplify week number calculation using milliseconds instead of ChronoUnit.DAYS - Remove @RequiresApi(Build.VERSION_CODES.O) annotations - Reorder constructor parameters (move beginWeekCalendar to end) - Format code for better readability - Fix import statements (use java.util.* instead of specific Calendar import) This change improves compatibility with older Android versions by removing Java 8 time API dependencies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Custom Week Number Calculation Support
Hi there 👋
Thanks for taking the time to review this pull request. I've implemented support for custom week number calculation to address the needs of applications using non-standard calendar systems (academic calendars, fiscal years, etc.).
Related Issue
This PR addresses the feature request in Issue #308 #294 - Support for Custom Week Number Calculation
Overview of Changes
Core Feature Implementation
I've added the ability to customize week number calculation through a new
beginWeekCalendarproperty inWeekView. This allows applications to specify a custom start date for week numbering, which is particularly useful for:Key Classes Modified
WeekView.kt
beginWeekCalendarproperty with@PublicApiannotationCalendarobject representing the custom start dateHeaderRendererfor week number calculationHeaderRenderer.kt
beginWeekCalendarparameterdrawWeekNumber()methodbeginWeekCalendaris setImplementation Details
The week number calculation works as follows:
beginWeekCalendaris null: Uses standard ISO week numbering (current behavior)beginWeekCalendaris set: Calculates the number of weeks between the custom start date and the current displayed dateAPI Compatibility Improvements
Initially implemented with Java 8 time API (Instant, LocalDateTime, ChronoUnit), but refactored to use the standard Calendar API to ensure compatibility with older Android versions (pre-API 26). This eliminates the need for
@RequiresApiannotations and makes the feature available to all users.Screenshots
Before (Standard Week Numbering)
Week numbers start from January 1st following ISO standard.
After (Custom Week Numbering)
When
beginWeekCalendaris set to September 1st, week numbers start from that date:Testing
beginWeekCalendaris nullAdditional Notes
beginWeekCalendarpropertyThank you for considering this contribution! I'm happy to make any adjustments based on your feedback.