Skip to content

Commit 60dcdcd

Browse files
authored
Merge pull request #162 from akaMrNagar/dev
New icon and screenshots
2 parents b74bd88 + 07d0337 commit 60dcdcd

File tree

83 files changed

+1240
-779
lines changed

Some content is hidden

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

83 files changed

+1240
-779
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,22 @@
104104
</activity>
105105

106106
<!-- _________________________________________________________________________________ -->
107-
<!-- ________________________________ RECEIVERS _______________________________________ -->
107+
<!-- ____________________________ WIDGET PROVIDERS ___________________________________ -->
108108
<!-- _________________________________________________________________________________ -->
109109
<receiver
110-
android:name=".receivers.DeviceAdminReceiver"
110+
android:name=".widgets.AggregatedUsageWidgetProvider"
111111
android:enabled="true"
112-
android:exported="false"
113-
android:label="@string/app_name"
114-
android:permission="android.permission.BIND_DEVICE_ADMIN">
115-
<meta-data
116-
android:name="android.app.device_admin"
117-
android:resource="@xml/device_admin_config" />
118-
112+
android:exported="false">
119113
<intent-filter>
120-
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
114+
<action android:name="android.appwidget.action.APPWI-+DGET_UPDATE" />
121115
</intent-filter>
116+
117+
<meta-data
118+
android:name="android.appwidget.provider"
119+
android:resource="@xml/widget_aggregated_usage_config" />
122120
</receiver>
123121
<receiver
124-
android:name=".widgets.DeviceUsageWidget"
122+
android:name=".widgets.ScreenUsageWidgetProvider"
125123
android:enabled="true"
126124
android:exported="false">
127125
<intent-filter>
@@ -130,7 +128,25 @@
130128

131129
<meta-data
132130
android:name="android.appwidget.provider"
133-
android:resource="@xml/device_usage_widget_info" />
131+
android:resource="@xml/widget_screen_usage_config" />
132+
</receiver>
133+
134+
<!-- _________________________________________________________________________________ -->
135+
<!-- ________________________________ RECEIVERS ______________________________________ -->
136+
<!-- _________________________________________________________________________________ -->
137+
<receiver
138+
android:name=".receivers.DeviceAdminReceiver"
139+
android:enabled="true"
140+
android:exported="false"
141+
android:label="@string/app_name"
142+
android:permission="android.permission.BIND_DEVICE_ADMIN">
143+
<meta-data
144+
android:name="android.app.device_admin"
145+
android:resource="@xml/mindful_admin_config" />
146+
147+
<intent-filter>
148+
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
149+
</intent-filter>
134150
</receiver>
135151
<receiver
136152
android:name=".receivers.DeviceBootReceiver"
@@ -166,6 +182,7 @@
166182
<intent-filter>
167183
<action android:name="android.service.quicksettings.action.QS_TILE" />
168184
</intent-filter>
185+
169186
<meta-data
170187
android:name="android.service.quicksettings.ACTIVE_TILE"
171188
android:value="true" />
@@ -184,7 +201,7 @@
184201

185202
<meta-data
186203
android:name="android.accessibilityservice"
187-
android:resource="@xml/accessibility_service_config" />
204+
android:resource="@xml/mindful_accessibility_config" />
188205
</service>
189206
<service
190207
android:name=".services.notification.MindfulNotificationListenerService"

android/app/src/main/java/com/mindful/android/helpers/device/NotificationHelper.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import android.app.PendingIntent
1818
import android.app.Service.NOTIFICATION_SERVICE
1919
import android.content.Context
2020
import android.content.Intent
21-
import android.net.Uri
2221
import android.os.Build
2322
import android.provider.Settings
2423
import android.util.Log
2524
import android.widget.Toast
2625
import androidx.core.app.NotificationCompat
26+
import androidx.core.net.toUri
2727
import com.mindful.android.R
2828
import com.mindful.android.enums.DndWakeLock
2929
import com.mindful.android.helpers.storage.SharedPrefsHelper
@@ -138,7 +138,7 @@ object NotificationHelper {
138138
*/
139139
fun buildFgServiceNotification(context: Context, content: String?): Notification {
140140
return NotificationCompat.Builder(context, SERVICE_CHANNEL_ID)
141-
.setSmallIcon(R.drawable.ic_mindful)
141+
.setSmallIcon(R.drawable.ic_mindful_notification)
142142
.setOngoing(true)
143143
.setAutoCancel(true)
144144
.setContentTitle(context.getString(R.string.service_running_notification_title))
@@ -157,7 +157,7 @@ object NotificationHelper {
157157
context.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
158158
val permissionIntent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
159159

160-
permissionIntent.setData(Uri.parse("package:${context.packageName}"))
160+
permissionIntent.setData("package:${context.packageName}".toUri())
161161
val pendingIntent = PendingIntent.getActivity(
162162
context.applicationContext,
163163
0,
@@ -172,7 +172,7 @@ object NotificationHelper {
172172
context,
173173
CRITICAL_CHANNEL_ID
174174
)
175-
.setSmallIcon(R.drawable.ic_mindful)
175+
.setSmallIcon(R.drawable.ic_mindful_notification)
176176
.setAutoCancel(true)
177177
.setContentTitle(context.getString(R.string.overlay_permission_denied_notification_title))
178178
.setContentText(msg)

android/app/src/main/java/com/mindful/android/helpers/usages/AppsUsageHelper.kt

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,26 @@ import android.content.Intent
88
import android.content.pm.PackageManager
99
import com.mindful.android.AppConstants.REMOVED_PACKAGE
1010
import com.mindful.android.AppConstants.TETHERING_PACKAGE
11-
import java.lang.IllegalArgumentException
1211

1312
object AppsUsageHelper {
13+
/// Keys for the map
14+
const val KEY_PACKAGE_NAME = "packageName"
15+
const val KEY_SCREEN_TIME = "screenTime"
16+
const val KEY_MOBILE_DATA = "mobileData"
17+
const val KEY_WIFI_DATA = "wifiData"
18+
19+
private fun getAppInfoMap(
20+
packageName: String,
21+
screenTime: Long,
22+
mobileData: Long,
23+
wifiData: Long,
24+
): Map<String, Any> = mapOf(
25+
KEY_PACKAGE_NAME to packageName,
26+
KEY_SCREEN_TIME to screenTime,
27+
KEY_MOBILE_DATA to mobileData,
28+
KEY_WIFI_DATA to wifiData,
29+
)
30+
1431
/**
1532
* Retrieves a Map of app packages along with their usage statistics.
1633
*
@@ -125,24 +142,4 @@ object AppsUsageHelper {
125142
onSuccess(appsUsageMapList)
126143
}.start()
127144
}
128-
129-
130-
/// Keys for the map
131-
const val KEY_PACKAGE_NAME = "packageName"
132-
const val KEY_SCREEN_TIME = "screenTime"
133-
const val KEY_MOBILE_DATA = "mobileData"
134-
const val KEY_WIFI_DATA = "wifiData"
135-
136-
private fun getAppInfoMap(
137-
packageName: String,
138-
screenTime: Long,
139-
mobileData: Long,
140-
wifiData: Long,
141-
): Map<String, Any> = mapOf(
142-
KEY_PACKAGE_NAME to packageName,
143-
KEY_SCREEN_TIME to screenTime,
144-
KEY_MOBILE_DATA to mobileData,
145-
KEY_WIFI_DATA to wifiData,
146-
);
147-
148145
}

android/app/src/main/java/com/mindful/android/helpers/usages/NetworkUsageHelper.kt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import android.app.usage.NetworkStats
1515
import android.app.usage.NetworkStatsManager
1616
import android.net.ConnectivityManager
1717
import android.util.Log
18+
import java.util.Calendar
1819

1920
/**
2021
* NetworkUsageHelper is a utility class responsible for gathering network usage statistics for
@@ -59,6 +60,29 @@ object NetworkUsageHelper {
5960
end
6061
)
6162

63+
/**
64+
* Fetches network usage statistics for a specified network type for today.
65+
*
66+
* @param networkStatsManager The NetworkStatsManager used to query network usage.
67+
* @param networkType The type of network (e.g., ConnectivityManager.TYPE_WIFI or TYPE_MOBILE).
68+
* @return A map where keys are app UIDs and values are the corresponding data usage in KBs.
69+
*/
70+
fun fetchNetworkUsageForTodayTillNow(
71+
networkStatsManager: NetworkStatsManager,
72+
networkType: Int,
73+
): Map<Int, Long> {
74+
val midNightCal = Calendar.getInstance()
75+
midNightCal[Calendar.HOUR_OF_DAY] = 0
76+
midNightCal[Calendar.MINUTE] = 0
77+
midNightCal[Calendar.SECOND] = 0
78+
midNightCal[Calendar.MILLISECOND] = 0
79+
80+
val start = midNightCal.timeInMillis
81+
val end = System.currentTimeMillis()
82+
83+
return fetchNetworkUsageForInterval(networkStatsManager, networkType, start, end)
84+
}
85+
6286
/**
6387
* Fetches network usage statistics for a specified network type over a given time interval.
6488
*
@@ -83,7 +107,8 @@ object NetworkUsageHelper {
83107
while (networkStats.hasNextBucket()) {
84108
networkStats.getNextBucket(bucket)
85109
val uid = bucket.uid
86-
usageMap[uid] = usageMap.getOrDefault(uid, 0L) + (bucket.rxBytes + bucket.txBytes)
110+
usageMap[uid] =
111+
usageMap.getOrDefault(uid, 0L) + (bucket.rxBytes + bucket.txBytes)
87112
}
88113

89114
} catch (e: Exception) {

android/app/src/main/java/com/mindful/android/helpers/usages/ScreenUsageHelper.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ object ScreenUsageHelper {
9696
midNightCal[Calendar.HOUR_OF_DAY] = 0
9797
midNightCal[Calendar.MINUTE] = 0
9898
midNightCal[Calendar.SECOND] = 0
99+
midNightCal[Calendar.MILLISECOND] = 0
99100

100101
val start = midNightCal.timeInMillis
101102
val end = System.currentTimeMillis()

android/app/src/main/java/com/mindful/android/receivers/alarm/BedtimeRoutineReceiver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class BedtimeRoutineReceiver : BroadcastReceiver() {
160160
context,
161161
NotificationHelper.BEDTIME_CHANNEL_ID
162162
)
163-
.setSmallIcon(R.drawable.ic_mindful)
163+
.setSmallIcon(R.drawable.ic_mindful_notification)
164164
.setOngoing(false)
165165
.setOnlyAlertOnce(true)
166166
.setContentIntent(

android/app/src/main/java/com/mindful/android/receivers/alarm/NotificationBatchReceiver.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class NotificationBatchReceiver : BroadcastReceiver() {
105105
context,
106106
NotificationHelper.NOTIFICATION_BATCHING_CHANNEL_ID
107107
)
108-
.setSmallIcon(R.drawable.ic_mindful)
108+
.setSmallIcon(R.drawable.ic_mindful_notification)
109109
.setAutoCancel(true)
110110
.setContentTitle(context.getString(R.string.notification_schedule_batch_title))
111111
.setContentIntent(mindfulPendingIntent)
@@ -173,7 +173,7 @@ class NotificationBatchReceiver : BroadcastReceiver() {
173173
context,
174174
NotificationHelper.CRITICAL_CHANNEL_ID
175175
)
176-
.setSmallIcon(R.drawable.ic_mindful)
176+
.setSmallIcon(R.drawable.ic_mindful_notification)
177177
.setLargeIcon(appIcon)
178178
.setContentTitle(appName)
179179
.setGroup(packageName)
@@ -208,7 +208,7 @@ class NotificationBatchReceiver : BroadcastReceiver() {
208208
context,
209209
NotificationHelper.NOTIFICATION_BATCHING_CHANNEL_ID
210210
)
211-
.setSmallIcon(R.drawable.ic_mindful)
211+
.setSmallIcon(R.drawable.ic_mindful_notification)
212212
.setStyle(summaryStyle)
213213
.setGroup(packageName)
214214
.setGroupSummary(true)

android/app/src/main/java/com/mindful/android/services/timer/NotificationTimer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class NotificationTimer(
5151

5252
private val notificationBuilder: NotificationCompat.Builder =
5353
NotificationCompat.Builder(context, notificationChannelId)
54-
.setSmallIcon(R.drawable.ic_mindful)
54+
.setSmallIcon(R.drawable.ic_mindful_notification)
5555
.setOngoing(true)
5656
.setOnlyAlertOnce(true)
5757
.setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE)

android/app/src/main/java/com/mindful/android/services/tracking/OverlayBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object OverlayBuilder {
2929
): View {
3030
// Inflate the custom layout for the dialog
3131
val inflater = LayoutInflater.from(context)
32-
val toastView = inflater.inflate(R.layout.toast_overlay_layout, null)
32+
val toastView = inflater.inflate(R.layout.overlay_toast_layout, null)
3333

3434
// Resolve app icon and label
3535
val (appName, appIcon) = getAppLabelAndIcon(context, packageName)
@@ -74,7 +74,7 @@ object OverlayBuilder {
7474
): View {
7575
// Inflate the custom layout for the dialog
7676
val inflater = LayoutInflater.from(context)
77-
val sheetView = inflater.inflate(R.layout.full_screen_overlay_layout, null)
77+
val sheetView = inflater.inflate(R.layout.overlay_full_screen_layout, null)
7878

7979
// Set quote and author
8080
val quoteTxt = sheetView.findViewById<TextView>(R.id.overlay_sheet_quote)

android/app/src/main/java/com/mindful/android/services/tracking/OverlayManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class OverlayManager(
187187
context,
188188
USAGE_REMINDERS_CHANNEL_ID
189189
)
190-
.setSmallIcon(R.drawable.ic_mindful)
190+
.setSmallIcon(R.drawable.ic_mindful_notification)
191191
.setLargeIcon(appIcon.toBitmap())
192192
.setContentTitle(appName)
193193
.setContentText(msg)

0 commit comments

Comments
 (0)