Skip to content

Commit ad247d0

Browse files
committed
resolve comments
1 parent b1b84ce commit ad247d0

File tree

5 files changed

+121
-61
lines changed

5 files changed

+121
-61
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
WITH distinct_devices AS (
2+
SELECT
3+
array_agg(device_id::text) AS device_list
4+
FROM
5+
(SELECT DISTINCT device_id
6+
FROM devices
7+
WHERE sensor_class = 'Activity') AS distinct_devices
8+
),
9+
10+
timeseries AS (
11+
SELECT
12+
timeseries.time AS time,
13+
timeseries.speed AS speed,
14+
timeseries.altitude AS altitude,
15+
timeseries.geom AS geom,
16+
timeseries.bearing AS bearing,
17+
timeseries.session_id AS session_id,
18+
timeseries.device_id AS device_id
19+
FROM
20+
public.get_location_table((SELECT device_list FROM distinct_devices)) AS timeseries
21+
ORDER BY time
22+
),
23+
24+
line AS (
25+
SELECT
26+
ts.time AS time,
27+
LAG(ts.geom) OVER (PARTITION BY ts.device_id, ts.session_id ORDER BY ts.time) AS prev_geom,
28+
ST_MakeLine(LAG(ts.geom) OVER (PARTITION BY ts.device_id, ts.session_id ORDER BY ts.time), ts.geom) AS geom,
29+
ts.speed AS speed,
30+
ts.altitude AS altitude,
31+
ts.bearing AS bearing,
32+
ts.device_id AS device_id,
33+
get_device_iri(ts.device_id) AS iri
34+
FROM
35+
timeseries ts
36+
),
37+
38+
activity_data AS (
39+
SELECT
40+
activity_data.time AS time,
41+
activity_data.device_id AS device_id,
42+
activity_data.activity_type AS activity_type,
43+
activity_data.confidence_level AS confidence_level,
44+
get_device_iri(activity_data.device_id) AS iri
45+
FROM
46+
public.get_activity_table((SELECT device_list FROM distinct_devices)) AS activity_data
47+
ORDER BY time
48+
),
49+
50+
all_data AS (
51+
SELECT
52+
COALESCE(l.time, a.time) AS time,
53+
l.geom,
54+
l.speed,
55+
l.altitude,
56+
l.bearing,
57+
COALESCE(a.activity_type, 'Unknown') AS activity_type,
58+
COALESCE(a.confidence_level, 0) AS confidence_level,
59+
COALESCE(l.iri, a.iri) AS iri
60+
FROM
61+
line l
62+
JOIN
63+
activity_data a
64+
ON
65+
l.device_id = a.device_id
66+
AND ABS(l.time - a.time) <= 5000 -- Allows up to 5 seconds difference in time
67+
WHERE
68+
l.prev_geom IS NOT NULL
69+
AND ('%device_id%' = '' OR COALESCE(l.device_id, a.device_id) = '%device_id%')
70+
AND (%lowerbound% = 0 OR l.time > %lowerbound%) -- Lower bound for time
71+
AND (%upperbound% = 0 OR l.time < %upperbound%) -- Upper bound for time
72+
ORDER BY time
73+
)
74+
SELECT DISTINCT * FROM all_data;

Apps/TimelineApp/feature/timeline/src/main/java/uk/ac/cam/cares/jps/timeline/ui/bottomsheet/NormalBottomSheet.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ void init(Context context) {
4848
summaryRecyclerView = bottomSheet.findViewById(R.id.summary_recycler_view);
4949

5050
summaryAdapter = new ActivitySummaryAdapter();
51-
summaryRecyclerView.setHasFixedSize(true);
52-
summaryRecyclerView.setNestedScrollingEnabled(true);
53-
summaryRecyclerView.setVerticalScrollBarEnabled(false);
54-
summaryRecyclerView.setHorizontalScrollBarEnabled(true);
55-
summaryRecyclerView.setScrollbarFadingEnabled(false);
5651
summaryRecyclerView.setAdapter(summaryAdapter);
5752
summaryRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
5853
}

Apps/TimelineApp/feature/timeline/src/main/java/uk/ac/cam/cares/jps/timeline/viewmodel/NormalBottomSheetViewModel.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ private List<SummaryActivityItem> parseActivitySummary(TrajectoryByDate trajecto
180180
Objects.requireNonNull(distancePerActivityType.get(activityType)).add(distance);
181181
}
182182
for (String activity : distancePerActivityType.keySet()) {
183-
int totalDistance = activity.equals("still") ? 0 : addTogether(Objects.requireNonNull(distancePerActivityType.get(activity)));
184-
long totalTime = addTogetherLong(Objects.requireNonNull(timePerActivityType.get(activity)));
183+
int totalDistance = activity.equals("still") ? 0 : Objects.requireNonNull(distancePerActivityType.get(activity)).stream().mapToInt(Integer::intValue).sum();
184+
long totalTime = Objects.requireNonNull(timePerActivityType.get(activity)).stream().mapToLong(Long::longValue).sum();;
185185

186186
int activityImage = getActivityImage(activity);
187187

@@ -202,14 +202,6 @@ private int getActivityImage(String activity) {
202202
return activityImage;
203203
}
204204

205-
private long addTogetherLong(List<Long> longs) {
206-
return longs.stream().mapToLong(Long::longValue).sum();
207-
}
208-
209-
private int addTogether(List<Integer> integers) {
210-
return integers.stream().mapToInt(Integer::intValue).sum();
211-
}
212-
213205
private long differenceInTime(long startTime, long endTime) {
214206
return ChronoUnit.MINUTES.between(
215207
Instant.ofEpochMilli(startTime).atZone(ZoneId.systemDefault()).toLocalDateTime(),
Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,41 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout
2+
<androidx.constraintlayout.widget.ConstraintLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:app="http://schemas.android.com/apk/res-auto"
55
android:layout_width="match_parent"
6-
android:layout_height="50dp"
7-
android:paddingVertical="10dp"
8-
android:gravity="left">
9-
6+
android:layout_height="wrap_content"
7+
android:paddingVertical="10dp">
108

119
<ImageView
1210
android:id="@+id/activityType"
13-
android:layout_width="150dp"
14-
android:layout_height="40dp"
15-
android:layout_marginStart="20dp"
16-
android:layout_marginTop="5dp"
17-
android:layout_marginEnd="20dp"
18-
android:src="@drawable/baseline_directions_walk_24"/>
19-
11+
android:layout_width="120dp"
12+
android:layout_height="32dp"
13+
android:src="@drawable/baseline_directions_walk_24"
14+
app:layout_constraintStart_toStartOf="parent"
15+
app:layout_constraintTop_toTopOf="parent"
16+
app:layout_constraintBottom_toBottomOf="parent"
17+
android:contentDescription="Activity Icon" />
2018

2119
<TextView
2220
android:id="@+id/timeSummary"
2321
android:layout_width="wrap_content"
2422
android:layout_height="wrap_content"
25-
android:layout_marginStart="50dp"
26-
android:layout_marginTop="5dp"
27-
android:layout_marginEnd="2dp"
28-
android:layout_toEndOf="@+id/activityType"
29-
android:gravity="center"
3023
android:text="00:00 - 00:00"
3124
android:textColor="#121212"
32-
android:textSize="16sp" />
25+
android:textSize="16sp"
26+
android:gravity="center_vertical"
27+
app:layout_constraintStart_toEndOf="@id/activityType"
28+
app:layout_constraintTop_toTopOf="@id/activityType"
29+
app:layout_constraintBottom_toBottomOf="@id/activityType" />
3330

34-
<ImageView
31+
<ImageView
3532
android:id="@+id/clicked"
36-
android:layout_width="150dp"
37-
android:layout_height="40dp"
38-
android:layout_marginStart="40dp"
39-
android:layout_marginTop="5dp"
40-
android:layout_marginEnd="20dp"
41-
android:layout_toEndOf="@+id/timeSummary"
42-
android:src="@drawable/baseline_keyboard_double_arrow_left_24"/>
43-
44-
</RelativeLayout>
33+
android:layout_width="112dp"
34+
android:layout_height="31dp"
35+
android:src="@drawable/baseline_keyboard_double_arrow_left_24"
36+
app:layout_constraintStart_toEndOf="@id/timeSummary"
37+
app:layout_constraintTop_toTopOf="@id/timeSummary"
38+
app:layout_constraintBottom_toBottomOf="@id/timeSummary"
39+
android:contentDescription="Click Icon" />
4540

41+
</androidx.constraintlayout.widget.ConstraintLayout>

Apps/TimelineApp/feature/timeline/src/main/res/layout/unique_session.xml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout
2+
<androidx.constraintlayout.widget.ConstraintLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
xmlns:tools="http://schemas.android.com/tools"
56
android:layout_width="match_parent"
67
android:layout_height="wrap_content"
78
android:paddingTop="10dp"
@@ -18,16 +19,16 @@
1819
android:clickable="true">
1920

2021
<TextView
21-
android:id="@+id/session_id"
22-
android:layout_width="wrap_content"
23-
android:layout_height="wrap_content"
24-
android:layout_marginStart="50dp"
25-
android:layout_marginTop="5dp"
26-
android:text="Trip 1"
27-
android:textAppearance="?attr/textAppearanceHeadline6"
28-
android:textStyle= "bold"
29-
android:textSize="20sp" />
30-
22+
android:id="@+id/session_id"
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
25+
android:layout_marginStart="50dp"
26+
android:layout_marginTop="5dp"
27+
android:text="Trip 1"
28+
android:textAppearance="?attr/textAppearanceHeadline6"
29+
android:textSize="20sp"
30+
android:textStyle="bold" />
31+
3132
<ImageView
3233
android:id="@+id/session_dropdown"
3334
android:layout_width="50dp"
@@ -45,20 +46,22 @@
4546
android:layout_width="match_parent"
4647
android:layout_height="wrap_content"
4748
android:layout_below="@id/session_dropdown_layout"
48-
android:layout_marginTop="10dp"
49-
android:layout_marginStart="10dp"
50-
android:layout_marginEnd="10dp"
49+
android:fadingEdge="none"
5150
android:nestedScrollingEnabled="true"
5251
android:overScrollMode="always"
5352
android:scrollbars="vertical"
54-
android:fadingEdge="none" />
53+
tools:layout_editor_absoluteX="25dp"
54+
tools:layout_editor_absoluteY="45dp" />
5555

5656
<View
5757
android:id="@+id/separator"
5858
android:layout_width="match_parent"
5959
android:layout_height="1dp"
60-
android:layout_below="@id/activity_items"
6160
android:layout_marginTop="5dp"
62-
android:background="@android:color/darker_gray" />
61+
android:background="@android:color/darker_gray"
62+
app:layout_constraintTop_toBottomOf="@id/activity_items"
63+
app:layout_constraintStart_toStartOf="parent"
64+
app:layout_constraintEnd_toEndOf="parent"
65+
/>
6366

64-
</RelativeLayout>
67+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)