mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-12 11:47:46 +01:00
alarm sounds, backlight, preset titles
This commit is contained in:
parent
8348c5349e
commit
b6b6c0d8f6
@ -46,7 +46,7 @@ public class GBDaoGenerator {
|
|||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
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 userAttributes = addUserAttributes(schema);
|
||||||
Entity user = addUserInfo(schema, userAttributes);
|
Entity user = addUserInfo(schema, userAttributes);
|
||||||
@ -1015,6 +1015,8 @@ public class GBDaoGenerator {
|
|||||||
alarm.addBooleanProperty("unused").notNull();
|
alarm.addBooleanProperty("unused").notNull();
|
||||||
alarm.addStringProperty("title");
|
alarm.addStringProperty("title");
|
||||||
alarm.addStringProperty("description");
|
alarm.addStringProperty("description");
|
||||||
|
alarm.addIntProperty("soundCode").notNull();
|
||||||
|
alarm.addBooleanProperty("backlight").notNull();
|
||||||
alarm.addToOne(user, userId);
|
alarm.addToOne(user, userId);
|
||||||
alarm.addToOne(device, deviceId);
|
alarm.addToOne(device, deviceId);
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,8 @@ import android.widget.EditText;
|
|||||||
import android.widget.TimePicker;
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -259,6 +261,38 @@ public class AlarmDetails extends AbstractGBActivity {
|
|||||||
return false;
|
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
|
@Override
|
||||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||||
final int itemId = item.getItemId();
|
final int itemId = item.getItemId();
|
||||||
|
@ -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) {
|
||||||
|
}
|
||||||
|
}
|
@ -567,6 +567,26 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
|||||||
return false;
|
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
|
@Override
|
||||||
public boolean supportsMusicInfo() {
|
public boolean supportsMusicInfo() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -451,6 +451,11 @@ public interface DeviceCoordinator {
|
|||||||
*/
|
*/
|
||||||
boolean supportsAlarmDescription(GBDevice device);
|
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.
|
* Returns true if the given device supports heart rate measurements.
|
||||||
* @return
|
* @return
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.forerunner;
|
package nodomain.freeyourgadget.gadgetbridge.devices.garmin.watches.forerunner;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCoordinator;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
|
|
||||||
public class GarminForerunner245Coordinator extends GarminCoordinator {
|
public class GarminForerunner245Coordinator extends GarminCoordinator {
|
||||||
@Override
|
@Override
|
||||||
@ -15,4 +18,33 @@ public class GarminForerunner245Coordinator extends GarminCoordinator {
|
|||||||
public int getDeviceNameResource() {
|
public int getDeviceNameResource() {
|
||||||
return R.string.devicetype_garmin_forerunner_245;
|
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"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
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();
|
int getPosition();
|
||||||
|
|
||||||
boolean getEnabled();
|
boolean getEnabled();
|
||||||
@ -61,4 +69,8 @@ public interface Alarm extends Serializable {
|
|||||||
String getTitle();
|
String getTitle();
|
||||||
|
|
||||||
String getDescription();
|
String getDescription();
|
||||||
|
|
||||||
|
int getSoundCode();
|
||||||
|
|
||||||
|
boolean getBacklight();
|
||||||
}
|
}
|
@ -808,7 +808,7 @@ public class HuaweiSupportProvider {
|
|||||||
title = context.getString(R.string.alarm_smart_wakeup);
|
title = context.getString(R.string.alarm_smart_wakeup);
|
||||||
description = context.getString(R.string.huawei_alarm_smart_description);
|
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() {
|
private void getAlarms() {
|
||||||
|
@ -78,7 +78,9 @@ public class GetEventAlarmList extends Request {
|
|||||||
eventAlarm.startMinute,
|
eventAlarm.startMinute,
|
||||||
false,
|
false,
|
||||||
eventAlarm.name,
|
eventAlarm.name,
|
||||||
""
|
"",
|
||||||
|
0,
|
||||||
|
true
|
||||||
));
|
));
|
||||||
usedBitmap |= 1 << eventAlarm.index;
|
usedBitmap |= 1 << eventAlarm.index;
|
||||||
}
|
}
|
||||||
@ -99,7 +101,9 @@ public class GetEventAlarmList extends Request {
|
|||||||
0,
|
0,
|
||||||
true,
|
true,
|
||||||
"",
|
"",
|
||||||
""
|
"",
|
||||||
|
0,
|
||||||
|
true
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,9 @@ public class GetSmartAlarmList extends Request {
|
|||||||
smartAlarm.startMinute,
|
smartAlarm.startMinute,
|
||||||
false,
|
false,
|
||||||
"Smart alarm",
|
"Smart alarm",
|
||||||
""
|
"",
|
||||||
|
0,
|
||||||
|
true
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -88,7 +90,9 @@ public class GetSmartAlarmList extends Request {
|
|||||||
0,
|
0,
|
||||||
true,
|
true,
|
||||||
"Smart alarm",
|
"Smart alarm",
|
||||||
""
|
"",
|
||||||
|
0,
|
||||||
|
true
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class AlarmUtils {
|
|||||||
*/
|
*/
|
||||||
public static nodomain.freeyourgadget.gadgetbridge.model.Alarm createSingleShot(int index, boolean smartWakeup, boolean snooze, Calendar calendar) {
|
public static nodomain.freeyourgadget.gadgetbridge.model.Alarm createSingleShot(int index, boolean smartWakeup, boolean snooze, Calendar calendar) {
|
||||||
// TODO: add interval setting?
|
// 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) {
|
public static Alarm createDefaultAlarm(DaoSession daoSession, GBDevice gbDevice, int position) {
|
||||||
Device device = DBHelper.getDevice(gbDevice, daoSession);
|
Device device = DBHelper.getDevice(gbDevice, daoSession);
|
||||||
User user = DBHelper.getUser(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 hour = Integer.parseInt(tokens[4]);
|
||||||
int minute = Integer.parseInt(tokens[5]);
|
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() {
|
private static Comparator<Alarm> createComparator() {
|
||||||
|
@ -23,6 +23,11 @@
|
|||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
android:paddingBottom="@dimen/activity_vertical_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
|
<EditText
|
||||||
android:id="@+id/alarm_title"
|
android:id="@+id/alarm_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -53,6 +58,21 @@
|
|||||||
android:text="@string/alarm_snooze"
|
android:text="@string/alarm_snooze"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
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
|
<androidx.appcompat.widget.AppCompatCheckedTextView
|
||||||
android:id="@+id/alarm_cb_smart_wakeup"
|
android:id="@+id/alarm_cb_smart_wakeup"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
Loading…
Reference in New Issue
Block a user