Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05f1b68d3f | ||
|
|
0bc20a6e08 | ||
|
|
a661cfabbb | ||
|
|
0e481f13cc | ||
|
|
436c96285c | ||
|
|
dd9d15172c | ||
|
|
42d4992b6b | ||
|
|
f20bd99da4 | ||
|
|
79578de1f7 | ||
|
|
183634dee5 | ||
|
|
2606116c62 | ||
|
|
424176a529 | ||
|
|
13a00917f9 | ||
|
|
76ef8a7131 | ||
|
|
8b466229e1 | ||
|
|
b62eff80c9 |
No files matched your search
@@ -27,6 +27,9 @@
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
|
||||
|
||||
<!-- Allow internet to work. -->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application
|
||||
android:label="Sunset Alarm"
|
||||
android:name="${applicationName}"
|
||||
|
||||
|
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 431 B |
|
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 306 B |
@@ -10,3 +10,4 @@
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
||||
|
||||
|
Before Width: | Height: | Size: 284 B After Width: | Height: | Size: 574 B |
|
Before Width: | Height: | Size: 443 B After Width: | Height: | Size: 842 B |
|
Before Width: | Height: | Size: 565 B After Width: | Height: | Size: 1.2 KiB |
@@ -10,3 +10,4 @@
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<monochrome android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
|
||||
</adaptive-icon>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<monochrome android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 816 B |
|
After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 456 B |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 626 B |
|
After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 334 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1022 B |
|
After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 586 B |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 946 B |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 8.2 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#FFFFFF</color>
|
||||
</resources>
|
||||
@@ -32,7 +32,7 @@ version=""
|
||||
for i in `grep version $app_details`; do
|
||||
version="$i"
|
||||
done
|
||||
version="v${version// /_}"
|
||||
version="${version// /_}"
|
||||
|
||||
if [[ -z $name || -z $version ]]; then
|
||||
echo "ERROR: Could not retrieve name or version. name='$name' version='$version'"
|
||||
|
||||
@@ -12,6 +12,11 @@ import 'package:alarm/alarm.dart';
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
// For trusting Let's Encrypt on older devices (SDK 24, Android 7)
|
||||
//import 'dart:io';
|
||||
//import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/services.dart' show rootBundle;
|
||||
|
||||
/// TBD:
|
||||
/// - Add other languages (Spanish, Croatian)
|
||||
/// v1.1.0
|
||||
@@ -22,6 +27,14 @@ import 'dart:convert';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
final certData = await rootBundle.load(
|
||||
'media/certs/open-meteo-com_isrg-root-x1.pem',
|
||||
);
|
||||
SecurityContext.defaultContext.setTrustedCertificatesBytes(
|
||||
certData.buffer.asUint8List(),
|
||||
);
|
||||
|
||||
tz.initializeTimeZones();
|
||||
await Alarm.init();
|
||||
runApp(const SunsetAlarmApp());
|
||||
@@ -66,8 +79,8 @@ class HomeScreen extends StatefulWidget {
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
final _latController = TextEditingController();
|
||||
final _lngController = TextEditingController();
|
||||
final _sunsetController = TextEditingController();
|
||||
final _minutesController = TextEditingController(text: '30');
|
||||
final _sunsetController = TextEditingController(text: "18:00");
|
||||
final _minutesController = TextEditingController(text: "30");
|
||||
|
||||
final FlutterLocalNotificationsPlugin _notifications =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
@@ -79,6 +92,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
String? _sunsetErrorText;
|
||||
String? _minuteErrorText;
|
||||
bool _validTime = false;
|
||||
|
||||
static const _alarmId = 1001;
|
||||
|
||||
@@ -107,15 +121,14 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Future<void> _loadPrefs() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
final lat = prefs.getDouble('lat');
|
||||
final lng = prefs.getDouble('lng');
|
||||
final sunset = prefs.getString('sunset_time');
|
||||
_latController.text = prefs.getDouble('lat').toString();
|
||||
_lngController.text = prefs.getDouble('lng').toString();
|
||||
_sunsetController.text = prefs.getString('sunset_time').toString();
|
||||
_alarmEnabled = prefs.getBool('alarm_enabled') ?? false;
|
||||
_minutesBefore = prefs.getInt('minutes_before') ?? 30;
|
||||
if (lat != null) _latController.text = lat.toString();
|
||||
if (lng != null) _lngController.text = lng.toString();
|
||||
if (sunset != null) _sunsetController.text = sunset;
|
||||
_minutesController.text = '$_minutesBefore';
|
||||
_minutesController.text = _minutesBefore.toString();
|
||||
_plural = prefs.getString('plural').toString();
|
||||
_validTime = prefs.getBool('valid_time') ?? false;
|
||||
});
|
||||
if (_alarmEnabled && _sunsetController.text.isNotEmpty) {
|
||||
_scheduleAlarm();
|
||||
@@ -133,6 +146,8 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
}
|
||||
await prefs.setBool('alarm_enabled', _alarmEnabled);
|
||||
await prefs.setInt('minutes_before', _minutesBefore);
|
||||
await prefs.setString('plural', _plural);
|
||||
await prefs.setBool('valid_time', _validTime);
|
||||
}
|
||||
|
||||
Future<void> _getGpsLocation() async {
|
||||
@@ -327,18 +342,26 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
if (value) {
|
||||
await _scheduleAlarm();
|
||||
} else {
|
||||
_alarmTimer?.cancel();
|
||||
if (!Platform.isLinux) {
|
||||
// Notification Method
|
||||
if (ANDROID_USE_NOTIF) await _notifications.cancel(id: _alarmId);
|
||||
|
||||
// Alarm Method
|
||||
if (ANDROID_USE_ALARM) await Alarm.stop(_alarmId);
|
||||
}
|
||||
_showSnack('Alarm Cancelled');
|
||||
_stopAlarm();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _stopAlarm() async {
|
||||
if (Platform.isLinux) {
|
||||
_alarmTimer?.cancel();
|
||||
} else if (Platform.isAndroid) {
|
||||
// Notification Method
|
||||
if (ANDROID_USE_NOTIF) {
|
||||
await _notifications.cancel(id: _alarmId);
|
||||
}
|
||||
// Alarm Method
|
||||
if (ANDROID_USE_ALARM) {
|
||||
await Alarm.stop(_alarmId);
|
||||
}
|
||||
}
|
||||
_showSnack('Alarm Cancelled');
|
||||
}
|
||||
|
||||
void _showSnack(String msg) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(msg)));
|
||||
}
|
||||
@@ -354,6 +377,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
}
|
||||
|
||||
String? _validateTime(String? value) {
|
||||
_validTime = false;
|
||||
if (value == null || !RegExp(r'^\d{2}:\d{2}$').hasMatch(value)) {
|
||||
return 'Use HH:MM Format';
|
||||
}
|
||||
@@ -361,6 +385,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
final m = int.parse(value.substring(3, 5));
|
||||
if (h > 23) return 'Hour Must Be 0–23';
|
||||
if (m > 59) return 'Minute Must Be 0–59';
|
||||
_validTime = true;
|
||||
return null; // valid
|
||||
}
|
||||
|
||||
@@ -462,6 +487,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
),
|
||||
onChanged: (v) {
|
||||
if (v == "") {
|
||||
_stopAlarm();
|
||||
}
|
||||
final val = _validateTime(v);
|
||||
if (val == null) {
|
||||
_savePrefs();
|
||||
@@ -532,17 +560,23 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
// --- Toggle ---
|
||||
Expanded(
|
||||
child: SwitchListTile(
|
||||
//title: const Text('Enable Sunset Alarm'),
|
||||
title: Text(_alarmEnabled ? 'Sunset Alarm Enabled' : ''),
|
||||
subtitle: Text(
|
||||
_alarmEnabled
|
||||
? '${_minutesBefore} Minute${_plural} Before @ $_alarmDisplayTime'
|
||||
: '',
|
||||
),
|
||||
value: _alarmEnabled,
|
||||
onChanged: _toggleAlarm,
|
||||
),
|
||||
child:
|
||||
_validTime
|
||||
? SwitchListTile(
|
||||
title: Text(
|
||||
_alarmEnabled ? 'Sunset Alarm Enabled' : "",
|
||||
),
|
||||
subtitle: Text(
|
||||
_validTime
|
||||
? _alarmEnabled
|
||||
? '${_minutesBefore} Minute${_plural} Before @ $_alarmDisplayTime'
|
||||
: ""
|
||||
: "Add Time",
|
||||
),
|
||||
value: _alarmEnabled,
|
||||
onChanged: _toggleAlarm,
|
||||
)
|
||||
: Center(child: Text("Sunset Time Invalid")),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
|
||||
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
||||
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
|
||||
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
|
||||
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
|
||||
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
|
||||
h77ct984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bMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
|
||||
ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
|
||||
TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
|
||||
jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
|
||||
oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
|
||||
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
|
||||
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
|
||||
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
|
||||
-----END CERTIFICATE-----
|
||||
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
@@ -1,7 +1,7 @@
|
||||
name: sunset_alarm
|
||||
description: "Set an alarm to go off a specified time before sunset."
|
||||
publish_to: 'none'
|
||||
version: 1.0.0
|
||||
version: 1.0.1
|
||||
|
||||
environment:
|
||||
sdk: ^3.7.2
|
||||
@@ -23,3 +23,5 @@ dev_dependencies:
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
assets:
|
||||
- media/certs/
|
||||