Add USB auto-read key transfer + UI redesign
USB auto-read: - ESP responds to 'KEY?\n' over USB serial with 'HMAC_KEY:<hex>' - Android UsbKeyReceiver (manifest BroadcastReceiver) catches USB_DEVICE_ATTACHED - Filters on Espressif vendor 0x303a, requests USB permission - Opens CDC-ACM serial (115200), sends KEY?, parses response, saves to SharedPreferences - Works even when app not in foreground - usb-serial-for-android v3.7.3 via JitPack UI redesign: - activity_main.xml: FrameLayout with settings icon top-right, relay button center, status bottom-left (14sp) - Scan & Connect button moved to SettingsActivity - SettingsActivity: hint text 'Voer de HMAC sleutel in of sluit de relaismodule aan op de telefoon' - SettingsActivity: scan button saves key + returns RESULT_OK to trigger scanning - MainActivity: removed scanButton, auto-scan on onResume when key is set - Back button removed from settings (ActionBar up navigation only) README updated with USB protocol docs, new UI description, and updated setup guide
This commit is contained in:
parent
7f68e9ad70
commit
4518aec34e
10 changed files with 270 additions and 74 deletions
|
|
@ -1,42 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:padding="32dp">
|
||||
android:padding="16dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/settingsButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_gravity="end|top"
|
||||
android:src="@drawable/ic_settings"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="Instellingen"
|
||||
android:layout_marginBottom="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/statusText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Disconnected"
|
||||
android:textSize="20sp"
|
||||
android:layout_marginBottom="48dp"/>
|
||||
android:contentDescription="Instellingen" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/relayButton"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_gravity="center"
|
||||
android:text="HOLD"
|
||||
android:textSize="24sp"
|
||||
android:enabled="false"/>
|
||||
android:enabled="false" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/scanButton"
|
||||
<TextView
|
||||
android:id="@+id/statusText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Scan & Connect"
|
||||
android:layout_marginTop="48dp"/>
|
||||
android:layout_gravity="bottom|start"
|
||||
android:text="Disconnected"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
Loading…
Reference in a new issue