Initial project with basic activity.
This commit is contained in:
46
app/src/main/java/com/github/mondei1/offpass/MainActivity.kt
Normal file
46
app/src/main/java/com/github/mondei1/offpass/MainActivity.kt
Normal file
@@ -0,0 +1,46 @@
|
||||
package com.github.mondei1.offpass
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.zxing.integration.android.IntentIntegrator
|
||||
import com.google.zxing.integration.android.IntentResult
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
this.supportActionBar?.hide()
|
||||
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
main_screen.setOnClickListener {
|
||||
IntentIntegrator(this)
|
||||
.setPrompt("Scan OffPass created QR-Code")
|
||||
.setBeepEnabled(false)
|
||||
.setBarcodeImageEnabled(false)
|
||||
.initiateScan()
|
||||
Log.i("Main", "Clicked on text")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
var result: IntentResult =
|
||||
IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
|
||||
if (result != null) {
|
||||
if (result.contents == null) {
|
||||
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show()
|
||||
} else {
|
||||
Log.i("SCANNER", "Scanned: " + result.contents)
|
||||
Toast.makeText(this, "Scanned: " + result.contents, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user