From 73c44d316d2c7cc87685cd87c5ed5dc402f54952 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:21:16 +0100 Subject: [PATCH 01/35] Update .gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index d306261..ce3b67a 100644 --- a/.gitignore +++ b/.gitignore @@ -82,3 +82,8 @@ lint/outputs/ lint/tmp/ # lint/reports/ app/src/main/res/values/api_keys.xml +.idea/compiler.xml +.idea/compiler.xml +.idea/compiler.xml +.idea/jarRepositories.xml +.idea/misc.xml From abeb0f5c45726ecbbed50f68f50bb17eefc45588 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:21:31 +0100 Subject: [PATCH 02/35] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ce3b67a..90c9579 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,5 @@ app/src/main/res/values/api_keys.xml .idea/compiler.xml .idea/jarRepositories.xml .idea/misc.xml +app/build.gradle +.idea/misc.xml From 71dd92efa9dbbcc6146b373a561de22f767bfd1a Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:21:40 +0100 Subject: [PATCH 03/35] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 90c9579..7cadcde 100644 --- a/.gitignore +++ b/.gitignore @@ -89,3 +89,4 @@ app/src/main/res/values/api_keys.xml .idea/misc.xml app/build.gradle .idea/misc.xml +.idea/misc.xml From 86c7ee3a19aa9df24dbb8ec6d09da8c2beff093e Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:21:53 +0100 Subject: [PATCH 04/35] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7cadcde..0cb68cf 100644 --- a/.gitignore +++ b/.gitignore @@ -90,3 +90,4 @@ app/src/main/res/values/api_keys.xml app/build.gradle .idea/misc.xml .idea/misc.xml +.idea/misc.xml From c014291f150827409cade4ccce4b6383c3727e47 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:22:48 +0100 Subject: [PATCH 05/35] update dependencies and gradle version --- app/build.gradle | 18 +++++++++--------- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 100b66d..47fd6fc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,10 +38,10 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.core:core-ktx:1.2.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' // Sentry Tracking implementation 'io.sentry:sentry-android-core:2.0.2' @@ -52,13 +52,13 @@ dependencies { // Coroutines implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0" implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2' // testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.0-RC2' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + testImplementation 'junit:junit:4.13.1' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' /** * This library helps to automate some parts of the USB serial connection. diff --git a/build.gradle b/build.gradle index c7f904f..41ced99 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.72' + ext.kotlin_version = '1.4.21' ext.koin_version = '2.1.5' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.6.3' + classpath 'com.android.tools.build:gradle:4.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.koin:koin-gradle-plugin:$koin_version" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8bb656d..fdc19d7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Mar 26 09:16:25 CET 2020 +#Sun Jan 24 09:15:57 CET 2021 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip From 825b8ea03131ac1a806615c959653a272c521d81 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:22:59 +0100 Subject: [PATCH 06/35] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0cb68cf..b61bf67 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,4 @@ app/build.gradle .idea/misc.xml .idea/misc.xml .idea/misc.xml +.idea/misc.xml From 398249cd573b77a5e28a0d813fb15e5cfdf77eec Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:26:58 +0100 Subject: [PATCH 07/35] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b61bf67..c3075a9 100644 --- a/.gitignore +++ b/.gitignore @@ -92,3 +92,5 @@ app/build.gradle .idea/misc.xml .idea/misc.xml .idea/misc.xml +.idea/misc.xml +.idea/.name From 667de830112e1d8442d4d113e204620f80921555 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:33:25 +0100 Subject: [PATCH 08/35] added a new step to hopefully run the ui tests on macOS --- .github/workflows/android.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 7ec0147..e2495eb 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -19,3 +19,17 @@ jobs: java-version: 1.8 - name: Build with Gradle run: ./gradlew build + + test: + runs-on: macOS-latest + steps: + - name: checkout + uses: actions/checkout@v1 + with: + fetch-depth: 1 + + - name: run tests + uses: reactivecircus/android-emulator-runner@v1 + with: + api-level: 29 + script: ./gradlew connectedCheck From cefedcb3eb17d08fc541e12d130b5fc6b06d08d5 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:41:36 +0100 Subject: [PATCH 09/35] for testing: run actions on every push regardless of the branch --- .github/workflows/android.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index e2495eb..4d2694b 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,10 +1,9 @@ name: Android CI on: - push: - branches: [ master ] + push pull_request: - branches: [ master ] + branches: [ main ] jobs: build: From e5ffa8aa33a1579ac51a4d9a048d99ed2d92b33a Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:43:39 +0100 Subject: [PATCH 10/35] hopefully run actions on every push --- .github/workflows/android.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 4d2694b..9205220 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,9 +1,6 @@ name: Android CI -on: - push - pull_request: - branches: [ main ] +on: [push] jobs: build: From 84ded408dfec2114023c853c1aa8c04151886853 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:48:27 +0100 Subject: [PATCH 11/35] temporarily ignore sentry --- app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5a26023..baad8f5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,7 +16,7 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> - + From 11adb493f9b54ec9916ad5d9fc63b17550525667 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:56:34 +0100 Subject: [PATCH 12/35] Update gradle-wrapper.properties --- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fdc19d7..94d93d5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Jan 24 09:15:57 CET 2021 +#Sun Jan 24 09:56:06 CET 2021 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip From 8487e5a0d839778d4be0f3f6e87afb9eddadbb40 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 09:56:48 +0100 Subject: [PATCH 13/35] added google truth for simple assertions --- app/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/app/build.gradle b/app/build.gradle index 47fd6fc..bf18dca 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,6 +57,7 @@ dependencies { // testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.0-RC2' testImplementation 'junit:junit:4.13.1' + testImplementation "com.google.truth:truth:1.1.2" androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' From 630e1c1ee78045add9739d2caae85d6d338ebdde Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 10:05:34 +0100 Subject: [PATCH 14/35] sentry needs empty dsn string to be disabled --- app/src/main/AndroidManifest.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index baad8f5..f89a8e9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,7 +16,8 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> - + + From d2498f0ef1d9eb340d9b82e76f1eb53116b7da58 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 10:05:51 +0100 Subject: [PATCH 15/35] update koin version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 41ced99..0005aef 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ buildscript { ext.kotlin_version = '1.4.21' - ext.koin_version = '2.1.5' + ext.koin_version = '2.2.0' repositories { google() jcenter() From d7f9d97a5528ca954a2bc27a897b1b67d9ce25e6 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 10:06:00 +0100 Subject: [PATCH 16/35] Create OutputTextTest.kt --- .../usbterminal/model/OutputTextTest.kt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/src/test/java/org/kabiri/android/usbterminal/model/OutputTextTest.kt diff --git a/app/src/test/java/org/kabiri/android/usbterminal/model/OutputTextTest.kt b/app/src/test/java/org/kabiri/android/usbterminal/model/OutputTextTest.kt new file mode 100644 index 0000000..de3a2e9 --- /dev/null +++ b/app/src/test/java/org/kabiri/android/usbterminal/model/OutputTextTest.kt @@ -0,0 +1,33 @@ +package org.kabiri.android.usbterminal.model + +import com.google.common.truth.Truth.assertThat +import org.junit.Test + +class OutputTextTest { + + @Test + fun testFields() { + val dummyText = "does not matter" + + var sut = OutputText( + text = dummyText, + type = OutputText.OutputType.TYPE_NORMAL + ) + assertThat(sut.text).isEqualTo(dummyText) + assertThat(sut.type).isEqualTo(OutputText.OutputType.TYPE_NORMAL) + + sut = OutputText( + text = dummyText, + type = OutputText.OutputType.TYPE_INFO + ) + assertThat(sut.text).isEqualTo(dummyText) + assertThat(sut.type).isEqualTo(OutputText.OutputType.TYPE_INFO) + + sut = OutputText( + text = dummyText, + type = OutputText.OutputType.TYPE_ERROR + ) + assertThat(sut.text).isEqualTo(dummyText) + assertThat(sut.type).isEqualTo(OutputText.OutputType.TYPE_ERROR) + } +} \ No newline at end of file From ac104d2533494b72e6a7346cabb7334f84c910e8 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 10:19:47 +0100 Subject: [PATCH 17/35] added instrumented testing libraries --- app/build.gradle | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index bf18dca..229cc20 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -56,10 +56,18 @@ dependencies { implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2' // testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.0-RC2' + // unit test libs testImplementation 'junit:junit:4.13.1' testImplementation "com.google.truth:truth:1.1.2" + + // instrumented test libs androidTestImplementation 'androidx.test.ext:junit:1.1.2' + // Espresso androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + // Hamcrest for view matching + androidTestImplementation 'org.hamcrest:hamcrest-library:1.3' + androidTestImplementation 'androidx.test:runner:1.3.0' + androidTestImplementation 'androidx.test:rules:1.3.0' /** * This library helps to automate some parts of the USB serial connection. From 16b89027d35863ccb1ec4d912013ab60c9969006 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 10:20:17 +0100 Subject: [PATCH 18/35] removed the example test files --- .../usbterminal/ExampleInstrumentedTest.kt | 24 ------------------- .../android/usbterminal/ExampleUnitTest.kt | 17 ------------- 2 files changed, 41 deletions(-) delete mode 100644 app/src/androidTest/java/org/kabiri/android/usbterminal/ExampleInstrumentedTest.kt delete mode 100644 app/src/test/java/org/kabiri/android/usbterminal/ExampleUnitTest.kt diff --git a/app/src/androidTest/java/org/kabiri/android/usbterminal/ExampleInstrumentedTest.kt b/app/src/androidTest/java/org/kabiri/android/usbterminal/ExampleInstrumentedTest.kt deleted file mode 100644 index 5c85d7e..0000000 --- a/app/src/androidTest/java/org/kabiri/android/usbterminal/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package org.kabiri.android.usbterminal - -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("org.kabiri.android.usbterminal", appContext.packageName) - } -} diff --git a/app/src/test/java/org/kabiri/android/usbterminal/ExampleUnitTest.kt b/app/src/test/java/org/kabiri/android/usbterminal/ExampleUnitTest.kt deleted file mode 100644 index 90abd69..0000000 --- a/app/src/test/java/org/kabiri/android/usbterminal/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package org.kabiri.android.usbterminal - -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) - } -} From 8b79840c03b6f84f83c40e12660be3076f5da7a2 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 10:20:41 +0100 Subject: [PATCH 19/35] added a basic instrumented test to check the main views are displayed --- .../android/usbterminal/MainActivityTest.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/src/androidTest/java/org/kabiri/android/usbterminal/MainActivityTest.kt diff --git a/app/src/androidTest/java/org/kabiri/android/usbterminal/MainActivityTest.kt b/app/src/androidTest/java/org/kabiri/android/usbterminal/MainActivityTest.kt new file mode 100644 index 0000000..f49d7fb --- /dev/null +++ b/app/src/androidTest/java/org/kabiri/android/usbterminal/MainActivityTest.kt @@ -0,0 +1,23 @@ +package org.kabiri.android.usbterminal + +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.ext.junit.rules.ActivityScenarioRule +import org.junit.Rule +import org.junit.Test + + +class MainActivityTest { + + @get:Rule + var rule = ActivityScenarioRule(MainActivity::class.java) + + @Test + fun checkUiViewsAreDisplayed() { + onView(withId(R.id.tvOutput)).check(matches(isDisplayed())) + onView(withId(R.id.btEnter)).check(matches(isDisplayed())) + onView(withId(R.id.etInput)).check(matches(isDisplayed())) + } +} \ No newline at end of file From 2de727232a44f5727ca93da103584a50fcfa6ed6 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 10:32:05 +0100 Subject: [PATCH 20/35] upgrade target sdk version to 30 --- app/build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 229cc20..cbbd574 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,6 @@ repositories { } android { - compileSdkVersion 29 - buildToolsVersion "29.0.3" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -19,7 +17,7 @@ android { defaultConfig { applicationId "org.kabiri.android.usbterminal" minSdkVersion 23 - targetSdkVersion 29 + targetSdkVersion 30 versionCode 7 versionName "0.7.0" From 8d295581476a0d091498218cf9e2ffc769f19ad0 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 10:32:39 +0100 Subject: [PATCH 21/35] Update android.yml --- .github/workflows/android.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 9205220..3cadf14 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -3,10 +3,9 @@ name: Android CI on: [push] jobs: - build: + build: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - name: set up JDK 1.8 @@ -16,16 +15,13 @@ jobs: - name: Build with Gradle run: ./gradlew build - test: + ui-test: runs-on: macOS-latest steps: - name: checkout - uses: actions/checkout@v1 - with: - fetch-depth: 1 - + uses: actions/checkout@v2 - name: run tests - uses: reactivecircus/android-emulator-runner@v1 + uses: reactivecircus/android-emulator-runner@v2 with: api-level: 29 script: ./gradlew connectedCheck From 3308a13fecb6bc6cb6dfe285bc307698047a8669 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 10:35:37 +0100 Subject: [PATCH 22/35] set compile sdk version to 30 --- app/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/app/build.gradle b/app/build.gradle index cbbd574..b4757a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,6 +8,7 @@ repositories { } android { + compileSdkVersion 30 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 From d6d59597fedfa44791315f0b060fdc59d8794554 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 10:42:13 +0100 Subject: [PATCH 23/35] activate view binding in the project --- app/build.gradle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index b4757a2..f354c54 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,5 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' apply plugin: 'koin' repositories { @@ -32,6 +31,10 @@ android { } } + buildFeatures { + viewBinding true + } + } dependencies { From 7ed46342f584ccf6105c1fb6232646262f45b77d Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 10:42:38 +0100 Subject: [PATCH 24/35] use viewbinding to access view items --- .../android/usbterminal/MainActivity.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/kabiri/android/usbterminal/MainActivity.kt b/app/src/main/java/org/kabiri/android/usbterminal/MainActivity.kt index 43f3a63..dd5d966 100644 --- a/app/src/main/java/org/kabiri/android/usbterminal/MainActivity.kt +++ b/app/src/main/java/org/kabiri/android/usbterminal/MainActivity.kt @@ -8,9 +8,7 @@ import android.view.Menu import android.view.MenuInflater import android.view.MenuItem import androidx.appcompat.app.AppCompatActivity -import androidx.lifecycle.Observer -import io.sentry.core.Sentry -import kotlinx.android.synthetic.main.activity_main.* +import org.kabiri.android.usbterminal.databinding.ActivityMainBinding import org.kabiri.android.usbterminal.viewmodel.MainActivityViewModel import org.koin.android.viewmodel.ext.android.viewModel @@ -22,34 +20,36 @@ class MainActivity : AppCompatActivity() { } private val viewModel: MainActivityViewModel by viewModel() + private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + setContentView(R.layout.activity_main) + binding = ActivityMainBinding.inflate(layoutInflater) // make the text view scrollable: - tvOutput.movementMethod = ScrollingMovementMethod() + binding.tvOutput.movementMethod = ScrollingMovementMethod() // open the device and port when the permission is granted by user. - viewModel.getGrantedDevice().observe(this, Observer { device -> + viewModel.getGrantedDevice().observe(this, { device -> viewModel.openDeviceAndPort(device) }) - viewModel.getLiveOutput().observe(this, Observer { + viewModel.getLiveOutput().observe(this, { val spannable = SpannableString(it.text) spannable.setSpan( it.getAppearance(this), 0, it.text.length, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE) - tvOutput.append(it.text) + binding.tvOutput.append(it.text) }) // send the command to device when the button is clicked. - btEnter.setOnClickListener { - val input = etInput.text.toString() + binding.btEnter.setOnClickListener { + val input = binding.etInput.text.toString() if (viewModel.serialWrite(input)) - etInput.setText("") // clear the terminal input. + binding.etInput.setText("") // clear the terminal input. else Log.e(TAG, "The message was not sent to Arduino") } } From 4021e988f7920549ae21576fdb2f6e918193a386 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 11:08:56 +0100 Subject: [PATCH 25/35] added fastlane to project to automate future distributions --- Gemfile | 3 + Gemfile.lock | 184 ++++++++++++++++++++++++++++++++++++++++++++++ fastlane/Appfile | 2 + fastlane/Fastfile | 38 ++++++++++ 4 files changed, 227 insertions(+) create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 fastlane/Appfile create mode 100644 fastlane/Fastfile diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..adc90d9 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gem "fastlane" \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..40f07ae --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,184 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.3) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + artifactory (3.0.15) + atomos (0.1.3) + aws-eventstream (1.1.0) + aws-partitions (1.416.0) + aws-sdk-core (3.111.0) + aws-eventstream (~> 1, >= 1.0.2) + aws-partitions (~> 1, >= 1.239.0) + aws-sigv4 (~> 1.1) + jmespath (~> 1.0) + aws-sdk-kms (1.41.0) + aws-sdk-core (~> 3, >= 3.109.0) + aws-sigv4 (~> 1.1) + aws-sdk-s3 (1.87.0) + aws-sdk-core (~> 3, >= 3.109.0) + aws-sdk-kms (~> 1) + aws-sigv4 (~> 1.1) + aws-sigv4 (1.2.2) + aws-eventstream (~> 1, >= 1.0.2) + babosa (1.0.4) + claide (1.0.3) + colored (1.2) + colored2 (3.1.2) + commander-fastlane (4.4.6) + highline (~> 1.7.2) + declarative (0.0.20) + declarative-option (0.1.0) + digest-crc (0.6.3) + rake (>= 12.0.0, < 14.0.0) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.7.6) + emoji_regex (3.2.1) + excon (0.78.1) + faraday (1.3.0) + faraday-net_http (~> 1.0) + multipart-post (>= 1.2, < 3) + ruby2_keywords + faraday-cookie_jar (0.0.7) + faraday (>= 0.8.0) + http-cookie (~> 1.0.0) + faraday-net_http (1.0.1) + faraday_middleware (1.0.0) + faraday (~> 1.0) + fastimage (2.2.1) + fastlane (2.172.0) + CFPropertyList (>= 2.3, < 4.0.0) + addressable (>= 2.3, < 3.0.0) + artifactory (~> 3.0) + aws-sdk-s3 (~> 1.0) + babosa (>= 1.0.3, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) + colored + commander-fastlane (>= 4.4.6, < 5.0.0) + dotenv (>= 2.1.1, < 3.0.0) + emoji_regex (>= 0.1, < 4.0) + excon (>= 0.71.0, < 1.0.0) + faraday (~> 1.0) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 1.0) + fastimage (>= 2.1.0, < 3.0.0) + gh_inspector (>= 1.1.2, < 2.0.0) + google-api-client (>= 0.37.0, < 0.39.0) + google-cloud-storage (>= 1.15.0, < 2.0.0) + highline (>= 1.7.2, < 2.0.0) + json (< 3.0.0) + jwt (>= 2.1.0, < 3) + mini_magick (>= 4.9.4, < 5.0.0) + multipart-post (~> 2.0.0) + plist (>= 3.1.0, < 4.0.0) + rubyzip (>= 2.0.0, < 3.0.0) + security (= 0.1.3) + simctl (~> 1.6.3) + slack-notifier (>= 2.0.0, < 3.0.0) + terminal-notifier (>= 2.0.0, < 3.0.0) + terminal-table (>= 1.4.5, < 2.0.0) + tty-screen (>= 0.6.3, < 1.0.0) + tty-spinner (>= 0.8.0, < 1.0.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 1.13.0, < 2.0.0) + xcpretty (~> 0.3.0) + xcpretty-travis-formatter (>= 0.0.3) + gh_inspector (1.1.3) + google-api-client (0.38.0) + addressable (~> 2.5, >= 2.5.1) + googleauth (~> 0.9) + httpclient (>= 2.8.1, < 3.0) + mini_mime (~> 1.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.0) + signet (~> 0.12) + google-cloud-core (1.5.0) + google-cloud-env (~> 1.0) + google-cloud-errors (~> 1.0) + google-cloud-env (1.4.0) + faraday (>= 0.17.3, < 2.0) + google-cloud-errors (1.0.1) + google-cloud-storage (1.29.2) + addressable (~> 2.5) + digest-crc (~> 0.4) + google-api-client (~> 0.33) + google-cloud-core (~> 1.2) + googleauth (~> 0.9) + mini_mime (~> 1.0) + googleauth (0.14.0) + faraday (>= 0.17.3, < 2.0) + jwt (>= 1.4, < 3.0) + memoist (~> 0.16) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (~> 0.14) + highline (1.7.10) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + jmespath (1.4.0) + json (2.5.1) + jwt (2.2.2) + memoist (0.16.2) + mini_magick (4.11.0) + mini_mime (1.0.2) + multi_json (1.15.0) + multipart-post (2.0.0) + nanaimo (0.3.0) + naturally (2.2.0) + os (1.1.1) + plist (3.6.0) + public_suffix (4.0.6) + rake (13.0.3) + representable (3.0.4) + declarative (< 0.1.0) + declarative-option (< 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) + rouge (2.0.7) + ruby2_keywords (0.0.2) + rubyzip (2.3.0) + security (0.1.3) + signet (0.14.0) + addressable (~> 2.3) + faraday (>= 0.17.3, < 2.0) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simctl (1.6.8) + CFPropertyList + naturally + slack-notifier (2.3.2) + terminal-notifier (2.0.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + tty-cursor (0.7.1) + tty-screen (0.8.1) + tty-spinner (0.9.3) + tty-cursor (~> 0.7) + uber (0.1.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.7-x64-mingw32) + unicode-display_width (1.7.0) + word_wrap (1.0.0) + xcodeproj (1.19.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.3.0) + xcpretty (0.3.0) + rouge (~> 2.0.7) + xcpretty-travis-formatter (1.0.1) + xcpretty (~> 0.2, >= 0.0.7) + +PLATFORMS + x64-mingw32 + +DEPENDENCIES + fastlane + +BUNDLED WITH + 2.1.4 diff --git a/fastlane/Appfile b/fastlane/Appfile new file mode 100644 index 0000000..235d891 --- /dev/null +++ b/fastlane/Appfile @@ -0,0 +1,2 @@ +json_key_file("") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one +package_name("org.kabiri.android.usbterminal") # e.g. com.krausefx.app diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 0000000..dc1afef --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,38 @@ +# This file contains the fastlane.tools configuration +# You can find the documentation at https://docs.fastlane.tools +# +# For a list of all available actions, check out +# +# https://docs.fastlane.tools/actions +# +# For a list of all available plugins, check out +# +# https://docs.fastlane.tools/plugins/available-plugins +# + +# Uncomment the line if you want fastlane to automatically update itself +# update_fastlane + +default_platform(:android) + +platform :android do + desc "Runs all the tests" + lane :test do + gradle(task: "testDebugUnitTest --stacktrace") + end + + desc "Submit a new Beta Build to Crashlytics Beta" + lane :beta do + gradle(task: "clean assembleRelease") + crashlytics + + # sh "your_script.sh" + # You can also use other beta testing services here + end + + desc "Deploy a new version to the Google Play" + lane :deploy do + gradle(task: "clean assembleRelease") + upload_to_play_store + end +end From 7432651ca5f96eafb6c4da78521ba0f65c597aca Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 11:09:35 +0100 Subject: [PATCH 26/35] running unit tests using fastlane; running gradlelint; upload artifacts to github for test reports --- .github/workflows/android.yml | 43 +++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 3cadf14..9cd386f 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -4,16 +4,45 @@ on: [push] jobs: - build: + unit-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Build with Gradle - run: ./gradlew build + - name: set up Ruby to install fastlane + - uses: actions/setup-ruby@v1 + - with: + ruby-version: '2.7' +# - name: set up JDK 1.8 +# uses: actions/setup-java@v1 +# with: +# java-version: 1.8 + - name: setup fastlane + run: bundle install + - name: distribute to firebase + run: bundle exec fastlane android run_unit_tests + - name: run unit tests + run: bundle exec fastlane android test + - name: Unit tests results + - uses: actions/upload-artifact@v1 + - with: + name: unit-test-results + path: app/build/reports/tests/testDebugUnitTest/index.html + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Lint + run: bash ./gradlew lint --stacktrace + - name: Lint results + uses: actions/upload-artifact@v1 + with: + name: app + path: app/build/reports/lint-results-debug.html ui-test: runs-on: macOS-latest From 700432db643218543325b12071279fec0d953738 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 11:11:08 +0100 Subject: [PATCH 27/35] hopefully fix the config file --- .github/workflows/android.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 9cd386f..4900cd5 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -10,8 +10,8 @@ jobs: - uses: actions/checkout@v2 - name: set up Ruby to install fastlane - uses: actions/setup-ruby@v1 - - with: - ruby-version: '2.7' + with: + ruby-version: '2.7' # - name: set up JDK 1.8 # uses: actions/setup-java@v1 # with: @@ -24,7 +24,7 @@ jobs: run: bundle exec fastlane android test - name: Unit tests results - uses: actions/upload-artifact@v1 - - with: + with: name: unit-test-results path: app/build/reports/tests/testDebugUnitTest/index.html From 6c562ac09d0215f63a31be993d7a8afd28d7bd4c Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 11:13:08 +0100 Subject: [PATCH 28/35] Update android.yml --- .github/workflows/android.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 4900cd5..496924f 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -9,21 +9,21 @@ jobs: steps: - uses: actions/checkout@v2 - name: set up Ruby to install fastlane - - uses: actions/setup-ruby@v1 + uses: actions/setup-ruby@v1 with: ruby-version: '2.7' -# - name: set up JDK 1.8 -# uses: actions/setup-java@v1 -# with: -# java-version: 1.8 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 - name: setup fastlane - run: bundle install + run: bundle install - name: distribute to firebase - run: bundle exec fastlane android run_unit_tests + run: bundle exec fastlane android run_unit_tests - name: run unit tests - run: bundle exec fastlane android test + run: bundle exec fastlane android test - name: Unit tests results - - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v1 with: name: unit-test-results path: app/build/reports/tests/testDebugUnitTest/index.html From 2c9ad451e91725dbc7ddb57cb0f48f985dba5cd6 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 11:15:36 +0100 Subject: [PATCH 29/35] hopefully fixed fastlane config to run android unit tests --- .github/workflows/android.yml | 2 +- fastlane/Fastfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 496924f..d7c077c 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -18,7 +18,7 @@ jobs: java-version: 1.8 - name: setup fastlane run: bundle install - - name: distribute to firebase + - name: run unit tests run: bundle exec fastlane android run_unit_tests - name: run unit tests run: bundle exec fastlane android test diff --git a/fastlane/Fastfile b/fastlane/Fastfile index dc1afef..1e03a18 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -17,7 +17,7 @@ default_platform(:android) platform :android do desc "Runs all the tests" - lane :test do + lane :run_unit_tests do gradle(task: "testDebugUnitTest --stacktrace") end From 893ba0f49c69f347ad776b17c709f8d19da32c4e Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 11:17:38 +0100 Subject: [PATCH 30/35] removed the extra step from unit-tests --- .github/workflows/android.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index d7c077c..ba6c4cb 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -20,8 +20,6 @@ jobs: run: bundle install - name: run unit tests run: bundle exec fastlane android run_unit_tests - - name: run unit tests - run: bundle exec fastlane android test - name: Unit tests results uses: actions/upload-artifact@v1 with: From 240dfd6e0ae36080987a35caed7ace3008e5a21d Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 11:19:57 +0100 Subject: [PATCH 31/35] fix the lint results path --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index ba6c4cb..f7d8181 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -40,7 +40,7 @@ jobs: uses: actions/upload-artifact@v1 with: name: app - path: app/build/reports/lint-results-debug.html + path: app/build/reports/lint-results.html ui-test: runs-on: macOS-latest From 4ff336516749a6f3e74411502bf7b9a3bc07ae36 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 11:28:17 +0100 Subject: [PATCH 32/35] add the CI badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c74bca..5274657 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ # arduino-usb-terminal Terminal-like app to send commands to Arduino through USB +![Android CI](https://github.com/k4biri/arduino-usb-terminal/workflows/Android%20CI/badge.svg) - This app simplifies testing your Arduino components that work with direct usb commands by giving you the ability to send custom commands and view the returned message from your Arduino device. This is being done as a hobby, and for experimenting, so probably there might be some flaws; As an example, the vendor ID of Arduino is hardcoded to only work with Arduino devices, but this is my use case and please feel free to change it to match your needs. From c70d03dcb262e3cc57eab19a5a733de967980be9 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 11:30:36 +0100 Subject: [PATCH 33/35] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c3075a9..92da779 100644 --- a/.gitignore +++ b/.gitignore @@ -94,3 +94,4 @@ app/build.gradle .idea/misc.xml .idea/misc.xml .idea/.name +.idea/codeStyles/Project.xml From 1c4cb37b461becb28760dbd630527cd9898dcb46 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 11:30:40 +0100 Subject: [PATCH 34/35] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5274657..af79857 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ # arduino-usb-terminal Terminal-like app to send commands to Arduino through USB + ![Android CI](https://github.com/k4biri/arduino-usb-terminal/workflows/Android%20CI/badge.svg) From e939d63c38a9c2004f9e4a4ddcfbb1b161b53b93 Mon Sep 17 00:00:00 2001 From: Ali Kabiri Date: Sun, 24 Jan 2021 11:41:49 +0100 Subject: [PATCH 35/35] bump version code and version number --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f354c54..0a8ba7c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ android { applicationId "org.kabiri.android.usbterminal" minSdkVersion 23 targetSdkVersion 30 - versionCode 7 - versionName "0.7.0" + versionCode 8 + versionName "0.7.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" }