Skip to content
This repository was archived by the owner on Aug 24, 2025. It is now read-only.

Commit fe0f1f3

Browse files
committed
show image in workout slide if no video is selected, see #10
1 parent 5989531 commit fe0f1f3

File tree

9 files changed

+398
-26
lines changed

9 files changed

+398
-26
lines changed
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 2,
5+
"identityHash": "007a41b5201e4b1e5a62195c5ba4415c",
6+
"entities": [
7+
{
8+
"tableName": "User",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`userId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `trainingsPlanId` INTEGER NOT NULL, `isMale` INTEGER NOT NULL)",
10+
"fields": [
11+
{
12+
"fieldPath": "userId",
13+
"columnName": "userId",
14+
"affinity": "INTEGER",
15+
"notNull": true
16+
},
17+
{
18+
"fieldPath": "trainingsPlanId",
19+
"columnName": "trainingsPlanId",
20+
"affinity": "INTEGER",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "isMale",
25+
"columnName": "isMale",
26+
"affinity": "INTEGER",
27+
"notNull": true
28+
}
29+
],
30+
"primaryKey": {
31+
"columnNames": [
32+
"userId"
33+
],
34+
"autoGenerate": true
35+
},
36+
"indices": [],
37+
"foreignKeys": []
38+
},
39+
{
40+
"tableName": "TrainingPlan",
41+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`trainingPlanId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `orderNr` INTEGER NOT NULL, `name` TEXT, `imagePath` TEXT, `isImagePathExternal` INTEGER NOT NULL, `countFinishedTraining` INTEGER NOT NULL)",
42+
"fields": [
43+
{
44+
"fieldPath": "trainingPlanId",
45+
"columnName": "trainingPlanId",
46+
"affinity": "INTEGER",
47+
"notNull": true
48+
},
49+
{
50+
"fieldPath": "orderNr",
51+
"columnName": "orderNr",
52+
"affinity": "INTEGER",
53+
"notNull": true
54+
},
55+
{
56+
"fieldPath": "name",
57+
"columnName": "name",
58+
"affinity": "TEXT",
59+
"notNull": false
60+
},
61+
{
62+
"fieldPath": "imagePath",
63+
"columnName": "imagePath",
64+
"affinity": "TEXT",
65+
"notNull": false
66+
},
67+
{
68+
"fieldPath": "isImagePathExternal",
69+
"columnName": "isImagePathExternal",
70+
"affinity": "INTEGER",
71+
"notNull": true
72+
},
73+
{
74+
"fieldPath": "countFinishedTraining",
75+
"columnName": "countFinishedTraining",
76+
"affinity": "INTEGER",
77+
"notNull": true
78+
}
79+
],
80+
"primaryKey": {
81+
"columnNames": [
82+
"trainingPlanId"
83+
],
84+
"autoGenerate": true
85+
},
86+
"indices": [],
87+
"foreignKeys": []
88+
},
89+
{
90+
"tableName": "WorkoutSession",
91+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`workoutSessionId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `trainingPlanId` INTEGER NOT NULL, `orderNr` INTEGER NOT NULL, `name` TEXT, `finished` INTEGER NOT NULL)",
92+
"fields": [
93+
{
94+
"fieldPath": "workoutSessionId",
95+
"columnName": "workoutSessionId",
96+
"affinity": "INTEGER",
97+
"notNull": true
98+
},
99+
{
100+
"fieldPath": "trainingPlanId",
101+
"columnName": "trainingPlanId",
102+
"affinity": "INTEGER",
103+
"notNull": true
104+
},
105+
{
106+
"fieldPath": "orderNr",
107+
"columnName": "orderNr",
108+
"affinity": "INTEGER",
109+
"notNull": true
110+
},
111+
{
112+
"fieldPath": "name",
113+
"columnName": "name",
114+
"affinity": "TEXT",
115+
"notNull": false
116+
},
117+
{
118+
"fieldPath": "finished",
119+
"columnName": "finished",
120+
"affinity": "INTEGER",
121+
"notNull": true
122+
}
123+
],
124+
"primaryKey": {
125+
"columnNames": [
126+
"workoutSessionId"
127+
],
128+
"autoGenerate": true
129+
},
130+
"indices": [],
131+
"foreignKeys": []
132+
},
133+
{
134+
"tableName": "WorkoutItem",
135+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`workoutItemId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `workoutSessionId` INTEGER NOT NULL, `orderNr` INTEGER NOT NULL, `name` TEXT, `description` TEXT, `elapsedTime` INTEGER NOT NULL, `imagePath` TEXT, `isImagePathExternal` INTEGER NOT NULL, `isVideoMode` INTEGER NOT NULL, `videoPath` TEXT, `isVideoPathExternal` INTEGER NOT NULL, `prepTime` INTEGER NOT NULL, `workoutTime` INTEGER NOT NULL, `breakTime` INTEGER NOT NULL, `repetitionCount` INTEGER NOT NULL, `isTimeMode` INTEGER NOT NULL, `finished` INTEGER NOT NULL)",
136+
"fields": [
137+
{
138+
"fieldPath": "workoutItemId",
139+
"columnName": "workoutItemId",
140+
"affinity": "INTEGER",
141+
"notNull": true
142+
},
143+
{
144+
"fieldPath": "workoutSessionId",
145+
"columnName": "workoutSessionId",
146+
"affinity": "INTEGER",
147+
"notNull": true
148+
},
149+
{
150+
"fieldPath": "orderNr",
151+
"columnName": "orderNr",
152+
"affinity": "INTEGER",
153+
"notNull": true
154+
},
155+
{
156+
"fieldPath": "name",
157+
"columnName": "name",
158+
"affinity": "TEXT",
159+
"notNull": false
160+
},
161+
{
162+
"fieldPath": "description",
163+
"columnName": "description",
164+
"affinity": "TEXT",
165+
"notNull": false
166+
},
167+
{
168+
"fieldPath": "elapsedTime",
169+
"columnName": "elapsedTime",
170+
"affinity": "INTEGER",
171+
"notNull": true
172+
},
173+
{
174+
"fieldPath": "imagePath",
175+
"columnName": "imagePath",
176+
"affinity": "TEXT",
177+
"notNull": false
178+
},
179+
{
180+
"fieldPath": "isImagePathExternal",
181+
"columnName": "isImagePathExternal",
182+
"affinity": "INTEGER",
183+
"notNull": true
184+
},
185+
{
186+
"fieldPath": "isVideoMode",
187+
"columnName": "isVideoMode",
188+
"affinity": "INTEGER",
189+
"notNull": true
190+
},
191+
{
192+
"fieldPath": "videoPath",
193+
"columnName": "videoPath",
194+
"affinity": "TEXT",
195+
"notNull": false
196+
},
197+
{
198+
"fieldPath": "isVideoPathExternal",
199+
"columnName": "isVideoPathExternal",
200+
"affinity": "INTEGER",
201+
"notNull": true
202+
},
203+
{
204+
"fieldPath": "prepTime",
205+
"columnName": "prepTime",
206+
"affinity": "INTEGER",
207+
"notNull": true
208+
},
209+
{
210+
"fieldPath": "workoutTime",
211+
"columnName": "workoutTime",
212+
"affinity": "INTEGER",
213+
"notNull": true
214+
},
215+
{
216+
"fieldPath": "breakTime",
217+
"columnName": "breakTime",
218+
"affinity": "INTEGER",
219+
"notNull": true
220+
},
221+
{
222+
"fieldPath": "repetitionCount",
223+
"columnName": "repetitionCount",
224+
"affinity": "INTEGER",
225+
"notNull": true
226+
},
227+
{
228+
"fieldPath": "isTimeMode",
229+
"columnName": "isTimeMode",
230+
"affinity": "INTEGER",
231+
"notNull": true
232+
},
233+
{
234+
"fieldPath": "finished",
235+
"columnName": "finished",
236+
"affinity": "INTEGER",
237+
"notNull": true
238+
}
239+
],
240+
"primaryKey": {
241+
"columnNames": [
242+
"workoutItemId"
243+
],
244+
"autoGenerate": true
245+
},
246+
"indices": [],
247+
"foreignKeys": []
248+
}
249+
],
250+
"views": [],
251+
"setupQueries": [
252+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
253+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '007a41b5201e4b1e5a62195c5ba4415c')"
254+
]
255+
}
256+
}

app/src/main/java/com/health/openworkout/core/OpenWorkout.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public void onOpen(SupportSQLiteDatabase db) {
8888
db.setForeignKeyConstraintsEnabled(true);
8989
}
9090
})
91+
.addMigrations(AppDatabase.MIGRATION_1_2)
9192
.build();
9293
}
9394

app/src/main/java/com/health/openworkout/core/database/AppDatabase.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,34 @@
1919

2020
import androidx.room.Database;
2121
import androidx.room.RoomDatabase;
22+
import androidx.room.migration.Migration;
23+
import androidx.sqlite.db.SupportSQLiteDatabase;
2224

2325
import com.health.openworkout.core.datatypes.TrainingPlan;
2426
import com.health.openworkout.core.datatypes.User;
2527
import com.health.openworkout.core.datatypes.WorkoutItem;
2628
import com.health.openworkout.core.datatypes.WorkoutSession;
2729

28-
@Database(entities = {User.class, TrainingPlan.class, WorkoutSession.class, WorkoutItem.class}, version = 1)
30+
@Database(entities = {User.class, TrainingPlan.class, WorkoutSession.class, WorkoutItem.class}, version = 2)
2931
public abstract class AppDatabase extends RoomDatabase {
3032
public abstract UserDAO userDAO();
3133
public abstract TrainingPlanDAO trainingPlanDAO();
3234
public abstract WorkoutSessionDAO workoutSessionDAO();
3335
public abstract WorkoutItemDAO workoutItemDAO();
36+
37+
public static final Migration MIGRATION_1_2 = new Migration(1, 2) {
38+
@Override
39+
public void migrate(SupportSQLiteDatabase database) {
40+
database.beginTransaction();
41+
try {
42+
// Add isVideoMode
43+
database.execSQL("ALTER TABLE workoutItem ADD isVideoMode INTEGER NOT NULL default 1");
44+
45+
database.setTransactionSuccessful();
46+
}
47+
finally {
48+
database.endTransaction();
49+
}
50+
}
51+
};
3452
}

app/src/main/java/com/health/openworkout/core/datatypes/WorkoutItem.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public class WorkoutItem implements Comparable<WorkoutItem>, Cloneable {
4949
@ColumnInfo
5050
private boolean isImagePathExternal;
5151
@ColumnInfo
52+
private boolean isVideoMode;
53+
@ColumnInfo
5254
private String videoPath;
5355
@ColumnInfo
5456
private boolean isVideoPathExternal;
@@ -79,6 +81,7 @@ public WorkoutItem() {
7981
repetitionCount = 5;
8082
isTimeMode = true;
8183
finished = false;
84+
isVideoMode = true;
8285
isVideoPathExternal = false;
8386
videoPath = "idle.mp4";
8487
isImagePathExternal = false;
@@ -170,6 +173,14 @@ public void setImagePathExternal(boolean imagePathExternal) {
170173
isImagePathExternal = imagePathExternal;
171174
}
172175

176+
public boolean isVideoMode() {
177+
return isVideoMode;
178+
}
179+
180+
public void setVideoMode(boolean videoMode) {
181+
isVideoMode = videoMode;
182+
}
183+
173184
public String getVideoPath() {
174185
return videoPath;
175186
}

0 commit comments

Comments
 (0)