Skip to content

Commit c1cfcd4

Browse files
authored
Merge pull request #22 from superus8r/develop
Prepare release 0.9.12
2 parents 139e076 + a7181ed commit c1cfcd4

File tree

10 files changed

+82
-37
lines changed

10 files changed

+82
-37
lines changed

.github/workflows/android.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ jobs:
77
unit-test:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v2
11-
- name: set up Ruby to install fastlane
12-
uses: actions/setup-ruby@v1
10+
- uses: actions/checkout@v3
11+
- uses: ruby/setup-ruby@v1
1312
with:
14-
ruby-version: '2.7'
13+
ruby-version: '3.0'
14+
bundler-cache: true
15+
1516
- name: set up JDK 11
1617
uses: actions/setup-java@v1
1718
with:

.idea/androidTestResultsUserPreferences.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ GEM
211211

212212
PLATFORMS
213213
universal-darwin-21
214+
universal-darwin-22
214215
x64-mingw32
216+
x86_64-linux
215217

216218
DEPENDENCIES
217219
fastlane

app/build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ android {
2222
applicationId "org.kabiri.android.usbterminal"
2323
minSdkVersion 23
2424
targetSdkVersion 33
25-
versionCode 10
26-
versionName "0.8.0"
25+
versionCode 13
26+
versionName "0.9.12"
2727
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2828
}
2929

@@ -64,7 +64,7 @@ private void loadKeyStore(Properties ksProp) {
6464
dependencies {
6565

6666
implementation fileTree(dir: 'libs', include: ['*.jar'])
67-
implementation 'androidx.appcompat:appcompat:1.5.1'
67+
implementation 'androidx.appcompat:appcompat:1.6.0'
6868
implementation 'androidx.core:core-ktx:1.9.0'
6969
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
7070

@@ -79,7 +79,7 @@ dependencies {
7979

8080
// Coroutines
8181
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
82-
implementation 'androidx.activity:activity-compose:1.6.0'
82+
implementation 'androidx.activity:activity-compose:1.6.1'
8383
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
8484
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
8585
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
@@ -96,15 +96,15 @@ dependencies {
9696
testImplementation "com.google.truth:truth:1.1.3"
9797

9898
// instrumented test libs
99-
androidTestImplementation 'androidx.test:core:1.5.0-alpha02'
100-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
101-
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3'
99+
androidTestImplementation 'androidx.test:core:1.5.0'
100+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
101+
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'
102102
// Espresso
103-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
103+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
104104
// Hamcrest for view matching
105105
androidTestImplementation 'org.hamcrest:hamcrest-library:2.2'
106-
androidTestImplementation 'androidx.test:runner:1.4.0'
107-
androidTestImplementation 'androidx.test:rules:1.4.0'
106+
androidTestImplementation 'androidx.test:runner:1.5.2'
107+
androidTestImplementation 'androidx.test:rules:1.5.0'
108108

109109
/**
110110
* This library helps to automate some parts of the USB serial connection.

app/src/main/java/org/kabiri/android/usbterminal/MainActivity.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import android.widget.TextView
1313
import androidx.activity.viewModels
1414
import androidx.appcompat.app.AppCompatActivity
1515
import dagger.hilt.android.AndroidEntryPoint
16+
import org.kabiri.android.usbterminal.extensions.scrollToLastLine
1617
import org.kabiri.android.usbterminal.viewmodel.MainActivityViewModel
1718

1819
@AndroidEntryPoint
@@ -51,7 +52,10 @@ class MainActivity : AppCompatActivity() {
5152
}
5253

5354
viewModel.output.observe(this) {
54-
tvOutput.apply { text = it }
55+
tvOutput.apply {
56+
text = it
57+
scrollToLastLine()
58+
}
5559
}
5660

5761
// send the command to device when the button is clicked.

app/src/main/java/org/kabiri/android/usbterminal/arduino/ArduinoHelper.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ class ArduinoHelper
7777
R.string.helper_error_connection_not_ready_to_close
7878
)
7979
)
80-
_liveErrorOutput.postValue(e.message)
80+
_liveErrorOutput.postValue("${e.localizedMessage}\n")
8181
} catch (e: Exception) {
8282
_liveErrorOutput.postValue(
8383
context.getString(
8484
R.string.helper_error_connection_failed_to_close
8585
)
8686
)
87-
_liveErrorOutput.postValue(e.message)
87+
_liveErrorOutput.postValue("${e.localizedMessage}\n")
8888
}
8989
}
9090

@@ -93,7 +93,8 @@ class ArduinoHelper
9393
context,
9494
0,
9595
Intent(Constants.ACTION_USB_PERMISSION),
96-
PendingIntent.FLAG_MUTABLE // it is necessary for connecting to the device.
96+
// it is necessary for connecting to the device.
97+
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
9798
)
9899
val filter = IntentFilter(Constants.ACTION_USB_PERMISSION)
99100
context.registerReceiver(arduinoPermReceiver, filter) // register the broadcast receiver
@@ -118,6 +119,14 @@ class ArduinoHelper
118119
} catch (e: IllegalStateException) {
119120
Log.e(TAG, "${e.message}")
120121
_liveErrorOutput.postValue(context.getString(R.string.helper_error_connection_closed_unexpectedly))
122+
} catch (e: NullPointerException) {
123+
Log.e(TAG, "${e.message}")
124+
_liveErrorOutput.postValue(context.getString(
125+
R.string.helper_error_connection_failed_to_open))
126+
} catch (e: Exception) {
127+
Log.e(TAG, "${e.message}")
128+
_liveErrorOutput.postValue(context.getString(
129+
R.string.helper_error_connection_failed_to_open_unknown))
121130
}
122131

123132
if (::serialPort.isInitialized)
@@ -164,7 +173,9 @@ class ArduinoHelper
164173
false
165174
}
166175
} catch (e: Exception) {
167-
_liveErrorOutput.postValue("${context.getString(R.string.helper_error_write_problem)} ${e.localizedMessage}")
176+
_liveErrorOutput.postValue(
177+
context.getString(R.string.helper_error_write_problem) +
178+
" \n${e.localizedMessage}\n")
168179
Log.e(TAG, "$e")
169180
false
170181
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.kabiri.android.usbterminal.extensions
2+
3+
import android.util.Log
4+
import android.widget.TextView
5+
6+
/**
7+
* Scroll the text view to last visible line.
8+
*/
9+
10+
private const val TAG = "TextViewExtensions"
11+
12+
fun TextView.scrollToLastLine() {
13+
try {
14+
if (this.text.isNotBlank()) {
15+
// find internal layout for the position of the final line and subtract the height
16+
val scrollAmount = this.layout.getLineTop(this.lineCount) - this.height
17+
// if no need scroll needed, scrollAmount will be <=0
18+
if (scrollAmount > 0) this.scrollTo(0, scrollAmount)
19+
else this.scrollTo(0, 0)
20+
}
21+
} catch (e: Exception) {
22+
Log.w(TAG, "Something went wrong when trying to autoscroll the output:\n${e.message}")
23+
}
24+
}

app/src/main/res/values/strings.xml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,23 @@
2020

2121
<!-- Messages -->
2222
<string name="helper_error_serial_port_is_null">Serial Port is null: The device might be disconnected.\n</string>
23-
<string name="helper_error_device_not_found">\nArduino Device not found (or the device might be a clone).</string>
24-
<string name="helper_error_connecting_anyway">\nConnecting anyway (may misbehave)…</string>
25-
<string name="helper_error_usb_devices_not_attached">\nNo USB devices are attached</string>
26-
<string name="helper_error_serial_connection_not_opened">\nPort not opened - There might be a problem with the serial connection to Arduino</string>
27-
<string name="helper_error_write_problem">Serial Write encountered an error:</string>
28-
<string name="helper_error_connection_closed_unexpectedly">Device connection was closed unexpectedly</string>
29-
<string name="helper_error_connection_not_ready_to_close">No device connection to close</string>
30-
<string name="helper_error_connection_failed_to_close">Device connection failed to close</string>
31-
<string name="helper_info_serial_connection_opened">\nSerial Connection Opened</string>
32-
<string name="helper_info_serial_connection_closed">\nSerial Connection Closed</string>
33-
<string name="helper_info_usb_permission_requested">Requested permission to access the USB device…</string>
34-
<string name="helper_info_checking_attached_usb_devices">\nChecking attached USB devices…</string>
23+
<string name="helper_error_device_not_found">Arduino Device not found (or the device might be a clone).\n</string>
24+
<string name="helper_error_connecting_anyway">Connecting anyway (may misbehave)…\n</string>
25+
<string name="helper_error_usb_devices_not_attached">No USB devices are attached\n</string>
26+
<string name="helper_error_serial_connection_not_opened">Port not opened - There might be a problem with the serial connection to Arduino\n</string>
27+
<string name="helper_error_write_problem">Serial Write encountered an error:\n</string>
28+
<string name="helper_error_connection_closed_unexpectedly">Device connection was closed unexpectedly\n</string>
29+
<string name="helper_error_connection_failed_to_open">Failed to open device connection. Please make sure the device is connected and the USB cable and the port are healthy.\n</string>
30+
<string name="helper_error_connection_failed_to_open_unknown">Failed to open device connection.\n</string>
31+
<string name="helper_error_connection_not_ready_to_close">No device connection to close\n</string>
32+
<string name="helper_error_connection_failed_to_close">Device connection failed to close\n</string>
33+
<string name="helper_info_serial_connection_opened">Serial Connection Opened\n</string>
34+
<string name="helper_info_serial_connection_closed">Serial Connection Closed\n</string>
35+
<string name="helper_info_usb_permission_requested">Requested permission to access the USB device…\n</string>
36+
<string name="helper_info_checking_attached_usb_devices">Checking attached USB devices…\n</string>
3537

36-
<string name="breceiver_info_usb_permission_granted">"\nPermission granted for: "</string>
37-
<string name="breceiver_error_usb_permission_denied">\npermission denied for device:</string>
38-
<string name="breceiver_info_device_attached">\nDevice attached</string>
39-
<string name="breceiver_info_device_detached">\nDevice detached</string>
38+
<string name="breceiver_info_usb_permission_granted">"Permission granted for: \n"</string>
39+
<string name="breceiver_error_usb_permission_denied">permission denied for device:\n</string>
40+
<string name="breceiver_info_device_attached">Device attached\n</string>
41+
<string name="breceiver_info_device_detached">Device detached\n</string>
4042
</resources>

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ buildscript {
1111
mavenCentral()
1212
}
1313
dependencies {
14-
classpath 'com.android.tools.build:gradle:7.3.0'
14+
classpath 'com.android.tools.build:gradle:7.4.0-rc01'
1515
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1616
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
1717
classpath 'com.google.gms:google-services:4.3.14'

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

0 commit comments

Comments
 (0)