Compare commits
	
		
			2 Commits
		
	
	
		
			219ef6d64e
			...
			25969dd6d6
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 25969dd6d6 | |||
| 1fe3035050 | 
@@ -7,3 +7,7 @@ Timer which loops over the specified interval, playing your default notification
 | 
				
			|||||||
### 2025-07-11
 | 
					### 2025-07-11
 | 
				
			||||||
(This article)[https://sijus.medium.com/resurrecting-a-5-year-old-android-app-a-developers-journey-59d8f5689e5b]
 | 
					(This article)[https://sijus.medium.com/resurrecting-a-5-year-old-android-app-a-developers-journey-59d8f5689e5b]
 | 
				
			||||||
 was very helpful in getting this app updated from SDK 25 to 36.
 | 
					 was very helpful in getting this app updated from SDK 25 to 36.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Licenses
 | 
				
			||||||
 | 
					Chime sound byte came free from here:
 | 
				
			||||||
 | 
					https://pixabay.com/sound-effects/chime-sound-7143/
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    <application
 | 
					    <application
 | 
				
			||||||
        android:allowBackup="true"
 | 
					        android:allowBackup="true"
 | 
				
			||||||
        android:icon="@drawable/icon_512"
 | 
					        android:icon="@mipmap/icon_512"
 | 
				
			||||||
 | 
					        android:roundIcon="@mipmap/icon_rounded_512"
 | 
				
			||||||
        android:label="@string/appName"
 | 
					        android:label="@string/appName"
 | 
				
			||||||
        android:supportsRtl="true"
 | 
					        android:supportsRtl="true"
 | 
				
			||||||
        android:theme="@style/InfiniteTimer"
 | 
					        android:theme="@style/InfiniteTimer"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,17 @@
 | 
				
			|||||||
package com.hyperling.apps.infinitetimer;
 | 
					package com.hyperling.apps.infinitetimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.app.NotificationManager;
 | 
				
			||||||
 | 
					import android.content.DialogInterface;
 | 
				
			||||||
import android.content.SharedPreferences;
 | 
					import android.content.SharedPreferences;
 | 
				
			||||||
import android.graphics.Color;
 | 
					import android.graphics.Color;
 | 
				
			||||||
import android.media.MediaPlayer;
 | 
					import android.media.MediaPlayer;
 | 
				
			||||||
 | 
					import android.media.Ringtone;
 | 
				
			||||||
import android.media.RingtoneManager;
 | 
					import android.media.RingtoneManager;
 | 
				
			||||||
import android.net.Uri;
 | 
					import android.net.Uri;
 | 
				
			||||||
import android.os.Bundle;
 | 
					import android.os.Bundle;
 | 
				
			||||||
import android.os.Handler;
 | 
					import android.os.Handler;
 | 
				
			||||||
import android.os.Message;
 | 
					import android.os.Message;
 | 
				
			||||||
 | 
					import android.support.v7.app.AlertDialog;
 | 
				
			||||||
import android.support.v7.app.AppCompatActivity;
 | 
					import android.support.v7.app.AppCompatActivity;
 | 
				
			||||||
import android.util.Log;
 | 
					import android.util.Log;
 | 
				
			||||||
import android.view.View;
 | 
					import android.view.View;
 | 
				
			||||||
@@ -68,17 +72,60 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        stringChronometerDefault = getString(R.string.chronometerDefault);
 | 
					        stringChronometerDefault = getString(R.string.chronometerDefault);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (DEBUG) Log.d(tag, "Got strings.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /***** Shared Preferences *****/
 | 
					        /***** Shared Preferences *****/
 | 
				
			||||||
        sharedPreferences = getSharedPreferences(keySharedPreferences, MODE_PRIVATE);
 | 
					        sharedPreferences = getSharedPreferences(keySharedPreferences, MODE_PRIVATE);
 | 
				
			||||||
        DEBUG = sharedPreferences.getBoolean(keyDebug, true);
 | 
					        DEBUG = sharedPreferences.getBoolean(keyDebug, true);
 | 
				
			||||||
        appOpen = sharedPreferences.getBoolean(keyAppOpen, false);
 | 
					        appOpen = sharedPreferences.getBoolean(keyAppOpen, false);
 | 
				
			||||||
        serviceRunning = sharedPreferences.getBoolean(keyServiceRunning, false);
 | 
					        serviceRunning = sharedPreferences.getBoolean(keyServiceRunning, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (DEBUG) Log.d(tag, "Got preferences.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Sound
 | 
					        // Sound
 | 
				
			||||||
        ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
 | 
					        ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
 | 
				
			||||||
 | 
					        if (DEBUG) Log.d(tag, "ringtoneUri=" + ringtoneUri.toString());
 | 
				
			||||||
        mediaPlayer = MediaPlayer.create(this, ringtoneUri);
 | 
					        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.";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (DEBUG) Log.d(tag, "Got strings.");
 | 
					            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();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                .setCancelable(false)
 | 
				
			||||||
 | 
					                .show()
 | 
				
			||||||
 | 
					            ;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            if (DEBUG) Log.d(tag, "mediaPlayer=" + mediaPlayer.toString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (DEBUG){
 | 
					        if (DEBUG){
 | 
				
			||||||
            // Print all preferences
 | 
					            // Print all preferences
 | 
				
			||||||
@@ -537,13 +584,34 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			|||||||
        String tag = TAG + "playSound";
 | 
					        String tag = TAG + "playSound";
 | 
				
			||||||
        if (DEBUG) Log.d(tag, "Starting");
 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* Original code, did not work on Nexus 7 with CM 12.1-20151117 (Android 5.1.1)
 | 
					        /* Original code, did not work on Nexus 7 with CM 12.1-20151117 (Android 5.1.1) * /
 | 
				
			||||||
        Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), ringtoneUri);
 | 
					        Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), ringtoneUri);
 | 
				
			||||||
        ringtone.play();
 | 
					        ringtone.play();
 | 
				
			||||||
        */
 | 
					        /**/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //mediaPlayer.reset();
 | 
					        try {
 | 
				
			||||||
            mediaPlayer.start();
 | 
					            mediaPlayer.start();
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            sharedPreferences.edit().putBoolean(keyStartStop, false).apply();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            String message = "Failed to play a notification sound.";
 | 
				
			||||||
 | 
					            message += " Please screenshot this error and send it to me@hyperling.com:\n\n";
 | 
				
			||||||
 | 
					            message += e.toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            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();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                .setCancelable(false)
 | 
				
			||||||
 | 
					                .show()
 | 
				
			||||||
 | 
					            ;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (DEBUG) Log.d(tag, "Finished");
 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
| 
		 Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/mipmap/icon_rounded.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								app/src/main/res/mipmap/icon_rounded.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 18 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/mipmap/icon_rounded_512.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								app/src/main/res/mipmap/icon_rounded_512.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 22 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/raw/chime_sound_7143.mp3
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								app/src/main/res/raw/chime_sound_7143.mp3
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								gimp/icon20250713.xcf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								gimp/icon20250713.xcf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								gimp/infinitetimer_rounded.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								gimp/infinitetimer_rounded.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 18 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								gimp/infinitetimer_rounded_512.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								gimp/infinitetimer_rounded_512.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 22 KiB  | 
		Reference in New Issue
	
	Block a user