Skip to content

Commit 76c8797

Browse files
committed
import NFC plugin (impoved UX & security)
1 parent 1393357 commit 76c8797

43 files changed

Lines changed: 6620 additions & 3 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/src/main/AndroidManifest.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
33

44
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
5+
<!-- Permission required to use the phone's NFC hardware -->
6+
<uses-permission android:name="android.permission.NFC" />
57
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
68
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
79
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
@@ -64,14 +66,38 @@
6466
<category android:name="android.intent.category.LAUNCHER" />
6567
</intent-filter>
6668
</activity>
69+
6770
<activity
6871
android:name="app.aaps.activities.PreferencesActivity"
6972
android:exported="false"
7073
android:theme="@style/AppTheme" />
74+
y
7175
<activity
7276
android:name="app.aaps.activities.HistoryBrowseActivity"
7377
android:exported="false"
7478
android:theme="@style/AppTheme" />
79+
80+
<!-- NfcControlActivity processes NFC tags with AAPS commands.
81+
The device must be unlocked before the activity can run.
82+
The intent filter limits it to tags with the specific MIME type. -->
83+
<activity
84+
android:name="app.aaps.plugins.main.general.nfcCommands.NfcControlActivity"
85+
android:exported="true"
86+
android:theme="@android:style/Theme.Translucent.NoTitleBar">
87+
<intent-filter>
88+
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
89+
<category android:name="android.intent.category.DEFAULT" />
90+
<data android:mimeType="application/vnd.app.aaps.command" />
91+
</intent-filter>
92+
</activity>
93+
94+
<!-- NfcBuildActivity: tag-command builder, launched from My Tags.
95+
Not exported — only started by the app itself. -->
96+
<activity
97+
android:name="app.aaps.plugins.main.general.nfcCommands.NfcBuildActivity"
98+
android:exported="false"
99+
android:theme="@style/AppTheme" />
100+
75101
<!-- Receive new BG readings from other local apps -->
76102
<receiver
77103
android:name="app.aaps.receivers.DataReceiver"

app/src/main/kotlin/app/aaps/activities/MyPreferenceFragment.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import app.aaps.core.validators.preferences.AdaptiveSwitchPreference
5353
import app.aaps.plugins.aps.autotune.AutotunePlugin
5454
import app.aaps.plugins.automation.AutomationPlugin
5555
import app.aaps.plugins.configuration.maintenance.MaintenancePlugin
56+
import app.aaps.plugins.main.general.nfcCommands.NfcCommandsPlugin
5657
import app.aaps.plugins.main.general.smsCommunicator.SmsCommunicatorPlugin
5758
import app.aaps.plugins.main.skins.SkinProvider
5859
import dagger.android.support.AndroidSupportInjection
@@ -73,6 +74,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
7374
@Inject lateinit var passwordCheck: PasswordCheck
7475
@Inject lateinit var automationPlugin: AutomationPlugin
7576
@Inject lateinit var autotunePlugin: AutotunePlugin
77+
@Inject lateinit var nfcCommandsPlugin: NfcCommandsPlugin
7678
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
7779
@Inject lateinit var maintenancePlugin: MaintenancePlugin
7880
@Inject lateinit var skinProvider: SkinProvider
@@ -150,6 +152,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
150152
addPreferencesIfEnabled(activePlugin.activeInsulin as PluginBase, rootKey)
151153
activePlugin.getSpecificPluginsList(PluginType.SYNC).forEach { addPreferencesIfEnabled(it, rootKey) }
152154
addPreferencesIfEnabled(smsCommunicatorPlugin, rootKey)
155+
addPreferencesIfEnabled(nfcCommandsPlugin, rootKey)
153156
addPreferencesIfEnabled(automationPlugin, rootKey)
154157
addPreferencesIfEnabled(autotunePlugin, rootKey)
155158
addAlertScreen(rootKey)

app/src/main/kotlin/app/aaps/di/PluginsListModule.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import app.aaps.plugins.insulin.InsulinOrefRapidActingPlugin
2222
import app.aaps.plugins.insulin.InsulinOrefUltraRapidActingPlugin
2323
import app.aaps.plugins.main.general.actions.ActionsPlugin
2424
import app.aaps.plugins.main.general.food.FoodPlugin
25+
import app.aaps.plugins.main.general.nfcCommands.NfcCommandsPlugin
2526
import app.aaps.plugins.main.general.overview.OverviewPlugin
2627
import app.aaps.plugins.main.general.persistentNotification.PersistentNotificationPlugin
2728
import app.aaps.plugins.main.general.smsCommunicator.SmsCommunicatorPlugin
@@ -289,6 +290,12 @@ abstract class PluginsListModule {
289290
@IntKey(280)
290291
abstract fun bindSmsCommunicatorPlugin(plugin: SmsCommunicatorPlugin): PluginBase
291292

293+
@Binds
294+
@NotNSClient
295+
@IntoMap
296+
@IntKey(285)
297+
abstract fun bindNfcCommandsPlugin(plugin: NfcCommandsPlugin): PluginBase
298+
292299
@Binds
293300
@APS
294301
@IntoMap
@@ -501,4 +508,4 @@ abstract class PluginsListModule {
501508

502509
@Qualifier
503510
annotation class Unfinished
504-
}
511+
}

core/data/src/main/kotlin/app/aaps/core/data/ue/Sources.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ enum class Sources {
6868
VirtualPump,
6969
Random,
7070
SMS, //From SMS plugin
71+
NfcCommands, //From NFC Commands plugin
7172
Treatments, //From Treatments plugin
7273
Wear, //From Wear plugin
7374
Food, //From Food plugin

core/interfaces/src/main/kotlin/app/aaps/core/interfaces/logging/LTag.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ enum class LTag(val tag: String, val defaultValue: Boolean = true, val requiresR
1515
GLUCOSE("GLUCOSE", defaultValue = false),
1616
HTTP("HTTP"),
1717
LOCATION("LOCATION"),
18+
NFC("NFC"),
1819
NOTIFICATION("NOTIFICATION"),
1920
NSCLIENT("NSCLIENT"),
2021
OHUPLOADER("OHUPLOADER"),
@@ -30,4 +31,4 @@ enum class LTag(val tag: String, val defaultValue: Boolean = true, val requiresR
3031
WIDGET("WIDGET"),
3132
WORKER("WORKER"),
3233
XDRIP("XDRIP")
33-
}
34+
}

core/keys/src/main/kotlin/app/aaps/core/keys/BooleanKey.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ enum class BooleanKey(
7676
SmsAllowRemoteCommands("smscommunicator_remotecommandsallowed", false),
7777
SmsReportPumpUnreachable("smscommunicator_report_pump_unreachable", true),
7878

79+
NfcAllowRemoteCommands("nfccommunicator_remotecommandsallowed", false),
80+
7981
VirtualPumpStatusUpload("virtualpump_uploadstatus", false, showInNsClientMode = false),
8082
NsClientUploadData("ns_upload", true, showInNsClientMode = false, hideParentScreenIfHidden = true),
8183
NsClientAcceptCgmData("ns_receive_cgm", false, showInNsClientMode = false, hideParentScreenIfHidden = true),
@@ -129,4 +131,4 @@ enum class BooleanKey(
129131
ExportCsvLocalEnabled("export_csv_local_enabled", defaultValue = true),
130132
ExportCsvCloudEnabled("export_csv_cloud_enabled", defaultValue = false),
131133

132-
}
134+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M20,2L4,2c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM20,20L4,20L4,4h16v16zM18,6h-5c-1.1,0 -2,0.9 -2,2v2.28c-0.6,0.35 -1,0.98 -1,1.72 0,1.1 0.9,2 2,2s2,-0.9 2,-2c0,-0.74 -0.4,-1.38 -1,-1.72L13,8h3v8L8,16L8,8h2L10,6L6,6v12h12L18,6z"/>
10+
</vector>

database/impl/src/main/kotlin/app/aaps/database/entities/UserEntry.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ data class UserEntry(
187187
VirtualPump,
188188
Random,
189189
SMS, //From SMS plugin
190+
NfcCommands, //From NFC Commands plugin
190191
Treatments, //From Treatments plugin
191192
Wear, //From Wear plugin
192193
Food, //From Food plugin

database/persistence/src/main/kotlin/app/aaps/database/persistence/converters/SourcesExtension.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ fun UserEntry.Sources.fromDb(): Sources =
7272
UserEntry.Sources.VirtualPump -> Sources.VirtualPump
7373
UserEntry.Sources.Random -> Sources.Random
7474
UserEntry.Sources.SMS -> Sources.SMS
75+
UserEntry.Sources.NfcCommands -> Sources.NfcCommands
7576
UserEntry.Sources.Treatments -> Sources.Treatments
7677
UserEntry.Sources.Wear -> Sources.Wear
7778
UserEntry.Sources.Food -> Sources.Food
@@ -154,6 +155,7 @@ fun Sources.toDb(): UserEntry.Sources =
154155
Sources.VirtualPump -> UserEntry.Sources.VirtualPump
155156
Sources.Random -> UserEntry.Sources.Random
156157
Sources.SMS -> UserEntry.Sources.SMS
158+
Sources.NfcCommands -> UserEntry.Sources.NfcCommands
157159
Sources.Treatments -> UserEntry.Sources.Treatments
158160
Sources.Wear -> UserEntry.Sources.Wear
159161
Sources.Food -> UserEntry.Sources.Food

implementation/src/main/kotlin/app/aaps/implementation/userEntry/UserEntryPresentationHelperImpl.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class UserEntryPresentationHelperImpl @Inject constructor(
108108
Sources.MDI -> R.drawable.ic_ict
109109
Sources.VirtualPump -> R.drawable.ic_virtual_pump
110110
Sources.SMS -> R.drawable.ic_sms
111+
Sources.NfcCommands -> R.drawable.ic_nfc
111112
Sources.Treatments -> R.drawable.ic_treatments
112113
Sources.Wear -> R.drawable.ic_watch
113114
Sources.Food -> R.drawable.ic_food

0 commit comments

Comments
 (0)