34 Commits
Author SHA1 Message Date
me 025836acb6 Agent fixed the current set of issues, now the app at least runs (and is actually staying alive in the background successfully!) but the countdown is visually messed up on SDK24 (hours field is missing) and SDK36 (fields do not count down at all even though the app is making the noise), plus the Pause button no longer pauses and causes the right button to be disabled indefinitely after using it. 2026-11-09 15:13:08 -07:00
me 9ff779b26c Agent thinks it fixed the crash on SDK36 and lack of interval counting down on SDK24. 2026-11-08 19:38:16 -07:00
me 432a1394b9 main, app is now worse off after agent experimentation, crashes immediately on SDK 36 and does not count down on SDK 24, turn on DEBUG to see if anything obvious and silly is happening. 2026-11-08 15:21:04 -07:00
me 3a057f0878 Agent says it now has the app working properly with a foreground service. 2026-11-08 15:03:46 -07:00
me f59bd78716 main, more Android Studio recommendations. 2026-11-06 14:38:21 -07:00
me 01472d90fb Update AGP. 2026-11-06 14:35:02 -07:00
me f0cd128025 main, take some suggestions given by Android Studio. 2026-11-06 14:31:07 -07:00
me b7a419eeab main, fix some silliness of agent using full class path. 2026-11-06 14:30:34 -07:00
me 4ede74e7a2 Agent's attempt to ensure the sound gets played every interval (adding Looper to Handler and moving release() from playSound to onDestroy) as well as ensuring it's not delayed (using play() rather than start()). 2026-11-06 13:35:08 -07:00
me 124e1bc211 Fix some of the agent's code, mediaplayer not defined in TimerForegroundService so maybe it was intended for Main, and PowerManager's WakeLock tag wanted to know the app name with a colon for logging. 2026-11-03 13:34:31 -07:00
me 1b9f40c002 Update plugin versions. 2026-11-03 13:32:39 -07:00
me 262aa439db Model's attempt to fix: 1) Only the first itnerval making a sound, all subsequent countdowns being silent. 2) App opening up directly to the Alarms & Reminders screen to get permissions approved without any prompting the user on what is going on. 2026-11-03 13:16:32 -07:00
me 9f1bfe8940 gradle, add but comment changes recommended by local model. 2026-11-01 06:27:18 -07:00
me 1099dec4e6 main, fix NullPointerException. 2026-11-01 06:22:48 -07:00
me 54418801c5 main, add missing import. 2026-10-28 17:36:01 -07:00
me 875d143076 More fixes trying to get the new changes to work. 2026-10-23 08:37:53 -07:00
me 595cffce78 main, add missing or deleted import. 2026-10-21 03:00:15 -07:00
me 3965aa6d88 Attempt to get app to work properly when in the background in newer versions of Android, with assistance from qwen3.6:35b. Testing TBD. 2026-10-20 18:39:07 -07:00
me 1786f03577 changelog, add header for 1.1.2. 2026-10-02 07:20:41 -07:00
me 5b991a5225 main, fix ending bracket. 2026-10-02 07:20:29 -07:00
me 54a0c53c1b Add CHANGELOG. 2026-10-02 07:02:19 -07:00
me 72a77eeef2 alert, begin adding changes to have a foreground service. 2026-10-02 06:54:52 -07:00
me 4e474f3fce Merge pull request '1.1.2' (#5) from dev into main
Reviewed-on: #5
2026-09-28 17:50:35 -07:00
me c40f6c0166 icon, change legacy to be a circle again. 2026-09-28 17:15:40 -07:00
me edb38612b5 Take all the yellow highlight suggestions regarding versions, besides sticking with SDK 36. 2026-09-28 17:15:26 -07:00
me 38eda443dc icon, change from webp to png to support legacy AOSP version. 2026-09-28 17:01:24 -07:00
me 51f8e67799 AGP Upgrade Assistant 2026-09-28 17:00:50 -07:00
me 26bcc3e496 manifest, update release file size enhancers. 2026-09-28 16:45:52 -07:00
me 92173b1cae manifest, increment version. 2026-09-28 16:41:56 -07:00
me bb78aa0a9a icon, update so that the background is white on non-monochrome rather than green grid. 2026-09-28 16:36:38 -07:00
me e4ab9c91c8 Save monochrome art changes. 2026-09-28 16:32:26 -07:00
me fa7926ca6e manifest, use the new icon. 2026-09-28 16:27:52 -07:00
me deb6369f37 Import the icon art. 2026-09-28 16:27:40 -07:00
me d6e952eae9 Update icon art. 2026-09-28 16:27:20 -07:00
46 changed files with 615 additions and 150 deletions

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
# Changelog
## 1.2.0 (In Development)
**Add Foreground Service**
- Allow the app to stay in the foreground so that it does not get killed while running.
## 1.1.2 (Sep 28, 2026)
**Fix App Icon**
- Fix and enhance the icon for all versions of Android. Tested to work properly from SDK 16 to 36.
- Changed a few compile time options to help optimize the file size.
- Updated Gradle, AGP, and a few other internals.
## 1.1.1 (Aug 17, 2025)
**Volume Seekbar Fixes**
- Correctly add a space via Java and not Strings.xml.
- Ensure volume seekbar is accurate after app is resumed.
## 1.1.0 (Jul 19, 2025)
**Enhancements**
- Target Android 36 and update theme so that the app may be used properly on current and future versions of Android.
- Volume slider for easy viewing and changing of current settings.
- Add a default sound for devices lacking notification sounds.
- Add a rounded icon.
**Bugfixes**
- App opening with Start already pressed.
- Large intervals (hundreds of hours) causing odd behavior.
## 1.0.6 (Jan 4, 2025)
**Final Production Release**
The release APK available from the Play Store and my website for the last few years.
+7 -6
View File
@@ -2,19 +2,20 @@ apply plugin: 'com.android.application'
android {
namespace "com.hyperling.apps.infinitetimer"
compileSdkVersion 36
compileSdkVersion 37
defaultConfig {
applicationId "com.hyperling.apps.infinitetimer"
minSdkVersion 14
targetSdkVersion 36
targetSdkVersion 37
versionCode 9
versionName "1.1.1"
versionName "1.1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
@@ -25,7 +26,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
// https://mvnrepository.com/artifact/com.android.support/appcompat-v7
implementation group: 'com.android.support', name: 'appcompat-v7', version: '28.0.0'
implementation "com.android.support:appcompat-v7:28.0.0"
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
}
+22 -4
View File
@@ -1,20 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 🔊 Required to play sound while backgrounded & bypass Doze -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- Android 14 requires declaring foreground service types -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<!-- ⏰ Android 12+ exact alarm permission (users can deny, code handles it gracefully) -->
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<application
android:allowBackup="true"
android:icon="@mipmap/icon_512"
android:roundIcon="@mipmap/icon_rounded_512"
android:icon="@mipmap/ic_launcher"
android:label="@string/appName"
android:supportsRtl="true"
android:theme="@style/InfiniteTimer"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<!-- 🔔 Register the receiver that triggers the alarm response -->
<receiver android:name=".TimerReceiver"
android:exported="false" />
<!-- 🎵 Transient service to play audio & hold WakeLock -->
<service android:name=".TimerForegroundService"
android:foregroundServiceType="mediaPlayback"
android:exported="false" />
</application>
</manifest>
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

@@ -0,0 +1,85 @@
package com.hyperling.apps.infinitetimer;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;
public class Alert {
private static final String TAG = "Alert";
public static final String ACTION_TIMER = "com.hyperling.apps.infinitetimer.ACTION_TIMER";
/**
* Sets a persistent alarm that triggers the TimerReceiver.
* Uses setExactAndAllowWhileIdle to bypass Android Doze mode.
*/
public static void start(Context context, long intervalMs) {
Intent intent = new Intent(context, TimerReceiver.class);
intent.setAction(ACTION_TIMER);
// FLAG_IMMUTABLE required for Android 12+ (API 31+)
int flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_CANCEL_CURRENT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
flags |= PendingIntent.FLAG_IMMUTABLE;
}
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, flags);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
if (alarmManager != null) {
long triggerTime = System.currentTimeMillis() + intervalMs;
// Exact alarm ensures it triggers even in Doze mode
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, triggerTime, pendingIntent);
} else {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerTime, pendingIntent);
}
Log.d(TAG, "Alarm set for " + intervalMs + "ms at " + triggerTime);
} else {
Log.e(TAG, "Could not get AlarmManager service");
}
}
/**
* Cancels the timer. If the app is killed, alarms are dropped automatically.
*/
public static void stop(Context context) {
Intent intent = new Intent(context, TimerReceiver.class);
int flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_CANCEL_CURRENT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
flags |= PendingIntent.FLAG_IMMUTABLE;
}
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, flags);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
if (alarmManager != null) {
alarmManager.cancel(pendingIntent);
Log.d(TAG, "Alarm cancelled");
}
}
/**
* Checks/Requests permission for exact alarms on Android 12+
*/
public static boolean isExactAlarmAllowed(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
return am != null && am.canScheduleExactAlarms();
}
return true; // Android 11 and below allow exact alarms by default
}
/**
* Helper to request exact alarm permission if missing
*/
public static void requestExactAlarmPermission(android.app.Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !isExactAlarmAllowed(activity)) {
Intent intent = new Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM);
activity.startActivity(intent);
}
}
}
@@ -1,17 +1,23 @@
package com.hyperling.apps.infinitetimer;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
@@ -24,7 +30,6 @@ import android.widget.SeekBar;
import android.widget.TableRow;
import android.widget.TextView;
import java.net.URI;
import java.util.Map;
public class MainActivity extends AppCompatActivity {
@@ -40,7 +45,7 @@ public class MainActivity extends AppCompatActivity {
// Interrupt based checking would be nice
int waitInterval = 99;
boolean DEBUG, start, appOpen, serviceRunning;
boolean DEBUG=true, start, appOpen, serviceRunning;
SharedPreferences sharedPreferences;
@@ -52,12 +57,21 @@ public class MainActivity extends AppCompatActivity {
TextView tvDot;
Uri ringtoneUri;
// RingtoneManager reference for consistent notification sound playback across loops
private android.media.Ringtone notificationRingtone;
// For proper sound lifecycle management across timer loops
private Ringtone ringtonePlayer;
MediaPlayer mediaPlayer;
SeekBar seekBar;
AudioManager audioManager;
TextView tvSeekBar;
// Local broadcast receiver to update UI while app is foregrounded
private BroadcastReceiver timerUpdateReceiver;
@Override
protected void onCreate(Bundle savedInstanceState) {
String tag = "onCreate";
@@ -82,6 +96,9 @@ public class MainActivity extends AppCompatActivity {
if (DEBUG) Log.d(tag, "Got strings.");
/***** Setup Local Broadcast Receiver *****/
setupTimerUpdateReceiver();
/***** Shared Preferences *****/
sharedPreferences = getSharedPreferences(keySharedPreferences, MODE_PRIVATE);
DEBUG = sharedPreferences.getBoolean(keyDebug, true);
@@ -91,48 +108,19 @@ public class MainActivity extends AppCompatActivity {
if (DEBUG) Log.d(tag, "Got preferences.");
// Sound
ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
if (DEBUG) Log.d(tag, "ringtoneUri=" + ringtoneUri.toString());
mediaPlayer = MediaPlayer.create(this, ringtoneUri);
if (mediaPlayer == null) {
if (DEBUG) Log.d(tag, "Media Player is null, trying alarm");
ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
mediaPlayer = MediaPlayer.create(this, ringtoneUri);
}
if (mediaPlayer == null) {
if (DEBUG) Log.d(tag, "Media Player is null, trying ringtone");
ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
mediaPlayer = MediaPlayer.create(this, ringtoneUri);
}
if (mediaPlayer == null) {
if (DEBUG) Log.d(tag, "Media Player is null, trying all");
ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALL);
mediaPlayer = MediaPlayer.create(this, ringtoneUri);
}
if (mediaPlayer == null) {
if (DEBUG) Log.d(tag, "Media Player is null, trying local sound byte");
mediaPlayer = MediaPlayer.create(this, R.raw.chime_sound_7143);
}
if (mediaPlayer == null) {
String message = "Could not find a notification, alarm, or ringtone to play.";
message += " App will not be able to function without one of these.";
message += " Please exit and install a system notification sound.";
// Check exact alarm permission for Android 12+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !Alert.isExactAlarmAllowed(this)) {
if (DEBUG) Log.w(tag, "Exact alarm permission not granted, requesting...");
new AlertDialog.Builder(MainActivity.this)
.setTitle("Error")
.setMessage(message)
.setPositiveButton("Exit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
.setTitle("Alarm Permission Required")
.setMessage("To ensure the timer alerts you reliably, please grant 'Alarms & Reminders' permission in system settings.")
.setPositiveButton("Grant Permission", (d, w) -> {
Intent intent = new Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM);
startActivity(intent);
})
.setNegativeButton("Not Now", (d, w) -> d.dismiss())
.setCancelable(false)
.show()
;
} else {
if (DEBUG) Log.d(tag, "mediaPlayer=" + mediaPlayer.toString());
.show();
}
if (DEBUG){
@@ -240,6 +228,20 @@ public class MainActivity extends AppCompatActivity {
if (DEBUG) Log.d(tag, "Finished");
}
private void setupTimerUpdateReceiver() {
timerUpdateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (DEBUG) Log.d(TAG + "Receiver", "Received service update");
// Update UI immediately with latest countdown state from Service
String remainingTime = intent.getStringExtra("remainingTime");
if (remainingTime != null && chronometer != null) {
chronometer.setText(remainingTime);
}
}
};
}
private void doTimeChooser(){
String tag = TAG + "doTimeChooser";
if (DEBUG) Log.d(tag, "Starting");
@@ -372,17 +374,29 @@ public class MainActivity extends AppCompatActivity {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(keyStartStop, start);
editor.putBoolean(keyAppOpen, true);
editor.putBoolean(keyServiceRunning, false);
editor.apply();
// hours:minutes:seconds should be disabled during count down.
flipInputTexts();
if (buttonText.equals(getString(R.string.btnStart))){
incrementTime.sendEmptyMessage(0);
setLoopInterval();
resetTimeLeft();
setStartTime();
long interval = longLoopInterval > 1000 ? longLoopInterval : 60000; // Minimum 1 minute interval for alarms
if (DEBUG) Log.d(tag, "Starting ForegroundService with interval: " + interval);
// Delegate countdown logic to ForegroundService to survive Doze mode on SDK 36+
Intent svcIntent = new Intent(this, TimerForegroundService.class);
svcIntent.setAction(Alert.ACTION_TIMER);
// Pass the calculated `interval` (which includes the 60s fallback if user entered nothing)
svcIntent.putExtra(TimerForegroundService.EXTRA_INTERVAL_MS, interval);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(svcIntent);
} else {
startService(svcIntent);
}
}
else if (buttonText.equals(getString(R.string.btnPause))){
btnStartStop.setText(getString(R.string.btnResume));
@@ -391,13 +405,11 @@ public class MainActivity extends AppCompatActivity {
etMinutes.setEnabled(false);
etSeconds.setEnabled(false);
}
else if (buttonText.equals(getString(R.string.btnStop))){
setChronometer(longLoopInterval);
}
else if (buttonText.equals(getString(R.string.btnResume))){
setStartTime();
incrementTime.sendEmptyMessage(0);
btnResetPause.setEnabled(true);
else if (buttonText.equals(getString(R.string.btnStop)) || buttonText.equals(getString(R.string.btnResume))){
// Stop the Foreground Service and cancel alarms
Intent svcIntent = new Intent(this, TimerForegroundService.class);
stopService(svcIntent);
Alert.stop(this);
}
flipStartStopButton();
@@ -494,79 +506,7 @@ public class MainActivity extends AppCompatActivity {
if (DEBUG) Log.d(tag, "Finished");
}
private final Handler incrementTime = new Handler(){
@Override
public void handleMessage(Message msg) {
String tag = TAG + "handleMessage";
if (DEBUG) Log.d(tag, "Starting");
super.handleMessage(msg);
appOpen = sharedPreferences.getBoolean(keyAppOpen, true);
if (appOpen) {
sharedPreferences.edit().putBoolean(keyServiceRunning, false).apply();
} else {
sharedPreferences.edit().putBoolean(keyServiceRunning, true).apply();
}
start = sharedPreferences.getBoolean(keyStartStop, false);
if (start){
//start = !start;
//sharedPreferences.edit().putBoolean(keyStartStop, false).apply();
// Calculate new time and text
setTimeLeft();
if (DEBUG) Log.d(tag, "longTimeLeft=" + longTimeLeft);
// Check if we need to beep
if (longTimeLeft < 1000){
playSound();
resetTimeLeft();
setStartTime();
if (DEBUG) {
Log.d(tag, "longLoopInterval=" + longLoopInterval);
Log.d(tag, "longStartTime=" + longStartTime);
Log.d(tag, "longEndTime=" + longEndTime);
Log.d(tag, "longTimeLeft=" + longTimeLeft);
Log.d(tag, "waitInterval=" + waitInterval);
Log.d(tag, "start=" + start);
//chronometer.setText("Test");
//setChronometer(200);
/*
start=false;
startStopChronometer("Start");
*/
}
}
// Wait
Runnable task = new Runnable() {
@Override
public void run() {
synchronized (this){
try{
wait(waitInterval);
if (DEBUG) Log.d(tag, "Done waiting.");
}
catch (Exception e){
e.printStackTrace();
if (DEBUG) Log.d(tag, "Failed to wait.");
}
}
//sharedPreferences.edit().putBoolean(keyStartStop, true).apply();
incrementTime.sendEmptyMessage(0);
//startStopChronometer("Start");
}
};
Thread t = new Thread(task);
t.start();
}
if (DEBUG) Log.d(tag, "Finished");
}
};
// Removed local countdown Handler - timing and background survival is now delegated to TimerForegroundService
private void setStartTime(){
String tag = TAG + "setStartTime";
@@ -616,15 +556,36 @@ public class MainActivity extends AppCompatActivity {
String tag = TAG + "playSound";
if (DEBUG) Log.d(tag, "Starting");
/* Original code, did not work on Nexus 7 with CM 12.1-20151117 (Android 5.1.1) * /
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/raw/chime_sound_7143");
//Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), ringtoneUri);
Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), uri);
ringtone.play();
/**/
try {
mediaPlayer.start();
// Stop any existing notification ringtone first to prevent overlap
if (notificationRingtone != null && notificationRingtone.isPlaying()) {
notificationRingtone.stop();
}
// Use RingtoneManager which handles async playback lifecycle properly
Uri uri = android.media.RingtoneManager.getDefaultUri(android.media.RingtoneManager.TYPE_NOTIFICATION);
notificationRingtone = android.media.RingtoneManager.getRingtone(this, uri);
if (notificationRingtone != null) {
// Ringtone.play() is asynchronous and handles its own lifecycle,
// avoiding the MediaPlayer.create() + immediate release bug that
// caused silence on subsequent loops
notificationRingtone.play();
} else {
// Fallback: if getRingtone fails, try direct MediaPlayer with proper lifecycle
MediaPlayer localPlayer = MediaPlayer.create(this, uri);
if (localPlayer != null) {
localPlayer.start();
final MediaPlayer fp = localPlayer;
// Release after playback completes (use delay as a safety net)
new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(
new Runnable() { @Override public void run() {
if (fp.isPlaying()) fp.stop();
fp.release();
}}, 2000
);
}
}
} catch (Exception e) {
sharedPreferences.edit().putBoolean(keyStartStop, false).apply();
@@ -665,6 +626,9 @@ public class MainActivity extends AppCompatActivity {
String tag = TAG + "resetAll";
if (DEBUG) Log.d(tag, "Starting");
// Stop the background alert service when resetting
Alert.stop(this);
if (DEBUG) Log.d(tag, "Resetting screen values...");
setChronometer(0);
setEditTexts("");
@@ -706,6 +670,8 @@ public class MainActivity extends AppCompatActivity {
protected void onPause() {
String tag = TAG + "onPause";
if (DEBUG) Log.d(tag, "Starting");
unregisterReceiver(timerUpdateReceiver);
stringLoopInterval =
etHours.getText().toString() + ":" +
@@ -736,6 +702,14 @@ public class MainActivity extends AppCompatActivity {
recoverScreen();
syncVolume();
// Register receiver to get live updates from ForegroundService while app is visible
IntentFilter filter = new IntentFilter(TimerForegroundService.class.getName() + ".UPDATE");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
registerReceiver(timerUpdateReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
} else {
registerReceiver(timerUpdateReceiver, filter);
}
if (DEBUG) Log.d(tag, "Finished");
}
@@ -745,7 +719,14 @@ public class MainActivity extends AppCompatActivity {
String tag = TAG + "onDestroy";
if (DEBUG) Log.d(tag, "Starting");
resetAll();
// Stop the background alert service when destroying activity
Alert.stop(this);
if (mediaPlayer != null) { mediaPlayer.release(); mediaPlayer = null; }
// Clean up ringtone player to prevent resource leak across config changes
if (notificationRingtone != null && notificationRingtone.isPlaying()) {
notificationRingtone.stop();
}
if (DEBUG) Log.d(tag, "Done with local code, calling super..");
@@ -764,4 +745,5 @@ public class MainActivity extends AppCompatActivity {
return bool;
}
return super.onKeyDown(keyCode, event);
}}
}
}
@@ -0,0 +1,188 @@
package com.hyperling.apps.infinitetimer;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.PowerManager;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
public class TimerForegroundService extends Service {
private static final String TAG = "TimerFGService";
public static final String CHANNEL_ID = "timer_notification_channel";
public static final int NOTIFICATION_ID = 1001;
// Intent extras to start the timer
public static final String EXTRA_INTERVAL_MS = "com.hyperling.apps.infinitetimer.INTERVAL_MS";
private PowerManager.WakeLock wakeLock;
private Handler serviceHandler;
// Timer state
private long loopIntervalMs;
private long endTimeMillis;
private Ringtone ringtonePlayer;
@Override
public void onCreate() {
super.onCreate();
createNotificationChannel();
// Acquire PARTIAL_WAKE_LOCK to keep CPU awake during Doze mode
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "InfiniteTimer:TimerFGWakeLock");
// Use main looper for safe UI updates from foreground service
serviceHandler = new Handler(Looper.getMainLooper());
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent == null || !Alert.ACTION_TIMER.equals(intent.getAction())) {
return START_NOT_STICKY;
}
// Start persistent foreground notification immediately to prevent Doze mode killing us
startForeground(NOTIFICATION_ID, buildNotification("Timer is active..."));
// Acquire wake lock briefly on start, but we'll hold it continuously as long as service runs
if (!wakeLock.isHeld()) {
wakeLock.acquire();
}
// If interval is passed via intent (first start), set it up.
// Otherwise, rely on AlarmManager/Handler to keep running.
long newInterval = intent.getLongExtra(EXTRA_INTERVAL_MS, -1);
if (newInterval > 0) {
loopIntervalMs = newInterval;
endTimeMillis = System.currentTimeMillis() + loopIntervalMs;
tick(); // Start the countdown immediately when the service is launched
} else {
Log.w(TAG, "Received start command without a valid positive interval.");
}
return START_STICKY;
}
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(
CHANNEL_ID, "Timer Notifications",
NotificationManager.IMPORTANCE_HIGH
);
// Disable default sound to avoid double-sound on some OEMs
channel.setSound(null, null);
channel.enableVibration(false);
NotificationManager manager = getSystemService(NotificationManager.class);
if (manager != null) manager.createNotificationChannel(channel);
}
}
private android.app.Notification buildNotification(String textContent) {
return new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("Infinite Timer")
.setContentText(textContent)
.setSmallIcon(android.R.drawable.ic_lock_idle_alarm)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setOngoing(true)
.setStyle(new NotificationCompat.InboxStyle().addLine(textContent))
.build();
}
// --- Core Timer Engine ---
/**
* Starts or resumes the countdown engine.
* Foreground services bypass Doze mode restrictions, allowing this to run reliably on SDK 36+.
*/
public void startTimer(long intervalMs) {
if (loopIntervalMs == intervalMs && serviceHandler.hasMessages(0)) {
return; // Already running at this interval
}
loopIntervalMs = intervalMs;
endTimeMillis = System.currentTimeMillis() + loopIntervalMs;
tick();
}
public void stopTimer() {
if (serviceHandler != null) {
serviceHandler.removeCallbacksAndMessages(null);
if (wakeLock.isHeld()) wakeLock.release();
}
}
private void tick() {
long currentTime = System.currentTimeMillis();
long remainingMs = endTimeMillis - currentTime;
if (remainingMs <= 0) {
playAlarmSound();
// Loop indefinitely: reschedule for the next interval
endTimeMillis += loopIntervalMs;
remainingMs = loopIntervalMs;
}
String timeStr = formatTime(remainingMs);
updateNotification(timeStr);
// Send local broadcast to MainActivity so UI updates live while app is visible
Intent broadcast = new Intent(TimerForegroundService.class.getName() + ".UPDATE");
broadcast.putExtra("remainingTime", timeStr);
sendBroadcast(broadcast);
// Schedule next tick immediately (foreground service allows high-frequency updates)
serviceHandler.postDelayed(tickRunnable, 500);
}
private final Runnable tickRunnable = new Runnable() {
@Override
public void run() { tick(); }
};
private void playAlarmSound() {
try {
// Stop any previous ringtone to prevent overlap
if (ringtonePlayer != null && ringtonePlayer.isPlaying()) {
ringtonePlayer.stop();
}
Uri uri = android.media.RingtoneManager.getDefaultUri(android.media.RingtoneManager.TYPE_NOTIFICATION);
ringtonePlayer = android.media.RingtoneManager.getRingtone(this, uri);
if (ringtonePlayer != null) ringtonePlayer.play();
} catch (Exception e) {
Log.e(TAG, "Failed to play alarm sound", e);
}
}
private void updateNotification(String timeStr) {
NotificationManager nm = getSystemService(NotificationManager.class);
if (nm != null) {
nm.notify(NOTIFICATION_ID, buildNotification(timeStr));
}
}
private String formatTime(long ms) {
long totalSeconds = ms / 1000;
long minutes = (totalSeconds % 3600) / 60;
long seconds = totalSeconds % 60;
return String.format("%02d:%02d", minutes, seconds);
}
@Override
public IBinder onBind(Intent intent) { return null; }
@Override
public void onDestroy() {
super.onDestroy();
stopTimer();
if (ringtonePlayer != null && ringtonePlayer.isPlaying()) ringtonePlayer.stop();
Log.d(TAG, "Service destroyed.");
}
}
@@ -0,0 +1,20 @@
package com.hyperling.apps.infinitetimer;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class TimerReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() != null && Alert.ACTION_TIMER.equals(intent.getAction())) {
// Android 8+ requires foreground service to play sound reliably while backgrounded
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
context.startForegroundService(new Intent(context, TimerForegroundService.class));
} else {
context.startService(new Intent(context, TimerForegroundService.class));
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 951 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
</vector>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
</adaptive-icon>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
</adaptive-icon>
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>
+2 -2
View File
@@ -13,7 +13,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:8.11.1'
classpath 'com.android.tools.build:gradle:9.5.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -27,6 +27,6 @@ allprojects {
}
}
task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.
+24 -1
View File
@@ -9,9 +9,32 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.builtInKotlin=false
android.defaults.buildfeatures.resvalues=true
android.dependency.useConstraints=true
android.enableAppCompileTimeRClass=false
android.newDsl=false
android.r8.optimizedResourceShrinking=false
android.r8.strictFullModeForKeepRules=false
android.sdk.defaultTargetSdkToCompileSdkIfUnset=false
android.uniquePackageNames=false
android.useAndroidX=false
android.usesSdkInManifest.disallowed=false
org.gradle.jvmargs=-Xmx1536m
### Changes recommended by qwen3.6:35b when DNS was failing to foojay.
##org.gradle.jvmargs=-Xmx1536m -Dorg.gradle.jvm.download.auto.install=false
##org.gradle.java.home=/usr/lib/jvm/java-21-openjdk
##
### Toolchain & Vendor Workarounds for missing foojay.io DNS resolution
##org.gradle.java.installations.paths=/usr/lib/jvm/java-21-openjdk
##kotlin.compiler.ignoreJdkVendor=true
### Suppress AGP deprecation warnings
##android.sync.suppressAgpWarnings=UNSUPPORTED_PROJECT_OPTION_USE
##android.generateSyncIssueWhenLibraryConstraintsAreEnabled=false
##android.sync.suppressAgpWarnings=LIBRARY_CONSTRAINTS_SHOULD_BE_DISABLED
##kotlin.compiler.execution.strategy=in-process
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec-decoupled_projects
# org.gradle.parallel=true
+13
View File
@@ -0,0 +1,13 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/491f83666ae7f4d6ebb28fee72ebb035/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/0d1a1acdc708062093673f65aa9aba4b/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/491f83666ae7f4d6ebb28fee72ebb035/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/0d1a1acdc708062093673f65aa9aba4b/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7083b89563e7ce20943037b8cd2b8cc2/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/060bbb778a1f55ea705fdebd2ccfeab9/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/491f83666ae7f4d6ebb28fee72ebb035/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/0d1a1acdc708062093673f65aa9aba4b/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/d09679dc60fe5aa05ef7d03efdefac20/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/ed4e3bf2f5e7c5d9aabc4cbd8acd555e/redirect
toolchainVendor=JETBRAINS
toolchainVersion=21
+1 -1
View File
@@ -1,6 +1,6 @@
#Fri Jul 11 12:55:34 MST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+3
View File
@@ -1 +1,4 @@
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}
include ':app'