1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-23 18:36:50 +01:00

Add title and description to Alarm table (currently unsued)

Includes migration script

Also bump version to 0.44.0 because of the previous Watch X merge
This commit is contained in:
Andreas Shimokawa 2020-04-24 00:31:04 +02:00
parent da23026e8f
commit a089e01433
5 changed files with 51 additions and 6 deletions

View File

@ -43,7 +43,7 @@ public class GBDaoGenerator {
public static void main(String[] args) throws Exception {
Schema schema = new Schema(25, MAIN_PACKAGE + ".entities");
Schema schema = new Schema(26, MAIN_PACKAGE + ".entities");
Entity userAttributes = addUserAttributes(schema);
Entity user = addUserInfo(schema, userAttributes);
@ -442,6 +442,8 @@ public class GBDaoGenerator {
alarm.addIntProperty("hour").notNull();
alarm.addIntProperty("minute").notNull();
alarm.addBooleanProperty("unused").notNull();
alarm.addStringProperty("title");
alarm.addStringProperty("description");
alarm.addToOne(user, userId);
alarm.addToOne(device, deviceId);
}

View File

@ -25,8 +25,8 @@ android {
targetSdkVersion 28
// Note: always bump BOTH versionCode and versionName!
versionName "0.43.3"
versionCode 172
versionName "0.44.0"
versionCode 173
vectorDrawables.useSupportLibrary = true
}
buildTypes {

View File

@ -146,7 +146,7 @@ public class ConfigureAlarms extends AbstractGBActivity {
}
private Alarm createDefaultAlarm(@NonNull Device device, @NonNull User user, int position) {
return new Alarm(device.getId(), user.getId(), position, false, false, false, 0, 6, 30, false);
return new Alarm(device.getId(), user.getId(), position, false, false, false, 0, 6, 30, false, null, null);
}
@Override

View File

@ -0,0 +1,43 @@
/* Copyright (C) 2017-2020 Andreas Shimokawa, protomors
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 <http://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_26 implements DBUpdateScript {
@Override
public void upgradeSchema(SQLiteDatabase db) {
if (!DBHelper.existsColumn(AlarmDao.TABLENAME, AlarmDao.Properties.Title.columnName, db)) {
String ADD_COLUMN_TITLE = "ALTER TABLE " + AlarmDao.TABLENAME + " ADD COLUMN "
+ AlarmDao.Properties.Title.columnName + " TEXT";
db.execSQL(ADD_COLUMN_TITLE);
}
if (!DBHelper.existsColumn(AlarmDao.TABLENAME, AlarmDao.Properties.Description.columnName, db)) {
String ADD_COLUMN_TITLE = "ALTER TABLE " + AlarmDao.TABLENAME + " ADD COLUMN "
+ AlarmDao.Properties.Description.columnName + " TEXT";
db.execSQL(ADD_COLUMN_TITLE);
}
}
@Override
public void downgradeSchema(SQLiteDatabase db) {
}
}

View File

@ -49,7 +49,7 @@ public class AlarmUtils {
* @return
*/
public static nodomain.freeyourgadget.gadgetbridge.model.Alarm createSingleShot(int index, boolean smartWakeup, boolean snooze, Calendar calendar) {
return new Alarm(-1, -1, index, true, smartWakeup, snooze, Alarm.ALARM_ONCE, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false);
return new Alarm(-1, -1, index, true, smartWakeup, snooze, Alarm.ALARM_ONCE, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false, null, null);
}
/**
@ -128,7 +128,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, false, repetition, hour, minute, false);
return new Alarm(device.getId(), user.getId(), index, enabled, smartWakeup, false, repetition, hour, minute, false, null, null);
}
private static Comparator<Alarm> createComparator() {