mirror of
https://github.com/ente-io/ente.git
synced 2025-08-14 02:07:33 +00:00
[mob][photos] Wait on interaction in iOS
This commit is contained in:
@@ -18,7 +18,7 @@ class MachineLearningController {
|
|||||||
|
|
||||||
static const kMaximumTemperature = 42; // 42 degree celsius
|
static const kMaximumTemperature = 42; // 42 degree celsius
|
||||||
static const kMinimumBatteryLevel = 20; // 20%
|
static const kMinimumBatteryLevel = 20; // 20%
|
||||||
static const kDefaultInteractionTimeout = Duration(seconds: 15);
|
final kDefaultInteractionTimeout = Duration(seconds: Platform.isIOS ? 5 : 15);
|
||||||
static const kUnhealthyStates = ["over_heat", "over_voltage", "dead"];
|
static const kUnhealthyStates = ["over_heat", "over_voltage", "dead"];
|
||||||
|
|
||||||
bool _isDeviceHealthy = true;
|
bool _isDeviceHealthy = true;
|
||||||
@@ -31,29 +31,26 @@ class MachineLearningController {
|
|||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
_logger.info('init called');
|
_logger.info('init called');
|
||||||
if (Platform.isAndroid) {
|
_startInteractionTimer(kDefaultInteractionTimeout);
|
||||||
_startInteractionTimer();
|
|
||||||
BatteryInfoPlugin()
|
|
||||||
.androidBatteryInfoStream
|
|
||||||
.listen((AndroidBatteryInfo? batteryInfo) {
|
|
||||||
_onAndroidBatteryStateUpdate(batteryInfo);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
BatteryInfoPlugin()
|
BatteryInfoPlugin()
|
||||||
.iosBatteryInfoStream
|
.iosBatteryInfoStream
|
||||||
.listen((IosBatteryInfo? batteryInfo) {
|
.listen((IosBatteryInfo? batteryInfo) {
|
||||||
_oniOSBatteryStateUpdate(batteryInfo);
|
_oniOSBatteryStateUpdate(batteryInfo);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
BatteryInfoPlugin()
|
||||||
|
.androidBatteryInfoStream
|
||||||
|
.listen((AndroidBatteryInfo? batteryInfo) {
|
||||||
|
_onAndroidBatteryStateUpdate(batteryInfo);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
_fireControlEvent();
|
_fireControlEvent();
|
||||||
_logger.info('init done');
|
_logger.info('init done');
|
||||||
}
|
}
|
||||||
|
|
||||||
void onUserInteraction() {
|
void onUserInteraction() {
|
||||||
if (Platform.isIOS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!_isUserInteracting) {
|
if (!_isUserInteracting) {
|
||||||
_logger.info("User is interacting with the app");
|
_logger.info("User is interacting with the app");
|
||||||
_isUserInteracting = true;
|
_isUserInteracting = true;
|
||||||
@@ -63,8 +60,7 @@ class MachineLearningController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool _canRunGivenUserInteraction() {
|
bool _canRunGivenUserInteraction() {
|
||||||
return (Platform.isIOS ? true : !_isUserInteracting) ||
|
return !_isUserInteracting || mlInteractionOverride;
|
||||||
mlInteractionOverride;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void forceOverrideML({required bool turnOn}) {
|
void forceOverrideML({required bool turnOn}) {
|
||||||
@@ -84,7 +80,7 @@ class MachineLearningController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _startInteractionTimer({Duration timeout = kDefaultInteractionTimeout}) {
|
void _startInteractionTimer(Duration timeout) {
|
||||||
_userInteractionTimer = Timer(timeout, () {
|
_userInteractionTimer = Timer(timeout, () {
|
||||||
_logger.info("User is not interacting with the app");
|
_logger.info("User is not interacting with the app");
|
||||||
_isUserInteracting = false;
|
_isUserInteracting = false;
|
||||||
@@ -94,7 +90,7 @@ class MachineLearningController {
|
|||||||
|
|
||||||
void _resetTimer() {
|
void _resetTimer() {
|
||||||
_userInteractionTimer.cancel();
|
_userInteractionTimer.cancel();
|
||||||
_startInteractionTimer();
|
_startInteractionTimer(kDefaultInteractionTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onAndroidBatteryStateUpdate(AndroidBatteryInfo? batteryInfo) {
|
void _onAndroidBatteryStateUpdate(AndroidBatteryInfo? batteryInfo) {
|
||||||
|
Reference in New Issue
Block a user