|
84 | 84 | import { clearTimeout, disableShowWhenLockedAndTurnScreenOn, enableShowWhenLockedAndTurnScreenOn, setTimeout } from '~/utils/utils'; |
85 | 85 | import { colors, screenHeightDips, screenWidthDips, windowInset } from '../../variables'; |
86 | 86 | import MapResultPager from '../search/MapResultPager.svelte'; |
| 87 | + import { startRefreshAlarm, stopRefreshAlarm } from '~/utils/utils'; |
87 | 88 |
|
88 | 89 | $: ({ colorBackground, colorError, colorPrimary } = $colors); |
89 | 90 | $: ({ bottom: windowInsetBottom, left: windowInsetLeft, right: windowInsetRight, top: windowInsetTop } = $windowInset); |
|
645 | 646 | }, 500); |
646 | 647 |
|
647 | 648 | let appUrlRegistered = false; |
| 649 | + let screenOnOffReceiver = null; |
| 650 | + function registerScreenOnOff(){ |
| 651 | + if (__ANDROID__) { |
| 652 | + if (!screenOnOffReceiver) { |
| 653 | + screenOnOffReceiver = new android.content.BroadcastReceiver({ |
| 654 | + onReceive: () => { |
| 655 | + const action = intent.getAction(); |
| 656 | + DEV_LOG && console.log('screenOnOffReceiver', action); |
| 657 | + import { startRefreshAlarm, stopRefreshAlarm } from '~/utils/utils'; |
| 658 | + if (action === android.content.Intent.ACTION_SCREEN_ON) { |
| 659 | + DEV_LOG && console.log("Screen ON"); |
| 660 | + stopRefreshAlarm(); |
| 661 | + } else if (action === android.content.Intent.ACTION_SCREEN_OFF) { |
| 662 | + DEV_LOG && console.log("Screen OFF"); |
| 663 | + startRefreshAlarm(); |
| 664 | + } |
| 665 | + } |
| 666 | + }); |
| 667 | + |
| 668 | + // Create an IntentFilter to listen for screen on/off events |
| 669 | + const filter = new android.content.IntentFilter(); |
| 670 | + filter.addAction(android.content.Intent.ACTION_SCREEN_ON); |
| 671 | + filter.addAction(android.content.Intent.ACTION_SCREEN_OFF); |
| 672 | + |
| 673 | + // Register the receiver |
| 674 | + const context = Utils.android.getApplicationContext(); |
| 675 | + context.registerReceiver(screenOnOffReceiver, filter); |
| 676 | + } |
| 677 | + } |
| 678 | + } |
| 679 | + function unregisterScreenOnOff(){ |
| 680 | + if (__ANDROID__) { |
| 681 | + if (screenOnOffReceiver) { |
| 682 | + |
| 683 | + const context = Utils.android.getApplicationContext(); |
| 684 | + context.unregisterReceiver(screenOnOffReceiver); |
| 685 | + screenOnOffReceiver = null; |
| 686 | + } |
| 687 | + } |
| 688 | + } |
648 | 689 | async function onMainMapReady(e) { |
649 | 690 | try { |
650 | 691 | // if (!PRODUCTION) { |
|
705 | 746 | }); |
706 | 747 | } |
707 | 748 | } |
| 749 | + registerScreenOnOff(); |
708 | 750 | } catch (error) { |
709 | 751 | console.error(error, error.stack); |
710 | 752 | } |
|
1802 | 1844 | // }); |
1803 | 1845 | onDestroy(() => { |
1804 | 1846 | webserver?.stop(); |
| 1847 | + unregisterScreenOnOff(); |
1805 | 1848 | }); |
1806 | 1849 | const showMapMenu = tryCatchFunction( |
1807 | 1850 | async (event) => { |
|
2110 | 2153 | isSelected: showOnLockscreen, |
2111 | 2154 | tooltip: lc('show_screen_lock'), |
2112 | 2155 | visible: __ANDROID__, |
2113 | | - onTap: switchShowOnLockscreen |
| 2156 | + onTap: switchShowOnLockscreen, |
| 2157 | + onLongPress: tryCatchFunction(async (event, button) => { |
| 2158 | + await showSliderPopover({ |
| 2159 | + debounceDuration: 100, |
| 2160 | + anchor: event.object, |
| 2161 | + vertPos: VerticalPosition.BELOW, |
| 2162 | + value: ApplicationSettings.getNumber('refreshAlarmInterval', 60 * 1000);, |
| 2163 | + onChange(value) { |
| 2164 | + ApplicationSettings.setNumber('refreshAlarmInterval', value); |
| 2165 | + }, |
| 2166 | + step: 100, |
| 2167 | + min: 0, |
| 2168 | + max: 10 * 60 * 1000 |
| 2169 | + title: lc('refresh_alarm_interval') |
| 2170 | + }); |
| 2171 | + |
| 2172 | + }) |
2114 | 2173 | } |
2115 | 2174 | ]; |
2116 | 2175 | if ((WITH_BUS_SUPPORT && customLayersModule?.devMode) || customLayersModule?.hasLocalData) { |
|
0 commit comments