Skip to content

Commit 4070f8f

Browse files
committed
added progress
1 parent fa46627 commit 4070f8f

2 files changed

Lines changed: 41 additions & 31 deletions

File tree

Samples/Advanced/DocumentReader-Kotlin/app/src/main/java/com/regula/documentreader/CustomRfidActivity.kt

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ class CustomRfidActivity : AppCompatActivity() {
158158
binding.currentDataGroupLt.visibility = View.VISIBLE
159159
binding.rfidStatus.setTextColor(getColor(android.R.color.holo_orange_light))
160160
}
161+
rfidProgress(
162+
results.documentReaderNotification!!.code,
163+
results.documentReaderNotification!!.value
164+
)
161165
}
162-
rfidProgress(
163-
results.documentReaderNotification!!.code,
164-
results.documentReaderNotification!!.value
165-
)
166166
}
167167
DocReaderAction.ERROR -> {
168168
val builder =
@@ -179,19 +179,26 @@ class CustomRfidActivity : AppCompatActivity() {
179179
}
180180
}
181181

182-
private fun codeToType(code: Int): Int = code and 0x10000
182+
// private fun codeToType(code: Int): Int = code and 0x10000
183183

184184
private fun rfidProgress(code: Int, value: Int) {
185-
when (code and -0x10000) {
186-
eRFID_NotificationAndErrorCodes.RFID_NOTIFICATION_PCSC_READING_DATAGROUP -> if (value == 0) {
187-
handler.post {
188-
binding.currentRfidDgTv.text = String.format(
189-
getString(R.string.strReadingRFIDDG), eRFID_DataFile_Type.getTranslation(
190-
applicationContext, codeToType(code)
191-
)
192-
)
193-
}
194-
}
185+
val hiword = code and -0x10000
186+
val loword = code and 0x0000FFFF
187+
val progress = value and -0x10
188+
189+
var currentDataGroup: String? = null
190+
if (hiword == eRFID_NotificationAndErrorCodes.RFID_NOTIFICATION_PCSC_READING_DATAGROUP)
191+
currentDataGroup = if (value == 100) null else String.format(
192+
getString(com.regula.documentreader.api.R.string.strReadingRFIDDG),
193+
eRFID_DataFile_Type.getTranslation(applicationContext, loword)
194+
)
195+
196+
if (currentDataGroup != null && currentDataGroup.isNotEmpty()) {
197+
binding.currentRfidDgTv.text = currentDataGroup
198+
}
199+
200+
if (progress in 1..100) {
201+
binding.progressBar.progress = progress
195202
}
196203
}
197204

Samples/Advanced/DocumentReader-Kotlin/app/src/main/res/layout/activity_custom_rfid.xml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,40 @@
55
android:layout_height="match_parent"
66
tools:context=".CustomRfidActivity">
77

8-
<androidx.constraintlayout.widget.ConstraintLayout
8+
<LinearLayout
99
android:id="@+id/currentDataGroupLt"
1010
android:layout_width="0dp"
1111
android:layout_height="wrap_content"
1212
android:layout_toStartOf="@id/skipRfidBtn"
1313
android:visibility="gone"
1414
app:layout_constraintBottom_toBottomOf="parent"
1515
app:layout_constraintEnd_toStartOf="@+id/skipRfidBtn"
16-
app:layout_constraintStart_toStartOf="parent">
16+
app:layout_constraintStart_toStartOf="parent"
17+
android:orientation="vertical"
18+
android:layout_margin="10dp">
1719

1820
<ProgressBar
19-
android:id="@+id/progress"
20-
android:layout_width="wrap_content"
21-
android:layout_height="wrap_content"
22-
android:indeterminateTint="?colorAccent"
23-
app:layout_constraintBottom_toBottomOf="parent"
24-
app:layout_constraintStart_toStartOf="parent"
25-
app:layout_constraintTop_toTopOf="parent" />
21+
android:id="@+id/progressBar"
22+
style="@android:style/Widget.ProgressBar.Horizontal"
23+
android:layout_width="200dp"
24+
android:layout_height="10dp"
25+
android:layout_below="@id/currentRfidDgTv"
26+
android:layout_centerHorizontal="true"
27+
android:layout_gravity="center_horizontal"
28+
android:indeterminate="false"
29+
android:visibility="visible"
30+
android:layout_marginTop="@dimen/reg_visual_element_margin"
31+
android:foregroundTint="@color/imageTintColor" />
2632

2733
<TextView
2834
android:id="@+id/currentRfidDgTv"
29-
android:layout_width="0dp"
35+
android:layout_width="match_parent"
3036
android:layout_height="wrap_content"
3137
android:paddingStart="@dimen/padding_gap"
3238
android:paddingEnd="@dimen/padding_gap"
33-
android:textColor="?colorOnSecondary"
34-
app:layout_constraintBottom_toBottomOf="parent"
35-
app:layout_constraintEnd_toEndOf="parent"
36-
app:layout_constraintStart_toEndOf="@+id/progress"
37-
app:layout_constraintTop_toTopOf="parent" />
38-
</androidx.constraintlayout.widget.ConstraintLayout>
39+
android:paddingTop="@dimen/padding_gap"
40+
android:textColor="?colorOnSecondary" />
41+
</LinearLayout>
3942

4043
<TextView
4144
android:id="@+id/rfidStatus"

0 commit comments

Comments
 (0)