Initial commit
Signed-off-by: William Brawner <me@wbrawner.com>
14
.gitignore
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
1
.idea/.name
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Interval Timer
|
123
.idea/codeStyles/Project.xml
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<JetCodeStyleSettings>
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
</JetCodeStyleSettings>
|
||||||
|
<codeStyleSettings language="XML">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
</indentOptions>
|
||||||
|
<arrangement>
|
||||||
|
<rules>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:android</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:id</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>style</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
</rules>
|
||||||
|
</arrangement>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="kotlin">
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
<option name="WRAP_ON_TYPING" value="1" />
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</state>
|
||||||
|
</component>
|
8
.idea/compiler.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel>
|
||||||
|
<module name="Interval_Timer.app" target="1.8" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
|
</component>
|
||||||
|
</project>
|
7
.idea/dictionaries/billybrawner.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="billybrawner">
|
||||||
|
<words>
|
||||||
|
<w>trainterval</w>
|
||||||
|
</words>
|
||||||
|
</dictionary>
|
||||||
|
</component>
|
20
.idea/gradle.xml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="PLATFORM" />
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
25
.idea/jarRepositories.xml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="BintrayJCenter" />
|
||||||
|
<option name="name" value="BintrayJCenter" />
|
||||||
|
<option name="url" value="https://jcenter.bintray.com/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="Google" />
|
||||||
|
<option name="name" value="Google" />
|
||||||
|
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
9
.idea/misc.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
12
.idea/runConfigurations.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
1
app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/build
|
89
app/build.gradle
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
apply plugin: 'kotlin-kapt'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 29
|
||||||
|
buildToolsVersion "29.0.3"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.wbrawner.trainterval"
|
||||||
|
minSdkVersion 23
|
||||||
|
targetSdkVersion 29
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
javaCompileOptions {
|
||||||
|
annotationProcessorOptions {
|
||||||
|
arguments = [
|
||||||
|
"room.schemaLocation" : "$projectDir/schemas".toString(),
|
||||||
|
"room.incremental" : "true",
|
||||||
|
"room.expandProjection": "true"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
|
||||||
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'
|
||||||
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.3.5'
|
||||||
|
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
|
implementation 'androidx.core:core-ktx:1.2.0'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
|
|
||||||
|
implementation 'com.google.android.material:material:1.2.0-alpha05'
|
||||||
|
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||||
|
|
||||||
|
def room_version = "2.2.5"
|
||||||
|
implementation "androidx.room:room-runtime:$room_version"
|
||||||
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
|
kapt "androidx.room:room-compiler:$room_version"
|
||||||
|
implementation "androidx.room:room-ktx:$room_version"
|
||||||
|
testImplementation "androidx.room:room-testing:$room_version"
|
||||||
|
|
||||||
|
def nav_version = "2.2.1"
|
||||||
|
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
|
||||||
|
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
|
||||||
|
// Requires 2.3.0 which is still in alpha at the time of writing
|
||||||
|
// androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
|
||||||
|
|
||||||
|
def lifecycle_version = "2.2.0"
|
||||||
|
def arch_version = "2.1.0"
|
||||||
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
|
||||||
|
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
|
||||||
|
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
|
||||||
|
testImplementation "androidx.arch.core:core-testing:$arch_version"
|
||||||
|
|
||||||
|
def koin_version = "2.1.5"
|
||||||
|
implementation "org.koin:koin-core:$koin_version"
|
||||||
|
implementation "org.koin:koin-android:$koin_version"
|
||||||
|
testImplementation "org.koin:koin-test:$koin_version"
|
||||||
|
|
||||||
|
testImplementation 'junit:junit:4.12'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||||
|
}
|
21
app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,88 @@
|
||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 1,
|
||||||
|
"identityHash": "03572fc3000245d00e3b4f85a3162fdd",
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"tableName": "interval_timer",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER, `name` TEXT NOT NULL, `description` TEXT NOT NULL, `warmUpDuration` INTEGER NOT NULL, `lowIntensityDuration` INTEGER NOT NULL, `highIntensityDuration` INTEGER NOT NULL, `restDuration` INTEGER NOT NULL, `coolDownDuration` INTEGER NOT NULL, `sets` INTEGER NOT NULL, `cycles` INTEGER NOT NULL, PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "description",
|
||||||
|
"columnName": "description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "warmUpDuration",
|
||||||
|
"columnName": "warmUpDuration",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lowIntensityDuration",
|
||||||
|
"columnName": "lowIntensityDuration",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "highIntensityDuration",
|
||||||
|
"columnName": "highIntensityDuration",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "restDuration",
|
||||||
|
"columnName": "restDuration",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "coolDownDuration",
|
||||||
|
"columnName": "coolDownDuration",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "sets",
|
||||||
|
"columnName": "sets",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "cycles",
|
||||||
|
"columnName": "cycles",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"autoGenerate": false
|
||||||
|
},
|
||||||
|
"indices": [],
|
||||||
|
"foreignKeys": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"views": [],
|
||||||
|
"setupQueries": [
|
||||||
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '03572fc3000245d00e3b4f85a3162fdd')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.wbrawner.trainterval
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
fun useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
|
assertEquals("com.wbrawner.intervaltimer", appContext.packageName)
|
||||||
|
}
|
||||||
|
}
|
35
app/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.wbrawner.trainterval">
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:name=".TraintervalApplication"
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/AppTheme">
|
||||||
|
<activity
|
||||||
|
android:name=".ItemListActivity"
|
||||||
|
android:label="@string/title_item_list"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"></activity>
|
||||||
|
<activity
|
||||||
|
android:name=".ItemDetailActivity"
|
||||||
|
android:label="@string/title_item_detail"
|
||||||
|
android:parentActivityName=".ItemListActivity"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value="com.wbrawner.trainterval.ItemListActivity" />
|
||||||
|
</activity>
|
||||||
|
<activity android:name=".MainActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
66
app/src/main/java/com/wbrawner/trainterval/DurationPicker.kt
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
package com.wbrawner.trainterval
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.widget.FrameLayout
|
||||||
|
import android.widget.NumberPicker
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
|
import androidx.annotation.StyleRes
|
||||||
|
import androidx.core.math.MathUtils
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
private const val MIN_DURATION = 0L
|
||||||
|
private val MAX_DURATION = TimeUnit.DAYS.toMillis(1)
|
||||||
|
|
||||||
|
class DurationPicker @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
@AttrRes defStyleAttr: Int = 0,
|
||||||
|
@StyleRes defStyleRes: Int = 0
|
||||||
|
) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) {
|
||||||
|
|
||||||
|
private var intervalDuration = IntervalDuration()
|
||||||
|
var duration: Long
|
||||||
|
get() = intervalDuration.toMillis()
|
||||||
|
set(value) {
|
||||||
|
intervalDuration = MathUtils.clamp(value, MIN_DURATION, MAX_DURATION).toIntervalDuration()
|
||||||
|
hours.value = intervalDuration.hours.toInt()
|
||||||
|
minutes.value = intervalDuration.minutes.toInt()
|
||||||
|
seconds.value = intervalDuration.seconds.toInt()
|
||||||
|
}
|
||||||
|
private val hours: NumberPicker
|
||||||
|
private val minutes: NumberPicker
|
||||||
|
private val seconds: NumberPicker
|
||||||
|
|
||||||
|
init {
|
||||||
|
val view = LayoutInflater.from(context).inflate(R.layout.duration_picker, this, true)
|
||||||
|
hours = view.findViewById(R.id.hours)
|
||||||
|
hours.minValue = 0
|
||||||
|
hours.maxValue = 23
|
||||||
|
hours.setOnValueChangedListener { _, _, newVal ->
|
||||||
|
intervalDuration = intervalDuration.copy(hours = newVal.toLong())
|
||||||
|
Log.v("DurationPicker", "Updated hours: $newVal")
|
||||||
|
}
|
||||||
|
hours.setFormatter(numberFormatter())
|
||||||
|
minutes = view.findViewById(R.id.minutes)
|
||||||
|
minutes.minValue = 0
|
||||||
|
minutes.maxValue = 59
|
||||||
|
minutes.setOnValueChangedListener { _, _, newVal ->
|
||||||
|
intervalDuration = intervalDuration.copy(minutes = newVal.toLong())
|
||||||
|
Log.v("DurationPicker", "Updated minutes: $newVal")
|
||||||
|
}
|
||||||
|
minutes.setFormatter(numberFormatter())
|
||||||
|
seconds = view.findViewById(R.id.seconds)
|
||||||
|
seconds.minValue = 0
|
||||||
|
seconds.maxValue = 59
|
||||||
|
seconds.setOnValueChangedListener { _, _, newVal ->
|
||||||
|
intervalDuration = intervalDuration.copy(seconds = newVal.toLong())
|
||||||
|
Log.v("DurationPicker", "Updated seconds: $newVal")
|
||||||
|
}
|
||||||
|
seconds.setFormatter(numberFormatter())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun numberFormatter() = NumberPicker.Formatter { "%02d".format(it) }
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.wbrawner.trainterval
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
|
||||||
|
data class IntervalDuration(
|
||||||
|
val hours: Long = 0,
|
||||||
|
val minutes: Long = 0,
|
||||||
|
val seconds: Long = 0
|
||||||
|
) {
|
||||||
|
override fun toString(): String {
|
||||||
|
return "%02d:%02d:%02d".format(hours, minutes, seconds)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun IntervalDuration.toMillis(): Long {
|
||||||
|
return TimeUnit.HOURS.toMillis(hours) +
|
||||||
|
TimeUnit.MINUTES.toMillis(minutes) +
|
||||||
|
TimeUnit.SECONDS.toMillis(seconds)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Long.toIntervalDuration(): IntervalDuration {
|
||||||
|
val SECONDS_IN_HOUR = 3600
|
||||||
|
val SECONDS_IN_MINUTE = 60
|
||||||
|
|
||||||
|
if (this < 1000) {
|
||||||
|
return IntervalDuration(0, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
var seconds: Long = this / 1000
|
||||||
|
var hours: Long = 0
|
||||||
|
if (seconds >= SECONDS_IN_HOUR) {
|
||||||
|
hours = seconds / SECONDS_IN_HOUR
|
||||||
|
seconds -= hours * SECONDS_IN_HOUR
|
||||||
|
}
|
||||||
|
|
||||||
|
var minutes: Long = 0
|
||||||
|
if (seconds >= SECONDS_IN_MINUTE) {
|
||||||
|
minutes = seconds / SECONDS_IN_MINUTE
|
||||||
|
seconds -= minutes * SECONDS_IN_MINUTE
|
||||||
|
}
|
||||||
|
|
||||||
|
return IntervalDuration(hours, minutes, seconds)
|
||||||
|
}
|
34
app/src/main/java/com/wbrawner/trainterval/Logger.kt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package com.wbrawner.trainterval
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
|
||||||
|
interface Logger {
|
||||||
|
val defaultTag: String
|
||||||
|
fun v(tag: String = defaultTag, message: String)
|
||||||
|
fun d(tag: String = defaultTag, message: String)
|
||||||
|
fun i(tag: String = defaultTag, message: String)
|
||||||
|
fun w(tag: String = defaultTag, message: String)
|
||||||
|
fun e(tag: String = defaultTag, message: String, error: Throwable? = null)
|
||||||
|
}
|
||||||
|
|
||||||
|
class AndroidLogger(override val defaultTag: String) : Logger {
|
||||||
|
override fun v(tag: String, message: String) {
|
||||||
|
Log.v(tag, message)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun d(tag: String, message: String) {
|
||||||
|
Log.d(tag, message)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun i(tag: String, message: String) {
|
||||||
|
Log.i(tag, message)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun w(tag: String, message: String) {
|
||||||
|
Log.w(tag, message)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun e(tag: String, message: String, error: Throwable?) {
|
||||||
|
Log.e(tag, message, error)
|
||||||
|
}
|
||||||
|
}
|
12
app/src/main/java/com/wbrawner/trainterval/MainActivity.kt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package com.wbrawner.trainterval
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
|
||||||
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_main)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.wbrawner.trainterval
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.Application
|
||||||
|
import android.os.Bundle
|
||||||
|
|
||||||
|
private const val TAG = "ActivityLifecycleCallbacks"
|
||||||
|
|
||||||
|
class TraintervalActivityLifecycleCallbacks(
|
||||||
|
private val logger: Logger
|
||||||
|
) : Application.ActivityLifecycleCallbacks {
|
||||||
|
private var currentActivity: Activity? = null
|
||||||
|
|
||||||
|
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
||||||
|
logger.v(TAG, "onActivityCreated: $activity")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityStarted(activity: Activity) {
|
||||||
|
logger.v(TAG, "onActivityStarted: $activity")
|
||||||
|
currentActivity = activity
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityResumed(activity: Activity) {
|
||||||
|
logger.v(TAG, "onActivityResumed: $activity")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityPaused(activity: Activity) {
|
||||||
|
logger.v(TAG, "onActivityPaused: $activity")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityStopped(activity: Activity) {
|
||||||
|
logger.v(TAG, "onActivityStopped: $activity")
|
||||||
|
currentActivity = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityDestroyed(activity: Activity) {
|
||||||
|
logger.v(TAG, "onActivityDestroyed: $activity")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
|
||||||
|
logger.v(TAG, "onActivitySaveInstanceState: $activity")
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.wbrawner.trainterval
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import androidx.room.Room
|
||||||
|
import com.wbrawner.trainterval.activetimer.ActiveTimerViewModel
|
||||||
|
import com.wbrawner.trainterval.timerform.TimerFormViewModel
|
||||||
|
import com.wbrawner.trainterval.timerlist.TimerListViewModel
|
||||||
|
import org.koin.android.ext.koin.androidContext
|
||||||
|
import org.koin.android.ext.koin.androidLogger
|
||||||
|
import org.koin.core.context.startKoin
|
||||||
|
import org.koin.core.parameter.parametersOf
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
class TraintervalApplication : Application() {
|
||||||
|
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
|
||||||
|
startKoin {
|
||||||
|
androidLogger()
|
||||||
|
androidContext(this@TraintervalApplication)
|
||||||
|
modules(traintervalModule)
|
||||||
|
}
|
||||||
|
|
||||||
|
val lifecycleCallbacks =
|
||||||
|
TraintervalActivityLifecycleCallbacks(AndroidLogger("LifecycleCallbacks"))
|
||||||
|
registerActivityLifecycleCallbacks(lifecycleCallbacks)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val traintervalModule = module {
|
||||||
|
single {
|
||||||
|
Room.databaseBuilder(get(), TraintervalDatabase::class.java, "trainterval")
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
single {
|
||||||
|
get<TraintervalDatabase>().timerDao()
|
||||||
|
}
|
||||||
|
|
||||||
|
single {
|
||||||
|
TimerListViewModel(get(parameters = { parametersOf("TimerListStore") }), get())
|
||||||
|
}
|
||||||
|
|
||||||
|
factory {
|
||||||
|
TimerFormViewModel(get(parameters = { parametersOf("TimerFormStore") }), get())
|
||||||
|
}
|
||||||
|
|
||||||
|
factory {
|
||||||
|
ActiveTimerViewModel(get(parameters = { parametersOf("ActiveTimerStore") }), get())
|
||||||
|
}
|
||||||
|
|
||||||
|
factory<Logger> { params ->
|
||||||
|
AndroidLogger(params.component1())
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.wbrawner.trainterval
|
||||||
|
|
||||||
|
import androidx.room.Database
|
||||||
|
import androidx.room.RoomDatabase
|
||||||
|
import com.wbrawner.trainterval.model.IntervalTimer
|
||||||
|
import com.wbrawner.trainterval.model.IntervalTimerDao
|
||||||
|
|
||||||
|
@Database(entities = [IntervalTimer::class], version = 1)
|
||||||
|
abstract class TraintervalDatabase : RoomDatabase() {
|
||||||
|
abstract fun timerDao(): IntervalTimerDao
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.wbrawner.trainterval.activetimer
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import com.wbrawner.trainterval.R
|
||||||
|
import kotlinx.android.synthetic.main.fragment_active_timer.*
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.cancel
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import org.koin.android.ext.android.inject
|
||||||
|
|
||||||
|
class ActiveTimerFragment : Fragment() {
|
||||||
|
|
||||||
|
private var coroutineScope: CoroutineScope? = null
|
||||||
|
private val activeTimerViewModel: ActiveTimerViewModel by inject()
|
||||||
|
private var timerId: Long = 0
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
timerId = requireArguments().getLong("timerId")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? = inflater.inflate(R.layout.fragment_active_timer, container, false)
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
coroutineScope = CoroutineScope(Dispatchers.Main)
|
||||||
|
coroutineScope!!.launch {
|
||||||
|
activeTimerViewModel.timerState.observe(viewLifecycleOwner, Observer { state ->
|
||||||
|
when (state) {
|
||||||
|
is IntervalTimerActiveState.LoadingState -> renderLoading()
|
||||||
|
is IntervalTimerActiveState.TimerRunningState -> renderTimer(state)
|
||||||
|
is IntervalTimerActiveState.ExitState -> findNavController().navigateUp()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
coroutineScope!!.launch {
|
||||||
|
activeTimerViewModel.init(timerId)
|
||||||
|
}
|
||||||
|
playPauseButton.setOnClickListener {
|
||||||
|
coroutineScope!!.launch {
|
||||||
|
activeTimerViewModel.toggleTimer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderLoading() {
|
||||||
|
progressBar.visibility = View.VISIBLE
|
||||||
|
timerLayout.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderTimer(state: IntervalTimerActiveState.TimerRunningState) {
|
||||||
|
progressBar.visibility = View.GONE
|
||||||
|
timerLayout.visibility = View.VISIBLE
|
||||||
|
playPauseButton.setImageDrawable(requireContext().getDrawable(state.playPauseIcon))
|
||||||
|
timeRemaining.text = state.timeRemaining
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
coroutineScope?.cancel()
|
||||||
|
coroutineScope = null
|
||||||
|
super.onDestroyView()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val EXTRA_TIMER_ID = "timerId"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,216 @@
|
||||||
|
package com.wbrawner.trainterval.activetimer
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import com.wbrawner.trainterval.Logger
|
||||||
|
import com.wbrawner.trainterval.R
|
||||||
|
import com.wbrawner.trainterval.activetimer.IntervalTimerActiveState.LoadingState
|
||||||
|
import com.wbrawner.trainterval.activetimer.IntervalTimerActiveState.TimerRunningState
|
||||||
|
import com.wbrawner.trainterval.model.IntervalTimer
|
||||||
|
import com.wbrawner.trainterval.model.IntervalTimerDao
|
||||||
|
import com.wbrawner.trainterval.model.Phase
|
||||||
|
import com.wbrawner.trainterval.toIntervalDuration
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import kotlin.coroutines.coroutineContext
|
||||||
|
|
||||||
|
class ActiveTimerViewModel(
|
||||||
|
private val logger: Logger,
|
||||||
|
private val timerDao: IntervalTimerDao
|
||||||
|
) : ViewModel() {
|
||||||
|
val timerState: MutableLiveData<IntervalTimerActiveState> = MutableLiveData(LoadingState)
|
||||||
|
private var timerJob: Job? = null
|
||||||
|
private lateinit var timer: IntervalTimer
|
||||||
|
private var timerComplete = false
|
||||||
|
private var timerRunning = false
|
||||||
|
private var currentPhase = Phase.WARM_UP
|
||||||
|
private var currentSet = 1
|
||||||
|
private var currentRound = 1
|
||||||
|
private var timeRemaining: Long = 0
|
||||||
|
|
||||||
|
suspend fun init(timerId: Long) {
|
||||||
|
logger.d(message = "Initializing with Timer id $timerId")
|
||||||
|
timer = timerDao.getById(timerId)
|
||||||
|
timeRemaining = timer.warmUpDuration
|
||||||
|
timerState.postValue(
|
||||||
|
TimerRunningState(
|
||||||
|
timerRunning,
|
||||||
|
timeRemaining.toIntervalDuration().toString(),
|
||||||
|
currentSet,
|
||||||
|
timer.sets,
|
||||||
|
currentRound,
|
||||||
|
timer.cycles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun toggleTimer() {
|
||||||
|
if (timerRunning) {
|
||||||
|
timerJob?.cancel()
|
||||||
|
timerRunning = false
|
||||||
|
timerState.postValue(
|
||||||
|
TimerRunningState(
|
||||||
|
timerRunning,
|
||||||
|
timeRemaining.toIntervalDuration().toString(),
|
||||||
|
currentSet,
|
||||||
|
timer.sets,
|
||||||
|
currentRound,
|
||||||
|
timer.cycles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
coroutineScope {
|
||||||
|
timerJob = launch {
|
||||||
|
startTimer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun startTimer() {
|
||||||
|
timerRunning = true
|
||||||
|
timerState.postValue(
|
||||||
|
TimerRunningState(
|
||||||
|
timerRunning,
|
||||||
|
timeRemaining.toIntervalDuration().toString(),
|
||||||
|
currentSet,
|
||||||
|
timer.sets,
|
||||||
|
currentRound,
|
||||||
|
timer.cycles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
while (coroutineContext.isActive && timerRunning) {
|
||||||
|
delay(1_000)
|
||||||
|
timeRemaining -= 1_000
|
||||||
|
if (timeRemaining <= 0) {
|
||||||
|
goForward()
|
||||||
|
}
|
||||||
|
timerState.postValue(
|
||||||
|
TimerRunningState(
|
||||||
|
timerRunning,
|
||||||
|
timeRemaining.toIntervalDuration().toString(),
|
||||||
|
currentSet,
|
||||||
|
timer.sets,
|
||||||
|
currentRound,
|
||||||
|
timer.cycles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun skipAhead() {
|
||||||
|
timerJob?.cancel()
|
||||||
|
when (currentPhase) {
|
||||||
|
Phase.COOL_DOWN -> {
|
||||||
|
timeRemaining = 0
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
goForward()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (timerRunning) {
|
||||||
|
startTimer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun goForward() {
|
||||||
|
timerComplete = currentPhase == Phase.COOL_DOWN
|
||||||
|
when (currentPhase) {
|
||||||
|
Phase.WARM_UP -> {
|
||||||
|
currentPhase = Phase.LOW_INTENSITY
|
||||||
|
timeRemaining = timer.lowIntensityDuration
|
||||||
|
}
|
||||||
|
Phase.LOW_INTENSITY -> {
|
||||||
|
currentPhase = Phase.HIGH_INTENSITY
|
||||||
|
timeRemaining = timer.highIntensityDuration
|
||||||
|
}
|
||||||
|
Phase.HIGH_INTENSITY -> {
|
||||||
|
when {
|
||||||
|
currentSet < timer.sets -> {
|
||||||
|
currentSet++
|
||||||
|
currentPhase = Phase.LOW_INTENSITY
|
||||||
|
timeRemaining = timer.lowIntensityDuration
|
||||||
|
}
|
||||||
|
currentRound < timer.cycles -> {
|
||||||
|
currentRound++
|
||||||
|
currentPhase = Phase.REST
|
||||||
|
timeRemaining = timer.restDuration
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
currentPhase = Phase.COOL_DOWN
|
||||||
|
timeRemaining = timer.coolDownDuration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Phase.REST -> {
|
||||||
|
currentSet = 1
|
||||||
|
currentPhase = Phase.LOW_INTENSITY
|
||||||
|
timeRemaining = timer.lowIntensityDuration
|
||||||
|
}
|
||||||
|
Phase.COOL_DOWN -> {
|
||||||
|
timerRunning = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun goBack() {
|
||||||
|
timerJob?.cancel()
|
||||||
|
when (currentPhase) {
|
||||||
|
Phase.WARM_UP -> {
|
||||||
|
timeRemaining = timer.warmUpDuration
|
||||||
|
}
|
||||||
|
Phase.LOW_INTENSITY -> {
|
||||||
|
when {
|
||||||
|
currentSet == 1 && currentRound == 1 -> {
|
||||||
|
currentPhase = Phase.WARM_UP
|
||||||
|
timeRemaining = timer.warmUpDuration
|
||||||
|
}
|
||||||
|
currentSet == 1 && currentRound > 1 -> {
|
||||||
|
currentPhase = Phase.REST
|
||||||
|
timeRemaining = timer.restDuration
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
currentPhase = Phase.HIGH_INTENSITY
|
||||||
|
timeRemaining = timer.highIntensityDuration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
timeRemaining = timer.highIntensityDuration
|
||||||
|
}
|
||||||
|
Phase.HIGH_INTENSITY -> {
|
||||||
|
currentPhase = Phase.LOW_INTENSITY
|
||||||
|
timeRemaining = timer.lowIntensityDuration
|
||||||
|
}
|
||||||
|
Phase.REST -> {
|
||||||
|
currentRound--
|
||||||
|
currentPhase = Phase.HIGH_INTENSITY
|
||||||
|
currentSet = timer.sets
|
||||||
|
timeRemaining = timer.highIntensityDuration
|
||||||
|
}
|
||||||
|
Phase.COOL_DOWN -> {
|
||||||
|
currentPhase = Phase.HIGH_INTENSITY
|
||||||
|
timeRemaining = timer.highIntensityDuration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (timerRunning) {
|
||||||
|
startTimer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to represent the state while a user has a specific timer open.
|
||||||
|
*/
|
||||||
|
sealed class IntervalTimerActiveState {
|
||||||
|
object LoadingState : IntervalTimerActiveState()
|
||||||
|
class TimerRunningState(
|
||||||
|
timerRunning: Boolean,
|
||||||
|
val timeRemaining: String,
|
||||||
|
val currentSet: Int,
|
||||||
|
val totalSets: Int,
|
||||||
|
val currentRound: Int,
|
||||||
|
val totalRounds: Int,
|
||||||
|
val timerComplete: Boolean = false,
|
||||||
|
@DrawableRes val playPauseIcon: Int = if (timerRunning) R.drawable.ic_pause else R.drawable.ic_play_arrow
|
||||||
|
) : IntervalTimerActiveState()
|
||||||
|
object ExitState : IntervalTimerActiveState()
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.wbrawner.trainterval.model
|
||||||
|
|
||||||
|
import androidx.room.*
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
@Entity(tableName = "interval_timer")
|
||||||
|
data class IntervalTimer(
|
||||||
|
@PrimaryKey val id: Long? = null,
|
||||||
|
val name: String = "",
|
||||||
|
val description: String = "",
|
||||||
|
val warmUpDuration: Long = TimeUnit.MINUTES.toMillis(5),
|
||||||
|
val lowIntensityDuration: Long = TimeUnit.SECONDS.toMillis(30),
|
||||||
|
val highIntensityDuration: Long = TimeUnit.MINUTES.toMillis(1),
|
||||||
|
val restDuration: Long = TimeUnit.MINUTES.toMillis(1),
|
||||||
|
val coolDownDuration: Long = TimeUnit.MINUTES.toMillis(5),
|
||||||
|
val sets: Int = 4,
|
||||||
|
val cycles: Int = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
enum class Phase {
|
||||||
|
WARM_UP,
|
||||||
|
LOW_INTENSITY,
|
||||||
|
HIGH_INTENSITY,
|
||||||
|
REST,
|
||||||
|
COOL_DOWN,
|
||||||
|
}
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface IntervalTimerDao {
|
||||||
|
@Query("SELECT * FROM interval_timer")
|
||||||
|
fun getAll(): Flow<List<IntervalTimer>>
|
||||||
|
|
||||||
|
@Query("SELECT * FROM interval_timer WHERE id = :id")
|
||||||
|
suspend fun getById(id: Long): IntervalTimer
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
suspend fun insert(timer: IntervalTimer): Long
|
||||||
|
|
||||||
|
@Update
|
||||||
|
suspend fun update(timer: IntervalTimer)
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
suspend fun delete(timer: IntervalTimer)
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
package com.wbrawner.trainterval.timerform
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import com.wbrawner.trainterval.R
|
||||||
|
import com.wbrawner.trainterval.model.IntervalTimer
|
||||||
|
import com.wbrawner.trainterval.timerform.IntervalTimerEditState.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_timer_form.*
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.cancel
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import org.koin.android.ext.android.inject
|
||||||
|
|
||||||
|
class TimerFormFragment : Fragment() {
|
||||||
|
|
||||||
|
private var coroutineScope: CoroutineScope? = null
|
||||||
|
private val timerFormViewModel: TimerFormViewModel by inject()
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? = inflater.inflate(R.layout.fragment_timer_form, container, false)
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
(activity as? AppCompatActivity)?.let {
|
||||||
|
it.setSupportActionBar(toolbar)
|
||||||
|
it.supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
}
|
||||||
|
coroutineScope = CoroutineScope(Dispatchers.Main)
|
||||||
|
coroutineScope!!.launch {
|
||||||
|
timerFormViewModel.timerState.observe(viewLifecycleOwner, Observer { state ->
|
||||||
|
when (state) {
|
||||||
|
is LoadingState -> renderLoading()
|
||||||
|
is EditTimerState -> renderEditingState(state.timer, state.title)
|
||||||
|
is EditTimerSavedState -> findNavController().navigate(R.id.timerListFragment)
|
||||||
|
is ErrorState -> renderErrorState(state.message)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
coroutineScope!!.launch {
|
||||||
|
timerFormViewModel.init(arguments?.getLong(EXTRA_TIMER_ID))
|
||||||
|
}
|
||||||
|
timerSets.minValue = 1
|
||||||
|
timerSets.maxValue = 99
|
||||||
|
timerRepeat.minValue = 1
|
||||||
|
timerRepeat.maxValue = 99
|
||||||
|
saveButton.setOnClickListener {
|
||||||
|
coroutineScope?.launch {
|
||||||
|
timerFormViewModel.saveTimer(
|
||||||
|
timerName.text.toString(),
|
||||||
|
timerDescription.text.toString(),
|
||||||
|
warmUpDuration.duration,
|
||||||
|
lowIntensityDuration.duration,
|
||||||
|
highIntensityDuration.duration,
|
||||||
|
restDuration.duration,
|
||||||
|
coolDownDuration.duration,
|
||||||
|
timerSets.value,
|
||||||
|
timerRepeat.value
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderLoading() {
|
||||||
|
timerForm.visibility = View.GONE
|
||||||
|
error.visibility = View.GONE
|
||||||
|
progressBar.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderEditingState(timer: IntervalTimer, title: String) {
|
||||||
|
toolbar.title = title
|
||||||
|
timerForm.visibility = View.VISIBLE
|
||||||
|
timerName.setText(timer.name)
|
||||||
|
timerDescription.setText(timer.description)
|
||||||
|
warmUpDuration.duration = timer.warmUpDuration
|
||||||
|
lowIntensityDuration.duration = timer.lowIntensityDuration
|
||||||
|
highIntensityDuration.duration = timer.highIntensityDuration
|
||||||
|
restDuration.duration = timer.restDuration
|
||||||
|
coolDownDuration.duration = timer.coolDownDuration
|
||||||
|
timerSets.value = timer.sets
|
||||||
|
timerRepeat.value = timer.cycles
|
||||||
|
error.visibility = View.GONE
|
||||||
|
progressBar.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderErrorState(message: String) {
|
||||||
|
timerForm.visibility = View.GONE
|
||||||
|
error.visibility = View.VISIBLE
|
||||||
|
error.text = message
|
||||||
|
progressBar.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
coroutineScope?.cancel()
|
||||||
|
coroutineScope = null
|
||||||
|
super.onDestroyView()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val EXTRA_TIMER_ID = "timerId"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.wbrawner.trainterval.timerform
|
||||||
|
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import com.wbrawner.trainterval.Logger
|
||||||
|
import com.wbrawner.trainterval.model.IntervalTimer
|
||||||
|
import com.wbrawner.trainterval.model.IntervalTimerDao
|
||||||
|
import com.wbrawner.trainterval.timerform.IntervalTimerEditState.*
|
||||||
|
|
||||||
|
class TimerFormViewModel(
|
||||||
|
private val logger: Logger,
|
||||||
|
private val timerDao: IntervalTimerDao
|
||||||
|
) : ViewModel() {
|
||||||
|
private lateinit var timer: IntervalTimer
|
||||||
|
val timerState: MutableLiveData<IntervalTimerEditState> = MutableLiveData(LoadingState)
|
||||||
|
|
||||||
|
suspend fun init(timerId: Long? = null) {
|
||||||
|
timer = if (timerId == null) {
|
||||||
|
IntervalTimer()
|
||||||
|
} else {
|
||||||
|
timerDao.getById(timerId)
|
||||||
|
}
|
||||||
|
logger.v(message = "Timer: ")
|
||||||
|
logger.v(message = timer.toString())
|
||||||
|
timerState.postValue(EditTimerState(timer))
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun saveTimer(
|
||||||
|
name: String,
|
||||||
|
description: String,
|
||||||
|
warmUpDuration: Long,
|
||||||
|
lowIntensityDuration: Long,
|
||||||
|
highIntensityDuration: Long,
|
||||||
|
restDuration: Long,
|
||||||
|
coolDownDuration: Long,
|
||||||
|
sets: Int,
|
||||||
|
cycles: Int
|
||||||
|
) {
|
||||||
|
timerState.postValue(LoadingState)
|
||||||
|
timer = timer.copy(
|
||||||
|
name = name,
|
||||||
|
description = description,
|
||||||
|
warmUpDuration = warmUpDuration,
|
||||||
|
lowIntensityDuration = lowIntensityDuration,
|
||||||
|
highIntensityDuration = highIntensityDuration,
|
||||||
|
restDuration = restDuration,
|
||||||
|
coolDownDuration = coolDownDuration,
|
||||||
|
sets = sets,
|
||||||
|
cycles = cycles
|
||||||
|
)
|
||||||
|
if (timer.id != null) {
|
||||||
|
timerDao.update(timer)
|
||||||
|
} else {
|
||||||
|
timer = timer.copy(id = timerDao.insert(timer))
|
||||||
|
}
|
||||||
|
timerState.postValue(EditTimerSavedState(timer))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to represent each state while a user is creating or editing a timer.
|
||||||
|
*/
|
||||||
|
sealed class IntervalTimerEditState {
|
||||||
|
object LoadingState : IntervalTimerEditState()
|
||||||
|
class EditTimerState(
|
||||||
|
val timer: IntervalTimer,
|
||||||
|
val title: String = if (timer.id != null) "Edit Timer" else "Add Timer",
|
||||||
|
val showDeleteButton: Boolean = timer.id != null
|
||||||
|
) : IntervalTimerEditState()
|
||||||
|
|
||||||
|
class EditTimerSavedState(val timer: IntervalTimer) : IntervalTimerEditState()
|
||||||
|
class ErrorState(val message: String) : IntervalTimerEditState()
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.wbrawner.trainterval.timerlist
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.wbrawner.trainterval.model.IntervalTimer
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class TimerListAdapter(
|
||||||
|
private val timerListViewModel: TimerListViewModel,
|
||||||
|
private val coroutineScope: CoroutineScope
|
||||||
|
) : ListAdapter<IntervalTimer, TimerListAdapter.ViewHolder>(IntervalTimerDiffUtilCallback()) {
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ViewHolder(
|
||||||
|
LayoutInflater.from(parent.context)
|
||||||
|
.inflate(android.R.layout.simple_list_item_2, parent, false)
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
val timer = getItem(position)
|
||||||
|
holder.title.text = timer.name
|
||||||
|
holder.description.text = timer.description
|
||||||
|
holder.itemView.setOnClickListener {
|
||||||
|
coroutineScope.launch {
|
||||||
|
timerListViewModel.openTimer(timer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
val title: TextView = itemView.findViewById(android.R.id.text1)
|
||||||
|
val description: TextView = itemView.findViewById(android.R.id.text2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class IntervalTimerDiffUtilCallback : DiffUtil.ItemCallback<IntervalTimer>() {
|
||||||
|
override fun areItemsTheSame(oldItem: IntervalTimer, newItem: IntervalTimer): Boolean {
|
||||||
|
return oldItem.id == newItem.id
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun areContentsTheSame(oldItem: IntervalTimer, newItem: IntervalTimer): Boolean {
|
||||||
|
return oldItem == newItem
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
package com.wbrawner.trainterval.timerlist
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.wbrawner.trainterval.R
|
||||||
|
import com.wbrawner.trainterval.model.IntervalTimer
|
||||||
|
import com.wbrawner.trainterval.timerlist.IntervalTimerListState.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_timer_list.*
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.cancel
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import org.koin.android.ext.android.inject
|
||||||
|
|
||||||
|
class TimerListFragment : Fragment() {
|
||||||
|
|
||||||
|
private var coroutineScope: CoroutineScope? = null
|
||||||
|
private val timerListViewModel: TimerListViewModel by inject()
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? = inflater.inflate(R.layout.fragment_timer_list, container, false)
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
coroutineScope = CoroutineScope(Dispatchers.Main)
|
||||||
|
(activity as? AppCompatActivity)?.let {
|
||||||
|
it.setSupportActionBar(toolbar)
|
||||||
|
it.supportActionBar?.setDisplayHomeAsUpEnabled(false)
|
||||||
|
}
|
||||||
|
timerList.layoutManager = LinearLayoutManager(view.context)
|
||||||
|
timerList.addItemDecoration(
|
||||||
|
DividerItemDecoration(
|
||||||
|
view.context,
|
||||||
|
LinearLayoutManager.VERTICAL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
timerList.adapter = TimerListAdapter(timerListViewModel, coroutineScope!!)
|
||||||
|
addTimerButton.setOnClickListener {
|
||||||
|
coroutineScope?.launch {
|
||||||
|
timerListViewModel.addTimer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
coroutineScope!!.launch {
|
||||||
|
timerListViewModel.timerState.observe(viewLifecycleOwner, Observer { state ->
|
||||||
|
when (state) {
|
||||||
|
is LoadingState -> renderLoading()
|
||||||
|
is EmptyListState -> renderEmptyList()
|
||||||
|
is SuccessListState -> renderSuccessState(state.timers)
|
||||||
|
is ErrorState -> renderErrorState(state.message)
|
||||||
|
is CreateTimer -> findNavController().navigate(R.id.timerFormFragment)
|
||||||
|
is EditTimer -> findNavController().navigate(R.id.timerFormFragment)
|
||||||
|
is OpenTimer -> findNavController().navigate(
|
||||||
|
R.id.activeTimerFragment,
|
||||||
|
Bundle().apply { putLong("timerId", state.timerId) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
coroutineScope!!.launch {
|
||||||
|
timerListViewModel.init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderLoading() {
|
||||||
|
addTimerButton.hide()
|
||||||
|
error.visibility = View.GONE
|
||||||
|
progressBar.visibility = View.VISIBLE
|
||||||
|
timerList.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderEmptyList() {
|
||||||
|
addTimerButton.show()
|
||||||
|
error.visibility = View.VISIBLE
|
||||||
|
error.text = "Add a new timer to get started."
|
||||||
|
progressBar.visibility = View.GONE
|
||||||
|
timerList.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderSuccessState(timers: List<IntervalTimer>) {
|
||||||
|
addTimerButton.show()
|
||||||
|
error.visibility = View.GONE
|
||||||
|
progressBar.visibility = View.GONE
|
||||||
|
timerList.visibility = View.VISIBLE
|
||||||
|
(timerList.adapter as? TimerListAdapter)?.submitList(timers)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderErrorState(message: String) {
|
||||||
|
addTimerButton.hide()
|
||||||
|
error.visibility = View.VISIBLE
|
||||||
|
error.text = message
|
||||||
|
progressBar.visibility = View.GONE
|
||||||
|
timerList.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
coroutineScope?.cancel()
|
||||||
|
coroutineScope = null
|
||||||
|
super.onDestroyView()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.wbrawner.trainterval.timerlist
|
||||||
|
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import com.wbrawner.trainterval.Logger
|
||||||
|
import com.wbrawner.trainterval.model.IntervalTimer
|
||||||
|
import com.wbrawner.trainterval.model.IntervalTimerDao
|
||||||
|
import com.wbrawner.trainterval.timerlist.IntervalTimerListState.*
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.flow.collect
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class TimerListViewModel(
|
||||||
|
private val logger: Logger,
|
||||||
|
val timerDao: IntervalTimerDao
|
||||||
|
) : ViewModel() {
|
||||||
|
val timerState: MutableLiveData<IntervalTimerListState> = MutableLiveData(LoadingState)
|
||||||
|
private val timers = ArrayList<IntervalTimer>()
|
||||||
|
private var initialized = false
|
||||||
|
|
||||||
|
fun init() {
|
||||||
|
if (initialized) return
|
||||||
|
initialized = true
|
||||||
|
GlobalScope.launch {
|
||||||
|
timerDao.getAll()
|
||||||
|
.collect {
|
||||||
|
logger.d(message = "Received updated intervaltimer list")
|
||||||
|
logger.d(message = it.toString())
|
||||||
|
timers.clear()
|
||||||
|
timers.addAll(it)
|
||||||
|
if (timers.isEmpty()) {
|
||||||
|
timerState.postValue(EmptyListState)
|
||||||
|
} else {
|
||||||
|
timerState.postValue(SuccessListState(timers))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun addTimer() {
|
||||||
|
timerState.postValue(CreateTimer)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun editTimer(timer: IntervalTimer) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun deleteTimer(timer: IntervalTimer) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun confirmDeleteTimer(timer: IntervalTimer) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun openTimer(timer: IntervalTimer) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to represent each state on the main list view.
|
||||||
|
*/
|
||||||
|
sealed class IntervalTimerListState {
|
||||||
|
object LoadingState : IntervalTimerListState()
|
||||||
|
object EmptyListState : IntervalTimerListState()
|
||||||
|
data class ConfirmDeleteTimerState(val timer: IntervalTimer) : IntervalTimerListState()
|
||||||
|
data class SuccessListState(val timers: List<IntervalTimer>) : IntervalTimerListState()
|
||||||
|
data class ErrorState(val message: String) : IntervalTimerListState()
|
||||||
|
object CreateTimer : IntervalTimerListState()
|
||||||
|
data class EditTimer(val timer: IntervalTimer) : IntervalTimerListState()
|
||||||
|
data class OpenTimer(val timerId: Long) : IntervalTimerListState()
|
||||||
|
}
|
30
app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/background_rounded_corners.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners android:radius="8dp" />
|
||||||
|
<solid android:color="@color/colorSurface" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/colorSurfaceStroke" />
|
||||||
|
</shape>
|
9
app/src/main/res/drawable/ic_add.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="@color/colorOnSurface"
|
||||||
|
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
||||||
|
</vector>
|
170
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_pause.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_play_arrow.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M8,5v14l11,-7z"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_skip_next.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M6,18l8.5,-6L6,6v12zM16,6v12h2V6h-2z"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_skip_previous.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M6,6h2v12L6,18zM9.5,12l8.5,6L18,6z"/>
|
||||||
|
</vector>
|
21
app/src/main/res/layout/activity_main.xml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<androidx.fragment.app.FragmentContainerView
|
||||||
|
android:id="@+id/nav_host_fragment"
|
||||||
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:defaultNavHost="true"
|
||||||
|
app:navGraph="@navigation/nav_graph" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
32
app/src/main/res/layout/duration_picker.xml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<NumberPicker
|
||||||
|
android:id="@+id/hours"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/duration_separator" />
|
||||||
|
|
||||||
|
<NumberPicker
|
||||||
|
android:id="@+id/minutes"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/duration_separator" />
|
||||||
|
|
||||||
|
<NumberPicker
|
||||||
|
android:id="@+id/seconds"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
96
app/src/main/res/layout/fragment_active_timer.xml
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context="com.wbrawner.trainterval.activetimer.ActiveTimerFragment">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appBarLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:elevation="0dp" />
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/timerLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/timeRemaining"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline2"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:text="00:00" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/skipPreviousButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:backgroundTint="@android:color/transparent"
|
||||||
|
android:contentDescription="@string/skip_previous"
|
||||||
|
android:src="@drawable/ic_skip_previous"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/playPauseButton"
|
||||||
|
app:layout_constraintHorizontal_chainStyle="packed"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/timeRemaining" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/playPauseButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:backgroundTint="@android:color/transparent"
|
||||||
|
android:contentDescription="@string/start_timer"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/skipNextButton"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/skipPreviousButton"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/timeRemaining"
|
||||||
|
tools:src="@drawable/ic_play_arrow" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/skipNextButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:backgroundTint="@android:color/transparent"
|
||||||
|
android:contentDescription="@string/skip_next"
|
||||||
|
android:src="@drawable/ic_skip_next"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/playPauseButton"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/timeRemaining" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</LinearLayout>
|
192
app/src/main/res/layout/fragment_timer_form.xml
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
|
android:fillViewport="true"
|
||||||
|
tools:context="com.wbrawner.trainterval.timerform.TimerFormFragment">
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="-90dp"
|
||||||
|
android:paddingTop="90dp"
|
||||||
|
android:clipChildren="false"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/timerForm"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/timerName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/timer_name"
|
||||||
|
android:inputType="textCapWords" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/timerDescription"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/timer_description"
|
||||||
|
android:inputType="textCapSentences" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/warm_up_duration"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" />
|
||||||
|
|
||||||
|
<com.wbrawner.trainterval.DurationPicker
|
||||||
|
android:id="@+id/warmUpDuration"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/low_intensity_duration"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" />
|
||||||
|
|
||||||
|
<com.wbrawner.trainterval.DurationPicker
|
||||||
|
android:id="@+id/lowIntensityDuration"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/high_intensity_duration"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" />
|
||||||
|
|
||||||
|
<com.wbrawner.trainterval.DurationPicker
|
||||||
|
android:id="@+id/highIntensityDuration"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/rest_duration"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" />
|
||||||
|
|
||||||
|
<com.wbrawner.trainterval.DurationPicker
|
||||||
|
android:id="@+id/restDuration"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/cool_down_duration"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" />
|
||||||
|
|
||||||
|
<com.wbrawner.trainterval.DurationPicker
|
||||||
|
android:id="@+id/coolDownDuration"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/sets"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" />
|
||||||
|
|
||||||
|
<NumberPicker
|
||||||
|
android:id="@+id/timerSets"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/repeat"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" />
|
||||||
|
|
||||||
|
<NumberPicker
|
||||||
|
android:id="@+id/timerRepeat"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/saveButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/save" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/error"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appBarLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="#00000000"
|
||||||
|
android:clipChildren="false"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:elevation="0dp"
|
||||||
|
app:elevation="0dp">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:background="@drawable/background_rounded_corners"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
|
app:title="@string/app_name" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
72
app/src/main/res/layout/fragment_timer_list.xml
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
|
android:clipChildren="false"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context="com.wbrawner.trainterval.timerlist.TimerListFragment">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/timerList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipChildren="false"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:layout_marginTop="-90dp"
|
||||||
|
android:paddingTop="90dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/error"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:text="An error has occurred"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/addTimerButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:src="@drawable/ic_add"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appBarLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="#00000000"
|
||||||
|
android:clipChildren="false"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:elevation="0dp"
|
||||||
|
app:elevation="0dp">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:background="@drawable/background_rounded_corners"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
|
app:title="@string/app_name" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 16 KiB |
34
app/src/main/res/navigation/nav_graph.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/nav_graph"
|
||||||
|
app:startDestination="@id/timerListFragment">
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/timerListFragment"
|
||||||
|
android:name="com.wbrawner.trainterval.timerlist.TimerListFragment"
|
||||||
|
android:label="fragment_timer_list"
|
||||||
|
tools:layout="@layout/fragment_timer_list" >
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_timerListFragment_to_activeTimerFragment"
|
||||||
|
app:destination="@id/activeTimerFragment" />
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_timerListFragment_to_timerFormFragment"
|
||||||
|
app:destination="@id/timerFormFragment" />
|
||||||
|
</fragment>
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/activeTimerFragment"
|
||||||
|
android:name="com.wbrawner.trainterval.activetimer.ActiveTimerFragment"
|
||||||
|
android:label="fragment_active_timer"
|
||||||
|
tools:layout="@layout/fragment_active_timer" >
|
||||||
|
<argument
|
||||||
|
android:name="timerId"
|
||||||
|
app:argType="long" />
|
||||||
|
</fragment>
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/timerFormFragment"
|
||||||
|
android:name="com.wbrawner.trainterval.timerform.TimerFormFragment"
|
||||||
|
android:label="fragment_timer_form"
|
||||||
|
tools:layout="@layout/fragment_timer_form" />
|
||||||
|
</navigation>
|
9
app/src/main/res/values/colors.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorPrimary">#6200EE</color>
|
||||||
|
<color name="colorPrimaryDark">#3700B3</color>
|
||||||
|
<color name="colorAccent">#03DAC5</color>
|
||||||
|
<color name="colorOnSurface">#111111</color>
|
||||||
|
<color name="colorSurface">#FFFFFF</color>
|
||||||
|
<color name="colorSurfaceStroke">#F1F1F1</color>
|
||||||
|
</resources>
|
21
app/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">Trainterval</string>
|
||||||
|
<string name="timer_name">Timer Name</string>
|
||||||
|
<string name="timer_description">Timer Description</string>
|
||||||
|
<string name="low_intensity_duration">Low Intensity Duration</string>
|
||||||
|
<string name="high_intensity_duration">High Intensity Duration</string>
|
||||||
|
<string name="save">Save</string>
|
||||||
|
<string name="sets">Sets</string>
|
||||||
|
<string name="cycles">Cycles</string>
|
||||||
|
<string name="warm_up_duration">Warm-Up Duration</string>
|
||||||
|
<string name="cool_down_duration">Cool-Down Duration</string>
|
||||||
|
<string name="repeat">Repeat</string>
|
||||||
|
<string name="timer_save_success">Successfully saved \'%1$s\' timer</string>
|
||||||
|
<string name="duration_separator">:</string>
|
||||||
|
<string name="skip_previous">Skip Previous</string>
|
||||||
|
<string name="skip_next">Skip Next</string>
|
||||||
|
<string name="start_timer">Start Timer</string>
|
||||||
|
<string name="rest_duration">Rest Duration</string>
|
||||||
|
<string name="title_item_list">Items</string>
|
||||||
|
<string name="title_item_detail">Item Detail</string>
|
||||||
|
</resources>
|
23
app/src/main/res/values/styles.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
|
<item name="android:statusBarColor">?android:windowBackground</item>
|
||||||
|
<item name="statusBarBackground">?android:windowBackground</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.NoActionBar">
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
|
|
||||||
|
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
|
|
||||||
|
</resources>
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.wbrawner.trainterval
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
fun addition_isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2)
|
||||||
|
}
|
||||||
|
}
|
29
build.gradle
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.3.70'
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:4.0.0'
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task clean(type: Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
21
gradle.properties
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx1536m
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# 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
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app's APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=true
|
||||||
|
# Automatically convert third-party libraries to use AndroidX
|
||||||
|
android.enableJetifier=true
|
||||||
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
|
kotlin.code.style=official
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#Sat Mar 28 18:33:36 MST 2020
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-rc-1-all.zip
|
172
gradlew
vendored
Executable file
|
@ -0,0 +1,172 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
84
gradlew.bat
vendored
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
2
settings.gradle
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
rootProject.name='Interval Timer'
|
||||||
|
include ':app'
|