Compare commits
7
Commits
3f0b69d6cf
..
1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07447a2ffe | ||
|
|
6627ab46e8 | ||
|
|
79d9da8285 | ||
|
|
03f9e2fa56 | ||
|
|
7ab13dd4de | ||
|
|
f5e368a902 | ||
|
|
251e03db5b |
No files matched your search
@@ -15,6 +15,8 @@ android {
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
ndkVersion = flutter.ndkVersion
|
||||
|
||||
|
||||
|
||||
compileOptions {
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
@@ -40,10 +42,30 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
getByName("release") {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
|
||||
/// 20260928 - Without minifying.
|
||||
/// Built build/app/outputs/flutter-apk/app-release.apk (54.3MB)
|
||||
/// Built build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk (17.2MB)
|
||||
/// Built build/app/outputs/flutter-apk/app-arm64-v8a-release.apk (19.8MB)
|
||||
/// Built build/app/outputs/flutter-apk/app-x86_64-release.apk (21.2MB)
|
||||
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
|
||||
/// 20260928 - With minifying, helped some, but also used
|
||||
/// in combination with `--obfuscate --split-debug-info=./debug-info/`
|
||||
/// Built build/app/outputs/flutter-apk/app-release.apk (54.3MB)
|
||||
/// Built build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk (16.1MB)
|
||||
/// Built build/app/outputs/flutter-apk/app-arm64-v8a-release.apk (18.8MB)
|
||||
/// Built build/app/outputs/flutter-apk/app-x86_64-release.apk (20.3MB)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
Whitespace-only changes.
@@ -1,5 +1,5 @@
|
||||
AuthorName: 'Chad Michael "Hyperling" Greenwood'
|
||||
AuthorEmail: 'me@hyperling.com'
|
||||
AuthorEmail: 'me+sunset@hyperling.com'
|
||||
AuthorWebSite: 'https://hyperling.com/about/'
|
||||
Donate: 'https://hyperling.com/donate/'
|
||||
Liberapay: 'HyperVegan'
|
||||
|
||||
+49
-11
@@ -15,6 +15,7 @@ function log {
|
||||
function clean_flutter {
|
||||
log "Cleaning..."
|
||||
flutter clean
|
||||
echo "Done!"
|
||||
}
|
||||
|
||||
## Variables ##
|
||||
@@ -41,12 +42,23 @@ fi
|
||||
RELEASE="release/$name-$version"
|
||||
echo "Running for '$RELEASE'."
|
||||
|
||||
BUILD_OPTIONS=(
|
||||
--release
|
||||
--obfuscate
|
||||
--split-debug-info=./debug-info/
|
||||
--extra-gen-snapshot-options="--strip"
|
||||
)
|
||||
|
||||
## Main ##
|
||||
|
||||
clean_flutter
|
||||
|
||||
# Linux
|
||||
|
||||
log "Building Linux Bundle..."
|
||||
flutter build linux
|
||||
set -x
|
||||
flutter build linux ${BUILD_OPTIONS[@]}
|
||||
set +x
|
||||
|
||||
log "Saving Linux Bundle..."
|
||||
filename=$RELEASE.linux-bundle.zip
|
||||
@@ -56,15 +68,41 @@ fi
|
||||
zip -r $filename build/linux/x64/release/bundle/*
|
||||
ls -sh $filename
|
||||
|
||||
clean_flutter
|
||||
# Android
|
||||
|
||||
log "Building APK..."
|
||||
flutter build apk
|
||||
log "Building Universal APK..."
|
||||
# Creates a generic (and large) app-release.apk
|
||||
set -x
|
||||
flutter build apk ${BUILD_OPTIONS[@]}
|
||||
set +x
|
||||
|
||||
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
|
||||
#log "Saving Universal APK..."
|
||||
#apk="build/app/outputs/flutter-apk/app-release.apk"
|
||||
#filename=`basename $apk`
|
||||
#filename=${filename//app/${RELEASE}}
|
||||
#if [[ -e $filename ]]; then
|
||||
# rm -v $filename
|
||||
#fi
|
||||
#cp -v "$apk" "$filename"
|
||||
#ls -sh "$filename"
|
||||
|
||||
log "Building Individual APKs..."
|
||||
# Creates files such as build/app/outputs/flutter-apk/app-arm64-v8a-release.apk
|
||||
set -x
|
||||
flutter build apk ${BUILD_OPTIONS[@]} --split-per-abi
|
||||
set +x
|
||||
|
||||
log "Saving APKs..."
|
||||
for apk in `ls build/app/outputs/flutter-apk/app*release.apk`; do
|
||||
#if [[ "$apk" == *"x86"* ]]; then echo "Skipping $apk" continue; fi
|
||||
#log "APK: $apk"
|
||||
filename=`basename $apk`
|
||||
filename=${filename//app/${RELEASE}}
|
||||
cp -v "$apk" "$filename"
|
||||
ls -sh "$filename"
|
||||
echo " "
|
||||
done
|
||||
|
||||
# Finish
|
||||
|
||||
exit 0
|
||||
+195
-188
@@ -13,9 +13,10 @@ import 'package:alarm/alarm.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
/// TBD:
|
||||
/// v0.3.0
|
||||
/// - Add other languages (Spanish, Croatian)
|
||||
/// v1.1.0
|
||||
/// - Change sunset grabber to checkbox and retrieve it each alarm or open.
|
||||
/// v1.0.0
|
||||
/// v2.0.0
|
||||
/// - Add sunrise section and change app name to Sunshine Alarm?
|
||||
/// :TBD
|
||||
|
||||
@@ -71,12 +72,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
final FlutterLocalNotificationsPlugin _notifications =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
|
||||
bool _loading = false;
|
||||
bool _alarmEnabled = false;
|
||||
int _minutesBefore = 30;
|
||||
bool _loading = false;
|
||||
String _plural = 's';
|
||||
|
||||
String? _sunsetErrorText = null;
|
||||
String? _minuteErrorText = null;
|
||||
String? _sunsetErrorText;
|
||||
String? _minuteErrorText;
|
||||
|
||||
static const _alarmId = 1001;
|
||||
|
||||
@@ -202,21 +204,6 @@ 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 Need Granted, Requesting...');
|
||||
await android?.requestExactAlarmsPermission();
|
||||
}
|
||||
|
||||
final sunsetText = _sunsetController.text.trim();
|
||||
if (sunsetText.isEmpty) return;
|
||||
|
||||
@@ -259,7 +246,22 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
'Alarm Enabled @ ${alarmTime.hour.toString().padLeft(2, '0')}:${alarmTime.minute.toString().padLeft(2, '0')} (App Must Stay Open!)',
|
||||
);
|
||||
} else if (Platform.isAndroid) {
|
||||
/*** Notifcation Method - Works ***/
|
||||
// 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 Need Granted, Requesting...');
|
||||
await android?.requestExactAlarmsPermission();
|
||||
}
|
||||
|
||||
/*** Notification Method - Works ***/
|
||||
if (ANDROID_USE_NOTIF) {
|
||||
// Android: use zonedSchedule (works in background)
|
||||
final tzAlarm = tz.TZDateTime.from(alarmTime, tz.local);
|
||||
@@ -289,7 +291,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
}
|
||||
// End Notification Method ***/
|
||||
|
||||
/*** Alarm Method - WIP ***/
|
||||
/*** Alarm Method - Works ***/
|
||||
if (ANDROID_USE_ALARM) {
|
||||
// Schedule:
|
||||
final settings = AlarmSettings(
|
||||
@@ -305,7 +307,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
notificationSettings: NotificationSettings(
|
||||
title: 'Sunset Alarm',
|
||||
body: 'Sun is setting in ${_minutesBefore} minute(s)!',
|
||||
body: 'Sun is setting in ${_minutesBefore} minute${_plural}!',
|
||||
stopButton: 'Dismiss',
|
||||
icon: 'ic_notification',
|
||||
),
|
||||
@@ -343,6 +345,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_savePrefs();
|
||||
_latController.dispose();
|
||||
_lngController.dispose();
|
||||
_sunsetController.dispose();
|
||||
@@ -365,182 +368,186 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Sunset Alarm')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// --- Location section ---
|
||||
const Text(
|
||||
'Location',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _latController,
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
signed: true,
|
||||
decimal: true,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Latitude',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onChanged: (_) => _savePrefs(),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _lngController,
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
signed: true,
|
||||
decimal: true,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Longitude',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onChanged: (_) => _savePrefs(),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
IconButton.filledTonal(
|
||||
icon: const Icon(Icons.my_location),
|
||||
tooltip: 'Get GPS Location',
|
||||
onPressed: _getGpsLocation,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// --- Sunset time section ---
|
||||
const Text(
|
||||
'Sunset',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _sunsetController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Sunset Time (HH:MM)',
|
||||
border: OutlineInputBorder(),
|
||||
errorText: _sunsetErrorText,
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(Icons.access_time),
|
||||
onPressed: () async {
|
||||
final picked = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
);
|
||||
if (picked != null) {
|
||||
_sunsetController.text =
|
||||
'${picked.hour.toString().padLeft(2, '0')}:'
|
||||
'${picked.minute.toString().padLeft(2, '0')}';
|
||||
setState(
|
||||
() =>
|
||||
_sunsetErrorText = _validateTime(
|
||||
_sunsetController.text,
|
||||
),
|
||||
);
|
||||
if (_alarmEnabled) {
|
||||
_scheduleAlarm();
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
onChanged: (v) {
|
||||
final val = _validateTime(v);
|
||||
if (val == null) {
|
||||
_savePrefs();
|
||||
if (_alarmEnabled) {
|
||||
_scheduleAlarm();
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
_sunsetErrorText = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
IconButton.filledTonal(
|
||||
icon:
|
||||
_loading
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Icon(Icons.cloud_done_outlined),
|
||||
tooltip: 'Fetch Open-Meteo Sunset Data',
|
||||
onPressed: () {
|
||||
if (!_loading) {
|
||||
_fetchSunset();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
const Text(
|
||||
'Alert',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// --- Minutes before ---
|
||||
Row(
|
||||
children: [
|
||||
if (!_alarmEnabled)
|
||||
resizeToAvoidBottomInset: true, // default, but be explicit
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// --- Location section ---
|
||||
const Text(
|
||||
'Location',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _minutesController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
controller: _latController,
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
signed: true,
|
||||
decimal: true,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Latitude',
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Minutes Before Sunset',
|
||||
errorText: _minuteErrorText,
|
||||
),
|
||||
onChanged: (_) => _savePrefs(),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _lngController,
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
signed: true,
|
||||
decimal: true,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Longitude',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onChanged: (_) => _savePrefs(),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
IconButton.filledTonal(
|
||||
icon: const Icon(Icons.my_location),
|
||||
tooltip: 'Get GPS Location',
|
||||
onPressed: _getGpsLocation,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// --- Sunset time section ---
|
||||
const Text(
|
||||
'Sunset',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _sunsetController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Sunset Time (HH:MM)',
|
||||
border: OutlineInputBorder(),
|
||||
errorText: _sunsetErrorText,
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(Icons.access_time),
|
||||
onPressed: () async {
|
||||
final picked = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
);
|
||||
if (picked != null) {
|
||||
_sunsetController.text =
|
||||
'${picked.hour.toString().padLeft(2, '0')}:'
|
||||
'${picked.minute.toString().padLeft(2, '0')}';
|
||||
setState(
|
||||
() =>
|
||||
_sunsetErrorText = _validateTime(
|
||||
_sunsetController.text,
|
||||
),
|
||||
);
|
||||
if (_alarmEnabled) {
|
||||
_scheduleAlarm();
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
onChanged: (v) {
|
||||
final val = int.tryParse(v);
|
||||
setState(() {
|
||||
if (val != null) {
|
||||
_minuteErrorText = null;
|
||||
_minutesBefore = val;
|
||||
} else {
|
||||
_minuteErrorText = 'Invalid Minute Value';
|
||||
final val = _validateTime(v);
|
||||
if (val == null) {
|
||||
_savePrefs();
|
||||
if (_alarmEnabled) {
|
||||
_scheduleAlarm();
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
_sunsetErrorText = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// --- Toggle ---
|
||||
Expanded(
|
||||
child: SwitchListTile(
|
||||
//title: const Text('Enable Sunset Alarm'),
|
||||
title: Text(_alarmEnabled ? 'Sunset Alarm Enabled' : ''),
|
||||
subtitle: Text(
|
||||
_alarmEnabled
|
||||
? 'Will alert ${_minutesBefore} min before sunset. ($_alarmDisplayTime)'
|
||||
: '',
|
||||
),
|
||||
value: _alarmEnabled,
|
||||
onChanged: _toggleAlarm,
|
||||
const SizedBox(width: 8),
|
||||
IconButton.filledTonal(
|
||||
icon:
|
||||
_loading
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Icon(Icons.cloud_done_outlined),
|
||||
tooltip: 'Fetch Open-Meteo Sunset Data',
|
||||
onPressed: () {
|
||||
if (!_loading) {
|
||||
_fetchSunset();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
const Text(
|
||||
'Alert',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// --- Minutes before ---
|
||||
Row(
|
||||
children: [
|
||||
if (!_alarmEnabled)
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _minutesController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Minutes Before Sunset',
|
||||
errorText: _minuteErrorText,
|
||||
),
|
||||
onChanged: (v) {
|
||||
final val = int.tryParse(v);
|
||||
setState(() {
|
||||
if (val != null) {
|
||||
_minuteErrorText = null;
|
||||
_minutesBefore = val;
|
||||
} else {
|
||||
_minuteErrorText = 'Invalid Minute Value';
|
||||
}
|
||||
_plural = (_minutesBefore == 1) ? '' : 's';
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// --- 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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name: sunset_alarm
|
||||
description: "Set an alarm to go off a specified time before sunset."
|
||||
publish_to: 'none'
|
||||
version: 0.2.0
|
||||
version: 1.0.0
|
||||
|
||||
environment:
|
||||
sdk: ^3.7.2
|
||||
|
||||
Reference in new issue
Block a user