/* * 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.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 implements Application.ActivityLifecycleCallbacks { /** Until the splash lets the user in; 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 splash (PIN, indexing wait) until it lets the user in. */ @Override public void onActivityStarted(Activity a) { started++; if (locked && !(a instanceof SplashActivity)) a.startActivity(new Intent(a, SplashActivity.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) { } }