Rajeev Velikkal
Published © GPL3+

QR Code Based Contact Tracing App

Easy Contact Tracing and Personal Route logging multi purpose app, that can hold your route/visits data for up to 30 days

AdvancedFull instructions providedOver 16 days33
QR Code Based Contact Tracing App

Things used in this project

Hardware components

Android device
Android device
×1

Software apps and online services

Android Studio
Android Studio
Amazon Web Services Arora

Story

Read more

Schematics

Flow Chart

Below flow chart depicts the details of screen interactions and data storing

Code

Source Code sample

Java
The complete package can be downloaded from www.rajeev.velikkal.com website
package com.connectedsystems.qrcodescanner

import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.util.Base64
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.Button
import android.widget.EditText
import android.widget.ProgressBar
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.android.volley.Request
import com.android.volley.Response
import com.android.volley.toolbox.StringRequest
import com.android.volley.toolbox.Volley
import kotlinx.android.synthetic.main.fragment_read.*
import kotlinx.android.synthetic.main.login_activity.*
import org.json.JSONException
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
import kotlinx.android.synthetic.main.fragment_read.progressBar as progressBar1


var result = "2"
class LoginActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.login_activity)
        var etusername: EditText = findViewById(R.id.et_user_name)
        var etpassword: EditText = findViewById(R.id.et_password)
        val btnreset: Button = findViewById(R.id.btn_reset)
        val btnsubmit: Button = findViewById(R.id.btn_submit)
        val btnregister: TextView = findViewById(R.id.textRegister)
        val btncreateqr: TextView = findViewById(R.id.textCreateQR)
        val progressBar: ProgressBar = findViewById(R.id.progressBar)
        progressBar.visibility = View.GONE
        btnreset.setOnClickListener {
            // clearing user_name and password edit text views on reset button click
            etusername.setText("")
            etpassword.setText("")
            statusLogin.text = ""
        }
        // set on-click listener
        btnsubmit.setOnClickListener {
            it.hideKeyboard()
            getloginresult(username = etusername.text.toString(), password = etpassword.text.toString())
            progressBar.visibility = View.VISIBLE
        }
        btnregister.setOnClickListener {
            btnregister.visibility = View.VISIBLE
            btnregister.setTextColor(Color.parseColor("#097741"))
            var intent = Intent(this, RegisterUserActivity::class.java)
            startActivity(intent)
        }
        btncreateqr.setOnClickListener {
            btncreateqr.visibility = View.VISIBLE
            btncreateqr.setTextColor(Color.parseColor("#097741"))
            var intent = Intent(this, CreateQRActivity::class.java)
            startActivity(intent)
        }
    }

    private fun getloginresult(username: String, password: String )
    {
        val stringRequest = StringRequest(Request.Method.GET, url, Response.Listener<String>
        { response ->
            try {
                    progressBar.visibility = View.GONE
                    result = "${response.substring(0, 1)}"
                    val location = response.substringAfter(',')
                    if (result.toIntOrNull() == 1) {
                                                    //Passing user name to the next activity, from which viewmodel will put it to the contols fragment
                                                    val intent = Intent(this, MainActivity::class.java)
                                                    .putExtra("location", location.substringBefore(','))
                                                    startActivity(intent)
                                                    } else {
                                                            statusLogin.text = "Invalid UserName or Password"
                                                            }
                } catch (e: JSONException) {
                                            e.printStackTrace()
                                            }
        },
                    Response.ErrorListener {
                        statusLogin.text = "Error Connecting to Server"
                        progressBar.visibility = View.GONE
                    })
        val queue = Volley.newRequestQueue(this)
        queue.add<String>(stringRequest)

    }

    fun View.hideKeyboard() {
        val inputManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        inputManager.hideSoftInputFromWindow(windowToken, 0)
    }
}

Credits

Rajeev Velikkal

Rajeev Velikkal

2 projects • 14 followers
Software engineer, interested in doing mechatronics projects, most of them listed in my personal website www.rajeev.velikkal.com

Comments

Add projectSign up / Login