Compare commits
15 Commits
219ef6d64e
...
main
Author | SHA1 | Date | |
---|---|---|---|
7e6c0b90e2 | |||
84c75f6be7 | |||
1b3ca8c8af | |||
f83a8b41e4 | |||
bc433b4185 | |||
34b13473c9 | |||
a642b51532 | |||
a5490b98c7 | |||
140350012b | |||
d610bfd40b | |||
b1c2dfaa6f | |||
e79ee82193 | |||
4f64ca49b7 | |||
25969dd6d6 | |||
1fe3035050 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -33,3 +33,5 @@ google-services.json
|
||||
# Android Profiling
|
||||
*.hprof
|
||||
|
||||
# Release Files
|
||||
app/release/*
|
||||
|
@@ -5,5 +5,9 @@ Timer which loops over the specified interval, playing your default notification
|
||||
## Update Notes
|
||||
|
||||
### 2025-07-11
|
||||
(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.
|
||||
This article was very helpful in getting this app updated from SDK 25 to 36.
|
||||
- https://sijus.medium.com/resurrecting-a-5-year-old-android-app-a-developers-journey-59d8f5689e5b
|
||||
|
||||
## Licenses
|
||||
Chime sound byte came free from here:
|
||||
https://pixabay.com/sound-effects/chime-sound-7143/
|
||||
|
@@ -7,8 +7,8 @@ android {
|
||||
applicationId "com.hyperling.apps.infinitetimer"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 36
|
||||
versionCode 8
|
||||
versionName "1.1.0"
|
||||
versionCode 9
|
||||
versionName "1.1.1"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
|
@@ -3,7 +3,8 @@
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/icon_512"
|
||||
android:icon="@mipmap/icon_512"
|
||||
android:roundIcon="@mipmap/icon_rounded_512"
|
||||
android:label="@string/appName"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/InfiniteTimer"
|
||||
|
@@ -1,22 +1,30 @@
|
||||
package com.hyperling.apps.infinitetimer;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.DialogInterface;
|
||||
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.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
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 {
|
||||
@@ -46,6 +54,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
Uri ringtoneUri;
|
||||
MediaPlayer mediaPlayer;
|
||||
|
||||
SeekBar seekBar;
|
||||
AudioManager audioManager;
|
||||
TextView tvSeekBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
String tag = "onCreate";
|
||||
@@ -68,17 +80,60 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
stringChronometerDefault = getString(R.string.chronometerDefault);
|
||||
|
||||
if (DEBUG) Log.d(tag, "Got strings.");
|
||||
|
||||
/***** Shared Preferences *****/
|
||||
sharedPreferences = getSharedPreferences(keySharedPreferences, MODE_PRIVATE);
|
||||
DEBUG = sharedPreferences.getBoolean(keyDebug, true);
|
||||
appOpen = sharedPreferences.getBoolean(keyAppOpen, false);
|
||||
serviceRunning = sharedPreferences.getBoolean(keyServiceRunning, false);
|
||||
|
||||
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.";
|
||||
|
||||
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){
|
||||
// Print all preferences
|
||||
@@ -155,8 +210,32 @@ public class MainActivity extends AppCompatActivity {
|
||||
etMillis.setVisibility(View.GONE);
|
||||
//(ViewManager) etMillis.getParent().remove
|
||||
|
||||
//sharedPreferences.edit().putBoolean(keyStartStop, false).apply();
|
||||
recoverScreen();
|
||||
seekBar = findViewById(R.id.seekBar);
|
||||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||
|
||||
audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
|
||||
int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||
seekBar.setMax(maxVolume);
|
||||
|
||||
tvSeekBar = findViewById(R.id.tvSeekbar);
|
||||
|
||||
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, i, AudioManager.FLAG_SHOW_UI);
|
||||
syncVolume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
syncVolume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
syncVolume();
|
||||
}
|
||||
});
|
||||
|
||||
if (DEBUG) Log.d(tag, "Finished");
|
||||
}
|
||||
@@ -537,13 +616,47 @@ 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)
|
||||
Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), ringtoneUri);
|
||||
/* 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();
|
||||
*/
|
||||
/**/
|
||||
|
||||
//mediaPlayer.reset();
|
||||
try {
|
||||
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");
|
||||
}
|
||||
|
||||
private void flipInputTexts() {
|
||||
String tag = TAG + "flipInputTexts";
|
||||
if (DEBUG) Log.d(tag, "Starting");
|
||||
|
||||
etHours.setEnabled(!start);
|
||||
etMinutes.setEnabled(!start);
|
||||
etSeconds.setEnabled(!start);
|
||||
|
||||
if (DEBUG) Log.d(tag, "Finished");
|
||||
}
|
||||
@@ -574,6 +687,21 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (DEBUG) Log.d(tag, "Finished");
|
||||
}
|
||||
|
||||
public void syncVolume() {
|
||||
String tag = TAG + "syncVolume";
|
||||
if (DEBUG) Log.d(tag, "Starting");
|
||||
|
||||
int currVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
|
||||
if (currVolume != seekBar.getProgress()) {
|
||||
seekBar.setProgress(currVolume);
|
||||
}
|
||||
|
||||
String volume = getString(R.string.tvSeekBar) + " " + seekBar.getProgress() + "/" + seekBar.getMax();
|
||||
tvSeekBar.setText(volume);
|
||||
|
||||
if (DEBUG) Log.d(tag, "Finished");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
String tag = TAG + "onPause";
|
||||
@@ -607,6 +735,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
sharedPreferences.edit().putBoolean(keyServiceRunning, false).apply();
|
||||
|
||||
recoverScreen();
|
||||
syncVolume();
|
||||
|
||||
if (DEBUG) Log.d(tag, "Finished");
|
||||
}
|
||||
@@ -625,15 +754,14 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (DEBUG) Log.d(tag, "Finished");
|
||||
}
|
||||
|
||||
private void flipInputTexts() {
|
||||
String tag = TAG + "flipInputTexts";
|
||||
if (DEBUG) Log.d(tag, "Starting");
|
||||
|
||||
etHours.setEnabled(!start);
|
||||
etMinutes.setEnabled(!start);
|
||||
etSeconds.setEnabled(!start);
|
||||
|
||||
if (DEBUG) Log.d(tag, "Finished");
|
||||
}
|
||||
|
||||
// TODO: This is somehow always 1 action behind the actual volume when pressing volume buttons.
|
||||
// Like when doing down+up+down, the bar does nothing+down+up.
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
boolean bool = super.onKeyDown(keyCode, event);
|
||||
syncVolume();
|
||||
return bool;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}}
|
||||
|
@@ -158,4 +158,27 @@
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tblButtons"
|
||||
android:layout_alignParentBottom="true">
|
||||
<SeekBar
|
||||
android:id="@+id/seekBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="@dimen/activity_vertical_margin"
|
||||
android:layout_centerInParent="true"
|
||||
android:indeterminate="false"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSeekbar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/seekBar"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="@string/tvSeekBar"
|
||||
android:textSize="14sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
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.
40
app/src/main/res/values-es/strings.xml
Normal file
40
app/src/main/res/values-es/strings.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<resources>
|
||||
<!-- App details -->
|
||||
<string name="appName">Infinite Timer</string>
|
||||
<string name="appVersion">v20250711</string>
|
||||
<string name="TAG">com.hyperling.apps.infinitetimer</string>
|
||||
|
||||
<!-- Keys -->
|
||||
<string name="keySharedPreferences">InfiniteTimer</string>
|
||||
<string name="keyDebug">DEBUG</string>
|
||||
<string name="keyChronometerTime">ChronometerTime</string>
|
||||
<string name="keyLoopInterval">LoopInterval</string>
|
||||
<string name="keyStartStop">StartStop</string>
|
||||
<string name="keyAppOpen">AppOpen</string>
|
||||
<string name="keyServiceRunning">ServiceRunning</string>
|
||||
|
||||
<!-- UI Text -->
|
||||
<string name="btnStart">Empezar</string>
|
||||
<string name="btnStop">Terminar</string>
|
||||
<string name="btnChooseTime">Elige un Tiempo</string>
|
||||
<string name="btnReset">Reiniciar</string>
|
||||
<string name="btnPause">Pausa</string>
|
||||
<string name="btnResume">Seguir</string>
|
||||
|
||||
<string name="chronometerDefault">00:00:00</string>
|
||||
|
||||
<string name="tvHoursHint">Horas</string>
|
||||
<string name="tvMinutesHint">Minutos</string>
|
||||
<string name="tvSecondsHint">Segundos</string>
|
||||
<string name="tvMillisHint">Millis</string>
|
||||
<string name="tvDot">.</string>
|
||||
|
||||
<string name="tvUpperLabel"><b>Tiempo entre notificaciones:</b></string>
|
||||
<string name="tvLowerLabel"><b>Cuenta regresiva hasta notificación:</b></string>
|
||||
|
||||
<string name="action_millis">Enable Millisecs</string>
|
||||
<string name="action_enable_ads">Enable Ads</string>
|
||||
<string name="action_exit">Exit</string>
|
||||
|
||||
<string name="tvSeekBar">Volumen: </string>
|
||||
</resources>
|
@@ -35,4 +35,6 @@
|
||||
<string name="action_millis">Enable Millisecs</string>
|
||||
<string name="action_enable_ads">Enable Ads</string>
|
||||
<string name="action_exit">Exit</string>
|
||||
|
||||
<string name="tvSeekBar">Media Volume:</string>
|
||||
</resources>
|
||||
|
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