20 Commits
Author SHA1 Message Date
me bf1c4614a1 Merge pull request '0.1.2' (#1) from dev into main
Reviewed-on: #1
2026-09-28 04:36:42 -07:00
me 9c681094c1 android, add additional needs to the manifest related to the alarm, but commented out for now. 2026-09-28 04:30:14 -07:00
me a44d4b1574 main, remove the alarm code for now, just do the notification based alert. 2026-09-28 04:27:23 -07:00
me ee9821f30f main, use the new version of flutter_local_notifications correctly. 2026-09-28 04:11:44 -07:00
me efde9624ff Changes from flutter pub upgrade --major-versions --tighten. 2026-09-28 04:05:25 -07:00
me b9bc2ca77d Changes from flutter pub uprade --major-versions. 2026-09-28 04:04:49 -07:00
me 105591910c packages, add alarm. 2026-09-28 04:00:04 -07:00
me 6030da178c main, add an actual alarm for Android. 2026-09-28 03:58:04 -07:00
me dad8fff6d2 main, fix minutes not working properly when set to 0. 2026-09-28 03:57:40 -07:00
me 3d89661b37 android, add receiver block to the manifest, seems to be the last piece of the puzzle for getting a notification to go off, but was not a true alarm. 2026-09-28 03:44:10 -07:00
me 6de5fbe991 main, ensure the notifications permission is requested. 2026-09-28 03:43:27 -07:00
me 9ac5fdd4f6 android, move permissions to beginning of manifest file based on studio suggestion. 2026-09-28 03:06:18 -07:00
me 5f14dbbc5b Add an additional permission in case that's why Android is not alarming. 2026-09-25 12:07:30 -07:00
me aade4fd7f2 Change alarm display code to ensure we're hitting the Android section. 2026-09-25 12:07:11 -07:00
me dfca094c95 gitignore, add anything in the release directory. 2026-09-25 11:58:32 -07:00
me e643e797c9 Begin changes to ask for Android permissions rather than silrently failing. 2026-09-25 11:56:14 -07:00
me 280e748bb7 android, AGP Upgrade Assistant. 2026-09-25 11:55:46 -07:00
me a19447b8a0 compile, overhaul the script to have the name and version in the filenames as well as reuse more code. 2026-09-25 11:55:27 -07:00
me 0ef88ba978 compile, fix permissions. 2026-09-24 09:44:53 -07:00
me 00566d9cc0 Add descriptions of the new folders. 2026-09-24 09:40:09 -07:00
9 changed files with 245 additions and 43 deletions

No files matched your search

+3 -1
View File
@@ -153,4 +153,6 @@ google-services.json
# Android Profiling
*.hprof
linux-bundle.zip
# Staged build files for distribution.
*.linux-bundle.zip
release/*
+83 -6
View File
@@ -1,4 +1,32 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.USE_EXACT_ALARM"/>
<!--
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
<uses-permission android:name="android.permission.USE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
-->
<application
android:label="sunset_alarm"
android:name="${applicationName}"
@@ -30,6 +58,60 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<receiver
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver"
android:enabled="true" />
<receiver
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<!--
<service
android:name="com.gdelataillade.alarm.AlarmService"
android:foregroundServiceType="mediaPlayback"
android:exported="false" />
<receiver
android:name="com.gdelataillade.alarm.AlarmBroadcastReceiver"
android:exported="false" />
<receiver
android:name="com.gdelataillade.alarm.BootBroadcastReceiver"
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service
android:name="dev.fluttercommunity.plus.androidalarmmanager.AlarmService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false"
tools:ignore="MissingClass"/>
<receiver
android:name="dev.fluttercommunity.plus.androidalarmmanager.AlarmBroadcastReceiver"
android:exported="false"
tools:ignore="MissingClass"/>
<receiver
android:name="dev.fluttercommunity.plus.androidalarmmanager.RebootBroadcastReceiver"
android:enabled="false"
android:exported="false"
tools:ignore="MissingClass">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
-->
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
@@ -42,9 +124,4 @@
<data android:mimeType="text/plain"/>
</intent>
</queries>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
</manifest>
+1 -1
View File
@@ -19,7 +19,7 @@ pluginManagement {
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "9.4.0" apply false
id("com.android.application") version "9.4.1" apply false
//id("com.android.application") version "9.0.1" apply false
// This will need removed in Gradle/AGP 9. JK - needs to exist otherwiese:
Regular → Executable
+60 -13
View File
@@ -1,23 +1,70 @@
#!/usr/bin/env bash
# 20260913 - Hyperling
# Build the project and add them to a releases folder.
# Build the project and add the output to a releases folder.
# TODO
# create dir name release-${version} to store these in,
## Setup ##
echo -e "\nCleaning..."
flutter clean
DIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
echo -e "\nBuilding Linux..."
## Functions ##
function log {
echo -e "\n $@ \n"
}
function clean_flutter {
log "Cleaning..."
flutter clean
}
## Variables ##
app_details="$DIR/pubspec.yaml"
name=""
for i in `grep name $app_details`; do
name="$i"
done
name="${name// /_}"
version=""
for i in `grep version $app_details`; do
version="$i"
done
version="v${version// /_}"
if [[ -z $name || -z $version ]]; then
echo "ERROR: Could not retrieve name or version. name='$name' version='$version'"
exit 1
fi
RELEASE="release/$name-$version"
echo "Running for '$RELEASE'."
## Main ##
clean_flutter
log "Building Linux Bundle..."
flutter build linux
zip -r release/linux-bundle.zip build/linux/x64/release/bundle/*
echo -e "\nCleaning..."
flutter clean
log "Saving Linux Bundle..."
filename=$RELEASE.linux-bundle.zip
if [[ -e $filename ]]; then
rm -v $filename
fi
zip -r $filename build/linux/x64/release/bundle/*
ls -sh $filename
echo -e "\nBuilding APK..."
clean_flutter
log "Building APK..."
flutter build apk
cp -v build/app/outputs/flutter-apk/app-release.apk release/
echo -e "\nCleaning..."
flutter clean
log "Saving APK..."
filename=$RELEASE.apk
if [[ -e $filename ]]; then
rm -v $filename
fi
cp -v build/app/outputs/flutter-apk/app-release.apk $filename
ls -sh $filename
+88 -16
View File
@@ -1,5 +1,6 @@
import 'dart:io';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -7,11 +8,14 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:timezone/data/latest_all.dart' as tz;
import 'package:timezone/timezone.dart' as tz;
import 'package:http/http.dart' as http;
//import 'package:alarm/alarm.dart';
import 'dart:convert';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
tz.initializeTimeZones();
//await Alarm.init();
runApp(const SunsetAlarmApp());
}
@@ -67,7 +71,7 @@ class _HomeScreenState extends State<HomeScreen> {
defaultActionName: 'Sunset Alarm',
);
await _notifications.initialize(
const InitializationSettings(
settings: const InitializationSettings(
android: androidInit,
iOS: iosInit,
linux: linuxInit,
@@ -171,6 +175,21 @@ class _HomeScreenState extends State<HomeScreen> {
Timer? _alarmTimer;
Future<void> _scheduleAlarm() async {
// Get the Notifications permission:
final android =
_notifications
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin
>();
await android?.requestNotificationsPermission();
// Ensure that Android has the correct alarm permissions.
final canSchedule = await android?.canScheduleExactNotifications();
if (canSchedule != true) {
_showSnack('Permissions not yet granted, requesting...');
await android?.requestExactAlarmsPermission();
}
final sunsetText = _sunsetController.text.trim();
if (sunsetText.isEmpty) return;
@@ -203,16 +222,17 @@ class _HomeScreenState extends State<HomeScreen> {
timeout: LinuxNotificationTimeout.expiresNever(),
);
_notifications.show(
_alarmId,
'Sunset in ${_minutesBefore} min',
'The sun sets at $sunsetText. Time to get ready!',
const NotificationDetails(linux: linuxDetails),
id: _alarmId,
title: 'Sunset in ${_minutesBefore} min',
body: 'The sun sets at $sunsetText. Time to get ready!',
notificationDetails: const NotificationDetails(linux: linuxDetails),
);
});
_showSnack(
'Alarm set for ${alarmTime.hour.toString().padLeft(2, '0')}:${alarmTime.minute.toString().padLeft(2, '0')} (app must stay open)',
);
} else {
} else if (Platform.isAndroid) {
/*** Notifcation Method - Works ***/
// Android: use zonedSchedule (works in background)
final tzAlarm = tz.TZDateTime.from(alarmTime, tz.local);
const androidDetails = AndroidNotificationDetails(
@@ -225,16 +245,42 @@ class _HomeScreenState extends State<HomeScreen> {
category: AndroidNotificationCategory.alarm,
);
await _notifications.zonedSchedule(
_alarmId,
'Sunset in ${_minutesBefore} min',
'The sun sets at $sunsetText. Time to get ready!',
tzAlarm,
const NotificationDetails(android: androidDetails),
id: _alarmId,
title: 'Sunset in ${_minutesBefore} min',
body: 'The sun sets at $sunsetText. Time to get ready!',
scheduledDate: tzAlarm,
notificationDetails: const NotificationDetails(android: androidDetails),
androidScheduleMode: AndroidScheduleMode.alarmClock,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
);
_showSnack('Alarm scheduled.');
_showSnack('Alarm scheduled!');
debugPrint('DEBUG: Alarm time: ${tzAlarm.toString()}');
debugPrint('DEBUG: Current time: ${DateTime.now().toUtc().toString()}');
debugPrint('DEBUG: ${_notifications.toString()}');
// End Notification Method ***/
/*** Alarm Method - WIP *** /
// Schedule:
final settings = AlarmSettings(
id: 42,
dateTime: alarmTime, // your computed sunset time
assetAudioPath: 'assets/alarm.mp3', // put an alarm sound in assets/
loopAudio: true, // keeps ringing until dismissed
vibrate: true,
androidFullScreenIntent: true, // wakes screen like clock app
volumeSettings: VolumeSettings.fade(
volume: 0.8,
fadeDuration: Duration(seconds: 5),
),
notificationSettings: const NotificationSettings(
title: 'Sunset Alarm',
body: 'The sun sets now. Time to get ready!',
stopButton: 'Dismiss',
),
);
await Alarm.set(alarmSettings: settings);
// End Alarm Method ***/
} else {
_showSnack('Platform not detected, unsure how to show alarm.');
}
}
@@ -246,7 +292,7 @@ class _HomeScreenState extends State<HomeScreen> {
} else {
_alarmTimer?.cancel();
if (!Platform.isLinux) {
await _notifications.cancel(_alarmId);
await _notifications.cancel(id: _alarmId);
}
_showSnack('Alarm cancelled.');
}
@@ -375,8 +421,10 @@ class _HomeScreenState extends State<HomeScreen> {
),
onChanged: (v) {
final val = int.tryParse(v);
if (val != null && val > 0) {
if (val != null && val >= 0) {
_minutesBefore = val;
} else {
_showSnack('Invalid Minute Value');
}
},
),
@@ -417,3 +465,27 @@ class _HomeScreenState extends State<HomeScreen> {
return '${dh.toString().padLeft(2, '0')}:${dm.toString().padLeft(2, '0')}';
}
}
final _plugin = FlutterLocalNotificationsPlugin();
Future<void> requestPermissions() async {
if (Platform.isAndroid) {
final android =
_plugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin
>();
// Android 13+ — standard notification permission (shows a dialog)
await android?.requestNotificationsPermission();
// Android 12+ — exact alarm special access (opens system settings page)
await android?.requestExactAlarmsPermission();
}
}
final android =
_plugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin
>();
+1
View File
@@ -0,0 +1 @@
Images, audio, and anything else used to support the app.
+1
View File
@@ -0,0 +1 @@
Images for use as app icons.
+1
View File
@@ -0,0 +1 @@
Images for use in app stores.
+7 -6
View File
@@ -9,16 +9,17 @@ environment:
dependencies:
flutter:
sdk: flutter
geolocator: ^13.0.0
shared_preferences: ^2.3.0
flutter_local_notifications: ^18.0.0
timezone: ^0.9.0
http: ^1.2.0
geolocator: ^14.1.1
shared_preferences: ^2.5.5
flutter_local_notifications: ^22.3.1
timezone: ^0.11.1
http: ^1.6.0
alarm: ^5.13.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0
flutter:
uses-material-design: true