add qr scan
This commit is contained in:
parent
d2d2ff101d
commit
fbcbeb0246
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
@ -28,16 +28,20 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "11"
|
jvmTarget = "17"
|
||||||
|
}
|
||||||
|
buildFeatures{
|
||||||
|
viewBinding = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.ktor.client.core)
|
implementation(libs.ktor.client.core)
|
||||||
|
implementation(libs.zbar.code)
|
||||||
implementation(libs.ktor.serialization.json)
|
implementation(libs.ktor.serialization.json)
|
||||||
implementation(libs.ktor.client.cio)
|
implementation(libs.ktor.client.cio)
|
||||||
implementation(libs.ktor.client.auth)
|
implementation(libs.ktor.client.auth)
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/>
|
||||||
|
<uses-feature android:name="android.hardware.camera"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
@ -20,6 +23,11 @@
|
|||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
<activity android:name=".qr.QrActivity" android:exported="true">
|
||||||
|
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import androidx.activity.enableEdgeToEdge
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import com.example.nto_2024_client.qr.QrFragment
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -16,5 +17,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
|
supportFragmentManager.beginTransaction().replace(R.id.fragment_login,QrFragment()).commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,21 +0,0 @@
|
|||||||
package com.example.nto_2024_client.data
|
|
||||||
|
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.engine.cio.CIO
|
|
||||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
|
||||||
import io.ktor.serialization.kotlinx.json.json
|
|
||||||
import io.ktor.util.Platform
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import java.net.HttpCookie
|
|
||||||
|
|
||||||
class Network {
|
|
||||||
var client = HttpClient(CIO){
|
|
||||||
install(ContentNegotiation){
|
|
||||||
json(Json {
|
|
||||||
isLenient = true
|
|
||||||
ignoreUnknownKeys = true
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
package com.example.nto_2024_client.login
|
package com.example.nto_2024_client.login
|
||||||
|
|
||||||
import com.example.nto_2024_client.data.Network
|
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.engine.cio.CIO
|
import io.ktor.client.engine.cio.CIO
|
||||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||||
|
@ -1,4 +1,44 @@
|
|||||||
package com.example.nto_2024_client.qr
|
package com.example.nto_2024_client.qr
|
||||||
|
|
||||||
class QrFragment {
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import com.example.nto_2024_client.R
|
||||||
|
import com.example.nto_2024_client.databinding.QrCodeFragmentBinding
|
||||||
|
import me.dm7.barcodescanner.zbar.Result
|
||||||
|
import me.dm7.barcodescanner.zbar.ZBarScannerView
|
||||||
|
|
||||||
|
class QrFragment: Fragment(R.layout.qr_code_fragment),ZBarScannerView.ResultHandler {
|
||||||
|
lateinit var binding:QrCodeFragmentBinding
|
||||||
|
lateinit var zBarScannerView: ZBarScannerView
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
zBarScannerView = ZBarScannerView(activity)
|
||||||
|
|
||||||
|
return zBarScannerView
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
zBarScannerView.setResultHandler(this)
|
||||||
|
zBarScannerView.startCamera()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
zBarScannerView.stopCamera()
|
||||||
|
}
|
||||||
|
override fun handleResult(result: Result?) {
|
||||||
|
Log.d("MyQr",result.toString())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.example.nto_2024_client.qr
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
|
||||||
|
class QrViewModel:ViewModel() {
|
||||||
|
|
||||||
|
}
|
@ -7,13 +7,14 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
<TextView
|
<FrameLayout
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/fragment_login"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:text="Hello World!"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
6
app/src/main/res/layout/qr_code_fragment.xml
Normal file
6
app/src/main/res/layout/qr_code_fragment.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -15,6 +15,8 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
|||||||
# Android operating system, and which are packaged with your app's APK
|
# Android operating system, and which are packaged with your app's APK
|
||||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
|
android.enableJetifier = true
|
||||||
|
android.enableBuildCache=false
|
||||||
# Kotlin code style for this project: "official" or "obsolete":
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
# Enables namespacing of each library's R class so that its R class includes only the
|
# Enables namespacing of each library's R class so that its R class includes only the
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.8.0"
|
agp = "8.7.3"
|
||||||
kotlin = "1.9.24"
|
kotlin = "2.0.0-RC1"
|
||||||
coreKtx = "1.15.0"
|
coreKtx = "1.15.0"
|
||||||
junit = "4.13.2"
|
junit = "4.13.2"
|
||||||
junitVersion = "1.2.1"
|
junitVersion = "1.2.1"
|
||||||
@ -10,6 +10,7 @@ material = "1.10.0"
|
|||||||
activity = "1.10.0"
|
activity = "1.10.0"
|
||||||
constraintlayout = "2.1.4"
|
constraintlayout = "2.1.4"
|
||||||
ktor ="3.0.3"
|
ktor ="3.0.3"
|
||||||
|
zbar = "1.9.7"
|
||||||
kotlinSerialization="1.8.0"
|
kotlinSerialization="1.8.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
@ -22,6 +23,7 @@ material = { group = "com.google.android.material", name = "material", version.r
|
|||||||
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
||||||
ktor-client-core = {module = "io.ktor:ktor-client-core",version.ref="ktor"}
|
ktor-client-core = {module = "io.ktor:ktor-client-core",version.ref="ktor"}
|
||||||
ktor-client-auth = {group="io.ktor",name="ktor-client-auth",version.ref="ktor"}
|
ktor-client-auth = {group="io.ktor",name="ktor-client-auth",version.ref="ktor"}
|
||||||
|
zbar-code = {group="me.dm7.barcodescanner",name="zbar",version.ref="zbar"}
|
||||||
ktor-client-cio = {module="io.ktor:ktor-client-cio",version.ref="ktor"}
|
ktor-client-cio = {module="io.ktor:ktor-client-cio",version.ref="ktor"}
|
||||||
ktor-client-content-negotiation={module="io.ktor:ktor-client-content-negotiation",version.ref="ktor"}
|
ktor-client-content-negotiation={module="io.ktor:ktor-client-content-negotiation",version.ref="ktor"}
|
||||||
ktor-serialization-json={module="io.ktor:ktor-serialization-kotlinx-json",version.ref="ktor"}
|
ktor-serialization-json={module="io.ktor:ktor-serialization-kotlinx-json",version.ref="ktor"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user