Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-stanek committed Sep 23, 2023
1 parent 3ed2c02 commit e378a1c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/detekt.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build:
maxIssues: 4
maxIssues: 3
excludeCorrectable: false
weights:
# complexity: 2
Expand Down
59 changes: 31 additions & 28 deletions app/src/main/java/cz/skaut/srs/ticketsreader/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,36 @@ class MainActivity : AppCompatActivity() {

Preferences.init(this)
updateUI()
setListeners()
}

override fun onResume() {
super.onResume()
updateUI()
}

private fun updateUI() {
if (Preferences.connected) {
btnConnectSrs.visibility = Button.GONE
btnDisconnectSrs.visibility = Button.VISIBLE
btnRefresh.visibility = Button.VISIBLE
btnScanTickets.visibility = Button.VISIBLE
tvSeminarName.text = Preferences.seminarName
} else {
btnConnectSrs.visibility = Button.VISIBLE
btnDisconnectSrs.visibility = Button.GONE
btnRefresh.visibility = Button.GONE
btnScanTickets.visibility = Button.GONE
tvSeminarName.text = getString(R.string.activity_main_tv_seminar_name_text_default)
}

val adapter = ArrayAdapter(this, R.layout.spinner_item, Preferences.subevents)
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item)
spnSubevent.adapter = adapter
spnSubevent.setSelection(Preferences.selectedSubeventPosition)
}

private fun setListeners() {
btnConnectSrs.setOnClickListener {
val intent = Intent(this, ScannerActivity::class.java)
intent.putExtra("connection_mode", true)
Expand Down Expand Up @@ -116,37 +145,11 @@ class MainActivity : AppCompatActivity() {
}
}

override fun onResume() {
super.onResume()
updateUI()
}

fun updateUI() {
if (Preferences.connected) {
btnConnectSrs.visibility = Button.GONE
btnDisconnectSrs.visibility = Button.VISIBLE
btnRefresh.visibility = Button.VISIBLE
btnScanTickets.visibility = Button.VISIBLE
tvSeminarName.text = Preferences.seminarName
} else {
btnConnectSrs.visibility = Button.VISIBLE
btnDisconnectSrs.visibility = Button.GONE
btnRefresh.visibility = Button.GONE
btnScanTickets.visibility = Button.GONE
tvSeminarName.text = getString(R.string.activity_main_tv_seminar_name_text_default)
}

val adapter = ArrayAdapter(this, R.layout.spinner_item, Preferences.subevents)
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item)
spnSubevent.adapter = adapter
spnSubevent.setSelection(Preferences.selectedSubeventPosition)
}

fun showToast(message: Int) {
private fun showToast(message: Int) {
showToast(getString(message))
}

fun showToast(message: String?) {
private fun showToast(message: String?) {
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import org.slf4j.LoggerFactory
import java.time.ZoneId
import java.time.format.DateTimeFormatter

private const val COLOR_ORANGE = 0xffffa500;

class TicketQrProcessor(context: FragmentActivity) : QrProcessor(context) {
private val log = LoggerFactory.getLogger(this.javaClass)
private val dateTimeFormatter: DateTimeFormatter =
Expand Down Expand Up @@ -74,7 +76,7 @@ class TicketQrProcessor(context: FragmentActivity) : QrProcessor(context) {
tvMessage.text = context.getString(R.string.dialog_ticket_message_missing_subevent)
} else if (ticketInfo.subeventChecks.isNotEmpty()) {
tvStatus.text = context.getString(R.string.dialog_ticket_status_used)
tvStatus.setTextColor(Color.rgb(255, 165, 0))
tvStatus.setTextColor(COLOR_ORANGE.toInt())
tvMessage.text = context.getString(R.string.dialog_ticket_message_used)
} else {
tvStatus.text = context.getString(R.string.dialog_ticket_status_valid)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/dialog_ticket.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" android:gravity="center_horizontal">
android:layout_height="match_parent"
android:gravity="center_horizontal">

<ImageView
android:id="@+id/dialog_ticket_iv_photo"
Expand Down

0 comments on commit e378a1c

Please sign in to comment.