Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
RALP-4812 Remove threeten package and replace with java.time
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrorosas committed Apr 17, 2024
1 parent 7fdf997 commit 547bf91
Show file tree
Hide file tree
Showing 20 changed files with 22 additions and 50 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ npm install backpack-react-native --save
ext {
compileSdkVersion = 30
targetSdkVersion = 30
minSdkVersion = 24
minSdkVersion = 26
}
```

Expand Down
1 change: 0 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ dependencies {
implementation project(':backpack-react-native')
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "com.google.android.material:material:1.5.0"
implementation "com.jakewharton.threetenabp:threetenabp:${rootProject.ext.threetenabpVersion}"

androidTestImplementation 'junit:junit:4.13.2'
androidTestImplementation "androidx.test:runner:1.4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.facebook.react.ReactPackage
import com.facebook.react.config.ReactFeatureFlags
import com.facebook.react.shell.MainReactPackage
import com.facebook.soloader.SoLoader
import com.jakewharton.threetenabp.AndroidThreeTen
import net.skyscanner.backpack.reactnative.BackpackReactNative
import net.skyscanner.backpack.reactnative.button.BpkButtonPackage
import net.skyscanner.backpack.reactnative.calendar.CalendarPackage
Expand Down Expand Up @@ -50,7 +49,6 @@ class MainApplication : Application(), ReactApplication {

override fun onCreate() {
super.onCreate()
AndroidThreeTen.init(this)
BackpackReactNative.init(this)
SoLoader.init(this, /* native exopackage */ false)
}
Expand Down
3 changes: 1 addition & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ ext {
backpackVersion = "42.2.2"
compileSdkVersion = 33
targetSdkVersion = 33
minSdkVersion = 24
minSdkVersion = 26
androidx = '1.6.0'
appcompat = '1.3.1'
playServicesVersion = "17.0.0"
androidMapsUtilsVersion = "xxx"
threetenabpVersion = "1.4.0"
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
Expand Down
3 changes: 1 addition & 2 deletions lib/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _reactNativeVersion = safeExtGet("reactNative", "+")
def _backpackAndroidVersion = safeExtGet("backpackVersion", "42.2.2")
def _compileSdkVersion = safeExtGet("compileSdkVersion", 33)
def _targetSdkVersion = safeExtGet("targetSdkVersion", 33)
def _minSdkVersion = safeExtGet("minSdkVersion", 24)
def _minSdkVersion = safeExtGet("minSdkVersion", 26)
def _internalBuild = safeExtGet("internalBuild", false)

apply plugin: "com.android.library"
Expand Down Expand Up @@ -62,5 +62,4 @@ dependencies {
compileOnly "com.facebook.react:react-native:${_reactNativeVersion}"
implementation "net.skyscanner.backpack:backpack-android:${_backpackAndroidVersion}"
implementation "androidx.constraintlayout:constraintlayout:2.1.3"
implementation "com.jakewharton.threetenabp:threetenabp:${rootProject.ext.threetenabpVersion}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,16 @@ package net.skyscanner.backpack.reactnative.calendar

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.jakewharton.threetenabp.AndroidThreeTen
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.threeten.bp.LocalDate
import java.time.LocalDate
import java.util.Locale

@RunWith(AndroidJUnit4::class)
class CalendarControllerTest {

@Before
fun setup() {
AndroidThreeTen.init(InstrumentationRegistry.getInstrumentation().targetContext)
}

@Test
fun test_is_date_disabled() {
val controller = CalendarController(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.uimanager.ReactStylesDiffMap
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.soloader.SoLoader
import com.jakewharton.threetenabp.AndroidThreeTen
import io.mockk.mockk
import io.mockk.verify
import net.skyscanner.backpack.calendar.presenter.HighlightedDaysAdapter
Expand All @@ -44,7 +43,7 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.threeten.bp.LocalDate
import java.time.LocalDate

@RunWith(AndroidJUnit4::class)
class CalendarViewManagerTest {
Expand All @@ -70,7 +69,6 @@ class CalendarViewManagerTest {
fun setup() {
SoLoader.init(contextRule.context, 0)

AndroidThreeTen.init(InstrumentationRegistry.getInstrumentation().targetContext)
date1 = LocalDate.of(2020, 3, 16)
date2 = LocalDate.of(2020, 3, 20)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,16 @@ package net.skyscanner.backpack.reactnative.calendar
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.facebook.react.bridge.JSApplicationIllegalArgumentException
import com.jakewharton.threetenabp.AndroidThreeTen
import net.skyscanner.backpack.reactnative.testing.Matchers.throws
import org.hamcrest.Matchers.*
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.threeten.bp.LocalDate
import java.time.LocalDate

@RunWith(AndroidJUnit4::class)
class DateMatcherTest {

@Before
fun setup() {
AndroidThreeTen.init(InstrumentationRegistry.getInstrumentation().targetContext)
}

@Test
fun test_create_range_matcher_from_js() {
val startDate = LocalDate.of(2020, 3, 16)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package net.skyscanner.backpack.reactnative.calendar

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.jakewharton.threetenabp.AndroidThreeTen
import net.skyscanner.backpack.calendar.BpkCalendar
import net.skyscanner.backpack.calendar.model.CalendarCellStyle
import net.skyscanner.backpack.calendar.model.ColoredBucket
Expand All @@ -30,11 +29,10 @@ import net.skyscanner.backpack.reactnative.testing.ReactContextTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.threeten.bp.LocalDate
import java.time.LocalDate
import java.util.*

@RunWith(AndroidJUnit4::class)
Expand All @@ -43,11 +41,6 @@ class RNCalendarViewTest {
@get:Rule
val contextRule = ReactContextTestRule()

@Before
fun setup() {
AndroidThreeTen.init(InstrumentationRegistry.getInstrumentation().targetContext)
}

@Test
fun test_render() {
val calendar = RNCalendarView(contextRule.context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import net.skyscanner.backpack.calendar.model.ColoredBucket
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.threeten.bp.LocalDate
import java.time.LocalDate

@RunWith(AndroidJUnit4::class)
class RNColorBucketTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.threeten.bp.LocalDate
import java.time.LocalDate
import java.util.Locale

@RunWith(AndroidJUnit4::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.threeten.bp.LocalDate
import java.time.LocalDate

@RunWith(AndroidJUnit4::class)
class TypeConversionsTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.threeten.bp.LocalDate
import java.time.LocalDate

@RunWith(AndroidJUnit4::class)
class CalendarChangeEventTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import net.skyscanner.backpack.calendar.model.CalendarSelection
import net.skyscanner.backpack.calendar.presenter.BpkCalendarController
import net.skyscanner.backpack.calendar.presenter.MonthFooterAdapter
import net.skyscanner.backpack.calendar.presenter.SelectionType
import org.threeten.bp.LocalDate
import java.time.LocalDate
import java.util.*

typealias ChangeCallback = (CalendarSelection) -> Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import net.skyscanner.backpack.calendar.model.SingleDay
import net.skyscanner.backpack.calendar.presenter.SelectionType
import net.skyscanner.backpack.reactnative.calendar.events.CalendarChangeEvent
import net.skyscanner.backpack.reactnative.extensions.getOptional
import org.threeten.bp.LocalDate
import org.threeten.bp.ZoneId
import java.time.LocalDate
import java.time.ZoneId

class CalendarViewManager : ViewGroupManager<RNCalendarView>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package net.skyscanner.backpack.reactnative.calendar

import com.facebook.react.bridge.JSApplicationIllegalArgumentException
import org.threeten.bp.LocalDate
import java.time.bp.LocalDate

interface DateMatcher {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import net.skyscanner.backpack.calendar.model.CalendarSelection
import net.skyscanner.backpack.calendar.model.SingleDay
import net.skyscanner.backpack.calendar.presenter.SelectionType
import net.skyscanner.backpack.reactnative.BpkViewStateHolder
import org.threeten.bp.LocalDate
import java.time.bp.LocalDate
import java.util.Locale

@SuppressLint("ViewConstructor")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package net.skyscanner.backpack.reactnative.calendar
import androidx.annotation.ColorInt
import net.skyscanner.backpack.calendar.model.CalendarCellStyle
import net.skyscanner.backpack.calendar.model.ColoredBucket
import org.threeten.bp.LocalDate
import java.time.bp.LocalDate

internal data class RNColorBucket(
@ColorInt val color: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ package net.skyscanner.backpack.reactnative.calendar

import com.facebook.react.bridge.JSApplicationIllegalArgumentException
import net.skyscanner.backpack.calendar.model.CalendarCellStyle
import org.threeten.bp.Instant
import org.threeten.bp.LocalDate
import java.time.Instant
import java.time.LocalDate

internal object TypeConversions {
fun stringToCellStyle(cellStyleString: String): CalendarCellStyle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event
import com.facebook.react.uimanager.events.RCTEventEmitter
import net.skyscanner.backpack.reactnative.calendar.CalendarViewManager
import org.threeten.bp.LocalDate
import org.threeten.bp.LocalDateTime
import org.threeten.bp.LocalTime
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime

class CalendarChangeEvent(
id: Int,
Expand Down

0 comments on commit 547bf91

Please sign in to comment.