Skip to content

A lot of changes: Kotlin, time/date formatting fixes, demo activity for whole view snapping... #97

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

Open
wants to merge 48 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
472162d
-updated sdks
AndroidDeveloperLB May 7, 2018
2b59062
-converted project to Kotlin. Code can be shortened a lot, but requir…
AndroidDeveloperLB May 7, 2018
9865f5e
-added fix for day&month formatting, to be according to current locale:
AndroidDeveloperLB May 8, 2018
1406c08
Fixed possible null issues with providing null as list of events.
AndroidDeveloperLB May 8, 2018
1f9e199
Cleaned code a bit.
AndroidDeveloperLB May 8, 2018
c37823c
Handled some warnings...
AndroidDeveloperLB May 8, 2018
3438aad
further consideration of current locale to use the best format for th…
AndroidDeveloperLB May 9, 2018
9523d1b
handled auto-refreshing of the view every minute, to reflect changes …
AndroidDeveloperLB May 9, 2018
291461b
Some code cleaning
AndroidDeveloperLB May 9, 2018
8873a5d
Using proper conversion of dp units as the default values of the Week…
AndroidDeveloperLB May 9, 2018
b1a88c0
Replaced "compile" with "implementation
AndroidDeveloperLB May 9, 2018
e58f6f5
minor tweaks to sample of the WholeViewSnappingActivity.
AndroidDeveloperLB May 9, 2018
078b791
reduced Calendar instance creation a bit
AndroidDeveloperLB May 9, 2018
99c423a
Fix scroll snapping
May 9, 2018
0be2f1d
Merge pull request #1 from SkyleKayma/ScrollFix
AndroidDeveloperLB May 10, 2018
0228dad
-a lot of conversions (and fixes) from fields to properties.
AndroidDeveloperLB May 10, 2018
79d8e04
-a lot of conversions (and fixes) from fields to properties.
AndroidDeveloperLB May 10, 2018
1bc68ab
Merge branch 'develop' of https://github.com/AndroidDeveloperLB/Andro…
AndroidDeveloperLB May 10, 2018
f2a4226
sample bug fix (reported here: https://github.com/Quivr/Android-Week-…
AndroidDeveloperLB May 10, 2018
10a7614
Refactored some attributes to make it easier to understand what they …
AndroidDeveloperLB May 13, 2018
4241b17
fixed text alignment and spacing issues
AndroidDeveloperLB May 14, 2018
ae17dee
-removed dropping from WholeViewSnappingActivity. It makes scrolling …
AndroidDeveloperLB May 15, 2018
7cb7cd8
-added a way to put text on the left of the all-day events.
AndroidDeveloperLB May 15, 2018
edd87c1
fixed background color of samples.
AndroidDeveloperLB May 15, 2018
50585ff
fixed positioning of events and their lines.
AndroidDeveloperLB May 16, 2018
ef94b8d
- fixed issue of not being able to add an all-day event with same sta…
AndroidDeveloperLB May 17, 2018
8ebc646
Restored prefetching mechanism, fixing this issue:
AndroidDeveloperLB May 27, 2018
9d6f070
fixed possible OOM when setting a time of 0:00 to events, due to spli…
AndroidDeveloperLB May 28, 2018
0be8d77
fixed various issues with all-day events.
AndroidDeveloperLB May 29, 2018
d021bc1
moved implementation of textColorPicker to default one of WeekView.
AndroidDeveloperLB May 29, 2018
2c8ca57
made WeekViewEvent to be extendable, yet made most of its fields final
AndroidDeveloperLB May 29, 2018
eacd593
handled NPE in PrefetchingWeekViewLoader.
AndroidDeveloperLB May 29, 2018
610bd21
added feature to set a default title for events that don't have a tit…
AndroidDeveloperLB May 29, 2018
068fdfb
allowed using extended classes of WeekViewEvent in various functions
AndroidDeveloperLB May 30, 2018
3e11806
split the padding of the header into top+bottom
AndroidDeveloperLB May 31, 2018
09435f8
optimized code a bit.
AndroidDeveloperLB May 31, 2018
b73991c
More optimizations, by caching formatted dates and times.
AndroidDeveloperLB May 31, 2018
125c9dc
fixed weird issue in sample about January events
AndroidDeveloperLB May 31, 2018
46e5259
setting a default gap between overlapping events as 1dp, because when…
AndroidDeveloperLB Jun 10, 2018
7fd7e08
setting a default gap between overlapping events as 1dp, because when…
AndroidDeveloperLB Jun 10, 2018
da67353
Merge branch 'develop' of https://github.com/AndroidDeveloperLB/Andro…
AndroidDeveloperLB Jun 10, 2018
b0b098f
added side subtitle text, so you can show the year in case it's not t…
AndroidDeveloperLB Jun 10, 2018
a6ff5c8
targeting Android P
AndroidDeveloperLB Jun 10, 2018
6f829dd
trying to fix not being able to use the library.
AndroidDeveloperLB Jun 11, 2018
2f9b1b9
Updated SDKs.
AndroidDeveloperLB Sep 30, 2018
5688b50
updated gradle version
AndroidDeveloperLB Oct 23, 2018
91ab45f
updated sdks
AndroidDeveloperLB Feb 8, 2019
88c9020
Update README.md
AndroidDeveloperLB Feb 10, 2019
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
67 changes: 10 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,13 @@
[Join our slack](https://join.slack.com/t/androidweekview/shared_invite/enQtMzEyMDE3NzU3NTM3LWQyZGRhNjRlMTUzNzNlNjNlM2M0OTMyMDhjMzE1NDMzOGQzYzhjNzI2YjZhZWM3MzJiY2I1YmY2NGEwOTlkNTY)
A fork of this repository:
https://github.com/Quachero/Android-Week-View
Which is a fork of this:
https://github.com/Quivr/Android-Week-View
Which is a fork of this:
https://github.com/alamkanak/Android-Week-View

All because all of those aren't functional anymore...

Android Week View
=================
I've added so many things compared to them. You can read about them in a pull request I've made:
https://github.com/Quivr/Android-Week-View/pull/97
https://github.com/Quachero/Android-Week-View/pull/1

**Android Week View** is an android library to display calendars (week view or day view) within the app. It supports custom styling.

[Why this fork? (features + community & contributing)](https://github.com/Quivr/Android-Week-View/issues/45)

![](images/screen-shot.png)

Features
------------

* Week view calendar
* Day view calendar
* Custom styling
* Vertical scrolling and zooming
* Infinite horizontal scrolling
* Possibility to set min and max date
* Possibility to set range of visible hours
* All day events at the top
* Live preview of custom styling in xml preview window

Who uses it
---------------

* [Quivr](https://quivr.be/en/)
* [Series Addict](https://play.google.com/store/apps/details?id=com.alamkanak.seriesaddict)
* [Unicaen Timetable](https://play.google.com/store/apps/details?id=fr.skyost.timetable)
* Using the library? Just make an issue

Getting Started
---------------

See the [wiki](https://github.com/Quivr/Android-Week-View/wiki)

Sample
----------

There is also a [sample app](https://github.com/quivr/Android-Week-View/tree/master/sample) to get you started.


License
----------

Copyright 2014 Raquib-ul-Alam

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.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.21'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -18,6 +21,7 @@ allprojects {
group = GROUP

repositories {
google()
jcenter()
}
}
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=quivr
POM_DEVELOPER_NAME=Quivr
POM_DEVELOPER_NAME=Quivr
android.useAndroidX=true
android.enableJetifier=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Aug 06 18:02:35 CEST 2017
#Fri Feb 08 08:07:15 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
15 changes: 8 additions & 7 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

repositories {
mavenCentral()
}

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
compileSdkVersion 28

defaultConfig {
minSdkVersion 9
targetSdkVersion 25
minSdkVersion 14
targetSdkVersion 28
}
}

configurations {
javadocDeps
}
dependencies {
compile 'com.android.support:appcompat-v7:25.1.0'
javadocDeps 'com.android.support:appcompat-v7:25.1.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
javadocDeps 'androidx.appcompat:appcompat:1.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

apply from: 'gradle-mvn-push.gradle'
apply from: 'gradle-mvn-push.gradle'
4 changes: 2 additions & 2 deletions library/gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'maven'
apply plugin: 'signing'

def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
return !VERSION_NAME.contains("SNAPSHOT")
}

def getReleaseRepositoryUrl() {
Expand Down Expand Up @@ -112,4 +112,4 @@ afterEvaluate { project ->
archives androidSourcesJar
// archives androidJavadocsJar
}
}
}
3 changes: 2 additions & 1 deletion library/project.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
android.library=true
# suppress inspection "UnusedProperty" for whole file
android.library=true
2 changes: 1 addition & 1 deletion library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.alamkanak.weekview"></manifest>
<manifest package="com.alamkanak.weekview"/>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.alamkanak.weekview

import java.util.*

interface DateTimeInterpreter {
fun getFormattedWeekDayTitle(date: Calendar): String

fun getFormattedTimeOfDay(hour: Int, minutes: Int): String


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.alamkanak.weekview

import android.util.Log

class DrawPerformanceTester(val measureDrawTime: Boolean = true) {
var drawSamplesCount = 0L
var drawTotalTime = 0L

private var startTime: Long = 0L

fun startMeasure() {
if (!measureDrawTime)
return
startTime = System.currentTimeMillis()
}

fun endMeasure() {
if (!measureDrawTime)
return
val endTime = System.currentTimeMillis()
val totalTime = endTime - startTime
++drawSamplesCount
drawTotalTime += totalTime
val drawAverageTime = drawTotalTime.toFloat() / drawSamplesCount.toFloat()
Log.d("AppLog", "currentTime:$totalTime average:$drawAverageTime")
}
}
44 changes: 0 additions & 44 deletions library/src/main/java/com/alamkanak/weekview/MonthLoader.java

This file was deleted.

30 changes: 30 additions & 0 deletions library/src/main/java/com/alamkanak/weekview/MonthLoader.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.alamkanak.weekview

import java.util.*

class MonthLoader(var onMonthChangeListener: MonthChangeListener?) : WeekViewLoader {

override fun toWeekViewPeriodIndex(instance: Calendar): Double {
return (instance.get(Calendar.YEAR) * 12).toDouble() + instance.get(Calendar.MONTH).toDouble() + (instance.get(Calendar.DAY_OF_MONTH) - 1) / 30.0
}

override fun onLoad(periodIndex: Int): MutableList<out WeekViewEvent>? {
return onMonthChangeListener!!.onMonthChange(periodIndex / 12, periodIndex % 12 + 1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you be sure that "onMonthChangeListener" will not be null here ?
I think that nullable "?" is better. It returns nullable List btw.

Copy link

@SkyleKayma SkyleKayma May 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you be sure that "onMonthChangeListener" will not be null here ?
I think that nullable "?" is better. It returns nullable List btw.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are both correct and incorrect. For some reason the library has code to check it that when you use it, you must set a listener:

    if (weekViewLoader == null && !isInEditMode)
        throw IllegalStateException("You must provide a MonthChangeListener")

and then when you set it:

var monthChangeListener: MonthLoader.MonthChangeListener?
    get() = if (weekViewLoader is MonthLoader) (weekViewLoader as MonthLoader).onMonthChangeListener else null
    set(monthChangeListener) {
        this.weekViewLoader = MonthLoader(monthChangeListener)
    }

So you can't escape it from being non null.

But why this requirement exists at all?
How odd...
I think it's better to remove the requirement, and check for null...

For now I will let it stay how it is.

}

interface MonthChangeListener {
/**
*
* Very important interface, it's the base to load events in the calendar.
* This method is called three times: once to load the previous month, once to load the next month and once to load the current month.
* **That's why you can have three times the same event at the same place if you mess up with the configuration**
*
* @param newYear : year of the events required by the view.
* @param newMonth :
*
*month of the events required by the view **1 based (not like JAVA API) : January = 1 and December = 12**.
* @return a list of the events happening **during the specified month**.
*/
fun onMonthChange(newYear: Int, newMonth: Int): MutableList<out WeekViewEvent>?
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.alamkanak.weekview

import androidx.annotation.IntRange
import java.util.*

/**
* <h1>PrefetchingWeekViewLoader</h1>
* This class provides prefetching data loading behaviour.
* By setting a specific period of N, data is retrieved for the current period,
* the next N periods and the previous N periods.
*/
/**
* @param weekViewLoader An instance of the WeekViewLoader class
* @param prefetchingPeriod The amount of periods to be fetched before and after the
* current period. Must be 1 or greater.
*/
class PrefetchingWeekViewLoader(val weekViewLoader: WeekViewLoader, @IntRange(from = 1L) val prefetchingPeriod: Int = 1) : WeekViewLoader {

init {
if (prefetchingPeriod < 1)
throw IllegalArgumentException("Must specify prefetching period of at least 1!")
}

override fun onLoad(periodIndex: Int): MutableList<WeekViewEvent>? {
// fetch the current period
var loadedEvents = weekViewLoader.onLoad(periodIndex)
val events = ArrayList<WeekViewEvent>()
if (loadedEvents != null)
events.addAll(loadedEvents)
// fetch periods before/after
for (i in 1..this.prefetchingPeriod) {
loadedEvents = weekViewLoader.onLoad(periodIndex - i)
if (loadedEvents != null)
events.addAll(loadedEvents)
loadedEvents = weekViewLoader.onLoad(periodIndex + i)
if (loadedEvents != null)
events.addAll(loadedEvents)
}
// return list of all events together
return events
}

override fun toWeekViewPeriodIndex(instance: Calendar) = weekViewLoader.toWeekViewPeriodIndex(instance)

}
9 changes: 9 additions & 0 deletions library/src/main/java/com/alamkanak/weekview/SimpleDate.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.alamkanak.weekview

import java.util.*

data class SimpleDate(val year: Int, val month: Int, val dayOfMonth: Int) {
override fun toString(): String = "$year-$month-$dayOfMonth"

constructor(cal: Calendar) : this(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH))
}
10 changes: 0 additions & 10 deletions library/src/main/java/com/alamkanak/weekview/TextColorPicker.java

This file was deleted.

10 changes: 10 additions & 0 deletions library/src/main/java/com/alamkanak/weekview/TextColorPicker.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.alamkanak.weekview

import androidx.annotation.ColorInt

interface TextColorPicker {

@ColorInt
fun getTextColor(event: WeekViewEvent): Int

}
Loading