1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-03 15:32:54 +01:00

alarm sounds, backlight, preset titles

This commit is contained in:
José Rebelo 2024-09-27 22:48:37 +01:00
parent 8348c5349e
commit b6b6c0d8f6
12 changed files with 187 additions and 10 deletions

View File

@ -46,7 +46,7 @@ public class GBDaoGenerator {
public static void main(String[] args) throws Exception {
final Schema schema = new Schema(78, MAIN_PACKAGE + ".entities");
final Schema schema = new Schema(79, MAIN_PACKAGE + ".entities");
Entity userAttributes = addUserAttributes(schema);
Entity user = addUserInfo(schema, userAttributes);
@ -1015,6 +1015,8 @@ public class GBDaoGenerator {
alarm.addBooleanProperty("unused").notNull();
alarm.addStringProperty("title");
alarm.addStringProperty("description");
alarm.addIntProperty("soundCode").notNull();
alarm.addBooleanProperty("backlight").notNull();
alarm.addToOne(user, userId);
alarm.addToOne(device, deviceId);
}

View File

@ -28,6 +28,8 @@ import android.widget.EditText;
import android.widget.TimePicker;
import java.text.NumberFormat;
import java.util.Collections;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
@ -259,6 +261,38 @@ public class AlarmDetails extends AbstractGBActivity {
return false;
}
private boolean supportsAlarmSounds() {
if (device != null) {
DeviceCoordinator coordinator = device.getDeviceCoordinator();
return coordinator.supportsAlarmSounds(device);
}
return false;
}
private boolean supportsAlarmBacklight() {
if (device != null) {
DeviceCoordinator coordinator = device.getDeviceCoordinator();
return coordinator.supportsAlarmBacklight(device);
}
return false;
}
private boolean supportsAlarmTitlePresets() {
if (device != null) {
DeviceCoordinator coordinator = device.getDeviceCoordinator();
return coordinator.supportsAlarmTitlePresets(device);
}
return false;
}
private List<String> getAlarmTitlePresets() {
if (device != null) {
DeviceCoordinator coordinator = device.getDeviceCoordinator();
return coordinator.getAlarmTitlePresets(device);
}
return Collections.emptyList();
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
final int itemId = item.getItemId();

View File

@ -0,0 +1,44 @@
/* Copyright (C) 2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.database.schema;
import android.database.sqlite.SQLiteDatabase;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.database.DBUpdateScript;
import nodomain.freeyourgadget.gadgetbridge.entities.AlarmDao;
public class GadgetbridgeUpdate_79 implements DBUpdateScript {
@Override
public void upgradeSchema(SQLiteDatabase db) {
if (!DBHelper.existsColumn(AlarmDao.TABLENAME, AlarmDao.Properties.SoundCode.columnName, db)) {
String ADD_COLUMN_SOUND_CODE = "ALTER TABLE " + AlarmDao.TABLENAME + " ADD COLUMN "
+ AlarmDao.Properties.SoundCode.columnName + " INTEGER NOT NULL DEFAULT 0;";
db.execSQL(ADD_COLUMN_SOUND_CODE);
}
if (!DBHelper.existsColumn(AlarmDao.TABLENAME, AlarmDao.Properties.Backlight.columnName, db)) {
String ADD_COLUMN_SOUND_CODE = "ALTER TABLE " + AlarmDao.TABLENAME + " ADD COLUMN "
+ AlarmDao.Properties.Backlight.columnName + " BOOLEAN NOT NULL DEFAULT TRUE;";
db.execSQL(ADD_COLUMN_SOUND_CODE);
}
}
@Override
public void downgradeSchema(SQLiteDatabase db) {
}
}

View File

@ -567,6 +567,26 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
return false;
}
@Override
public boolean supportsAlarmSounds(GBDevice device) {
return false;
}
@Override
public boolean supportsAlarmBacklight(GBDevice device) {
return false;
}
@Override
public boolean supportsAlarmTitlePresets(GBDevice device) {
return false;
}
@Override
public List<String> getAlarmTitlePresets(GBDevice device) {
return Collections.emptyList();
}
@Override
public boolean supportsMusicInfo() {
return false;

View File

@ -451,6 +451,11 @@ public interface DeviceCoordinator {
*/
boolean supportsAlarmDescription(GBDevice device);
boolean supportsAlarmSounds(GBDevice device);
boolean supportsAlarmBacklight(GBDevice device);
boolean supportsAlarmTitlePresets(GBDevice device);
List<String> getAlarmTitlePresets(GBDevice device);
/**
* Returns true if the given device supports heart rate measurements.
* @return

View File

@ -1,9 +1,12 @@
package nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.forerunner;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
public class GarminForerunner245Coordinator extends GarminCoordinator {
@Override
@ -15,4 +18,33 @@ public class GarminForerunner245Coordinator extends GarminCoordinator {
public int getDeviceNameResource() {
return R.string.devicetype_garmin_forerunner_245;
}
@Override
public int getAlarmSlotCount(final GBDevice device) {
return 10;
}
@Override
public boolean supportsAlarmSounds(final GBDevice device) {
return true;
}
@Override
public boolean supportsAlarmBacklight(final GBDevice device) {
return true;
}
@Override
public boolean supportsAlarmTitlePresets(final GBDevice device) {
return true;
}
@Override
public List<String> getAlarmTitlePresets(final GBDevice device) {
return Arrays.asList(
"label 1",
"label 2",
"label 3"
);
}
}

View File

@ -36,6 +36,14 @@ public interface Alarm extends Serializable {
byte ALARM_DAILY = Alarm.ALARM_MON | Alarm.ALARM_TUE | Alarm.ALARM_WED | Alarm.ALARM_THU | Alarm.ALARM_FRI | Alarm.ALARM_SAT | Alarm.ALARM_SUN;
enum ALARM_SOUND {
UNSET,
OFF,
TONE,
VIBRATION,
TONE_AND_VIBRATION,
}
int getPosition();
boolean getEnabled();
@ -61,4 +69,8 @@ public interface Alarm extends Serializable {
String getTitle();
String getDescription();
}
int getSoundCode();
boolean getBacklight();
}

View File

@ -808,7 +808,7 @@ public class HuaweiSupportProvider {
title = context.getString(R.string.alarm_smart_wakeup);
description = context.getString(R.string.huawei_alarm_smart_description);
}
return new Alarm(device.getId(), user.getId(), position, false, smartWakeup, null, false, 0, 6, 30, true, title, description);
return new Alarm(device.getId(), user.getId(), position, false, smartWakeup, null, false, 0, 6, 30, true, title, description, 0, true);
}
private void getAlarms() {

View File

@ -78,7 +78,9 @@ public class GetEventAlarmList extends Request {
eventAlarm.startMinute,
false,
eventAlarm.name,
""
"",
0,
true
));
usedBitmap |= 1 << eventAlarm.index;
}
@ -99,7 +101,9 @@ public class GetEventAlarmList extends Request {
0,
true,
"",
""
"",
0,
true
));
}
}

View File

@ -69,7 +69,9 @@ public class GetSmartAlarmList extends Request {
smartAlarm.startMinute,
false,
"Smart alarm",
""
"",
0,
true
)
});
} else {
@ -88,7 +90,9 @@ public class GetSmartAlarmList extends Request {
0,
true,
"Smart alarm",
""
"",
0,
true
)
});
}

View File

@ -52,7 +52,7 @@ public class AlarmUtils {
*/
public static nodomain.freeyourgadget.gadgetbridge.model.Alarm createSingleShot(int index, boolean smartWakeup, boolean snooze, Calendar calendar) {
// TODO: add interval setting?
return new Alarm(-1, -1, index, true, smartWakeup, null, snooze, Alarm.ALARM_ONCE, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false, GBApplication.getContext().getString(R.string.quick_alarm), GBApplication.getContext().getString(R.string.quick_alarm_description));
return new Alarm(-1, -1, index, true, smartWakeup, null, snooze, Alarm.ALARM_ONCE, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false, GBApplication.getContext().getString(R.string.quick_alarm), GBApplication.getContext().getString(R.string.quick_alarm_description), 0, true);
}
/**
@ -78,7 +78,7 @@ public class AlarmUtils {
public static Alarm createDefaultAlarm(DaoSession daoSession, GBDevice gbDevice, int position) {
Device device = DBHelper.getDevice(gbDevice, daoSession);
User user = DBHelper.getUser(daoSession);
return new Alarm(device.getId(), user.getId(), position, false, false, null, false, 0, 6, 30, false, null, null);
return new Alarm(device.getId(), user.getId(), position, false, false, null, false, 0, 6, 30, false, null, null, 0, true);
}
/**
@ -157,7 +157,7 @@ public class AlarmUtils {
int hour = Integer.parseInt(tokens[4]);
int minute = Integer.parseInt(tokens[5]);
return new Alarm(device.getId(), user.getId(), index, enabled, smartWakeup, null, false, repetition, hour, minute, false, null, null);
return new Alarm(device.getId(), user.getId(), index, enabled, smartWakeup, null, false, repetition, hour, minute, false, null, null, 0, true);
}
private static Comparator<Alarm> createComparator() {

View File

@ -23,6 +23,11 @@
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
<Spinner
android:id="@+id/alarm_preset_title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/alarm_title"
android:layout_width="match_parent"
@ -53,6 +58,21 @@
android:text="@string/alarm_snooze"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Spinner
android:id="@+id/alarm_sound"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/alarm_cb_backlight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:drawableStart="?android:attr/listChoiceIndicatorMultiple"
android:gravity="center"
android:text="@string/watchface_setting_button_toggle_backlight"
android:textAppearance="?android:attr/textAppearanceSmall" />
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/alarm_cb_smart_wakeup"
android:layout_width="wrap_content"