Skip to content

Commit c133d6e

Browse files
authored
Merge pull request #5403 from TrainLCD/dev
2 parents 17ba1e2 + ed70f20 commit c133d6e

File tree

8 files changed

+76
-33
lines changed

8 files changed

+76
-33
lines changed

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ android {
143143
dimension "environment"
144144
applicationId "me.tinykitten.trainlcd.dev"
145145
versionNameSuffix "-dev"
146-
versionCode 100000264
146+
versionCode 100000265
147147
versionName "10.1.2"
148148
}
149149
prod {
150150
dimension "environment"
151-
versionCode 100000264
151+
versionCode 100000265
152152
versionName "10.1.2"
153153
}
154154
}

app.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default ({ config }: ConfigContext) => ({
4343
},
4444
},
4545
ios: {
46-
buildNumber: '2477',
46+
buildNumber: '2478',
4747
bundleIdentifier:
4848
process.env.EAS_BUILD_PROFILE === 'production'
4949
? 'me.tinykitten.trainlcd'
@@ -60,7 +60,7 @@ export default ({ config }: ConfigContext) => ({
6060
? 'me.tinykitten.trainlcd'
6161
: 'me.tinykitten.trainlcd.dev',
6262
permissions: [],
63-
versionCode: 100000264,
63+
versionCode: 100000265,
6464
},
6565
owner: 'trainlcd',
6666
});
@@ -93,5 +93,6 @@ export default ({ config }: ConfigContext) => ({
9393

9494

9595

96+
9697

9798

ios/TrainLCD.xcodeproj/project.pbxproj

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,7 +2435,7 @@
24352435
CODE_SIGN_ENTITLEMENTS = ProdTrainLCD.entitlements;
24362436
CODE_SIGN_IDENTITY = "Apple Development";
24372437
CODE_SIGN_STYLE = Automatic;
2438-
CURRENT_PROJECT_VERSION = 2477;
2438+
CURRENT_PROJECT_VERSION = 2478;
24392439
DEAD_CODE_STRIPPING = YES;
24402440
DEVELOPMENT_TEAM = E6R2G33Z36;
24412441
INFOPLIST_FILE = TrainLCD/Schemes/Prod/Info.plist;
@@ -2474,7 +2474,7 @@
24742474
CODE_SIGN_ENTITLEMENTS = ProdTrainLCD.entitlements;
24752475
CODE_SIGN_IDENTITY = "Apple Development";
24762476
CODE_SIGN_STYLE = Automatic;
2477-
CURRENT_PROJECT_VERSION = 2477;
2477+
CURRENT_PROJECT_VERSION = 2478;
24782478
DEVELOPMENT_TEAM = E6R2G33Z36;
24792479
INFOPLIST_FILE = TrainLCD/Schemes/Prod/Info.plist;
24802480
INFOPLIST_KEY_CFBundleDisplayName = TrainLCD;
@@ -2533,7 +2533,7 @@
25332533
CODE_SIGN_ENTITLEMENTS = TrainLCD/trainlcd.entitlements;
25342534
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
25352535
COPY_PHASE_STRIP = NO;
2536-
CURRENT_PROJECT_VERSION = 2477;
2536+
CURRENT_PROJECT_VERSION = 2478;
25372537
CXX = "";
25382538
ENABLE_STRICT_OBJC_MSGSEND = YES;
25392539
ENABLE_TESTABILITY = YES;
@@ -2639,7 +2639,7 @@
26392639
CODE_SIGN_ENTITLEMENTS = TrainLCD/trainlcd.entitlements;
26402640
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
26412641
COPY_PHASE_STRIP = YES;
2642-
CURRENT_PROJECT_VERSION = 2477;
2642+
CURRENT_PROJECT_VERSION = 2478;
26432643
CXX = "";
26442644
ENABLE_NS_ASSERTIONS = NO;
26452645
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -2718,7 +2718,7 @@
27182718
CODE_SIGN_ENTITLEMENTS = CanaryTrainLCD.entitlements;
27192719
CODE_SIGN_IDENTITY = "Apple Development";
27202720
CODE_SIGN_STYLE = Automatic;
2721-
CURRENT_PROJECT_VERSION = 2477;
2721+
CURRENT_PROJECT_VERSION = 2478;
27222722
DEAD_CODE_STRIPPING = YES;
27232723
DEVELOPMENT_TEAM = E6R2G33Z36;
27242724
INFOPLIST_FILE = TrainLCD/Schemes/Dev/Info.plist;
@@ -2757,7 +2757,7 @@
27572757
CODE_SIGN_ENTITLEMENTS = CanaryTrainLCD.entitlements;
27582758
CODE_SIGN_IDENTITY = "Apple Development";
27592759
CODE_SIGN_STYLE = Automatic;
2760-
CURRENT_PROJECT_VERSION = 2477;
2760+
CURRENT_PROJECT_VERSION = 2478;
27612761
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
27622762
DEVELOPMENT_TEAM = E6R2G33Z36;
27632763
INFOPLIST_FILE = TrainLCD/Schemes/Dev/Info.plist;
@@ -2968,7 +2968,7 @@
29682968
CODE_SIGN_ENTITLEMENTS = RideSessionActivity/CanaryRideSessionActivity.entitlements;
29692969
CODE_SIGN_IDENTITY = "Apple Development";
29702970
CODE_SIGN_STYLE = Automatic;
2971-
CURRENT_PROJECT_VERSION = 2477;
2971+
CURRENT_PROJECT_VERSION = 2478;
29722972
DEBUG_INFORMATION_FORMAT = dwarf;
29732973
DEVELOPMENT_TEAM = E6R2G33Z36;
29742974
GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -3019,7 +3019,7 @@
30193019
CODE_SIGN_IDENTITY = "Apple Development";
30203020
CODE_SIGN_STYLE = Automatic;
30213021
COPY_PHASE_STRIP = NO;
3022-
CURRENT_PROJECT_VERSION = 2477;
3022+
CURRENT_PROJECT_VERSION = 2478;
30233023
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
30243024
DEVELOPMENT_TEAM = E6R2G33Z36;
30253025
GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -3070,7 +3070,7 @@
30703070
CODE_SIGN_ENTITLEMENTS = WatchWidget/ProdWatchWidget.entitlements;
30713071
CODE_SIGN_IDENTITY = "Apple Development";
30723072
CODE_SIGN_STYLE = Automatic;
3073-
CURRENT_PROJECT_VERSION = 2477;
3073+
CURRENT_PROJECT_VERSION = 2478;
30743074
DEBUG_INFORMATION_FORMAT = dwarf;
30753075
DEVELOPMENT_TEAM = E6R2G33Z36;
30763076
ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -3128,7 +3128,7 @@
31283128
CODE_SIGN_IDENTITY = "Apple Development";
31293129
CODE_SIGN_STYLE = Automatic;
31303130
COPY_PHASE_STRIP = NO;
3131-
CURRENT_PROJECT_VERSION = 2477;
3131+
CURRENT_PROJECT_VERSION = 2478;
31323132
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
31333133
DEVELOPMENT_TEAM = E6R2G33Z36;
31343134
ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -3179,7 +3179,7 @@
31793179
CODE_SIGN_ENTITLEMENTS = WatchWidget/CanaryWatchWidget.entitlements;
31803180
CODE_SIGN_IDENTITY = "Apple Development";
31813181
CODE_SIGN_STYLE = Automatic;
3182-
CURRENT_PROJECT_VERSION = 2477;
3182+
CURRENT_PROJECT_VERSION = 2478;
31833183
DEBUG_INFORMATION_FORMAT = dwarf;
31843184
DEVELOPMENT_TEAM = E6R2G33Z36;
31853185
ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -3236,7 +3236,7 @@
32363236
CODE_SIGN_IDENTITY = "Apple Development";
32373237
CODE_SIGN_STYLE = Automatic;
32383238
COPY_PHASE_STRIP = NO;
3239-
CURRENT_PROJECT_VERSION = 2477;
3239+
CURRENT_PROJECT_VERSION = 2478;
32403240
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
32413241
DEVELOPMENT_TEAM = E6R2G33Z36;
32423242
ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -3284,7 +3284,7 @@
32843284
CODE_SIGN_ENTITLEMENTS = RideSessionActivity/ProdRideSessionActivity.entitlements;
32853285
CODE_SIGN_IDENTITY = "Apple Development";
32863286
CODE_SIGN_STYLE = Automatic;
3287-
CURRENT_PROJECT_VERSION = 2477;
3287+
CURRENT_PROJECT_VERSION = 2478;
32883288
DEBUG_INFORMATION_FORMAT = dwarf;
32893289
DEVELOPMENT_TEAM = E6R2G33Z36;
32903290
GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -3335,7 +3335,7 @@
33353335
CODE_SIGN_IDENTITY = "Apple Development";
33363336
CODE_SIGN_STYLE = Automatic;
33373337
COPY_PHASE_STRIP = NO;
3338-
CURRENT_PROJECT_VERSION = 2477;
3338+
CURRENT_PROJECT_VERSION = 2478;
33393339
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
33403340
DEVELOPMENT_TEAM = E6R2G33Z36;
33413341
GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -3554,7 +3554,7 @@
35543554
CODE_SIGN_ENTITLEMENTS = ProdAppClip/ProdAppClip.entitlements;
35553555
CODE_SIGN_IDENTITY = "Apple Development";
35563556
CODE_SIGN_STYLE = Automatic;
3557-
CURRENT_PROJECT_VERSION = 2477;
3557+
CURRENT_PROJECT_VERSION = 2478;
35583558
DEBUG_INFORMATION_FORMAT = dwarf;
35593559
DEVELOPMENT_TEAM = E6R2G33Z36;
35603560
ENABLE_USER_SCRIPT_SANDBOXING = NO;
@@ -3610,7 +3610,7 @@
36103610
CODE_SIGN_IDENTITY = "Apple Development";
36113611
CODE_SIGN_STYLE = Automatic;
36123612
COPY_PHASE_STRIP = NO;
3613-
CURRENT_PROJECT_VERSION = 2477;
3613+
CURRENT_PROJECT_VERSION = 2478;
36143614
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
36153615
DEVELOPMENT_TEAM = E6R2G33Z36;
36163616
ENABLE_USER_SCRIPT_SANDBOXING = NO;
@@ -3660,7 +3660,7 @@
36603660
CODE_SIGN_ENTITLEMENTS = CanaryAppClip/CanaryAppClip.entitlements;
36613661
CODE_SIGN_IDENTITY = "Apple Development";
36623662
CODE_SIGN_STYLE = Automatic;
3663-
CURRENT_PROJECT_VERSION = 2477;
3663+
CURRENT_PROJECT_VERSION = 2478;
36643664
DEBUG_INFORMATION_FORMAT = dwarf;
36653665
DEVELOPMENT_TEAM = E6R2G33Z36;
36663666
ENABLE_USER_SCRIPT_SANDBOXING = NO;
@@ -3718,7 +3718,7 @@
37183718
CODE_SIGN_IDENTITY = "Apple Development";
37193719
CODE_SIGN_STYLE = Automatic;
37203720
COPY_PHASE_STRIP = NO;
3721-
CURRENT_PROJECT_VERSION = 2477;
3721+
CURRENT_PROJECT_VERSION = 2478;
37223722
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
37233723
DEVELOPMENT_TEAM = E6R2G33Z36;
37243724
ENABLE_USER_SCRIPT_SANDBOXING = NO;

src/components/DevOverlay.test.tsx

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,17 @@ const mockUseNextStation = useNextStation as jest.MockedFunction<
6464
describe('DevOverlay', () => {
6565
beforeEach(() => {
6666
// Default mock implementations for useAtomValue
67-
// locationAtom, accuracyHistoryAtomの順で呼ばれる (useTelemetryEnabledは別途モック済み)
67+
// locationAtom, accuracyHistoryAtom, backgroundLocationTrackingAtomの順で呼ばれる
68+
// (useTelemetryEnabledは別途モック済み)
6869
mockUseAtomValue
6970
.mockReturnValueOnce({
7071
coords: {
7172
speed: 10,
7273
accuracy: 15,
7374
},
7475
}) // locationAtom
75-
.mockReturnValue([10, 15, 20]); // accuracyHistoryAtom
76+
.mockReturnValueOnce([10, 15, 20]) // accuracyHistoryAtom
77+
.mockReturnValue(false); // backgroundLocationTrackingAtom
7678

7779
mockUseDistanceToNextStation.mockReturnValue('500');
7880
mockUseNextStation.mockReturnValue({
@@ -106,6 +108,24 @@ describe('DevOverlay', () => {
106108
const { getByText } = render(<DevOverlay />);
107109
expect(getByText('Telemetry: ON')).toBeTruthy();
108110
});
111+
112+
it('バックグラウンド位置情報のOFF状態を表示する', () => {
113+
const { getByText } = render(<DevOverlay />);
114+
expect(getByText('BG Loc: OFF')).toBeTruthy();
115+
});
116+
117+
it('バックグラウンド位置情報のON状態を表示する', () => {
118+
mockUseAtomValue.mockReset();
119+
mockUseAtomValue
120+
.mockReturnValueOnce({
121+
coords: { speed: 10, accuracy: 15 },
122+
}) // locationAtom
123+
.mockReturnValueOnce([10, 15, 20]) // accuracyHistoryAtom
124+
.mockReturnValue(true); // backgroundLocationTrackingAtom
125+
126+
const { getByText } = render(<DevOverlay />);
127+
expect(getByText('BG Loc: ON')).toBeTruthy();
128+
});
109129
});
110130

111131
describe('位置情報の表示', () => {
@@ -138,7 +158,7 @@ describe('DevOverlay', () => {
138158
mockUseAtomValue
139159
.mockReturnValueOnce(null) // locationAtom
140160
.mockReturnValueOnce([]) // accuracyHistoryAtom
141-
.mockReturnValue({ telemetryEnabled: true });
161+
.mockReturnValue(false); // backgroundLocationTrackingAtom
142162

143163
expect(() => {
144164
render(<DevOverlay />);
@@ -152,7 +172,7 @@ describe('DevOverlay', () => {
152172
coords: { speed: null, accuracy: 15 },
153173
}) // locationAtom
154174
.mockReturnValueOnce([]) // accuracyHistoryAtom
155-
.mockReturnValue({ telemetryEnabled: true });
175+
.mockReturnValue(false); // backgroundLocationTrackingAtom
156176

157177
const { getByText } = render(<DevOverlay />);
158178
expect(getByText('Speed: 0km/h')).toBeTruthy();
@@ -165,7 +185,7 @@ describe('DevOverlay', () => {
165185
coords: { speed: -5, accuracy: 15 },
166186
}) // locationAtom
167187
.mockReturnValueOnce([]) // accuracyHistoryAtom
168-
.mockReturnValue({ telemetryEnabled: true });
188+
.mockReturnValue(false); // backgroundLocationTrackingAtom
169189

170190
const { getByText } = render(<DevOverlay />);
171191
expect(getByText('Speed: 0km/h')).toBeTruthy();
@@ -178,7 +198,7 @@ describe('DevOverlay', () => {
178198
coords: { speed: 10, accuracy: null },
179199
}) // locationAtom
180200
.mockReturnValueOnce([]) // accuracyHistoryAtom
181-
.mockReturnValue({ telemetryEnabled: true });
201+
.mockReturnValue(false); // backgroundLocationTrackingAtom
182202

183203
const { getByText } = render(<DevOverlay />);
184204
expect(getByText('Accuracy: m')).toBeTruthy();
@@ -191,7 +211,7 @@ describe('DevOverlay', () => {
191211
coords: { speed: 10, accuracy: 15 },
192212
}) // locationAtom
193213
.mockReturnValueOnce([]) // accuracyHistoryAtom
194-
.mockReturnValue({ telemetryEnabled: true });
214+
.mockReturnValue(false); // backgroundLocationTrackingAtom
195215

196216
expect(() => {
197217
render(<DevOverlay />);
@@ -242,7 +262,7 @@ describe('DevOverlay', () => {
242262
coords: { speed: 0, accuracy: 15 },
243263
}) // locationAtom
244264
.mockReturnValueOnce([]) // accuracyHistoryAtom
245-
.mockReturnValue({ telemetryEnabled: true });
265+
.mockReturnValue(false); // backgroundLocationTrackingAtom
246266

247267
const { getByText } = render(<DevOverlay />);
248268
expect(getByText('Speed: 0km/h')).toBeTruthy();
@@ -255,7 +275,7 @@ describe('DevOverlay', () => {
255275
coords: { speed: 13.89, accuracy: 15 }, // 約50 km/h
256276
}) // locationAtom
257277
.mockReturnValueOnce([]) // accuracyHistoryAtom
258-
.mockReturnValue({ telemetryEnabled: true });
278+
.mockReturnValue(false); // backgroundLocationTrackingAtom
259279

260280
const { getByText } = render(<DevOverlay />);
261281
expect(getByText('Speed: 50km/h')).toBeTruthy();

src/components/DevOverlay.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import React, { useMemo } from 'react';
44
import { StyleSheet, Text, useWindowDimensions, View } from 'react-native';
55
import { useDistanceToNextStation, useNextStation } from '~/hooks';
66
import { useTelemetryEnabled } from '~/hooks/useTelemetryEnabled';
7-
import { accuracyHistoryAtom, locationAtom } from '~/store/atoms/location';
7+
import {
8+
accuracyHistoryAtom,
9+
backgroundLocationTrackingAtom,
10+
locationAtom,
11+
} from '~/store/atoms/location';
812
import { generateAccuracyChart } from '~/utils/accuracyChart';
913
import Typography from './Typography';
1014

@@ -35,6 +39,9 @@ const DevOverlay: React.FC = () => {
3539
const distanceToNextStation = useDistanceToNextStation();
3640
const nextStation = useNextStation(false);
3741
const isTelemetryEnabled = useTelemetryEnabled();
42+
const isBackgroundLocationTracking = useAtomValue(
43+
backgroundLocationTrackingAtom
44+
);
3845

3946
const coordsSpeed = ((speed ?? 0) < 0 ? 0 : speed) ?? 0;
4047

@@ -88,6 +95,9 @@ const DevOverlay: React.FC = () => {
8895
<Typography style={styles.text}>
8996
Telemetry: {isTelemetryEnabled ? 'ON' : 'OFF'}
9097
</Typography>
98+
<Typography style={styles.text}>
99+
BG Loc: {isBackgroundLocationTracking ? 'ON' : 'OFF'}
100+
</Typography>
91101
</View>
92102
);
93103
};

src/hooks/useStartBackgroundLocationUpdates.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import { useStartBackgroundLocationUpdates } from './useStartBackgroundLocationU
1010

1111
jest.mock('expo-location');
1212
jest.mock('./useLocationPermissionsGranted');
13+
jest.mock('~/store', () => ({
14+
store: { set: jest.fn() },
15+
}));
1316
jest.mock('~/store/atoms/location', () => ({
17+
backgroundLocationTrackingAtom: {},
1418
setLocation: jest.fn(),
1519
}));
1620
jest.mock('~/store/atoms/navigation', () => ({

src/hooks/useStartBackgroundLocationUpdates.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import * as Location from 'expo-location';
22
import { useAtomValue } from 'jotai';
33
import { useEffect } from 'react';
4-
import { setLocation } from '~/store/atoms/location';
4+
import { store } from '~/store';
5+
import {
6+
backgroundLocationTrackingAtom,
7+
setLocation,
8+
} from '~/store/atoms/location';
59
import navigationState from '~/store/atoms/navigation';
610
import {
711
LOCATION_START_MAX_RETRIES,
@@ -60,6 +64,8 @@ export const useStartBackgroundLocationUpdates = () => {
6064
stopError
6165
);
6266
}
67+
} else {
68+
store.set(backgroundLocationTrackingAtom, true);
6369
}
6470
return;
6571
} catch (error) {
@@ -82,6 +88,7 @@ export const useStartBackgroundLocationUpdates = () => {
8288

8389
return () => {
8490
cancelled = true;
91+
store.set(backgroundLocationTrackingAtom, false);
8592
Location.stopLocationUpdatesAsync(LOCATION_TASK_NAME).catch((error) => {
8693
console.warn(
8794
'バックグラウンド位置情報の更新停止に失敗しました:',

src/store/atoms/location.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const SMOOTHING_ALPHA = 0.6;
1212

1313
export const locationAtom = atom<Location.LocationObject | null>(null);
1414
export const accuracyHistoryAtom = atom<number[]>([]);
15+
export const backgroundLocationTrackingAtom = atom(false);
1516

1617
export const setLocation = (location: Location.LocationObject) => {
1718
const prev = store.get(locationAtom);

0 commit comments

Comments
 (0)