Skip to content

Commit

Permalink
Change java time lib usages to threetenabp lib
Browse files Browse the repository at this point in the history
  • Loading branch information
shrikanth7698 committed Apr 5, 2022
1 parent ea9bc1b commit 51ef087
Show file tree
Hide file tree
Showing 26 changed files with 58 additions and 38 deletions.
6 changes: 6 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ object Kotest {
const val Assertions = "io.kotest:kotest-assertions-core-jvm:$Version"
}

object Jakewharton {
private const val Version = "1.4.0"

const val Threetenabp = "com.jakewharton.threetenabp:threetenabp:$Version"
}

object ComposeTest {
const val Core = "androidx.compose.ui:ui-test-junit4:${Compose.Version}"
const val Manifest = "androidx.compose.ui:ui-test-manifest:${Compose.Version}"
Expand Down
1 change: 1 addition & 0 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
implementation(Compose.Foundation)
implementation(Compose.FoundationLayout)
implementation(Compose.Material)
implementation(Jakewharton.Threetenabp)
implementation(Timber.Core)

testImplementation(Kotest.Assertions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.compose.ui.test.swipeLeft
import androidx.compose.ui.test.swipeRight
import org.junit.Rule
import org.junit.Test
import java.time.YearMonth
import org.threeten.bp.YearMonth

internal class ScrollBehaviorTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import io.github.boguszpawlowski.composecalendar.selection.SelectionMode
import io.github.boguszpawlowski.composecalendar.selection.SelectionState
import io.github.boguszpawlowski.composecalendar.week.DefaultWeekHeader
import io.github.boguszpawlowski.composecalendar.week.rotateRight
import java.time.DayOfWeek
import java.time.LocalDate
import java.time.YearMonth
import java.time.temporal.WeekFields
import org.threeten.bp.DayOfWeek
import org.threeten.bp.LocalDate
import org.threeten.bp.YearMonth
import org.threeten.bp.temporal.WeekFields
import java.util.Locale

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.boguszpawlowski.composecalendar.day

import java.time.LocalDate
import org.threeten.bp.LocalDate

/**
* Container for basic info about the displayed day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import io.github.boguszpawlowski.composecalendar.selection.SelectionState
import java.time.LocalDate
import org.threeten.bp.LocalDate

/**
* Default implementation for day content. It supports different appearance for days from
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.boguszpawlowski.composecalendar.day

import androidx.compose.runtime.Immutable
import java.time.LocalDate
import org.threeten.bp.LocalDate

@Immutable
internal class WeekDay(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import java.time.format.TextStyle.FULL
import org.threeten.bp.format.TextStyle.FULL
import java.util.Locale

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.setValue
import java.time.YearMonth
import org.threeten.bp.YearMonth

@Suppress("FunctionName") // Factory function
public fun MonthState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import io.github.boguszpawlowski.composecalendar.pager.toIndex
import io.github.boguszpawlowski.composecalendar.selection.SelectionState
import io.github.boguszpawlowski.composecalendar.week.WeekContent
import io.github.boguszpawlowski.composecalendar.week.getWeeks
import java.time.DayOfWeek
import java.time.LocalDate
import java.time.YearMonth
import org.threeten.bp.DayOfWeek
import org.threeten.bp.LocalDate
import org.threeten.bp.YearMonth

internal const val DaysOfWeek = 7

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.runningFold
import java.time.YearMonth
import org.threeten.bp.YearMonth

internal const val PageCount = 3

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.boguszpawlowski.composecalendar.selection

import io.github.boguszpawlowski.composecalendar.util.addOrRemoveIfExists
import java.time.LocalDate
import org.threeten.bp.LocalDate

/**
* Helper class for calculating new selection, when using a [DynamicSelectionState] approach.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.boguszpawlowski.composecalendar.selection

import java.time.LocalDate
import org.threeten.bp.LocalDate

internal fun Collection<LocalDate>.startOrMax() = firstOrNull() ?: LocalDate.MAX

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.listSaver
import androidx.compose.runtime.setValue
import java.time.LocalDate
import org.threeten.bp.LocalDate

@Stable
public interface SelectionState {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.boguszpawlowski.composecalendar.util

import java.time.DayOfWeek
import java.time.LocalDate
import org.threeten.bp.DayOfWeek
import org.threeten.bp.LocalDate

internal fun Collection<LocalDate>.addOrRemoveIfExists(date: LocalDate) =
if (contains(date)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.boguszpawlowski.composecalendar.util

import java.time.YearMonth
import org.threeten.bp.YearMonth

internal operator fun YearMonth.dec() = this.minusMonths(1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import java.time.DayOfWeek
import java.time.format.TextStyle.SHORT
import org.threeten.bp.DayOfWeek
import org.threeten.bp.format.TextStyle.SHORT
import java.util.Locale

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package io.github.boguszpawlowski.composecalendar.week

import io.github.boguszpawlowski.composecalendar.day.WeekDay
import io.github.boguszpawlowski.composecalendar.util.daysUntil
import java.time.DayOfWeek
import java.time.LocalDate
import java.time.YearMonth
import org.threeten.bp.DayOfWeek
import org.threeten.bp.LocalDate
import org.threeten.bp.YearMonth

private const val DaysInAWeek = 7

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import io.kotest.assertions.throwables.shouldNotThrowAny
import io.kotest.core.spec.style.ShouldSpec
import io.kotest.matchers.collections.shouldContainExactly
import io.kotest.matchers.shouldBe
import java.time.LocalDate
import java.time.Month.APRIL
import org.threeten.bp.LocalDate
import org.threeten.bp.Month.APRIL

internal class SelectionStateTest : ShouldSpec({

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import io.kotest.matchers.collections.shouldContainAll
import io.kotest.matchers.collections.shouldContainExactly
import io.kotest.matchers.collections.shouldHaveSize
import io.kotest.matchers.shouldBe
import java.time.DayOfWeek.MONDAY
import java.time.DayOfWeek.SATURDAY
import java.time.DayOfWeek.SUNDAY
import java.time.LocalDate
import java.time.YearMonth
import org.threeten.bp.DayOfWeek.MONDAY
import org.threeten.bp.DayOfWeek.SATURDAY
import org.threeten.bp.DayOfWeek.SUNDAY
import org.threeten.bp.LocalDate
import org.threeten.bp.YearMonth

internal class WeekUtilTest : ShouldSpec({

Expand Down
1 change: 1 addition & 0 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
implementation(Compose.Foundation)
implementation(Compose.FoundationLayout)
implementation(Compose.Material)
implementation(Jakewharton.Threetenabp)
implementation(Timber.Core)

debugImplementation(Debug.LeakCanary)
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package="io.github.boguszpawlowski.composecalendar">

<application
android:name=".sample.CalendarApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.boguszpawlowski.composecalendar.sample

import android.app.Application
import com.jakewharton.threetenabp.AndroidThreeTen

public class CalendarApplication: Application() {
override fun onCreate() {
super.onCreate()
AndroidThreeTen.init(this)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import androidx.compose.ui.unit.dp
import io.github.boguszpawlowski.composecalendar.StaticCalendar
import io.github.boguszpawlowski.composecalendar.day.NonSelectableDayState
import io.github.boguszpawlowski.composecalendar.header.MonthState
import java.time.DayOfWeek
import java.time.DayOfWeek.SUNDAY
import java.time.format.TextStyle.NARROW
import org.threeten.bp.DayOfWeek
import org.threeten.bp.DayOfWeek.SUNDAY
import org.threeten.bp.format.TextStyle.NARROW
import java.util.Locale

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import io.github.boguszpawlowski.composecalendar.Calendar
import io.github.boguszpawlowski.composecalendar.CalendarState
import io.github.boguszpawlowski.composecalendar.header.MonthState
import io.github.boguszpawlowski.composecalendar.selection.SelectionState
import java.time.LocalDate
import java.time.YearMonth
import org.threeten.bp.LocalDate
import org.threeten.bp.YearMonth

@Composable
fun CustomSelectionSample() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import io.github.boguszpawlowski.composecalendar.selection.SelectionMode
import io.github.boguszpawlowski.composecalendar.selection.SelectionMode.Period
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
import java.time.LocalDate
import org.threeten.bp.LocalDate

/**
* In this sample, calendar composable is wired with an ViewModel. It's purpose is to show how to use
Expand Down

0 comments on commit 51ef087

Please sign in to comment.