Skip to content

Commit

Permalink
- Added: Functionality to scan console's serial number from barcode i…
Browse files Browse the repository at this point in the history
…n Serial Checker window.
  • Loading branch information
MenosGrante committed Jul 15, 2019
1 parent 0664aa9 commit 9454013
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 24 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.pavelrekun.rekado"
minSdkVersion minimumSDKVersion
targetSdkVersion currentSDKVersion
versionCode 53
versionName "3.1.1"
versionCode 54
versionName "3.2"
}

buildTypes {
Expand Down Expand Up @@ -67,6 +67,7 @@ dependencies {
implementation "org.greenrobot:eventbus:$eventBusVersion"
implementation "com.afollestad.material-dialogs:core:$materialDialogsVersion"
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
implementation "com.journeyapps:zxing-android-embedded:$zxingVersion"

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<application
android:name=".RekadoApplication"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
Expand Down Expand Up @@ -39,7 +40,9 @@
<activity
android:name=".screens.serial_checker_activity.SerialCheckerActivity"
android:label="@string/navigation_serial_checker"
android:launchMode="singleTop" />
android:launchMode="singleTop"
android:screenOrientation="fullSensor"
tools:replace="screenOrientation" />

<activity
android:name=".screens.translators_activity.TranslatorsActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.pavelrekun.rekado.screens.serial_checker_activity

import android.content.Intent
import android.os.Bundle
import com.pavelrekun.rekado.R
import com.pavelrekun.rekado.base.BaseActivity
Expand All @@ -14,4 +15,8 @@ class SerialCheckerActivity : BaseActivity() {

mvpView = SerialCheckerView(this)
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
mvpView.onActivityResult(requestCode, resultCode, data)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.pavelrekun.rekado.screens.serial_checker_activity

import android.content.Intent

interface SerialCheckerContract {

interface View {
Expand All @@ -12,6 +14,8 @@ interface SerialCheckerContract {

fun generateInformation()

fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?)

}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.pavelrekun.rekado.screens.serial_checker_activity

import android.content.Intent
import android.widget.Toast
import com.google.zxing.integration.android.IntentIntegrator
import com.pavelrekun.rekado.R
import com.pavelrekun.rekado.base.BaseActivity
import com.pavelrekun.rekado.services.Constants
Expand Down Expand Up @@ -52,10 +54,28 @@ class SerialCheckerView(private val activity: BaseActivity) : SerialCheckerContr
activity.serialCheckerHelp.setOnClickListener {
Utils.openLink(activity, Constants.HELP_SERIAL_CHECKER)
}

activity.serialCheckerScan.setOnClickListener {
IntentIntegrator(activity).apply {
setOrientationLocked(false)
setBeepEnabled(false)
}.initiateScan()
}
}

override fun generateInformation() {
val serialsInformation = activity.getString(R.string.serial_checker_information_xaw1) + activity.getString(R.string.serial_checker_information_xaw4) + activity.getString(R.string.serial_checker_information_xaw7) + activity.getString(R.string.serial_checker_information_xaj1) + activity.getString(R.string.serial_checker_information_xaj4) + activity.getString(R.string.serial_checker_information_xaj7) + activity.getString(R.string.serial_checker_information_xaw9) + activity.getString(R.string.serial_checker_information_xak)
activity.serialCheckerInformation.text = serialsInformation
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
val result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data)

if (result.contents != null) {
activity.serialCheckerField.setText(result.contents)
activity.serialCheckerField.requestFocus()
} else {
Toast.makeText(activity, R.string.serial_checker_status_scan_failed, Toast.LENGTH_SHORT).show()
}
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_serial_checker_scan.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="?attr/colorAccent"
android:pathData="M4,6H6V18H4V6M7,6H8V18H7V6M9,6H12V18H9V6M13,6H14V18H13V6M16,6H18V18H16V6M19,6H20V18H19V6M2,4V8H0V4A2,2 0 0,1 2,2H6V4H2M22,2A2,2 0 0,1 24,4V8H22V4H18V2H22M2,16V20H6V22H2A2,2 0 0,1 0,20V16H2M22,20V16H24V20A2,2 0 0,1 22,22H18V20H22Z" />
</vector>
61 changes: 40 additions & 21 deletions app/src/main/res/layout/activity_serial_checker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,51 @@
android:layout_height="wrap_content"
android:text="@string/serial_checker_category_checker" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/serialCheckerFieldOverflow"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
app:boxCornerRadiusBottomEnd="6dp"
app:boxCornerRadiusBottomStart="6dp"
app:boxCornerRadiusTopEnd="6dp"
app:boxCornerRadiusTopStart="6dp"
app:boxStrokeColor="?attr/colorAccent"
app:boxStrokeWidth="1dp"
app:counterEnabled="true"
app:counterMaxLength="14"
app:passwordToggleDrawable="@null">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/serialCheckerField"
android:orientation="horizontal">

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/serialCheckerFieldOverflow"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/serial_checker_checker_serial_number" />
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:boxCornerRadiusBottomEnd="6dp"
app:boxCornerRadiusBottomStart="6dp"
app:boxCornerRadiusTopEnd="6dp"
app:boxCornerRadiusTopStart="6dp"
app:boxStrokeColor="?attr/colorAccent"
app:boxStrokeWidth="1dp"
app:counterEnabled="true"
app:counterMaxLength="14"
app:passwordToggleDrawable="@null">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/serialCheckerField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/serial_checker_checker_serial_number" />

</com.google.android.material.textfield.TextInputLayout>

<ImageView
android:id="@+id/serialCheckerScan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@null"
android:src="@drawable/ic_serial_checker_scan" />

</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/serialCheckerCheck"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<string name="serial_checker_status_error">Can\'t check this serial number!</string>
<string name="serial_checker_status_empty">Serial number can\'t be empty!</string>
<string name="serial_checker_status_too_long">Maximum length of the serial number is 14 characters!</string>
<string name="serial_checker_status_scan_failed">Failed to scan barcode!</string>

<!-- Strings for Helper -->
<string name="helper_error_adding_payload">Selected payload can not be added!</string>
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ ext {
paperVersion = '2.6'
eventBusVersion = '3.1.1'
okHttpVersion = '4.0.0'
zxingVersion = '3.6.0'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.

2 comments on commit 9454013

@Akorax
Copy link

@Akorax Akorax commented on 9454013 Jul 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downloaded and tested. Seems to work just fine ^^

@MenosGrante
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thanks :)

Please sign in to comment.