From 48b44a6e27b87ee8bf5340a8d7ff37afaf04b7f9 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 22 Oct 2026 12:04:10 +0200 Subject: Optional app PIN, settings header, pink selection ring - A PIN (4 to 8 digits, salted SHA-256 in prefs) set in Settings shows a logo splash with a PIN prompt at start and whenever the app returns after leaving the screen; Back there leaves the app. - Settings gets the back-arrow header shared with the folder grid (Ui.header) and scrolls, since the PIN fields overflow the screen. - Tile and list focus rings use the icon pink. Co-Authored-By: Claude Opus 5.5 --- app/src/main/java/mygram/droid/LockActivity.java | 63 ++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 app/src/main/java/mygram/droid/LockActivity.java (limited to 'app/src/main/java/mygram/droid/LockActivity.java') diff --git a/app/src/main/java/mygram/droid/LockActivity.java b/app/src/main/java/mygram/droid/LockActivity.java new file mode 100644 index 0000000..dd95915 --- /dev/null +++ b/app/src/main/java/mygram/droid/LockActivity.java @@ -0,0 +1,63 @@ +/* + * mygram-droid: Android TV client for Foldergram. + * Copyright (C) 2026 Danilo M. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +package mygram.droid; + +import android.app.Activity; +import android.os.Bundle; +import android.text.InputType; +import android.view.View; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.Toast; + +/** Splash with the logo and a PIN prompt; App shows it while the app is locked. */ +public final class LockActivity extends Activity { + @Override + protected void onCreate(Bundle state) { + super.onCreate(state); + LinearLayout box = Ui.column(this); + ImageView logo = new ImageView(this); + logo.setImageResource(R.drawable.ic_launcher); + logo.setContentDescription("mygram"); + int s = Ui.dp(this, 96); + LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(s, s); + lp.bottomMargin = Ui.dp(this, 24); + box.addView(logo, lp); + EditText pin = Ui.field(this, "PIN", InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); + box.addView(pin); + View ok = Ui.iconButton(this, R.drawable.ic_check, "Unlock", v -> { + if (Prefs.checkPin(pin.getText().toString())) { + App.locked = false; + finish(); + } else { + pin.setText(""); + Toast.makeText(this, "Wrong PIN", Toast.LENGTH_SHORT).show(); + } + }); + box.addView(ok); + // The keyboard's done key unlocks; the D-pad cannot leave the keyboard. + pin.setOnEditorActionListener((v, action, event) -> ok.performClick()); + setContentView(box); + pin.requestFocus(); + } + + /** Back leaves the app instead of revealing the screen underneath. */ + @Override + @SuppressWarnings("deprecation") // no predictive back on this TV; onBackPressed still fires + public void onBackPressed() { + finishAffinity(); + } +} -- cgit v1.2.3