Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf1c4614a1 | ||
|
|
9c681094c1 | ||
|
|
a44d4b1574 | ||
|
|
ee9821f30f | ||
|
|
efde9624ff | ||
|
|
b9bc2ca77d | ||
|
|
105591910c | ||
|
|
6030da178c | ||
|
|
dad8fff6d2 | ||
|
|
3d89661b37 | ||
|
|
6de5fbe991 | ||
|
|
9ac5fdd4f6 | ||
|
|
5f14dbbc5b | ||
|
|
aade4fd7f2 | ||
|
|
dfca094c95 | ||
|
|
e643e797c9 | ||
|
|
280e748bb7 | ||
|
|
a19447b8a0 | ||
|
|
0ef88ba978 | ||
|
|
00566d9cc0 | ||
|
|
b0f59e2296 | ||
|
|
7fe2af8058 | ||
|
|
09fdcea0f9 | ||
|
|
6586398db6 | ||
|
|
46eeaca422 | ||
|
|
657b41d63c | ||
|
|
d6c0c79f8a |
No files matched your search
@@ -153,3 +153,6 @@ google-services.json
|
|||||||
# Android Profiling
|
# Android Profiling
|
||||||
*.hprof
|
*.hprof
|
||||||
|
|
||||||
|
# Staged build files for distribution.
|
||||||
|
*.linux-bundle.zip
|
||||||
|
release/*
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
|
|
||||||
// This will need removed in Gradle/AGP 9.
|
// This supposedly needs removed in Gradle/AGP 9 but works fine.
|
||||||
id("org.jetbrains.kotlin.android") // id("kotlin-android")
|
id("org.jetbrains.kotlin.android") // id("kotlin-android")
|
||||||
|
|
||||||
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
||||||
id("dev.flutter.flutter-gradle-plugin")
|
id("dev.flutter.flutter-gradle-plugin")
|
||||||
}
|
}
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.hyperling.sunset_alarm"
|
namespace = "com.hyperling.sunset_alarm"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
@@ -21,7 +21,7 @@ android {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_17
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will need removed in Gradle/AGP 9.
|
// This supposedly needs removed in Gradle/AGP 9, but then uses 21 and fails to build.
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
jvmTarget.set(JvmTarget.JVM_17)
|
jvmTarget.set(JvmTarget.JVM_17)
|
||||||
@@ -49,7 +49,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
|
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
flutter {
|
flutter {
|
||||||
|
|||||||
@@ -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
|
<application
|
||||||
android:label="sunset_alarm"
|
android:label="sunset_alarm"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
@@ -30,6 +58,60 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
android:name="flutterEmbedding"
|
android:name="flutterEmbedding"
|
||||||
android:value="2" />
|
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>
|
</application>
|
||||||
<!-- Required to query activities that can process text, see:
|
<!-- Required to query activities that can process text, see:
|
||||||
https://developer.android.com/training/package-visibility and
|
https://developer.android.com/training/package-visibility and
|
||||||
@@ -42,9 +124,4 @@
|
|||||||
<data android:mimeType="text/plain"/>
|
<data android:mimeType="text/plain"/>
|
||||||
</intent>
|
</intent>
|
||||||
</queries>
|
</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>
|
</manifest>
|
||||||
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,74 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector
|
||||||
|
android:height="108dp"
|
||||||
|
android:width="108dp"
|
||||||
|
android:viewportHeight="108"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
|
||||||
|
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +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"/>
|
||||||
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
<monochrome android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
@@ -0,0 +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"/>
|
||||||
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
<monochrome android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
|
Before Width: | Height: | Size: 544 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 910 B |
|
After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 442 B |
|
After Width: | Height: | Size: 818 B |
|
After Width: | Height: | Size: 602 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 721 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 8.0 KiB |
@@ -1,7 +1,7 @@
|
|||||||
#Sat Sep 12 19:36:23 MST 2026
|
#Sat Sep 12 19:36:23 MST 2026
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
|
||||||
#distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
|
#distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
@@ -19,10 +19,11 @@ pluginManagement {
|
|||||||
plugins {
|
plugins {
|
||||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
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
|
//id("com.android.application") version "9.0.1" apply false
|
||||||
|
|
||||||
// This will need removed in Gradle/AGP 9.
|
// This will need removed in Gradle/AGP 9. JK - needs to exist otherwiese:
|
||||||
|
// "Error: Your project's Kotlin version (2.2.10) is lower than Flutter's minimum supported version of 2.2.20."
|
||||||
id("org.jetbrains.kotlin.android") version "2.4.20" apply false
|
id("org.jetbrains.kotlin.android") version "2.4.20" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# 20260913 - Hyperling
|
||||||
|
# Build the project and add the output to a releases folder.
|
||||||
|
|
||||||
|
## Setup ##
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
clean_flutter
|
||||||
|
|
||||||
|
log "Building APK..."
|
||||||
|
flutter build apk
|
||||||
|
|
||||||
|
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
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.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/data/latest_all.dart' as tz;
|
||||||
import 'package:timezone/timezone.dart' as tz;
|
import 'package:timezone/timezone.dart' as tz;
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
//import 'package:alarm/alarm.dart';
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
tz.initializeTimeZones();
|
tz.initializeTimeZones();
|
||||||
|
//await Alarm.init();
|
||||||
runApp(const SunsetAlarmApp());
|
runApp(const SunsetAlarmApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +71,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
defaultActionName: 'Sunset Alarm',
|
defaultActionName: 'Sunset Alarm',
|
||||||
);
|
);
|
||||||
await _notifications.initialize(
|
await _notifications.initialize(
|
||||||
const InitializationSettings(
|
settings: const InitializationSettings(
|
||||||
android: androidInit,
|
android: androidInit,
|
||||||
iOS: iosInit,
|
iOS: iosInit,
|
||||||
linux: linuxInit,
|
linux: linuxInit,
|
||||||
@@ -171,6 +175,21 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
Timer? _alarmTimer;
|
Timer? _alarmTimer;
|
||||||
|
|
||||||
Future<void> _scheduleAlarm() async {
|
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();
|
final sunsetText = _sunsetController.text.trim();
|
||||||
if (sunsetText.isEmpty) return;
|
if (sunsetText.isEmpty) return;
|
||||||
|
|
||||||
@@ -203,16 +222,17 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
timeout: LinuxNotificationTimeout.expiresNever(),
|
timeout: LinuxNotificationTimeout.expiresNever(),
|
||||||
);
|
);
|
||||||
_notifications.show(
|
_notifications.show(
|
||||||
_alarmId,
|
id: _alarmId,
|
||||||
'Sunset in ${_minutesBefore} min',
|
title: 'Sunset in ${_minutesBefore} min',
|
||||||
'The sun sets at $sunsetText. Time to get ready!',
|
body: 'The sun sets at $sunsetText. Time to get ready!',
|
||||||
const NotificationDetails(linux: linuxDetails),
|
notificationDetails: const NotificationDetails(linux: linuxDetails),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
_showSnack(
|
_showSnack(
|
||||||
'Alarm set for ${alarmTime.hour.toString().padLeft(2, '0')}:${alarmTime.minute.toString().padLeft(2, '0')} (app must stay open)',
|
'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)
|
// Android: use zonedSchedule (works in background)
|
||||||
final tzAlarm = tz.TZDateTime.from(alarmTime, tz.local);
|
final tzAlarm = tz.TZDateTime.from(alarmTime, tz.local);
|
||||||
const androidDetails = AndroidNotificationDetails(
|
const androidDetails = AndroidNotificationDetails(
|
||||||
@@ -225,16 +245,42 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
category: AndroidNotificationCategory.alarm,
|
category: AndroidNotificationCategory.alarm,
|
||||||
);
|
);
|
||||||
await _notifications.zonedSchedule(
|
await _notifications.zonedSchedule(
|
||||||
_alarmId,
|
id: _alarmId,
|
||||||
'Sunset in ${_minutesBefore} min',
|
title: 'Sunset in ${_minutesBefore} min',
|
||||||
'The sun sets at $sunsetText. Time to get ready!',
|
body: 'The sun sets at $sunsetText. Time to get ready!',
|
||||||
tzAlarm,
|
scheduledDate: tzAlarm,
|
||||||
const NotificationDetails(android: androidDetails),
|
notificationDetails: const NotificationDetails(android: androidDetails),
|
||||||
androidScheduleMode: AndroidScheduleMode.alarmClock,
|
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 {
|
} else {
|
||||||
_alarmTimer?.cancel();
|
_alarmTimer?.cancel();
|
||||||
if (!Platform.isLinux) {
|
if (!Platform.isLinux) {
|
||||||
await _notifications.cancel(_alarmId);
|
await _notifications.cancel(id: _alarmId);
|
||||||
}
|
}
|
||||||
_showSnack('Alarm cancelled.');
|
_showSnack('Alarm cancelled.');
|
||||||
}
|
}
|
||||||
@@ -375,8 +421,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
),
|
),
|
||||||
onChanged: (v) {
|
onChanged: (v) {
|
||||||
final val = int.tryParse(v);
|
final val = int.tryParse(v);
|
||||||
if (val != null && val > 0) {
|
if (val != null && val >= 0) {
|
||||||
_minutesBefore = val;
|
_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')}';
|
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
|
||||||
|
>();
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Images, audio, and anything else used to support the app.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Images for use as app icons.
|
||||||
|
After Width: | Height: | Size: 3.6 KiB |
@@ -0,0 +1 @@
|
|||||||
|
Images for use in app stores.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
name: sunset_alarm
|
name: sunset_alarm
|
||||||
description: "Set an alarm to go off a specified time before sunset."
|
description: "Set an alarm to go off a specified time before sunset."
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 0.1.1
|
version: 0.1.2
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.7.2
|
sdk: ^3.7.2
|
||||||
@@ -9,16 +9,17 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
geolocator: ^13.0.0
|
geolocator: ^14.1.1
|
||||||
shared_preferences: ^2.3.0
|
shared_preferences: ^2.5.5
|
||||||
flutter_local_notifications: ^18.0.0
|
flutter_local_notifications: ^22.3.1
|
||||||
timezone: ^0.9.0
|
timezone: ^0.11.1
|
||||||
http: ^1.2.0
|
http: ^1.6.0
|
||||||
|
alarm: ^5.13.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^5.0.0
|
flutter_lints: ^6.0.0
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||