001// SPDX-License-Identifier: GPL-3.0-or-later 002// Copyright © 2026 Aurélien Pierre 003 004package com.aurelienpierre.sioul; 005 006import android.app.Activity; 007import android.content.Intent; 008import android.os.Bundle; 009import android.util.Log; 010 011/** 012 * A reminder tapped: its dose kept for Sioul ({@link DoseAlarms#takeOpened}, which 013 * Rust reads when the window comes up), then Sioul brought up as by its icon. 014 * A window of its own, never shown, so that no intent with a dose in it stays 015 * with Sioul's window, to be given again when Android restores it. 016 */ 017public final class DoseOpener extends Activity 018{ 019 @Override 020 protected void onCreate(Bundle state) 021 { 022 super.onCreate(state); 023 String key = DoseAlarms.key(getIntent()); 024 if (state == null && !key.isEmpty()) { 025 DoseAlarms.opened(this, key); 026 Log.i(DoseAlarms.TAG, "Doses: a reminder tapped, its dose kept for Sioul."); 027 } 028 Intent sioul = getPackageManager().getLaunchIntentForPackage(getPackageName()); 029 if (sioul != null) 030 startActivity(sioul.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)); 031 finish(); 032 } 033}