Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

feat: implement mandatory legal consent gate for initial launch and policy updates

Rishabh Bajpai2153845b97fc
diff --git a/app/src/main/assets/legal/disclaimer.md b/app/src/main/assets/legal/disclaimer.md
new file mode 100644
index 0000000..1f8da2b
--- /dev/null
+++ b/app/src/main/assets/legal/disclaimer.md
@@ -0,0 +1,134 @@
+DISCLAIMER AND DECLARATION
+
+Last updated: [effective date]
+
+PLEASE READ THIS CAREFULLY BEFORE USING GOTCHA. BY INSTALLING OR USING
+THE APP, YOU ACKNOWLEDGE AND AGREE TO THE FOLLOWING.
+
+1. AI CAN MAKE MISTAKES
+
+ 1.1 The App is powered by a generative AI model. AI output may be
+ inaccurate, incomplete, outdated, biased, or fabricated — including
+ plausible-sounding but false statements, citations, code, or
+ instructions.
+ 1.2 You must independently verify any AI output before acting on it,
+ especially when the action has real-world consequences (sending a
+ message, placing a call, making a purchase, deleting files,
+ installing software, configuring security settings, etc.).
+
+2. AGE AND RESPONSIBILITY
+
+ 2.1 You must be at least 18 years of age to use the App.
+ 2.2 You are responsible for how you use the App, including any
+ instructions you give the AI agent and any actions it performs on
+ your behalf.
+
+3. LAWFUL AND RESPONSIBLE USE
+
+ 3.1 The App must be used only for lawful purposes. You may not use it
+ (or instruct the agent it controls) to commit, attempt, plan, or
+ facilitate any illegal activity, including but not limited to:
+ harassment, stalking, fraud, identity theft, hacking, malware
+ distribution, child exploitation, drug trafficking, weapons
+ trafficking, sanctions evasion, market manipulation, money
+ laundering, or unauthorized access to any system or data.
+ 3.2 You may not use the App in any way that violates the rights of
+ others, including intellectual property, privacy, or publicity
+ rights.
+
+4. DEVICE INTEGRITY AND DATA
+
+ 4.1 The AI agent, once granted Android permissions (Accessibility,
+ Device Admin, Notifications, Storage, Media Projection, SMS,
+ Phone, Camera, Microphone, Contacts, Location, etc.), is capable
+ of performing real, often irreversible actions on your device.
+ 4.2 Such actions may include — without limitation — deleting or
+ uninstalling apps, deleting or modifying files (including those
+ outside the App's sandbox), sending messages, placing calls,
+ changing system settings, locking the screen, changing the device
+ password, disabling the camera, and altering network or account
+ configurations.
+ 4.3 Software may fail. AI may misunderstand. Third-party services may
+ misroute. Prompts may be injected. Despite our reasonable efforts,
+ the App may cause loss, corruption, or unauthorized disclosure of
+ data; may alter the configuration or operating state of your
+ device; or may perform unintended actions under your identity.
+ 4.4 YOU ASSUME FULL RESPONSIBILITY FOR BACKING UP YOUR DATA AND
+ SAFEGUARDING YOUR DEVICE, ACCOUNTS, AND CREDENTIALS BEFORE
+ GRANTING THE AGENT BROAD DEVICE ACCESS.
+
+5. NO WARRANTY
+
+ 5.1 The App and all related services are provided "as is" and "as
+ available," without any warranty of any kind, express or implied,
+ including the warranties of merchantability, fitness for a
+ particular purpose, non-infringement, and accuracy.
+
+6. LIMITATION OF LIABILITY
+
+ 6.1 To the fullest extent permitted by law, neither Gotcha nor
+ Samosa AI is liable for any direct, indirect, incidental, special,
+ consequential, exemplary, or punitive damages, or for any loss of
+ data, profits, revenue, goodwill, or use, arising out of or
+ related to your use of (or inability to use) the App — even if
+ advised of the possibility of such damages.
+ 6.2 This includes, without limitation, damages arising from:
+ (a) the actions or omissions of the AI agent;
+ (b) inaccuracies in AI output;
+ (c) loss, corruption, or unauthorized disclosure of data on
+ your device;
+ (d) damage to your device's software, settings, or
+ configuration;
+ (e) actions taken by the agent under your identity (messages,
+ calls, purchases, posts);
+ (f) reliance on, or use of, AI output;
+ (g) acts or omissions of any third-party backend, network, or
+ service; or
+ (h) any unauthorized access to your accounts or credentials
+ caused by you sharing them with a third-party provider.
+
+7. BACKEND PROVIDERS
+
+ 7.1 The App can route your requests to:
+ (a) Samosa AI — managed AI service via the Samosa AIR proxy;
+ or
+ (b) a User-Provided Provider — an OpenAI-compatible endpoint
+ configured by you (your own API key).
+ 7.2 Each provider has its own terms, privacy practices, and data
+ handling. By choosing a backend, you accept that provider's terms
+ in addition to these.
+ 7.3 We are not responsible for the acts or omissions of any backend
+ provider. In particular, if you supply your own API key and
+ credentials to a User-Provided Provider, we cannot guarantee the
+ security of those credentials once transmitted to that provider
+ and we will not be liable for any resulting issue.
+
+8. NO PROFESSIONAL ADVICE
+
+ 8.1 The App does not provide legal, medical, financial, tax, or other
+ professional advice. AI output in these areas is informational
+ only. Consult a qualified professional before acting on any
+ matter that could affect your legal rights, health, finances, or
+ safety.
+
+9. EXPORT AND SANCTIONS
+
+ 9.1 You agree to comply with all applicable export-control and
+ sanctions laws and not to use the App in or from any sanctioned
+ jurisdiction or for any sanctioned end-use.
+
+10. CHILDREN
+
+ 10.1 The App is not directed to children under 18. We do not
+ knowingly collect information from children under 18. If you
+ believe a child under 18 is using the App, contact us at
+ [email protected] so we can take appropriate steps.
+
+11. ACKNOWLEDGEMENT
+
+ 11.1 You acknowledge that you have read this Disclaimer, that you
+ understand it, that you accept its terms, and that these terms
+ apply alongside the Terms and Conditions and the Data Retention
+ Policy.
+
+— END OF DISCLAIMER —
diff --git a/app/src/main/assets/legal/privacy-data-retention.md b/app/src/main/assets/legal/privacy-data-retention.md
new file mode 100644
index 0000000..035fb64
--- /dev/null
+++ b/app/src/main/assets/legal/privacy-data-retention.md
@@ -0,0 +1,147 @@
+DATA RETENTION AND PRIVACY POLICY
+
+Last updated: [effective date]
+
+This policy explains what data the Gotcha App ("App") and the underlying
+AI backends handle, how long it is kept, and where it lives. The short
+version: the App itself does not collect or retain data on our
+servers — everything stays on your device unless you choose to use a
+backend that transmits data to a third-party AI provider.
+
+1. WHAT THE APP STORES, AND WHERE
+
+ 1.1 All user-generated content (chat history, call recordings,
+ screenshots captured during sessions, custom skills, action audit
+ log, cached LLM responses) is stored locally on your device under
+ Android's app-private storage:
+ (a) /data/data/com.gotcha/files/chats/ — chat history
+ (b) /data/data/com.gotcha/files/calls/ — voice-call logs
+ (c) /data/data/com.gotcha/files/action_log.txt
+ (d) /data/data/com.gotcha/cache/llm_cache/
+ 1.2 This data is never uploaded to us by the App. We have no way to
+ read it. If you uninstall the App, all of it is removed.
+ 1.3 Settings (preferences, model selections, permission choices,
+ legal acceptance) are stored in Android's encrypted
+ SharedPreferences on your device. They are never uploaded to us.
+ 1.4 The App does not ship analytics, crash reporting, telemetry, or
+ any background tracking SDK. We have no server-side record of
+ your activity in the App.
+
+2. WHAT IS TRANSMITTED, AND WHEN
+
+ 2.1 The App does not transmit data unless you send a request to an
+ AI backend. A request is sent only when you (or the agent you
+ have configured) initiate one — for example, by typing a message,
+ starting a voice call, or invoking a tool that needs vision.
+
+ 2.2 If you choose to use Samosa AI as your backend, requests are
+ transmitted to Samosa AI over HTTPS, authenticated with the
+ short-lived JWT issued by Samosa AIR after your Google sign-in.
+ See Section 4 for how Samosa AI handles that request.
+
+ 2.3 If you choose to use a User-Provided Provider, requests are
+ transmitted directly to that provider's endpoint over HTTPS,
+ authenticated with the API key you supplied. The App does not
+ proxy or store that key on any server we operate.
+
+3. ZERO COLLECTION / ZERO RETENTION BY US
+
+ 3.1 We do not operate a server that retains your chats, calls,
+ screenshots, prompts, completions, or credentials. We have no
+ analytics, no logging pipeline, no telemetry endpoint. There is
+ therefore nothing on our side to "delete," because nothing is
+ kept there in the first place.
+ 3.2 If you want to remove local data, uninstall the App, or use the
+ in-app controls (e.g. "Clear chat," "Clear LLM cache").
+
+4. THIRD-PARTY AI BACKENDS — PLEASE READ
+
+ 4.1 The App is a frontend. The actual AI processing is performed by
+ a third-party backend you select. Each backend has its own data
+ practices. Once a request leaves your device, the backend's
+ terms apply.
+
+ 4.2 Samosa AI (the Samosa AIR proxy):
+ (a) Samosa AI is operated independently of Gotcha. By
+ using Samosa AI as your backend, you accept Samosa AI's
+ own terms and privacy policy, in addition to these.
+ (b) Samosa AI routes requests to underlying model providers.
+ Samosa AI is designed to minimize what is forwarded:
+ identifying metadata such as your IP address is not
+ included in the prompt payload sent to the underlying
+ model provider.
+ (c) However, Samosa AI cannot fully eliminate provider-side
+ exposure. The underlying model provider will receive the
+ contents of your prompt and may receive provider-managed
+ identifiers (request IDs, abuse-prevention tokens) for the
+ purpose of operating the service.
+ (d) Underlying model providers may, under their own policies,
+ retain prompts and completions, and may use them to train
+ and improve their models. Samosa AI uses providers that
+ commit not to train on inputs delivered via the Samosa
+ AIR proxy, but those commitments are governed by the
+ provider's terms and may change.
+ (e) You should review Samosa AI's privacy policy directly for
+ the current, authoritative description of how Samosa AI
+ and its underlying providers handle your data.
+
+ 4.3 User-Provided Providers (your own OpenAI-compatible endpoint):
+ (a) When you supply your own API key and base URL, requests
+ are sent directly to that endpoint under your credentials.
+ The App does not proxy them through us.
+ (b) Whatever that provider logs, retains, or trains on is
+ governed by that provider's terms — not ours.
+ (c) If you supply credentials to a third-party provider,
+ those credentials are transmitted to that provider. We do
+ not guarantee their security once transmitted, and we are
+ not responsible for any resulting misuse, billing,
+ retention, or training by that provider.
+
+5. LOCAL DATA — RETENTION AND DELETION
+
+ 5.1 Local data persists on your device until you remove it. The App
+ provides controls to:
+ (a) clear individual chat histories ("Clear chat" in the
+ drawer);
+ (b) clear the LLM response cache (Settings → AI Configuration);
+ (c) clear debug screenshots (Settings → AI Configuration);
+ (d) uninstall the App, which removes all app-private data,
+ including settings, caches, and history.
+ 5.2 Android may retain app-private data in backups (e.g. Auto Backup
+ to Google Drive) depending on the user's Android settings. We
+ do not control backup behavior; please review your device
+ settings if this matters to you.
+
+6. PERMISSIONS
+
+ 6.1 The App requests only the permissions it needs to operate as
+ described in its on-device documentation. The full list is
+ enumerated in the Permissions section of the App's Settings.
+ 6.2 Permissions you grant stay on your device. You can revoke them
+ at any time through Android Settings → Apps → Gotcha.
+
+7. YOUR RESPONSIBILITY
+
+ 7.1 Because the App does not collect data on our servers, it is
+ your responsibility to:
+ (a) safeguard your device with a screen lock;
+ (b) review what permissions you have granted, and revoke
+ those you no longer need;
+ (c) back up any data you care about before granting the agent
+ broad device access;
+ (d) choose a backend whose data practices you are comfortable
+ with; and
+ (e) clear local data (or uninstall) before selling, gifting,
+ or otherwise disposing of the device.
+
+8. CHANGES
+
+ 8.1 We may update this policy. Material changes will be surfaced in
+ the App (in-app notice or first-launch dialog). The "Last
+ updated" date at the top will reflect the current version.
+
+9. CONTACT
+
+ 9.1 Questions about this policy can be sent to [email protected].
+
+— END OF DATA RETENTION POLICY —
diff --git a/app/src/main/assets/legal/terms.md b/app/src/main/assets/legal/terms.md
new file mode 100644
index 0000000..ab53f46
--- /dev/null
+++ b/app/src/main/assets/legal/terms.md
@@ -0,0 +1,230 @@
+TERMS AND CONDITIONS
+
+Last updated: [effective date]
+
+These Terms and Conditions ("Terms") govern your access to and use of the
+Gotcha mobile application ("App") and related services provided by
+Gotcha ("we," "us," or "our"). By installing, accessing, or otherwise
+using the App, you agree to be bound by these Terms. If you do not agree,
+do not install or use the App.
+
+1. ELIGIBILITY
+
+ 1.1 You must be at least 18 years of age (or the age of digital consent
+ in your jurisdiction, whichever is higher) to use the App.
+ 1.2 By using the App, you represent and warrant that you meet the age
+ requirement and have the legal capacity to enter into these Terms.
+ 1.3 If you are using the App on behalf of an organization, you further
+ represent that you have authority to bind that organization.
+
+2. THE SERVICE
+
+ 2.1 Gotcha is an on-device AI assistant. The App itself does not require
+ a network connection; the user chooses the AI backend.
+ 2.2 The App supports two classes of backends:
+ (a) "Samosa AI" — a managed AI service accessed by signing in
+ through Google and routing requests through Samosa AI's
+ proxy endpoint ("Samosa AIR"); and
+ (b) any "User-Provided Provider" — an OpenAI-compatible endpoint
+ configured by you (your own key, your own endpoint).
+ 2.3 The user is responsible for selecting which backend to use and for
+ the consequences of that choice (cost, data handling, accuracy).
+
+3. LICENSE
+
+ 3.1 Subject to your compliance with these Terms, we grant you a limited,
+ non-exclusive, non-transferable, revocable license to install and
+ use the App on devices you own or control.
+ 3.2 You may not: (a) copy, modify, or distribute the App; (b) reverse
+ engineer it except to the extent applicable law expressly permits;
+ (c) rent, lease, sell, sublicense, or transfer it; (d) use it to
+ build a competing product; or (e) remove or alter proprietary notices.
+
+4. ACCOUNTS, CREDENTIALS, AND API KEYS
+
+ 4.1 When you sign in to Samosa AI, your session is authenticated through
+ Google and bound to a short-lived token managed by us. We do not
+ see or store your Google password.
+ 4.2 When you bring your own provider, the App stores your base URL and
+ API key locally on your device using Android's encrypted SharedPreferences.
+ The key never leaves your device except as a request header to the
+ endpoint you configured.
+ 4.3 You are solely responsible for the security of any credentials you
+ enter into the App, for any endpoint you point the App at, and for
+ any access or cost incurred under your account.
+
+5. ACCEPTABLE USE
+
+ 5.1 You agree to use the App only for lawful purposes and in a manner
+ that does not infringe the rights of, restrict, or inhibit anyone
+ else's use and enjoyment of the App.
+ 5.2 You agree NOT to use the App (directly or via the AI agent it
+ controls) to:
+ (a) violate any applicable law, regulation, or third-party right;
+ (b) generate, distribute, or act on content that is illegal,
+ infringing, defamatory, harassing, hateful, sexually
+ exploitative of minors, or otherwise harmful;
+ (c) target, harm, or attempt to gain unauthorized access to any
+ system, account, network, or device;
+ (d) send unsolicited communications, spam, or phishing;
+ (e) produce or distribute malware, ransomware, or other malicious
+ code;
+ (f) interfere with or disrupt the App, its backends, or any
+ network or system used to provide them;
+ (g) conduct fraud, money laundering, market manipulation, or
+ other deceptive practices;
+ (h) reverse-engineer prompts, model weights, or other proprietary
+ AI assets belonging to us or to any backend provider;
+ (i) bypass any rate limits, safety filters, or paywalls; or
+ (j) attempt any of the above or assist anyone else to do so.
+
+6. THE AI ASSISTANT — IMPORTANT DISCLAIMER
+
+ 6.1 The App uses a large language model that can produce incorrect,
+ incomplete, misleading, or outdated output ("AI Output"). AI Output
+ is provided for informational purposes only and is not professional
+ advice (legal, medical, financial, or otherwise).
+ 6.2 You are responsible for verifying AI Output before relying on it.
+ Treat AI Output as a draft, not as a fact.
+ 6.3 The AI agent is granted broad on-device capabilities through the
+ Android permissions you grant it (Accessibility, Device Admin, Media
+ Projection, Notifications, Storage, SMS, Calls, etc.). When those
+ permissions are granted, the agent can perform real, irreversible
+ actions on your device: send messages, place calls, uninstall apps,
+ delete files, modify system settings, set passwords, lock the
+ screen, format storage, and more.
+ 6.4 You are solely responsible for granting those permissions, for the
+ instructions you give the agent, and for any consequences that
+ follow — including accidental data loss, unintended purchases,
+ messages sent in your name, settings changed, or device damage.
+
+7. DEVICE INTEGRITY AND DATA LOSS
+
+ 7.1 The App and its AI agent are designed to operate within the bounds
+ of standard Android permission systems. Nonetheless, software may
+ fail; an AI may misunderstand; a permission may be misused; a
+ network or service may misbehave.
+ 7.2 You acknowledge and agree that the App may, through user error,
+ model error, prompt injection, third-party service error, or
+ software bug:
+ (a) cause loss, corruption, or unauthorized disclosure of data
+ stored on your device;
+ (b) damage the configuration, software, or operating state of
+ your device;
+ (c) cause unintended communications or financial transactions
+ performed under your identity; or
+ (d) otherwise affect the integrity of your device or accounts.
+ 7.3 TO THE FULLEST EXTENT PERMITTED BY LAW, NEITHER WE NOR SAMOSA AI
+ ARE LIABLE FOR ANY SUCH DAMAGE. YOU ASSUME FULL RESPONSIBILITY FOR
+ SAFEGUARDING YOUR DATA (BACKUPS, VERSION CONTROL, RECOVERY PLANS)
+ BEFORE GRANTING THE AGENT BROAD DEVICE ACCESS.
+
+8. THIRD-PARTY BACKENDS AND PROVIDERS
+
+ 8.1 The App interoperates with third-party AI providers. When you use
+ Samosa AI, requests are routed through the Samosa AIR proxy. When
+ you use a User-Provided Provider, requests go directly to that
+ endpoint under your credentials.
+ 8.2 Third-party providers have their own terms, privacy practices,
+ pricing, and data-handling policies. We do not control and are not
+ responsible for the practices of any third-party provider you
+ choose to use, including how they retain, train on, log, or share
+ the requests sent to them.
+ 8.3 If you supply your own credentials to a User-Provided Provider,
+ those credentials (and the prompts you send) are transmitted to that
+ provider under its own terms. We do not warrant the security of any
+ user-supplied credentials once transmitted to a third-party.
+
+9. FEES
+
+ 9.1 The App itself is provided free of charge unless explicitly stated
+ otherwise.
+ 9.2 You are responsible for all fees charged by your chosen backend:
+ Samosa AI's pricing, the pricing of any User-Provided Provider, and
+ any data, messaging, or carrier charges incurred by actions the
+ agent takes on your behalf.
+
+10. INTELLECTUAL PROPERTY
+
+ 10.1 We (and our licensors) retain all right, title, and interest in
+ and to the App, including all related software, branding, and
+ documentation. No rights are transferred to you other than the
+ limited license in Section 3.
+ 10.2 You retain ownership of content you create or input into the App,
+ subject to the licenses required for us and our backends to
+ process it as described in our Data Retention Policy.
+
+11. TERMINATION
+
+ 11.1 You may stop using the App at any time by uninstalling it.
+ 11.2 We may suspend or terminate your access to any backend feature at
+ any time, with or without notice, if we reasonably believe you
+ have violated these Terms or if the underlying service is
+ discontinued.
+ 11.3 Upon termination, the license in Section 3 ends. Sections that by
+ their nature should survive (including 5, 6, 7, 8, 12, 13, 14)
+ survive termination.
+
+12. DISCLAIMER OF WARRANTIES
+
+ 12.1 TO THE FULLEST EXTENT PERMITTED BY LAW, THE APP AND ALL RELATED
+ SERVICES ARE PROVIDED "AS IS" AND "AS AVAILABLE," WITHOUT
+ WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT
+ LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
+ A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND ACCURACY.
+ 12.2 WE DO NOT WARRANT THAT THE APP WILL BE UNINTERRUPTED, ERROR-FREE,
+ SECURE, OR FREE OF HARMFUL COMPONENTS, OR THAT DEFECTS WILL BE
+ CORRECTED.
+
+13. LIMITATION OF LIABILITY
+
+ 13.1 TO THE FULLEST EXTENT PERMITTED BY LAW, IN NO EVENT WILL WE,
+ SAMOSA AI, OR OUR RESPECTIVE AFFILIATES, OFFICERS, DIRECTORS,
+ EMPLOYEES, AGENTS, OR LICENSORS BE LIABLE FOR ANY INDIRECT,
+ INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR FOR
+ ANY LOSS OF PROFITS, REVENUE, DATA, GOODWILL, OR USE, ARISING OUT
+ OF OR RELATING TO YOUR USE OF (OR INABILITY TO USE) THE APP,
+ WHETHER BASED ON WARRANTY, CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STATUTE, OR ANY OTHER LEGAL THEORY, AND WHETHER OR NOT WE HAVE
+ BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ 13.2 IN ANY EVENT, OUR TOTAL AGGREGATE LIABILITY FOR ALL CLAIMS
+ RELATING TO THE APP WILL NOT EXCEED ONE HUNDRED U.S. DOLLARS
+ (USD $100) OR THE EQUIVALENT IN YOUR LOCAL CURRENCY.
+
+14. INDEMNIFICATION
+
+ 14.1 You agree to indemnify, defend, and hold harmless Gotcha,
+ Samosa AI, and our respective affiliates, officers, directors,
+ employees, and agents from and against any third-party claim,
+ demand, loss, liability, damage, or expense (including reasonable
+ legal fees) arising out of or relating to your use of the App,
+ your violation of these Terms, or your violation of any
+ applicable law or third-party right.
+
+15. CHANGES TO THESE TERMS
+
+ 15.1 We may update these Terms from time to time. The "Last updated"
+ date at the top will reflect the current version.
+ 15.2 Material changes will be communicated through the App (in-app
+ notice or first-launch dialog). Continued use of the App after
+ such notice constitutes acceptance of the updated Terms.
+ 15.3 If you do not agree to an update, stop using the App and
+ uninstall it.
+
+16. GOVERNING LAW AND DISPUTES
+
+ 16.1 These Terms are governed by the laws of India, without regard to
+ its conflict-of-laws principles.
+ 16.2 Any dispute arising out of or relating to these Terms or the App
+ will be resolved exclusively in the competent courts of India,
+ except where mandatory consumer-protection laws of your country
+ of residence give you the right to bring an action in that
+ jurisdiction.
+ 16.3 Nothing in this section limits any non-waivable right you have
+ under the consumer laws of your jurisdiction.
+
+17. CONTACT
+
+ 17.1 Questions about these Terms can be sent to [email protected].
+
+— END OF TERMS —
diff --git a/app/src/main/java/com/gotcha/LegalConsentDialog.kt b/app/src/main/java/com/gotcha/LegalConsentDialog.kt
new file mode 100644
index 0000000..63106da
--- /dev/null
+++ b/app/src/main/java/com/gotcha/LegalConsentDialog.kt
@@ -0,0 +1,212 @@
+package com.gotcha
+
+import android.content.Context
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.selection.toggleable
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material3.AlertDialog
+import androidx.compose.material3.Checkbox
+import androidx.compose.material3.HorizontalDivider
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextButton
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.testTag
+import androidx.compose.ui.res.stringArrayResource
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import com.gotcha.ui.renderLegalMarkdown
+
+/**
+ * First-launch / re-acceptance gate. Non-dismissable: the only way out is the
+ * "I agree" button, which is itself disabled until the user toggles the
+ * "I have read and accept…" checkbox. When that toggle is on, the dialog
+ * expands to show all three legal documents inline (Terms, Disclaimer, Data
+ * Retention) so the user knows exactly what they are agreeing to without
+ * leaving the dialog.
+ *
+ * Re-prompted by [com.gotcha.MainActivity] whenever the stored
+ * [com.gotcha.data.Settings.legalAcceptedVersion] doesn't match the current
+ * [com.gotcha.data.LEGAL_VERSION], which is the e-tag-style mechanism the
+ * documents ship under.
+ */
+@Composable
+fun LegalConsentDialog(
+ onAgree: () -> Unit
+) {
+ val context = LocalContext.current
+ var showFull by remember { mutableStateOf(false) }
+ var termsText by remember { mutableStateOf<String?>(null) }
+ var disclaimerText by remember { mutableStateOf<String?>(null) }
+ var privacyText by remember { mutableStateOf<String?>(null) }
+
+ // Lazy load the three legal documents on first toggle. Reading them from
+ // assets is fast (a few KB each), but doing it eagerly would block the
+ // dialog's first frame for no benefit when the user never toggles.
+ LaunchedEffect(showFull) {
+ if (showFull && termsText == null) {
+ termsText = readAsset(context, "legal/terms.md")
+ disclaimerText = readAsset(context, "legal/disclaimer.md")
+ privacyText = readAsset(context, "legal/privacy-data-retention.md")
+ }
+ }
+
+ val bullets = stringArrayResource(R.array.legal_consent_bullets)
+ val loadingLabel = stringResource(R.string.legal_consent_loading)
+
+ AlertDialog(
+ onDismissRequest = { /* non-dismissable until accepted */ },
+ title = {
+ Text(
+ text = stringResource(R.string.legal_consent_title),
+ fontWeight = FontWeight.Bold
+ )
+ },
+ text = {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .verticalScroll(rememberScrollState()),
+ verticalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ Text(
+ text = stringResource(R.string.legal_consent_intro),
+ style = MaterialTheme.typography.bodyMedium
+ )
+
+ bullets.forEach { bullet ->
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(6.dp),
+ verticalAlignment = Alignment.Top
+ ) {
+ Text(
+ text = "•",
+ style = MaterialTheme.typography.bodyMedium,
+ fontWeight = FontWeight.Bold
+ )
+ Text(
+ text = bullet,
+ style = MaterialTheme.typography.bodyMedium,
+ modifier = Modifier.weight(1f)
+ )
+ }
+ }
+
+ HorizontalDivider(thickness = 1.dp)
+
+ // The toggle row. Whole row is clickable so the user can hit
+ // anywhere on the label, not just the small checkbox target.
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .toggleable(
+ value = showFull,
+ role = Role.Checkbox,
+ onValueChange = { showFull = it }
+ )
+ .padding(vertical = 4.dp)
+ .testTag("legal_consent_toggle_row"),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(8.dp)
+ ) {
+ Checkbox(
+ checked = showFull,
+ onCheckedChange = null,
+ modifier = Modifier.testTag("legal_consent_toggle_checkbox")
+ )
+ Text(
+ text = stringResource(R.string.legal_consent_toggle_label),
+ style = MaterialTheme.typography.bodyMedium,
+ modifier = Modifier.weight(1f)
+ )
+ }
+
+ if (showFull) {
+ HorizontalDivider(thickness = 1.dp)
+
+ DocumentBlock(
+ title = stringResource(R.string.legal_consent_section_terms),
+ body = termsText,
+ loadingLabel = loadingLabel
+ )
+ DocumentBlock(
+ title = stringResource(R.string.legal_consent_section_disclaimer),
+ body = disclaimerText,
+ loadingLabel = loadingLabel
+ )
+ DocumentBlock(
+ title = stringResource(R.string.legal_consent_section_privacy),
+ body = privacyText,
+ loadingLabel = loadingLabel
+ )
+ }
+ }
+ },
+ confirmButton = {
+ TextButton(
+ onClick = onAgree,
+ enabled = showFull,
+ modifier = Modifier.testTag("legal_consent_agree_button")
+ ) { Text(stringResource(R.string.legal_consent_agree)) }
+ }
+ // No dismissButton — the dialog has no "later" path on purpose.
+ )
+}
+
+/**
+ * One legal document inline: section title plus its rendered Markdown body.
+ * Sits in a soft surface card so the eye picks it out from the surrounding
+ * summary text, which uses the default background.
+ */
+@Composable
+private fun DocumentBlock(title: String, body: String?, loadingLabel: String) {
+ Surface(
+ shape = RoundedCornerShape(8.dp),
+ color = MaterialTheme.colorScheme.surfaceVariant,
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 12.dp, vertical = 10.dp),
+ verticalArrangement = Arrangement.spacedBy(6.dp)
+ ) {
+ Text(
+ text = title,
+ style = MaterialTheme.typography.titleSmall,
+ fontWeight = FontWeight.SemiBold,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ Text(
+ text = renderLegalMarkdown(body ?: loadingLabel),
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+ }
+}
+
+/** Read a UTF-8 text asset; never throws — a missing asset shows an error string. */
+private fun readAsset(context: Context, path: String): String = try {
+ context.assets.open(path).use { it.readBytes().toString(Charsets.UTF_8) }
+} catch (t: Throwable) {
+ "Failed to read asset $path: ${t.message ?: t::class.java.simpleName}"
+}
diff --git a/app/src/main/java/com/gotcha/MainActivity.kt b/app/src/main/java/com/gotcha/MainActivity.kt
index 0ff7b81..c3b6c41 100644
--- a/app/src/main/java/com/gotcha/MainActivity.kt
+++ b/app/src/main/java/com/gotcha/MainActivity.kt
@@ -38,6 +38,7 @@ import com.gotcha.audio.AudioModel
import com.gotcha.audio.ModelCategory
import com.gotcha.auth.SamosaAuthManager
import com.gotcha.auth.SamosaSignInResult
+import com.gotcha.data.LEGAL_VERSION
import com.gotcha.data.Settings
import com.gotcha.data.SettingsRepository
import com.gotcha.llm.ChatMessage
@@ -84,6 +85,13 @@ class MainActivity : ComponentActivity() {
/** Appearance, applied immediately when changed in Settings ▸ Appearance. */
private var appearance by mutableStateOf(Appearance())
+ /**
+ * ETag-style version of the legal bundle the user has accepted. Empty until
+ * the first-launch dialog is dismissed with "I agree." Re-prompted whenever
+ * [Settings.LEGAL_VERSION] (in [SettingsRepository]) is bumped.
+ */
+ private var legalAcceptedVersion by mutableStateOf("")
+
/** The one setting that decides what the app looks like. */
private data class Appearance(val skinId: String = Skins.DEFAULT_ID)
@@ -193,6 +201,13 @@ class MainActivity : ComponentActivity() {
appearance = settingsRepository.load().appearance()
applyLaunchBackground()
+ // First-launch / re-acceptance gate. Stored version is whatever the user
+ // last agreed to; if it doesn't match the current LEGAL_VERSION (or is
+ // empty), the consent dialog shows and the rest of the app waits behind
+ // it. The dialog itself is mounted in [GotchaApp]; this only seeds the
+ // initial state for the activity.
+ legalAcceptedVersion = settingsRepository.load().legalAcceptedVersion
+
setContent {
GotchaTheme(skinId = appearance.skinId) {
Surface(
@@ -475,7 +490,8 @@ class MainActivity : ComponentActivity() {
ModalNavigationDrawer(
drawerState = drawerState,
- gesturesEnabled = currentRoute == Route.HOME || drawerState.isOpen,
+ gesturesEnabled = (currentRoute == Route.HOME || drawerState.isOpen) &&
+ legalAcceptedVersion == LEGAL_VERSION,
drawerContent = {
AppDrawerContent(
sessions = sessions,
@@ -673,10 +689,16 @@ class MainActivity : ComponentActivity() {
}
// Composed last so this innermost enabled handler wins back dispatch:
- // back closes an open drawer before any other navigation.
+ // back closes an open drawer before any other navigation. When the
+ // legal-consent dialog is up, we swallow back entirely — the only way
+ // out is "I agree" (or uninstalling the app), which keeps a fresh
+ // install from booting straight into Settings via the back button.
BackHandler(enabled = drawerState.isOpen) {
scope.launch { drawerState.close() }
}
+ if (legalAcceptedVersion != LEGAL_VERSION) {
+ BackHandler(enabled = true) { /* swallow */ }
+ }
notificationPayload?.let { payload ->
NotificationDetailDialog(
@@ -684,6 +706,23 @@ class MainActivity : ComponentActivity() {
onDismiss = { notificationPayload = null }
)
}
+
+ // First-launch / re-acceptance gate. Non-dismissable while not accepted
+ // — the only way out is tapping "I agree." Re-prompted whenever the
+ // current LEGAL_VERSION doesn't match the stored acceptance, so a
+ // meaningful change to any of the three documents forces re-acceptance
+ // on every install.
+ if (legalAcceptedVersion != LEGAL_VERSION) {
+ LegalConsentDialog(
+ onAgree = {
+ val current = settingsRepository.load()
+ settingsRepository.save(
+ current.copy(legalAcceptedVersion = LEGAL_VERSION)
+ )
+ legalAcceptedVersion = LEGAL_VERSION
+ }
+ )
+ }
}
/** Cheap "ping" request to validate credentials (Phase 6). */
diff --git a/app/src/main/java/com/gotcha/data/SettingsRepository.kt b/app/src/main/java/com/gotcha/data/SettingsRepository.kt
index 3b2dbda..40bb3c4 100644
--- a/app/src/main/java/com/gotcha/data/SettingsRepository.kt
+++ b/app/src/main/java/com/gotcha/data/SettingsRepository.kt
@@ -100,7 +100,16 @@ data class Settings(
val userResponseStyle: String = "",
val preferredLanguage: String = "English",
val preferredCurrency: String = "USD",
- val communitySkillHosts: Set<String> = setOf("samosa-ai.example")
+ val communitySkillHosts: Set<String> = setOf("samosa-ai.example"),
+ /**
+ * Version tag of the Terms / Disclaimer / Data Retention bundle the user has
+ * accepted. Empty string means "never accepted." The first-launch consent
+ * dialog writes the current [LEGAL_VERSION] here when the user agrees;
+ * MainActivity re-prompts whenever the stored tag is older than
+ * [LEGAL_VERSION], so a meaningful change to the legal copy forces re-acceptance
+ * without losing any user data.
+ */
+ val legalAcceptedVersion: String = ""
) {
/** True when the active provider has everything it needs to make requests. */
val isConfigured: Boolean
@@ -318,7 +327,8 @@ class SettingsRepository(context: Context) {
userResponseStyle = string(KEY_USER_RESPONSE_STYLE),
preferredLanguage = string(KEY_PREFERRED_LANGUAGE, "English"),
preferredCurrency = string(KEY_PREFERRED_CURRENCY, "USD"),
- communitySkillHosts = stringSet(KEY_COMMUNITY_SKILL_HOSTS, defaultCommunitySkillHosts)
+ communitySkillHosts = stringSet(KEY_COMMUNITY_SKILL_HOSTS, defaultCommunitySkillHosts),
+ legalAcceptedVersion = string(KEY_LEGAL_ACCEPTED_VERSION)
)
fun save(settings: Settings) {
@@ -372,6 +382,7 @@ class SettingsRepository(context: Context) {
.putString(KEY_PREFERRED_LANGUAGE, settings.preferredLanguage)
.putString(KEY_PREFERRED_CURRENCY, settings.preferredCurrency)
.putStringSet(KEY_COMMUNITY_SKILL_HOSTS, settings.communitySkillHosts)
+ .putString(KEY_LEGAL_ACCEPTED_VERSION, settings.legalAcceptedVersion)
.apply()
}
@@ -444,6 +455,16 @@ class SettingsRepository(context: Context) {
const val KEY_PREFERRED_LANGUAGE = "preferred_language"
const val KEY_PREFERRED_CURRENCY = "preferred_currency"
const val KEY_COMMUNITY_SKILL_HOSTS = "community_skill_hosts"
+ const val KEY_LEGAL_ACCEPTED_VERSION = "legal_accepted_version"
val defaultCommunitySkillHosts: Set<String> = setOf("samosa-ai.example")
}
}
+
+/**
+ * Bump this whenever any of the three legal documents in `assets/legal/`
+ * changes in a way the user must re-acknowledge. The first-launch consent
+ * dialog re-prompts whenever the stored accepted version is older than this
+ * constant, so non-material edits (typo fixes, formatting) should leave it
+ * unchanged.
+ */
+const val LEGAL_VERSION: String = "1"
diff --git a/app/src/main/java/com/gotcha/ui/LegalScreen.kt b/app/src/main/java/com/gotcha/ui/LegalScreen.kt
new file mode 100644
index 0000000..3766525
--- /dev/null
+++ b/app/src/main/java/com/gotcha/ui/LegalScreen.kt
@@ -0,0 +1,190 @@
+package com.gotcha.ui
+
+import android.content.Context
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ColumnScope
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.HorizontalDivider
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.OutlinedButton
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.testTag
+import androidx.compose.ui.text.AnnotatedString
+import androidx.compose.ui.text.SpanStyle
+import androidx.compose.ui.text.buildAnnotatedString
+import androidx.compose.ui.text.font.FontStyle
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.text.withStyle
+import androidx.compose.ui.unit.dp
+import com.gotcha.data.LEGAL_VERSION
+import com.gotcha.data.Settings
+
+/**
+ * The Legal page: shows the Terms, Disclaimer, and Data Retention documents
+ * and lets the user re-affirm acceptance from here.
+ *
+ * The three documents are loaded once from `assets/legal/{terms,disclaimer,
+ * privacy-data-retention}.md` and rendered with a small, dependency-free
+ * Markdown pass (headings, blockquotes, bold). An "I agree" button writes
+ * [Settings.legalAcceptedVersion] so the user never sees the first-launch
+ * gate again unless the documents change.
+ */
+@Composable
+fun LegalScreen(
+ context: Context,
+ load: () -> Settings,
+ onSave: ((Settings) -> Settings) -> Unit,
+ onBack: () -> Unit
+) {
+ val overlay = rememberSettingsOverlayState()
+ val initial = remember { load() }
+
+ var termsText by remember { mutableStateOf<String?>(null) }
+ var disclaimerText by remember { mutableStateOf<String?>(null) }
+ var privacyText by remember { mutableStateOf<String?>(null) }
+
+ LaunchedEffect(Unit) {
+ termsText = readAsset(context, "legal/terms.md")
+ disclaimerText = readAsset(context, "legal/disclaimer.md")
+ privacyText = readAsset(context, "legal/privacy-data-retention.md")
+ }
+
+ SettingsScaffold(title = SettingsPage.LEGAL.title, onBack = onBack, overlay = overlay) {
+ Text(
+ "By using Gotcha you accept these documents.",
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+
+ LegalSection(label = "Terms and Conditions", markdown = termsText)
+ LegalSection(label = "Disclaimer and Declaration", markdown = disclaimerText)
+ LegalSection(label = "Data Retention and Privacy Policy", markdown = privacyText)
+
+ HorizontalDivider(thickness = 1.dp)
+
+ AcceptBlock(
+ acceptedVersion = initial.legalAcceptedVersion,
+ onAccept = {
+ onSave { it.copy(legalAcceptedVersion = LEGAL_VERSION) }
+ overlay.show("Accepted. You won't see this gate again until the legal copy changes.")
+ }
+ )
+ }
+}
+
+@Composable
+private fun LegalSection(label: String, markdown: String?) {
+ Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
+ Text(
+ text = label,
+ style = MaterialTheme.typography.titleMedium,
+ fontWeight = FontWeight.Bold
+ )
+ Box(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(vertical = 4.dp)
+ ) {
+ val body = markdown ?: "(loading…)"
+ Text(text = renderLegalMarkdown(body), style = MaterialTheme.typography.bodyMedium)
+ }
+ }
+}
+
+@Composable
+private fun ColumnScope.AcceptBlock(
+ acceptedVersion: String,
+ onAccept: () -> Unit
+) {
+ val currentVersion = LEGAL_VERSION
+ if (acceptedVersion == currentVersion) {
+ Text(
+ text = "You've accepted version $currentVersion. You'll be asked again " +
+ "only if the legal copy changes.",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ textAlign = TextAlign.Start
+ )
+ return
+ }
+ OutlinedButton(
+ onClick = onAccept,
+ modifier = Modifier
+ .fillMaxWidth()
+ .testTag("settings_legal_accept_button")
+ ) { Text("I agree") }
+ Text(
+ text = if (acceptedVersion.isBlank()) {
+ "You haven't accepted yet. The first-launch dialog will keep showing " +
+ "until you tap I agree."
+ } else {
+ "You accepted an earlier version ($acceptedVersion). The current " +
+ "version is $currentVersion."
+ },
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+}
+
+private fun readAsset(context: Context, path: String): String = try {
+ context.assets.open(path).use { it.readBytes().toString(Charsets.UTF_8) }
+} catch (t: Throwable) {
+ "Failed to read asset $path: ${t.message ?: t::class.java.simpleName}"
+}
+
+/**
+ * Tiny, dependency-free Markdown pass for the features the legal documents
+ * actually use: `#`/`##`/`###` headings, `> ` blockquotes, blank-line
+ * paragraph breaks. The legal copy is hand-written and only uses these
+ * primitives, so this is enough for readability without a library.
+ *
+ * Numbered and bulleted list items are left as inline text — the legal
+ * documents number sections manually ("1.1", "1.2", …), which would be
+ * mangled by a naive list pass, and the current rendered form is fine.
+ */
+internal fun renderLegalMarkdown(src: String): AnnotatedString = buildAnnotatedString {
+ for (line in src.lines()) {
+ when {
+ line.startsWith("# ") -> {
+ withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
+ append(line.removePrefix("# "))
+ }
+ append('\n')
+ }
+ line.startsWith("## ") -> {
+ withStyle(SpanStyle(fontWeight = FontWeight.SemiBold)) {
+ append(line.removePrefix("## "))
+ }
+ append('\n')
+ }
+ line.startsWith("### ") -> {
+ withStyle(SpanStyle(fontWeight = FontWeight.Medium)) {
+ append(line.removePrefix("### "))
+ }
+ append('\n')
+ }
+ line.startsWith("> ") -> {
+ withStyle(SpanStyle(fontStyle = FontStyle.Italic)) {
+ append(line.removePrefix("> "))
+ }
+ append('\n')
+ }
+ line.isBlank() -> append('\n')
+ else -> {
+ append(line)
+ append('\n')
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
index c46c9d9..24e6c0d 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
@@ -108,6 +108,11 @@ enum class SettingsPage(val title: String, val summary: String, val testTag: Str
"Notifications",
"How you're alerted when a reply arrives",
"settings_notifications_row"
+ ),
+ LEGAL(
+ "Legal",
+ "Terms, disclaimer, data retention",
+ "settings_legal_row"
)
}
diff --git a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
index 0c782d9..26d3130 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
@@ -149,6 +149,12 @@ fun SettingsScreen(
onBack = backToHome,
onSyncServerMessages = onSyncServerMessages
)
+ SettingsPage.LEGAL -> LegalScreen(
+ context = androidx.compose.ui.platform.LocalContext.current,
+ load = load,
+ onSave = onSave,
+ onBack = backToHome
+ )
null -> SettingsHome(
onBack = onBack,
onOpenPage = { page = it }
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a11654b..5db23d1 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -3,4 +3,19 @@
<string name="app_name">Gotcha</string>
<string name="accessibility_service_description">Lets Gotcha read on-screen content and perform taps, swipes and text input on your behalf, so the assistant can operate other apps for you.</string>
<string name="device_admin_description">Lets Gotcha lock the screen, enforce password policy and disable the camera when you ask it to.</string>
+ <string name="legal_consent_title">Before you continue</string>
+ <string name="legal_consent_intro">Gotcha is an AI assistant that can take real, sometimes irreversible actions on your device. By tapping "I agree" you accept the Terms and Conditions, the Disclaimer and Declaration, and the Data Retention and Privacy Policy. You must be at least 18 years old.</string>
+ <string name="legal_consent_toggle_label">I have read and accept the full Terms and Conditions, Disclaimer, and Data Retention Policy.</string>
+ <string name="legal_consent_agree">I agree</string>
+ <string name="legal_consent_section_terms">Terms and Conditions</string>
+ <string name="legal_consent_section_disclaimer">Disclaimer and Declaration</string>
+ <string name="legal_consent_section_privacy">Data Retention and Privacy Policy</string>
+ <string name="legal_consent_loading">(loading…)</string>
+ <string-array name="legal_consent_bullets">
+ <item>The AI can make mistakes. Treat its output as a draft and verify before acting on anything with real-world consequences (messages, calls, purchases, deletes, settings changes).</item>
+ <item>Once you grant the agent permissions, it can send messages, place calls, install or uninstall apps, delete files, and modify system settings on your device.</item>
+ <item>Your chats, screenshots, and API keys stay on your device. The App does not upload them anywhere; there is nothing on our side to delete.</item>
+ <item>Third-party backends (Samosa AI or a User-Provided Provider you configure yourself) have their own terms and data-retention practices, which apply once a request leaves your phone.</item>
+ <item>You must use the App lawfully — no hacking, fraud, harassment, illegal activity, or infringement of others\' rights. You are responsible for any damage to your device or data.</item>
+ </string-array>
</resources>
diff --git a/app/src/test/java/com/gotcha/data/LegalSettingsTest.kt b/app/src/test/java/com/gotcha/data/LegalSettingsTest.kt
new file mode 100644
index 0000000..ae3061a
--- /dev/null
+++ b/app/src/test/java/com/gotcha/data/LegalSettingsTest.kt
@@ -0,0 +1,93 @@
+package com.gotcha.data
+
+import android.app.Application
+import androidx.test.core.app.ApplicationProvider
+import com.gotcha.testsupport.FakeAndroidKeyStore
+import org.junit.After
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.RobolectricTestRunner
+import org.robolectric.annotation.Config
+
+/**
+ * Round-trip for [Settings.legalAcceptedVersion], which is the e-tag the
+ * first-launch consent dialog uses to decide whether to re-prompt.
+ *
+ * Bumping [LEGAL_VERSION] in code is what forces re-acceptance on every
+ * install; [SettingsRepository.save] must persist the new tag, and
+ * [SettingsRepository.load] must read it back so the gate closes on the
+ * next launch.
+ */
+@RunWith(RobolectricTestRunner::class)
+@Config(sdk = [34])
+class LegalSettingsTest {
+
+ private val application: Application = ApplicationProvider.getApplicationContext()
+ private lateinit var repository: SettingsRepository
+
+ @Before
+ fun setUp() {
+ FakeAndroidKeyStore.setUp()
+ repository = SettingsRepository(application)
+ // Fresh settings for every test — important: the consent flag lives
+ // in the encrypted prefs file alongside everything else, so a stale
+ // value from a previous test would mask the assertion.
+ repository.save(Settings(apiKey = "test-key"))
+ }
+
+ @After
+ fun tearDown() {
+ repository.save(
+ Settings(apiKey = "test-key").copy(legalAcceptedVersion = "")
+ )
+ }
+
+ @Test
+ fun `default settings have an empty legal accepted version`() {
+ assertEquals("", repository.load().legalAcceptedVersion)
+ }
+
+ @Test
+ fun `saving the current LEGAL_VERSION closes the gate on next load`() {
+ // Simulates tapping "I agree" in the first-launch dialog.
+ repository.save(
+ repository.load().copy(legalAcceptedVersion = LEGAL_VERSION)
+ )
+
+ val loaded = repository.load()
+
+ assertEquals(LEGAL_VERSION, loaded.legalAcceptedVersion)
+ // The gate-closed predicate the activity uses:
+ assertEquals(LEGAL_VERSION, loaded.legalAcceptedVersion)
+ }
+
+ @Test
+ fun `save and load preserves the stored version across writes`() {
+ repository.save(repository.load().copy(legalAcceptedVersion = LEGAL_VERSION))
+ // Write a different field to confirm the legal tag isn't disturbed
+ // by an unrelated save.
+ repository.save(
+ repository.load().copy(model = "gpt-4o-mini")
+ )
+
+ val loaded = repository.load()
+
+ assertEquals(LEGAL_VERSION, loaded.legalAcceptedVersion)
+ assertEquals("gpt-4o-mini", loaded.model)
+ }
+
+ @Test
+ fun `an older accepted version still triggers the gate`() {
+ // Simulates a downgrade scenario (e.g. an upgrade that reverts the
+ // version constant). The stored value must come back exactly.
+ repository.save(repository.load().copy(legalAcceptedVersion = "0"))
+
+ val loaded = repository.load()
+
+ assertEquals("0", loaded.legalAcceptedVersion)
+ assertTrue(loaded.legalAcceptedVersion != LEGAL_VERSION)
+ }
+}