Compare commits

...

13 Commits

38 changed files with 321 additions and 22 deletions

View File

@ -5,7 +5,8 @@
<application
android:label="egg_timer_advanced"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round">
<activity
android:name=".MainActivity"
android:exported="true"

View File

@ -0,0 +1,5 @@
<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>

View File

@ -0,0 +1,5 @@
<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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>

BIN
assets/alarm.wav Normal file

Binary file not shown.

View File

@ -2,10 +2,12 @@ import 'dart:async';
import 'dart:convert';
import 'dart:math' as math;
import 'package:audioplayers/audioplayers.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; // SystemSound
import 'package:geolocator/geolocator.dart';
import 'package:http/http.dart' as http;
import 'package:package_info_plus/package_info_plus.dart';
enum EggSize { small, normal, large }
enum EggDoneness { soft, medium, hard }
@ -47,14 +49,19 @@ class _EggTimerScreenState extends State<EggTimerScreen> {
Duration _cookTime = const Duration(minutes: 7);
Duration _remainingTime = Duration.zero;
Timer? _timer;
late final AudioPlayer _audioPlayer;
bool _loadingLocation = false;
String? _error;
String? _appVersion;
@override
void initState() {
super.initState();
_audioPlayer = AudioPlayer();
_configureAudioContext();
_initLocationAndAltitude();
_loadAppVersion();
}
Future<void> _initLocationAndAltitude() async {
@ -166,7 +173,30 @@ class _EggTimerScreenState extends State<EggTimerScreen> {
}
Future<void> _playAlarm() async {
await SystemSound.play(SystemSoundType.alert);
try {
await _audioPlayer.stop();
await _audioPlayer.play(AssetSource('alarm.wav'));
} catch (_) {
await SystemSound.play(SystemSoundType.alert);
}
}
Future<void> _configureAudioContext() async {
await AudioPlayer.global.setAudioContext(
AudioContext(
android: const AudioContextAndroid(
isSpeakerphoneOn: true,
stayAwake: false,
contentType: AndroidContentType.sonification,
usageType: AndroidUsageType.alarm,
audioFocus: AndroidAudioFocus.gainTransient,
),
iOS: AudioContextIOS(
category: AVAudioSessionCategory.playback,
options: {AVAudioSessionOptions.defaultToSpeaker},
),
),
);
}
String _formatDuration(Duration d) {
@ -186,13 +216,24 @@ class _EggTimerScreenState extends State<EggTimerScreen> {
@override
void dispose() {
_timer?.cancel();
_audioPlayer.dispose();
super.dispose();
}
Future<void> _loadAppVersion() async {
final info = await PackageInfo.fromPlatform();
if (!mounted) return;
setState(() {
_appVersion = info.version;
});
}
@override
Widget build(BuildContext context) {
final altitudeText =
_altitude != null ? '$_altitude m über NN' : 'unbekannt';
final versionLabel =
_appVersion != null ? 'EggTimer Version $_appVersion' : 'EggTimer';
return Scaffold(
appBar: AppBar(
@ -420,16 +461,16 @@ class _EggTimerScreenState extends State<EggTimerScreen> {
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(
children: [
const Icon(
Icons.smart_toy,
size: 18,
color: Colors.black54,
),
SizedBox(width: 6),
const SizedBox(width: 6),
Text(
'Made with AI by ChatGPT',
style: TextStyle(color: Colors.black54),
versionLabel,
style: const TextStyle(color: Colors.black54),
),
],
),

View File

@ -6,6 +6,10 @@
#include "generated_plugin_registrant.h"
#include <audioplayers_linux/audioplayers_linux_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin");
audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar);
}

View File

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_linux
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

View File

@ -54,6 +54,29 @@ static void my_application_activate(GApplication* application) {
gtk_window_set_default_size(window, 1280, 720);
// Set the window and application icon from the bundled assets.
GError* icon_error = nullptr;
g_autofree gchar* executable_path =
g_file_read_link("/proc/self/exe", &icon_error);
if (icon_error != nullptr) {
g_warning("Failed to read executable path: %s", icon_error->message);
g_clear_error(&icon_error);
}
if (executable_path != nullptr) {
g_autofree gchar* executable_dir = g_path_get_dirname(executable_path);
g_autofree gchar* icon_path = g_build_filename(
executable_dir, "data", "flutter_assets", "assets", "app_icon.png",
nullptr);
gtk_window_set_icon_from_file(window, icon_path, &icon_error);
if (icon_error != nullptr) {
g_warning("Failed to load window icon: %s", icon_error->message);
g_clear_error(&icon_error);
} else {
gtk_window_set_default_icon_from_file(icon_path, nullptr);
}
}
g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(
project, self->dart_entrypoint_arguments);

View File

@ -5,8 +5,14 @@
import FlutterMacOS
import Foundation
import audioplayers_darwin
import geolocator_apple
import package_info_plus
import path_provider_foundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
}

View File

@ -9,6 +9,62 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.13.0"
audioplayers:
dependency: "direct main"
description:
name: audioplayers
sha256: "5441fa0ceb8807a5ad701199806510e56afde2b4913d9d17c2f19f2902cf0ae4"
url: "https://pub.dev"
source: hosted
version: "6.5.1"
audioplayers_android:
dependency: transitive
description:
name: audioplayers_android
sha256: "60a6728277228413a85755bd3ffd6fab98f6555608923813ce383b190a360605"
url: "https://pub.dev"
source: hosted
version: "5.2.1"
audioplayers_darwin:
dependency: transitive
description:
name: audioplayers_darwin
sha256: "0811d6924904ca13f9ef90d19081e4a87f7297ddc19fc3d31f60af1aaafee333"
url: "https://pub.dev"
source: hosted
version: "6.3.0"
audioplayers_linux:
dependency: transitive
description:
name: audioplayers_linux
sha256: f75bce1ce864170ef5e6a2c6a61cd3339e1a17ce11e99a25bae4474ea491d001
url: "https://pub.dev"
source: hosted
version: "4.2.1"
audioplayers_platform_interface:
dependency: transitive
description:
name: audioplayers_platform_interface
sha256: "0e2f6a919ab56d0fec272e801abc07b26ae7f31980f912f24af4748763e5a656"
url: "https://pub.dev"
source: hosted
version: "7.1.1"
audioplayers_web:
dependency: transitive
description:
name: audioplayers_web
sha256: "1c0f17cec68455556775f1e50ca85c40c05c714a99c5eb1d2d57cc17ba5522d7"
url: "https://pub.dev"
source: hosted
version: "5.1.1"
audioplayers_windows:
dependency: transitive
description:
name: audioplayers_windows
sha256: "4048797865105b26d47628e6abb49231ea5de84884160229251f37dfcbe52fd7"
url: "https://pub.dev"
source: hosted
version: "4.2.1"
boolean_selector:
dependency: transitive
description:
@ -65,6 +121,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.3"
ffi:
dependency: transitive
description:
name: ffi
sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
file:
dependency: transitive
description:
name: file
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
url: "https://pub.dev"
source: hosted
version: "7.0.1"
fixnum:
dependency: transitive
description:
@ -216,6 +288,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.17.0"
package_info_plus:
dependency: "direct main"
description:
name: package_info_plus
sha256: "16eee997588c60225bda0488b6dcfac69280a6b7a3cf02c741895dd370a02968"
url: "https://pub.dev"
source: hosted
version: "8.3.1"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
path:
dependency: transitive
description:
@ -224,6 +312,62 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.1"
path_provider:
dependency: transitive
description:
name: path_provider
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
url: "https://pub.dev"
source: hosted
version: "2.1.5"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e
url: "https://pub.dev"
source: hosted
version: "2.2.22"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: "97390a0719146c7c3e71b6866c34f1cde92685933165c1c671984390d2aca776"
url: "https://pub.dev"
source: hosted
version: "2.4.4"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
url: "https://pub.dev"
source: hosted
version: "2.2.1"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.dev"
source: hosted
version: "2.3.0"
platform:
dependency: transitive
description:
name: platform
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.dev"
source: hosted
version: "3.1.6"
plugin_platform_interface:
dependency: transitive
description:
@ -269,6 +413,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.1"
synchronized:
dependency: transitive
description:
name: synchronized
sha256: c254ade258ec8282947a0acbbc90b9575b4f19673533ee46f2f6e9b3aeefd7c0
url: "https://pub.dev"
source: hosted
version: "3.4.0"
term_glyph:
dependency: transitive
description:
@ -325,6 +477,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.1"
win32:
dependency: transitive
description:
name: win32
sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e
url: "https://pub.dev"
source: hosted
version: "5.15.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
sdks:
dart: ">=3.10.1 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
flutter: ">=3.35.0"

View File

@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 0.9.3
version: 0.9.15
environment:
sdk: ^3.10.1
@ -37,6 +37,8 @@ dependencies:
http: ^1.2.0 # Webservice für Höhe
geolocator: ^13.0.0 # Standortbestimmung
package_info_plus: ^8.0.0
audioplayers: ^6.1.0
dev_dependencies:
flutter_test:
@ -63,6 +65,7 @@ flutter:
assets:
- assets/egg_background.png
- assets/app_icon.png
- assets/alarm.wav
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg

View File

@ -1,15 +1,5 @@
#!/bin/bash
set -euo pipefail
flutter clean
flutter pub get
flutter build apk --release
cp build/app/outputs/flutter-apk/app-release.apk ./release/eggtimer.apk
echo "APK built and copied to ./release/eggtimer.apk"
GITEA_URL="https://git.ude-consult.de"
GITEA_TOKEN="6ea286299e8e081d9923d5deea2fbd91ad83dc8e"
OWNER="Arnold"
REPO="EggTimer"
APK_PATH="release/eggtimer.apk"
PUBSPEC="pubspec.yaml"
@ -22,16 +12,29 @@ minor=$(echo $before_plus | cut -d. -f2)
patch=$(echo $before_plus | cut -d. -f3)
patch=$((patch + 1))
build=$((build + 1))
new="${major}.${minor}.${patch}+${build}"
new="${major}.${minor}.${patch}"
echo "Neue Version: $new"
sed -i "s/^version: .*/version: ${new}/" "$PUBSPEC"
flutter clean
flutter pub get
flutter build apk --release
mkdir -p release
cp build/app/outputs/flutter-apk/app-release.apk ./release/eggtimer.apk
echo "APK built and copied to ./release/eggtimer.apk"
GITEA_URL="https://git.ude-consult.de"
GITEA_TOKEN="6ea286299e8e081d9923d5deea2fbd91ad83dc8e"
OWNER="Arnold"
REPO="EggTimer"
APK_PATH="release/eggtimer.apk"
# Version z.B. aus Datei oder Argument
VERSION_TAG=$(grep "^version:" pubspec.yaml | awk '{print $2}')
git commit -a -m"Version auf ${VERSION_TAG} gesetzt"
git push
RELEASE_TITLE="EggTimer ${VERSION_TAG}"
RELEASE_BODY="Automatisch erstelltes Release ${VERSION_TAG}."
@ -60,12 +63,38 @@ fi
echo "Release ${VERSION_TAG} erstellt, ID=${release_id}"
APK_FILENAME="eggtimer-${VERSION_TAG}.apk"
# Alte Assets entfernen, damit nur die APK im Release bleibt
existing_assets=$(curl -sS \
-H "Authorization: token ${GITEA_TOKEN}" \
"${GITEA_URL}/api/v1/repos/${OWNER}/${REPO}/releases/${release_id}/assets")
echo "$existing_assets" | jq -r '.[] | [.id, .name] | @tsv' | while IFS=$'\t' read -r asset_id asset_name; do
echo "Entferne altes Asset: ${asset_name}"
curl -sS -X DELETE \
-H "Authorization: token ${GITEA_TOKEN}" \
"${GITEA_URL}/api/v1/repos/${OWNER}/${REPO}/releases/${release_id}/assets/${asset_id}" >/dev/null
done
# 2. APK hochladen
curl -sS -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-F "attachment=@${APK_PATH};filename=eggtimer-${VERSION_TAG}.apk" \
-F "attachment=@${APK_PATH};filename=${APK_FILENAME}" \
"${GITEA_URL}/api/v1/repos/${OWNER}/${REPO}/releases/${release_id}/assets"
echo "APK hochgeladen."
# Nur die drei neuesten Releases behalten, ältere löschen
all_releases=$(curl -sS \
-H "Authorization: token ${GITEA_TOKEN}" \
"${GITEA_URL}/api/v1/repos/${OWNER}/${REPO}/releases")
echo "$all_releases" | jq -r 'sort_by(.created_at) | .[0:-3] | .[]? | "\(.id)\t\(.tag_name)"' | while IFS=$'\t' read -r old_id old_tag; do
echo "Lösche altes Release: ${old_tag} (ID ${old_id})"
curl -sS -X DELETE \
-H "Authorization: token ${GITEA_TOKEN}" \
"${GITEA_URL}/api/v1/repos/${OWNER}/${REPO}/releases/${old_id}" >/dev/null
done
echo "Ältere Releases bereinigt; es bleiben die letzten drei."

Binary file not shown.

5
testrelease.sh Executable file
View File

@ -0,0 +1,5 @@
# Test the release before publishing
flutter emulator --launch Pixel_7
sleep 5s
flutter run

View File

@ -6,9 +6,12 @@
#include "generated_plugin_registrant.h"
#include <audioplayers_windows/audioplayers_windows_plugin.h>
#include <geolocator_windows/geolocator_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
AudioplayersWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
GeolocatorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("GeolocatorWindows"));
}

View File

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_windows
geolocator_windows
)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 364 KiB