diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-22 12:04:10 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-22 12:04:10 +0200 |
| commit | 48b44a6e27b87ee8bf5340a8d7ff37afaf04b7f9 (patch) | |
| tree | 1eb779b880a78bda3af7bed4eb93a43dafd288bc /app/src/main/java/mygram/droid/App.java | |
| parent | a605449390de7737e718e6d10574e5581cf757e3 (diff) | |
| download | mygram-droid-48b44a6e27b87ee8bf5340a8d7ff37afaf04b7f9.tar.gz mygram-droid-48b44a6e27b87ee8bf5340a8d7ff37afaf04b7f9.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'app/src/main/java/mygram/droid/App.java')
| -rw-r--r-- | app/src/main/java/mygram/droid/App.java | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/app/src/main/java/mygram/droid/App.java b/app/src/main/java/mygram/droid/App.java index ffbdd8d..1919343 100644 --- a/app/src/main/java/mygram/droid/App.java +++ b/app/src/main/java/mygram/droid/App.java @@ -14,19 +14,61 @@ package mygram.droid; +import android.app.Activity; import android.app.Application; +import android.content.Intent; +import android.os.Bundle; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; -public final class App extends Application { +public final class App extends Application implements Application.ActivityLifecycleCallbacks { + /** Until the PIN is entered; set again whenever the app leaves the screen. */ + static boolean locked = true; + private int started; + @Override public void onCreate() { super.onCreate(); Prefs.init(this); + registerActivityLifecycleCallbacks(this); // One cookie jar for the Foldergram session: Api, Glide and ExoPlayer // all use HttpURLConnection, which consults the default handler. CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); } + + /** Before any screen draws, cover it with the PIN prompt if the app is locked. */ + @Override + public void onActivityStarted(Activity a) { + started++; + if (locked && Prefs.hasPin() && !(a instanceof LockActivity)) + a.startActivity(new Intent(a, LockActivity.class)); + } + + @Override + public void onActivityStopped(Activity a) { + if (--started == 0) + locked = true; + } + + @Override + public void onActivityCreated(Activity a, Bundle state) { + } + + @Override + public void onActivityResumed(Activity a) { + } + + @Override + public void onActivityPaused(Activity a) { + } + + @Override + public void onActivitySaveInstanceState(Activity a, Bundle state) { + } + + @Override + public void onActivityDestroyed(Activity a) { + } } |
