Skip to content

Commit 4cec6cf

Browse files
authored
Merge pull request #113 from akaMrNagar/dev
Major improvements and bug fixes
2 parents 4f1744a + 9d0185b commit 4cec6cf

File tree

181 files changed

+7078
-3431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+7078
-3431
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ A clear and concise description of what you expected to happen.
2626
If applicable, add screenshots to help explain your problem.
2727

2828
**Additional context**
29+
Mindful's version -
30+
Android version -
31+
Device manufacturer -
32+
Device OS/ROM -
33+
2934
Add any other context about the problem here.
3035

3136
**Log file**
32-
You can get the log file from: _**Settings > Advance > Share crash logs**_
37+
You can get the log file from: _**Settings > Database > Export crash logs**_

README.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,31 @@
3030

3131
# 💪 Features
3232

33-
### 1. Focus Mode
34-
Pause distracting apps and stay productive with session types like Study, Work, or Creative. Choose between countdown or stopwatch modes and track your progress over time.
33+
### Focus Mode
34+
Stay on track with session types like Study, Work, or Creative. Use countdown or stopwatch modes, and review your session timeline to track progress and stay consistent.
3535

36-
### 2. Screen Time Management
37-
Set daily limits on apps, including addictive short-form content like Reels and YouTube Shorts. Group apps together and add shared limits for better control. Struggling with serious addiction? Turn on Invincible Mode for extra discipline.
36+
### Screen Time Limits
37+
Set daily usage limits for apps — especially for addictive short content like Reels or Shorts. Group similar apps, add shared limits, and enable Invincible Mode to lock restrictions after they're hit.
3838

39-
### 3. Detailed Statistics
40-
Track your weekly app usage with insights on time spent and data consumed for each app, helping you stay aware and in control.
39+
### Detailed Usage Insights
40+
Check weekly screen time, app usage, and data consumption. Mindful helps you understand your habits so you can take control of your time.
4141

42-
### 4. Internet Blocker
43-
Block internet access for distracting apps in a single tap. Filter out adult content and create a safe browsing environment. You can also block unwanted apps to stay focused.
42+
### App & Internet Blocking
43+
Block distracting apps or cut off internet access with one tap. Filter adult content and create a focused, safe environment for work or study.
4444

45-
### 5. Bedtime Mode
46-
Unwind effectively by pausing distracting apps and enabling Do Not Disturb during bedtime. Start your mornings fresh as apps automatically unblock and notifications resume.
45+
### Notification Management
46+
Batch notifications, schedule delivery, or mute apps during focus time. Keep interruptions low and your attention high.
4747

48-
### 6. Completely Ad-Free & Privacy-Focused
49-
Enjoy a distraction-free experience without any ads. Mindful works entirely offline, keeping your data secure on your device.
48+
### Bedtime Mode
49+
Wind down with paused apps and DND during sleep hours. Wake up to a clean slate — apps resume automatically when the day begins.
5050

51+
### Parental Controls
52+
Set healthy digital habits for children with tamper-proof restrictions, invincible mode, and optional biometric lock.
5153

52-
> ### ⚠️ Note: *INTERNET* permission
54+
### Privacy-First & Open Source
55+
No ads. No tracking. Mindful works completely offline, keeping your data on your device and it's fully open-source, forever.
56+
57+
> [!caution] About internet permission in manifest
5358
> Android restricts apps from creating and protecting Local VPN tunnels without network permission. The Local VPN allows Mindful to block internet access for selected apps. This is why you see the network permission in Mindful's manifest. However, rest assured that Mindful does not collect or transmit any user data. You can verify this by checking the network usage in the app or in your device settings.
5459
5560

@@ -64,19 +69,17 @@ _Note: Drop your socials along with your donation to get recognized as a support
6469
 
6570
<a href="https://github.com/akaMrNagar/Mindful?tab=readme-ov-file#donate"><img src="docs/assets/donation/upi_qr.png" height="184" ></a>
6671

67-
<a href="https://buymeacoffee.com/akamrnagar"><img src="https://img.shields.io/badge/-Buy%20Me%20A%20Coffee-394379?logo=Buy-Me-A-Coffee&logoColor=ffdd00" height="32"></a>
68-
&emsp;
69-
<a href="https://github.com/akaMrNagar/Mindful?tab=readme-ov-file#donate"><img src="https://img.shields.io/badge/akamrnagar@upi-394379?logo=zalando&logoColor=f47820" height="32"></a>
70-
&emsp;
71-
<a href="https://github.com/sponsors/akaMrNagar"><img src="https://img.shields.io/badge/GitHub%20Sponser-394379?logo=GitHub-Sponsors&logoColor=f92f60" height="32"></a>
72+
[![Buy Me a Coffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-🖤-ffdd00)](https://www.buymeacoffee.com/akamrnagar)
73+
[![UPI](https://img.shields.io/badge/akamrnagar@upi-🖤-f47820)](upi://pay?pa=akamrnagar@upi&pn=Pawan%20Nagar&cu=INR$tn=Donation%20for%20Mindful)
74+
[![Sponsor Me on GitHub](https://img.shields.io/badge/Sponsor%20Me%20on%20GitHub-🖤-db61a2)](https://github.com/sponsors/akamrnagar)
7275

7376

7477
# Feedback and Support
7578

7679
Your feedback is invaluable to us! If you have suggestions, encounter issues, or simply want to share your thoughts, please reach out to us through the following channels :
7780

7881
* **[GitHub (bug)](https://github.com/akaMrNagar/Mindful/issues/new?&template=bug_report.md)**
79-
* **[GitHub (enhancement)](https://github.com/akaMrNagar/Mindful/issues/new?&tem**plate=feature_request.md)**
82+
* **[GitHub (enhancement)](https://github.com/akaMrNagar/Mindful/issues/new?&template=feature_request.md)**
8083
* **[GitHub (vulnerability)](https://github.com/akaMrNagar/Mindful/security/advisories/new)**
8184
* **[Write to us via email](mailto:[email protected])**
8285

android/app/src/main/java/com/mindful/android/utils/AppConstants.kt renamed to android/app/src/main/java/com/mindful/android/AppConstants.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* *
1010
*
1111
*/
12-
package com.mindful.android.utils
12+
package com.mindful.android
1313

1414
object AppConstants {
1515
const val FLUTTER_METHOD_CHANNEL_FG: String = "com.mindful.android.methodchannel.fg"
@@ -22,7 +22,6 @@ object AppConstants {
2222

2323
// Extra intent data
2424
const val INTENT_EXTRA_IS_SELF_RESTART: String = "com.mindful.android.isSelfRestart"
25-
const val INTENT_EXTRA_PACKAGE_NAME: String = "com.mindful.android.packageName"
2625

2726
// Notification IDs
2827
const val TRACKER_SERVICE_NOTIFICATION_ID: Int = 101
@@ -34,6 +33,7 @@ object AppConstants {
3433
const val NOTIFICATION_BATCH_SCHEDULE_NOTIFICATION_ID: Int = 107
3534

3635
const val SETTINGS_PACKAGE: String = "com.android.settings"
36+
const val SYSTEM_UI_PACKAGE: String = "com.android.systemui"
3737

3838
// Platforms package names
3939
const val SYSTEM_SETTINGS_PACKAGE: String = "com.android.settings"

android/app/src/main/java/com/mindful/android/FgMethodCallHandler.kt

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,23 @@ import com.mindful.android.helpers.device.NotificationHelper
1919
import com.mindful.android.helpers.device.PermissionsHelper
2020
import com.mindful.android.helpers.storage.SharedPrefsHelper
2121
import com.mindful.android.helpers.usages.AppsUsageHelper.getAppsUsageForInterval
22-
import com.mindful.android.models.AppRestrictions
23-
import com.mindful.android.models.BedtimeSettings
22+
import com.mindful.android.models.AppRestriction
23+
import com.mindful.android.models.BedtimeSchedule
2424
import com.mindful.android.models.FocusSession
25+
import com.mindful.android.models.Notification
26+
import com.mindful.android.models.NotificationSettings
2527
import com.mindful.android.models.RestrictionGroup
2628
import com.mindful.android.services.notification.MindfulNotificationListenerService
2729
import com.mindful.android.services.timer.EmergencyPauseService
2830
import com.mindful.android.services.timer.FocusSessionService
2931
import com.mindful.android.services.tracking.MindfulTrackerService
3032
import com.mindful.android.services.vpn.MindfulVpnService
31-
import com.mindful.android.utils.JsonDeserializer
33+
import com.mindful.android.utils.AppUtils
34+
import com.mindful.android.utils.JsonUtils
3235
import com.mindful.android.utils.Utils
3336
import io.flutter.plugin.common.MethodCall
3437
import io.flutter.plugin.common.MethodChannel
3538
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
36-
import org.json.JSONObject
3739
import java.util.Locale
3840

3941
class FgMethodCallHandler(
@@ -111,7 +113,7 @@ class FgMethodCallHandler(
111113
}
112114

113115
"getDeviceInfo" -> {
114-
result.success(Utils.getDeviceInfoMap(context))
116+
result.success(AppUtils.getDeviceInfoMap(context))
115117
}
116118

117119
"getDeviceAppsInfo" -> {
@@ -137,16 +139,12 @@ class FgMethodCallHandler(
137139
)
138140
}
139141

140-
"getUpComingNotifications" -> {
141-
result.success(SharedPrefsHelper.getSerializedNotificationsJson(context))
142-
}
143-
144142
"getShortsScreenTimeMs" -> {
145143
result.success(SharedPrefsHelper.getSetShortsScreenTimeMs(context, null))
146144
}
147145

148146
"getNativeCrashLogs" -> {
149-
result.success(SharedPrefsHelper.getCrashLogsArrayString(context))
147+
result.success(SharedPrefsHelper.getCrashLogsArrayJsonString(context))
150148
}
151149

152150
"clearNativeCrashLogs" -> {
@@ -159,15 +157,15 @@ class FgMethodCallHandler(
159157
// ==============================================================================================================
160158

161159
"updateAppRestrictions" -> {
162-
val appRestrictions = JsonDeserializer.jsonStrToAppRestrictionsHashMap(
160+
val appRestrictions = JsonUtils.parseAppRestrictionsMap(
163161
call.arguments() ?: ""
164162
)
165163
updateTrackerServiceRestrictions(appRestrictions, null)
166164
result.success(true)
167165
}
168166

169167
"updateRestrictionsGroups" -> {
170-
val restrictionGroups = JsonDeserializer.jsonStrToRestrictionGroupsHashMap(
168+
val restrictionGroups = JsonUtils.parseRestrictionGroupsMap(
171169
call.arguments() ?: ""
172170
)
173171
updateTrackerServiceRestrictions(null, restrictionGroups)
@@ -176,7 +174,7 @@ class FgMethodCallHandler(
176174

177175
"updateInternetBlockedApps" -> {
178176
val blockedApps =
179-
JsonDeserializer.jsonStrToStringHashSet(call.arguments() ?: "")
177+
JsonUtils.parseStringSet(call.arguments() ?: "")
180178
if (vpnServiceConn.isActive) {
181179
vpnServiceConn.service?.updateBlockedApps(blockedApps)
182180
} else if (blockedApps.isNotEmpty() && getAndAskVpnPermission(false)) {
@@ -201,7 +199,7 @@ class FgMethodCallHandler(
201199

202200
"updateBedtimeSchedule" -> {
203201
val jsonBedtimeSettings = call.arguments() ?: ""
204-
val bedtimeSettings = BedtimeSettings(JSONObject(jsonBedtimeSettings))
202+
val bedtimeSettings = BedtimeSchedule.fromJson(jsonBedtimeSettings)
205203
if (bedtimeSettings.isScheduleOn) {
206204
scheduleBedtimeRoutineTasks(context, jsonBedtimeSettings)
207205
} else {
@@ -229,7 +227,7 @@ class FgMethodCallHandler(
229227
}
230228

231229
"updateFocusSession" -> {
232-
val focusSession = FocusSession(JSONObject(call.arguments() ?: ""))
230+
val focusSession = FocusSession.fromJson(call.arguments() ?: "")
233231
if (focusServiceConn.isActive) {
234232
focusServiceConn.service?.updateFocusSession(focusSession)
235233
} else {
@@ -251,29 +249,27 @@ class FgMethodCallHandler(
251249
result.success(true)
252250
}
253251

254-
"updateDistractingNotificationApps" -> {
255-
val distractingApps =
256-
JsonDeserializer.jsonStrToStringHashSet(call.arguments() ?: "")
252+
"updateNotificationSettings" -> {
253+
val settingsJson = call.arguments() ?: ""
254+
val settings = NotificationSettings.fromJson(settingsJson)
255+
256+
/// Update service
257257
if (notificationServiceConn.isActive) {
258-
notificationServiceConn.service?.updateDistractingApps(distractingApps)
259-
} else if (distractingApps.isNotEmpty()) {
258+
notificationServiceConn.service?.updateNotificationSettings(settings)
259+
} else if (settings.batchedApps.isNotEmpty() || settings.storeNonBatchedToo) {
260260
notificationServiceConn.setOnConnectedCallback { service: MindfulNotificationListenerService ->
261-
service.updateDistractingApps(
262-
distractingApps
263-
)
261+
service.updateNotificationSettings(settings)
264262
}
265263
notificationServiceConn.bindService()
266264
}
267-
result.success(true)
268-
}
269265

270-
"updateNotificationBatchSchedules" -> {
271-
val jsonScheduleTods = call.arguments() ?: ""
272-
if (jsonScheduleTods.isNotBlank()) {
273-
scheduleNotificationBatchTask(context, jsonScheduleTods)
266+
/// Schedule batches
267+
if (settings.schedules.isNotEmpty()) {
268+
scheduleNotificationBatchTask(context, settingsJson)
274269
} else {
275270
cancelNotificationBatchTask(context)
276271
}
272+
277273
result.success(true)
278274
}
279275

@@ -389,6 +385,18 @@ class FgMethodCallHandler(
389385
result.success(true)
390386
}
391387

388+
"openAppWithNotificationThread" -> {
389+
val notification = Notification.fromJson(call.arguments() ?: "")
390+
NewActivitiesLaunchHelper.openAppWithNotificationThread(
391+
context = context,
392+
notification = notification,
393+
pendingIntent = notificationServiceConn.service?.getPendingIntentForKey(
394+
notification.key
395+
),
396+
)
397+
result.success(true)
398+
}
399+
392400
"openAppSettingsForPackage" -> {
393401
NewActivitiesLaunchHelper.openSettingsForPackage(
394402
context,
@@ -438,7 +446,7 @@ class FgMethodCallHandler(
438446
* or null if only app-specific restrictions are being updated.
439447
*/
440448
private fun updateTrackerServiceRestrictions(
441-
appRestrictions: HashMap<String, AppRestrictions>?,
449+
appRestrictions: HashMap<String, AppRestriction>?,
442450
restrictionGroups: HashMap<Int, RestrictionGroup>?,
443451
) {
444452
if (trackerServiceConn.isActive) {

android/app/src/main/java/com/mindful/android/MainActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import androidx.activity.result.contract.ActivityResultContracts
1818
import com.mindful.android.helpers.AlarmTasksSchedulingHelper.scheduleMidnightResetTask
1919
import com.mindful.android.helpers.device.NotificationHelper
2020
import com.mindful.android.helpers.storage.SharedPrefsHelper
21-
import com.mindful.android.utils.AppConstants
2221
import io.flutter.embedding.android.FlutterFragmentActivity
2322
import io.flutter.embedding.engine.FlutterEngine
2423
import io.flutter.plugin.common.MethodChannel

android/app/src/main/java/com/mindful/android/enums/PlatformFeatures.kt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,20 @@ enum class PlatformFeatures {
1010
SNAPCHAT_DISCOVER,
1111
FACEBOOK_REELS,
1212
REDDIT_SHORTS,
13-
YOUTUBE_SHORTS,
14-
}
13+
YOUTUBE_SHORTS;
14+
15+
companion object {
16+
fun fromName(name: String): PlatformFeatures? {
17+
return when (name) {
18+
"instagramReels" -> INSTAGRAM_REELS
19+
"instagramExplore" -> INSTAGRAM_EXPLORE
20+
"snapchatSpotlight" -> SNAPCHAT_SPOTLIGHT
21+
"snapchatDiscover" -> SNAPCHAT_DISCOVER
22+
"facebookReels" -> FACEBOOK_REELS
23+
"redditShorts" -> REDDIT_SHORTS
24+
"youtubeShorts" -> YOUTUBE_SHORTS
25+
else -> null
26+
}
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)