Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require a log file in order to be able to connect. #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions app/src/main/java/crazydude/com/telemetry/ui/MapsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import crazydude.com.telemetry.service.DataService
import crazydude.com.telemetry.ui.viewmodels.MapsViewModel
import crazydude.com.telemetry.utils.DocumentLogFile
import crazydude.com.telemetry.utils.LogFile
import crazydude.com.telemetry.utils.NullOutputStream
import crazydude.com.telemetry.utils.StandardLogFile
import uk.co.deanwild.materialshowcaseview.MaterialShowcaseView
import java.io.File
Expand Down Expand Up @@ -888,7 +889,7 @@ class MapsActivity : AppCompatActivity() {

private fun connectToBluetoothDevice(device: BluetoothDevice, isBLE: Boolean) {
dataService?.let {
createLogFile()?.let { file ->
createLogFile().let { file ->
it.connect(device, file, isBLE)
}
}
Expand All @@ -899,7 +900,7 @@ class MapsActivity : AppCompatActivity() {
connection: UsbDeviceConnection
) {
dataService?.let {
createLogFile()?.let { file ->
createLogFile().let { file ->
it.connect(port, connection, file)
}
}
Expand Down Expand Up @@ -1144,9 +1145,9 @@ class MapsActivity : AppCompatActivity() {
}
}

private fun createLogFile(): OutputStream? {
var fileOutputStream: OutputStream? = null
private fun createLogFile(): OutputStream {
if (preferenceManager.isLoggingEnabled()) {
var fileOutputStream: OutputStream
val name = SimpleDateFormat("yyyy-MM-dd HH-mm-ss").format(Date())
if (!shouldUseStorageAPI()) {
val dir = Environment.getExternalStoragePublicDirectory("TelemetryLogs")
Expand All @@ -1167,7 +1168,7 @@ class MapsActivity : AppCompatActivity() {
return fileOutputStream
}

return null
return NullOutputStream()
}

private val batInfoReceiver: BroadcastReceiver = object : BroadcastReceiver() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package crazydude.com.telemetry.utils

import java.io.OutputStream

class NullOutputStream : OutputStream() {
override fun write(b: Int) {
// do nothing
}
}