first bits of the nfc reader
This commit is contained in:
		| @ -2,6 +2,7 @@ | ||||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|           package="org.mosad.seil0.projectlaogai"> | ||||
|     <uses-permission android:name="android.permission.INTERNET"/> | ||||
|     <uses-permission android:name="android.permission.NFC" /> | ||||
|  | ||||
|     <application | ||||
|             android:allowBackup="true" | ||||
| @ -17,6 +18,7 @@ | ||||
|                 android:label="@string/app_name" | ||||
|                 android:theme="@style/SplashTheme" | ||||
|                 android:screenOrientation="portrait"> | ||||
|  | ||||
|             <intent-filter> | ||||
|                 <action android:name="android.intent.action.MAIN"/> | ||||
|                 <category android:name="android.intent.category.LAUNCHER"/> | ||||
| @ -27,7 +29,17 @@ | ||||
|                 android:name=".MainActivity" | ||||
|                 android:label="@string/app_name" | ||||
|                 android:theme="@style/AppTheme.Light" | ||||
|                 android:screenOrientation="portrait"> | ||||
|                 android:screenOrientation="portrait" | ||||
|                 android:launchMode="singleTop"> | ||||
|  | ||||
|             <!-- nfc stuff --> | ||||
|             <intent-filter> | ||||
|                 <action android:name="android.nfc.action.TECH_DISCOVERED"/> | ||||
|             </intent-filter> | ||||
|  | ||||
|             <meta-data android:name="android.nfc.action.TECH_DISCOVERED" | ||||
|                        android:resource="@xml/nfc_tech_filter" /> | ||||
|  | ||||
|         </activity> | ||||
|     </application> | ||||
|  | ||||
|  | ||||
| @ -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() { | ||||
|  | ||||
| @ -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() { | ||||
|  | ||||
|  | ||||
| @ -27,6 +27,6 @@ | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:clickable="true" android:id="@+id/faBtnAddLesson" android:elevation="7dp" | ||||
|             android:visibility="visible" android:layout_gravity="bottom|center|end" android:layout_marginEnd="11dp" | ||||
|             android:visibility="gone" android:layout_gravity="bottom|center|end" android:layout_marginEnd="11dp" | ||||
|             android:layout_marginBottom="11dp" android:focusable="true"/> | ||||
| </FrameLayout> | ||||
							
								
								
									
										6
									
								
								app/src/main/res/xml/nfc_tech_filter.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								app/src/main/res/xml/nfc_tech_filter.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> | ||||
|     <tech-list> | ||||
|         <tech>android.nfc.tech.NfcA</tech> | ||||
|     </tech-list> | ||||
| </resources> | ||||
		Reference in New Issue
	
	Block a user