-
-
Notifications
You must be signed in to change notification settings - Fork 37
Implementing new continuous usage timer function #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing new continuous usage timer function #239
Conversation
This commit introduces a new feature that allows users to set a continuous usage timer for applications. When a user sets a continuous usage timer for an app, the app will be blocked after the specified duration of continuous use. The user will then be required to take a break for a specified duration before they can use the app again. This feature has been implemented by: - Adding `maxContinuousUsageSec` and `breakTimeSec` fields to the `AppRestriction` model in both the Flutter and native Android code. - Adding a new UI component (`ContinuousUsageTile`) to the app's dashboard to allow users to configure these new settings. - Creating a `ContinuousUsageManager` on the native Android side to handle the core logic of tracking continuous usage and blocking/unblocking the app. - Integrating the `ContinuousUsageManager` into the main `MindfulTrackerService`.
This commit fixes several compilation errors that were introduced in a previous update. The changes include: - Updating the `defaultAppRestrictionModel` to include the required `maxContinuousUsageSec` and `breakTimeSec` parameters. - Fixing errors in `continuous_usage_tile.dart` by passing a `heroTag` to `showAppTimerPicker` and converting integer values to `Duration` objects. - Manually updating the generated file `app_database.g.dart` to include the missing parameters in the `AppRestriction` constructor and initialize the new fields in the `AppRestrictionTableCompanion.insert` constructor.
This commit fixes several compilation errors that were introduced in a previous update. The changes include: - Updating the `defaultAppRestrictionModel` to include the required `maxContinuousUsageSec` and `breakTimeSec` parameters. - Fixing errors in `continuous_usage_tile.dart` by passing a `heroTag` to `showAppTimerPicker` and converting integer values to `Duration` objects. - Manually updating the generated file `app_database.g.dart` to include the missing parameters in the `AppRestriction` constructor and initialize the new fields in the `AppRestrictionTableCompanion.insert` constructor. - Replacing the calls to the non-existent `toTime` method with `toTimeShort`.
This commit fixes several compilation errors that were introduced in a previous update and implements the continuous usage blocking feature on the native Android side. The changes include: - Updating the `defaultAppRestrictionModel` to include the required `maxContinuousUsageSec` and `breakTimeSec` parameters. - Fixing errors in `continuous_usage_tile.dart` by passing a `heroTag` to `showAppTimerPicker` and converting integer values to `Duration` objects. - Manually updating the generated file `app_database.g.dart` to include the missing parameters in the `AppRestriction` constructor and initialize the new fields in the `AppRestrictionTableCompanion.insert` constructor. - Replacing the calls to the non-existent `toTime` method with `toTimeShort`. - Updating the `AppRestriction.kt` data class to include the `maxContinuousUsageSec` and `breakTimeSec` fields. - Handling the `CONTINUOUS_USAGE` restriction type in `OverlayBuilder.kt`. - Implementing the continuous usage blocking logic by creating a `ContinuousUsageManager` and integrating it with the `RestrictionManager` and `MindfulTrackerService`. - Adding the missing string resources to `android/app/src/main/res/values/strings.xml`.
This commit updates the `MindfulTrackerService` to pass the `packageName` along with the `restriction` object to the `continuousUsageManager.startTracking` method. This change is necessary to allow the `ContinuousUsageManager` to correctly identify which application it is tracking.
The continuous usage timer was previously coupled to the app timer. This change ensures that the continuous usage timer functions even when the app timer is not set. The `_updateTrackerService` function in `apps_restrictions_provider.dart` was incorrectly filtering out restrictions. The `where` clause was missing a check for `maxContinuousUsageSec > 0`, which caused the continuous usage settings to be ignored if no other restrictions were active. This fix adds the `maxContinuousUsageSec > 0` condition to the `where` clause, ensuring that continuous usage restrictions are always sent to the native Android service.
|
I really appreciate your efforts and time but you should have at least asked about this before implementing. I am already working on these feature more at #200 I would gladly merge these changes but the base service have been removed with full accessibility only service in #200 so anyway these changes will be removed and doesn't make sense now. |
|
Thanks I understand, I will close this and will work with new fork that works based on other beta pull request. |
|
Once i release v1.4 beta you are good to go. I'm really sorry that it's taking so much time, but i want to make sure that we don't need rewrite just to add new feature. Right now Mindful uses method channels to talk to native but in the new update i am trying to add native APIs directly through FFI |
Adding new continues usage timer. This is will block user to extended use of application. You can set a time for continues usage, application will be closed - just like App Timer. However you can restart application after given break time.