Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alarm tones #596

Merged
merged 10 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: "17"

java-version: "17.x"

- name: Setup Flutter
uses: subosito/flutter-action@v2
Expand Down
5 changes: 4 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ android {
applicationId "com.ccextractor.ultimate_alarm_clock"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 23
minSdkVersion 24
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand All @@ -64,6 +64,8 @@ android {
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
v1SigningEnabled true
v2SigningEnabled true
}
}
buildTypes {
Expand All @@ -88,5 +90,6 @@ dependencies {
implementation 'com.google.firebase:protolite-well-known-types:18.0.0'
implementation("com.android.volley:volley:1.2.1")
implementation("com.google.code.gson:gson:2.10.1")
implementation("androidx.multidex:multidex:2.0.1")

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,68 +41,68 @@ fun getLatestAlarm(db: SQLiteDatabase, wantNextAlarm: Boolean, profile: String):
var alarm = AlarmModel.fromCursor(cursor)
var intervaltoAlarm = Long.MAX_VALUE
var setAlarm: AlarmModel? =null
do {
alarm = AlarmModel.fromCursor(cursor)
if (alarm.ringOn == 0) {
do {
alarm = AlarmModel.fromCursor(cursor)
if (alarm.ringOn == 0) {

var dayfromToday = 0
var timeDif = getTimeDifferenceInMillis(alarm.alarmTime)
Log.d("d","timeDiff ${timeDif}")

if ((alarm.days[currentDay] == '1' || alarm.days=="0000000") && timeDif > -1L) {
if (timeDif < intervaltoAlarm) {
intervaltoAlarm = timeDif
setAlarm = alarm
}
} else {
dayfromToday = getDaysUntilNextAlarm(alarm.days, currentDay)
if (dayfromToday == 0) {

if(alarm.days=="0000000")
{
var dayfromToday = 0
var timeDif = getTimeDifferenceInMillis(alarm.alarmTime)
Log.d("d","timeDiff ${timeDif}")

if ((alarm.days[currentDay] == '1' || alarm.days=="0000000") && timeDif > -1L) {
if (timeDif < intervaltoAlarm) {
intervaltoAlarm = timeDif
setAlarm = alarm
}
} else {
dayfromToday = getDaysUntilNextAlarm(alarm.days, currentDay)
if (dayfromToday == 0) {

if(alarm.days=="0000000")
{

var timeDif =
getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight()
if (timeDif < intervaltoAlarm && timeDif > -1L ) {
intervaltoAlarm = timeDif
setAlarm = alarm
}
}
else{

var timeDif =
getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight() + 86400000 * 6
if (timeDif < intervaltoAlarm && timeDif > -1L ) {
intervaltoAlarm = timeDif
setAlarm = alarm
}
}
} else if (dayfromToday == 1) {
var timeDif =
getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight()
if (timeDif < intervaltoAlarm && timeDif > -1L ) {
Log.d("d","timeDiff ${timeDif}")

if (timeDif < intervaltoAlarm && timeDif > -1L) {
intervaltoAlarm = timeDif
setAlarm = alarm
}
}
else{

} else {
var timeDif =
getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight() + 86400000 * 6
if (timeDif < intervaltoAlarm && timeDif > -1L ) {
getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight() + 86400000 * (dayfromToday - 1)
if (timeDif < intervaltoAlarm && timeDif > -1L) {
intervaltoAlarm = timeDif
setAlarm = alarm
}
}
} else if (dayfromToday == 1) {
var timeDif =
getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight()
Log.d("d","timeDiff ${timeDif}")

if (timeDif < intervaltoAlarm && timeDif > -1L) {
intervaltoAlarm = timeDif
setAlarm = alarm
}
} else {
var timeDif =
getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight() + 86400000 * (dayfromToday - 1)
if (timeDif < intervaltoAlarm && timeDif > -1L) {
intervaltoAlarm = timeDif
setAlarm = alarm
}
}

}
} else {
val dayfromToday = getDaysFromCurrentDate(alarm.alarmDate)
if (dayfromToday == 0L) {
var timeDif = getTimeDifferenceInMillis(alarm.alarmTime)
if (alarm.days[currentDay] == '1' && timeDif > -1L) {
if (timeDif < intervaltoAlarm) {
intervaltoAlarm = timeDif
}
} else {
val dayfromToday = getDaysFromCurrentDate(alarm.alarmDate)
if (dayfromToday == 0L) {
var timeDif = getTimeDifferenceInMillis(alarm.alarmTime)
if (alarm.days[currentDay] == '1' && timeDif > -1L) {
if (timeDif < intervaltoAlarm) {
intervaltoAlarm = timeDif
setAlarm = alarm
}
}
Expand Down Expand Up @@ -135,7 +135,8 @@ fun getLatestAlarm(db: SQLiteDatabase, wantNextAlarm: Boolean, profile: String):
"isLocation" to setAlarm.isLocationEnabled,
"location" to setAlarm.location,
"isWeather" to setAlarm.isWeatherEnabled,
"weatherTypes" to setAlarm.weatherTypes
"weatherTypes" to setAlarm.weatherTypes,
"alarmID" to setAlarm.alarmId
)
Log.d("s","sdsd ${a}")
return a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class MainActivity : FlutterActivity() {

if (intent != null && intent.hasExtra(EXTRA_KEY)) {
val receivedData = intent.getStringExtra(EXTRA_KEY)
alarmConfig["shouldAlarmRing"] = true
if(receivedData == "true") {
alarmConfig["shouldAlarmRing"] = true
}
isAlarm = intent.getStringExtra(ALARM_TYPE)
val cleanIntent = Intent(intent)
cleanIntent.removeExtra(EXTRA_KEY)
Expand All @@ -63,7 +65,10 @@ class MainActivity : FlutterActivity() {
}

if (isAlarm == "true") {
val cleanIntent = Intent(intent)
cleanIntent.removeExtra(EXTRA_KEY)
methodChannel1.invokeMethod("appStartup", alarmConfig)
alarmConfig["shouldAlarmRing"] = false
}
methodChannel2.setMethodCallHandler { call, result ->
if (call.method == "playDefaultAlarm") {
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
buildscript {
ext.kotlin_version = '1.7.10'
ext {
compileSdkVersion = 33 // or latest
targetSdkVersion = 33 // or latest
compileSdkVersion = 34 // or latest
targetSdkVersion = 34 // or latest
appCompatVersion = "1.4.2" // or latest
}
repositories {
Expand All @@ -11,7 +11,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15'
}
Expand Down
Binary file added assets/ringtones/digialarm.mp3
Binary file not shown.
Binary file added assets/ringtones/digialarm2.mp3
Binary file not shown.
Binary file added assets/ringtones/digialarm3.mp3
Binary file not shown.
Binary file added assets/ringtones/mystery.mp3
Binary file not shown.
Binary file added assets/ringtones/newday.mp3
Binary file not shown.
39 changes: 38 additions & 1 deletion lib/app/data/providers/isar_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ class IsarDb {
final isarProvider = IsarDb();
final db = await isarProvider.db;

final query = db.ringtoneModels.where().findAll();
final query = db.ringtoneModels.where().sortByRingtoneName().findAll();

return query;
} catch (e) {
Expand Down Expand Up @@ -626,4 +626,41 @@ class IsarDb {
rethrow;
}
}

static loadDefaultRingtones() async {
final isarProvider = IsarDb();
final db = await isarProvider.db;
final ringtoneCount = await db.ringtoneModels.where().findAll();
if (ringtoneCount.isEmpty) {
await db.writeTxn(() async {
await db.ringtoneModels.importJson([
{'isarId' : fastHash('Digital Alarm 1'),
'ringtoneName': 'Digital Alarm 1',
'ringtonePath': 'ringtones/digialarm.mp3',
'currentCounterOfUsage': 0
},
{'isarId' : fastHash('Digital Alarm 2'),
'ringtoneName': 'Digital Alarm 2',
'ringtonePath': 'ringtones/digialarm2.mp3',
'currentCounterOfUsage': 0
},
{'isarId' : fastHash('Digital Alarm 3'),
'ringtoneName': 'Digital Alarm 3',
'ringtonePath': 'ringtones/digialarm3.mp3',
'currentCounterOfUsage': 0
},
{'isarId' : fastHash('Mystery'),
'ringtoneName': 'Mystery',
'ringtonePath': 'ringtones/mystery.mp3',
'currentCounterOfUsage': 0
},
{'isarId' : fastHash('New Day'),
'ringtoneName': 'New Day',
'ringtonePath': 'ringtones/newday.mp3',
'currentCounterOfUsage': 0
},
]);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class AddOrUpdateAlarmController extends GetxController {
final RxBool isOneTime = true.obs;
final RxString label = ''.obs;
final RxInt snoozeDuration = 1.obs;
var customRingtoneName = 'Default'.obs;
var customRingtoneName = 'Digital Alarm 1'.obs;
var customRingtoneNames = [].obs;
var previousRingtone = '';
final noteController = TextEditingController();
Expand Down Expand Up @@ -708,6 +708,7 @@ class AddOrUpdateAlarmController extends GetxController {
userName.value = userModel.value!.fullName;
lastEditedUserId.value = userModel.value!.id;
}
IsarDb.loadDefaultRingtones();

// listens to the userModel declared in homeController and updates on signup event
homeController.userModel.stream.listen((UserModel? user) {
Expand Down
Loading