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

Feature/small gui improvements #26

Merged
merged 3 commits into from
Mar 19, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ class LinkChirpActivity : AppCompatActivity() {

sharedPreferences = PreferenceManager.getDefaultSharedPreferences(SurveyorApp.instance)

// load old values as default values
if (sharedPreferences.getString(getString(R.string.PREF_NETWORK_SERVER),"").equals(getString(R.string.NS_CHIRP))) {
binding.editTextMqttUsername.setText(sharedPreferences.getString(getString(R.string.PREF_MQTT_USERNAME), ""))
binding.editTextMqttPassword.setText(sharedPreferences.getString(getString(R.string.PREF_MQTT_PASSWORD), ""))
binding.editTextMqttAddress.setText(sharedPreferences.getString(getString(R.string.PREF_MQTT_BROKER), ""))

var deviceEui: String = sharedPreferences.getString(getString(R.string.PREF_MQTT_TOPIC), "")!!
if (!deviceEui.equals("")) {
deviceEui = deviceEui.substring(0, deviceEui.length - 9)
deviceEui = deviceEui.substring(deviceEui.lastIndexOf('/') + 1)
}
binding.editTextDeviceEui.setText(deviceEui)

var appId: String = sharedPreferences.getString(getString(R.string.PREF_MQTT_TOPIC), "")!!
if (!appId.equals("")) {
appId = appId.substring(12)
appId = appId.substring(0, appId.indexOf('/'))
}
binding.editTextAppId.setText(appId)
}

binding.buttonLinkDevice.setOnClickListener {
val editor = sharedPreferences.edit()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ class LinkTtnV2Activity : AppCompatActivity() {

sharedPreferences = PreferenceManager.getDefaultSharedPreferences(SurveyorApp.instance)

// load old values as default values
if (sharedPreferences.getString(getString(R.string.PREF_NETWORK_SERVER),"").equals(getString(R.string.NS_TTN_V2))) {
binding.editTextAppId.setText(sharedPreferences.getString(getString(R.string.PREF_MQTT_USERNAME), ""))
binding.editTextAccessKey.setText(sharedPreferences.getString(getString(R.string.PREF_MQTT_PASSWORD), ""))
binding.editTextMqttAddress.setText(sharedPreferences.getString(getString(R.string.PREF_MQTT_BROKER), ""))
var deviceId: String = sharedPreferences.getString(getString(R.string.PREF_MQTT_TOPIC), "")!!
if (!deviceId.equals("")) {
deviceId = deviceId.substring(0, deviceId.length - 3)
deviceId = deviceId.substring(deviceId.lastIndexOf('/') + 1)
}
binding.editTextDevId.setText(deviceId)
}

binding.buttonLinkDevice.setOnClickListener {
val editor = sharedPreferences.edit()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ class LinkTtsV3Activity : AppCompatActivity() {

sharedPreferences = PreferenceManager.getDefaultSharedPreferences(SurveyorApp.instance)

// load old values as default values
if (sharedPreferences.getString(getString(R.string.PREF_NETWORK_SERVER),"").equals(getString(R.string.NS_TTS_V3))) {
binding.editTextUsername.setText(sharedPreferences.getString(getString(R.string.PREF_MQTT_USERNAME), ""))
binding.editTextPassword.setText(sharedPreferences.getString(getString(R.string.PREF_MQTT_PASSWORD), ""))
binding.editTextPublicAddress.setText(sharedPreferences.getString(getString(R.string.PREF_MQTT_BROKER), ""))
var deviceId: String = sharedPreferences.getString(getString(R.string.PREF_MQTT_TOPIC), "")!!
if (!deviceId.equals("")) {
deviceId = deviceId.substring(0, deviceId.length - 3)
deviceId = deviceId.substring(deviceId.lastIndexOf('/') + 1)
}
binding.editTextEndDeviceId.setText(deviceId)
}

binding.buttonLinkDevice.setOnClickListener {
val editor = sharedPreferences.edit()

Expand Down
19 changes: 17 additions & 2 deletions app/src/main/java/org/ttnmapper/phonesurveyor/ui/MapFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class MapFragment : Fragment()/*, View.OnTouchListener*/ {
+ mImageFilenameEnding)
}
})
this.setStatusMessageColor(Color.BLACK)
}

// Terrain
Expand All @@ -126,6 +127,7 @@ class MapFragment : Fragment()/*, View.OnTouchListener*/ {
+ mImageFilenameEnding)
}
})
this.setStatusMessageColor(Color.BLACK)
}

// Satellite
Expand All @@ -143,6 +145,7 @@ class MapFragment : Fragment()/*, View.OnTouchListener*/ {
+ mImageFilenameEnding)
}
})
this.setStatusMessageColor(Color.WHITE)
}

// OSM Mapnik
Expand All @@ -161,6 +164,7 @@ class MapFragment : Fragment()/*, View.OnTouchListener*/ {
+ mImageFilenameEnding)
}
})
this.setStatusMessageColor(Color.BLACK)
}

// OSM Mapnik greyscale
Expand All @@ -183,9 +187,10 @@ class MapFragment : Fragment()/*, View.OnTouchListener*/ {
// Apply grayscale filter
val matrix = ColorMatrix()
matrix.setSaturation(0.0f)
val filter = ColorMatrixColorFilter(matrix);
val filter = ColorMatrixColorFilter(matrix)
//map.getOverlayManager().getTilesOverlay().setColorFilter(TilesOverlay.INVERT_COLORS) //night mode
binding.map.getOverlayManager().getTilesOverlay().setColorFilter(filter);
binding.map.getOverlayManager().getTilesOverlay().setColorFilter(filter)
this.setStatusMessageColor(Color.BLACK)
}

// OSM Mapnik night mode
Expand All @@ -207,6 +212,7 @@ class MapFragment : Fragment()/*, View.OnTouchListener*/ {

// Apply grayscale filter
binding.map.getOverlayManager().getTilesOverlay().setColorFilter(TilesOverlay.INVERT_COLORS) //night mode
this.setStatusMessageColor(Color.WHITE)
}
}

Expand Down Expand Up @@ -445,4 +451,13 @@ class MapFragment : Fragment()/*, View.OnTouchListener*/ {
binding.textViewGPSStatus.setText(message)
}

fun setStatusMessageColor(color: Int) {
if(_binding == null) {
Log.w(TAG, "Binding is null, so fragment does not exist")
return
}
binding.textViewMQTTStatus.setTextColor(color)
binding.textViewGPSStatus.setTextColor(color)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,16 @@ class SessionListActivity : AppCompatActivity() {
}

private fun refreshUi() {

// Select new total count
val count = AppAggregate.db?.linkDao()?.getSessionCount()
runOnUiThread {
binding.textViewNumberSessions.text = "Number of recorded sessions: " + count.toString()
var sessionLinkCounts: List<SessionLinkCount>? = AppAggregate.db?.linkDao()?.getSessions()
if(sessionLinkCounts == null) {
sessionLinkCounts = emptyList()
}

// Update list in UI
// val testList = AppAggregate.db?.linkDao()?.getSessionIDs()
// Select new total count and update list
runOnUiThread {
// sessionAdapter.updateDataList(testList!!)
binding.textViewNumberSessions.text = "Number of recorded sessions: ${sessionLinkCounts.count()}"
sessionAdapter.updateDataList(sessionLinkCounts)
}

}

private fun exportSession(sessionId: String) {
Expand Down