by long pressing value label, the app will not go in sceen lock anymore - as with iosxdripreader

This commit is contained in:
Johan Degraeve 2019-11-14 13:28:52 +01:00
parent 1ca68d6bb2
commit 2bb9db0129
2 changed files with 32 additions and 1 deletions

View File

@ -40,11 +40,15 @@
<action selector="preSnoozeButtonAction:" destination="9pv-A4-QxB" eventType="touchUpInside" id="nuJ-Sh-3Xy"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="---" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="We3-bN-ffR">
<label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="---" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="We3-bN-ffR">
<rect key="frame" x="0.0" y="100.5" width="320" height="119.5"/>
<gestureRecognizers/>
<fontDescription key="fontDescription" type="system" pointSize="100"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
<connections>
<outletCollection property="gestureRecognizers" destination="tYH-fG-Lky" appends="YES" id="IyM-sF-P0i"/>
</connections>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uyn-2k-K74">
<rect key="frame" x="10" y="49" width="61.5" height="31.5"/>
@ -100,6 +104,11 @@
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="W5J-7L-Pyd" sceneMemberID="firstResponder"/>
<pongPressGestureRecognizer allowableMovement="10" minimumPressDuration="0.90000000000000002" id="tYH-fG-Lky">
<connections>
<action selector="valueLabelLongPressedAction:" destination="9pv-A4-QxB" id="NlL-kQ-dpZ"/>
</connections>
</pongPressGestureRecognizer>
</objects>
<point key="canvasLocation" x="748" y="-466"/>
</scene>

View File

@ -57,6 +57,11 @@ final class RootViewController: UIViewController {
/// outlet for chart
@IBOutlet weak var chartOutlet: BloodGlucoseChartView!
/// user long pressed the value label
@IBAction func valueLabelLongPressedAction(_ sender: UILongPressGestureRecognizer) {
valueLabelLongPressed(sender)
}
// MARK: - Constants for ApplicationManager usage
/// constant for key in ApplicationManager.shared.addClosureToRunWhenAppWillEnterForeground - create updatelabelstimer
@ -239,6 +244,11 @@ final class RootViewController: UIViewController {
return self?.glucoseChartManager?.glucoseChartWithFrame(frame)?.view
}
// user may have long pressed the value label, so the screen will not lock, when going back to background, set isIdleTimerDisabled back to false
ApplicationManager.shared.addClosureToRunWhenAppDidEnterBackground(key: applicationManagerKeyInvalidateUpdateLabelsTimer, closure: {
UIApplication.shared.isIdleTimerDisabled = false
})
}
/// sets AVAudioSession category to AVAudioSession.Category.playback with option mixWithOthers and
@ -1132,6 +1142,18 @@ final class RootViewController: UIViewController {
}
private func valueLabelLongPressed(_ sender: UILongPressGestureRecognizer) {
if sender.state == .began {
// vibrate so that user knows the long press is detected
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
// prevent screen lock
UIApplication.shared.isIdleTimerDisabled = true
}
}
}
// MARK: - conform to CGMTransmitter protocol