first bits of the nfc reader

This commit is contained in:
2019-08-17 01:51:15 +02:00
parent f52151fbf1
commit 3a0a31f781
5 changed files with 34 additions and 3 deletions

View File

@ -23,6 +23,8 @@
package org.mosad.seil0.projectlaogai
import android.graphics.Color
import android.nfc.NfcAdapter
import android.nfc.Tag
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
@ -32,6 +34,7 @@ import androidx.core.view.GravityCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import com.afollestad.aesthetic.Aesthetic
import com.afollestad.materialdialogs.MaterialDialog
import com.google.android.material.navigation.NavigationView
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_bar_main.*
@ -42,6 +45,7 @@ import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.
import org.mosad.seil0.projectlaogai.fragments.*
import kotlin.system.measureTimeMillis
// TODO save the current fragment to show it when the app is restarted
class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
private var activeFragment: Fragment = HomeFragment() // the currently active fragment, home at the start
@ -68,6 +72,16 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
toggle.syncState()
nav_view.setNavigationItemSelectedListener(this)
// TODO nfc stuff, needs to move to it's own function
if (intent.action == NfcAdapter.ACTION_TECH_DISCOVERED) {
val tag: Tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)
MaterialDialog(this)
.title(text = "nfc tag detected")
.message(text = tag.toString())
.show()
}
}
override fun onResume() {

View File

@ -43,7 +43,6 @@ import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
/**
* The mensa controller class
* contains all needed parts to display and the mensa detail screen
* TODO investigate reading the mensa card value via nfc in a background task, show value if card detected
*/
class MensaFragment : Fragment() {