Skip to content

Commit

Permalink
Tempo 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanHasegawaTw committed Sep 6, 2020
1 parent bf8812a commit 3cf6416
Show file tree
Hide file tree
Showing 64 changed files with 1,147 additions and 1,774 deletions.
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ Initialize the library in your `Application` class:

After the library is initialized, you can get the time with:

val timeNowInMs = Tempo.now()
val timeNowInMs = Tempo.nowOrNull()

`Tempo::now()` will return either a `Long` or a `null`. A `null` is returned when *Tempo* has not been
initialized yet. When initialized, `Tempo::now()` returns the current
`Tempo::nowOrNull()` will return either a `Long` or a `null`.
A `null` is returned when *Tempo* has not been initialized yet.
When initialized, `Tempo::nowOrNull()` returns the current
[unix epoch time](https://www.epochconverter.com/) in milliseconds.

You can observe all the events emitted by the library:

Tempo.observeEvents().subscribe {
if (it is Tempo.Initialized) {
Log.i("Tempo", "Initialized!")
}
}
Tempo.addEventsListener { event -> Log.d("TempoEvent", event.toString()) }

## Dependency

Expand Down Expand Up @@ -111,8 +108,6 @@ Then, add it during initialization:
Tempo.initialize(this,
scheduler = WorkManagerScheduler(periodicIntervalMinutes = 60L))

Note: The old `tempo-android-job-scheduler` is **deprecated** and no longer supported.

## FAQ

1. What happens if the application gets destroyed?
Expand All @@ -130,11 +125,12 @@ Then you should use a fallback strategy, like `System.currentTimeMillis()`.

4. Will *Tempo* ever support Java?

If there's enough interest. Open an issue if you would like to use it with Java.
No official support for Java because Kotlin is now the official language for Android.
However, it "should" work with Java.

## License

Copyright (c) 2017 Allan Yoshio Hasegawa
Copyright (c) 2020 Allan Yoshio Hasegawa

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
60 changes: 38 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
def versionMajor = 0
def versionMinor = 3
def versionMajor = 1
def versionMinor = 0
def versionPatch = 0
def versionCode = versionPatch + versionMinor * 100 + versionMajor * 10000

Expand All @@ -12,50 +12,56 @@ ext {
versionCode : versionCode,
versionName : "${versionMajor}.${versionMinor}.${versionPatch}",

testInstrumentationRunner: "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner: "androidx.test.runner.AndroidJUnitRunner"
]
}

buildscript {
ext {
depPaths = {
def versions = [
gradlePlugin : '4.0.0',
kotlin : '1.3.70',
supportLib : '28.0.0',
rxJava : '2.2.7',
rxAndroid : '2.1.1',
androidJob : '1.1.11',
play : '11.0.2',
workManager : '1.0.0-rc02',
gradlePlugin : '4.0.1',
androidJunit5 : '1.6.2.0',
kotlin : '1.4.0',
coroutines : '1.3.8',
appCompat : '1.2.0',
material : '1.2.0',
workManager : '2.4.0',

junit : '4.12',
junitAnd : '1.1.2-rc03',
spek : '2.0.12',
mockk : '1.10.0',
hamkrest : '1.4.1.0',
mockitoKotlin : '1.5.0',
mockitoAndroid: '2.8.47',
espresso : '2.2.2',
espresso : '3.3.0-rc03',
]

[
gradlePlugin : "com.android.tools.build:gradle:$versions.gradlePlugin",
kotlinPlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin",
androidJunit5 : "de.mannodermaus.gradle.plugins:android-junit5:$versions.androidJunit5",

kotlinStd : "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlin",
kotlinStd : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$versions.kotlin",
kotlinReflect : "org.jetbrains.kotlin:kotlin-reflect:$versions.kotlin",
supportAppCompat: "com.android.support:appcompat-v7:$versions.supportLib",
supportDesign : "com.android.support:design:$versions.supportLib",
supportCardView : "com.android.support:cardview-v7:$versions.supportLib",
rxJava : "io.reactivex.rxjava2:rxjava:$versions.rxJava",
rxAndroid : "io.reactivex.rxjava2:rxandroid:$versions.rxAndroid",
androidJob : "com.evernote:android-job:$versions.androidJob",
playGCM : "com.google.android.gms:play-services-gcm:$versions.play",
workManager : "android.arch.work:work-runtime:$versions.workManager",
kotlinTestJ5 : "org.jetbrains.kotlin:kotlin-test-junit5:$versions.kotlin",
coroutines : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$versions.coroutines",
coroutinesTest : "org.jetbrains.kotlinx:kotlinx-coroutines-test:$versions.coroutines",
coroutinesAnd : "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.coroutines",
appCompat : "androidx.appcompat:appcompat:$versions.appCompat",
material : "com.google.android.material:material:$versions.material",
workManager : "androidx.work:work-runtime:$versions.workManager",

junit : "junit:junit:$versions.junit",
junitAnd : "androidx.test.ext:junit:$versions.junitAnd",
spekDsl : "org.spekframework.spek2:spek-dsl-jvm:$versions.spek",
spekRunner : "org.spekframework.spek2:spek-runner-junit5:$versions.spek",
mockk : "io.mockk:mockk:$versions.mockk",
hamkrest : "com.natpryce:hamkrest:$versions.hamkrest",
mockitoKotlin : "com.nhaarman:mockito-kotlin-kt1.1:$versions.mockitoKotlin",
mockitoAndroid : "org.mockito:mockito-android:$versions.mockitoAndroid",
espressoCore : "com.android.support.test.espresso:espresso-core:$versions.espresso",
espressoCore : "androidx.test.espresso:espresso-core:$versions.espresso",
]
}()
}
Expand All @@ -68,6 +74,7 @@ buildscript {
dependencies {
classpath depPaths.gradlePlugin
classpath depPaths.kotlinPlugin
classpath depPaths.androidJunit5

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -79,6 +86,15 @@ allprojects {
google()
jcenter()
}

if (!project.name.contains("sample")) {
// https://youtrack.jetbrains.com/issue/KT-37652
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
freeCompilerArgs += '-Xexplicit-api=strict'
}
}
}
}

task clean(type: Delete) {
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ org.gradle.jvmargs=-Xmx1536m
# 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.useAndroidX=true
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Mon Jul 27 18:14:15 BST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.6-rc-6-bin.zip
19 changes: 8 additions & 11 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion androidConfig.compileSdkVersion
Expand All @@ -20,21 +19,19 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

buildFeatures {
viewBinding true
}
}

dependencies {
implementation project(':tempo')
implementation project(':tempo-android-workmanager-scheduler')
implementation project(':tempo-android-gps-time-source')
implementation depPaths.kotlinStd
implementation depPaths.supportAppCompat
implementation depPaths.supportDesign
implementation depPaths.supportCardView
implementation depPaths.rxJava
implementation depPaths.rxAndroid

testImplementation depPaths.junit
androidTestImplementation(depPaths.espressoCore, {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation depPaths.appCompat
implementation depPaths.material
implementation depPaths.coroutines
implementation depPaths.coroutinesAnd
}

This file was deleted.

Loading

0 comments on commit 3cf6416

Please sign in to comment.