Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Reef/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ android {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlin.compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
Expand All @@ -51,6 +52,7 @@ android {
buildToolsVersion = "36.1.0"
ndkVersion = "29.0.14033849 rc4"
compileSdkMinor = 1

}

dependencies {
Expand Down
36 changes: 0 additions & 36 deletions Reef/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
android:exported="true"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:foregroundServiceType="specialUse"
android:process=":blocker_process"
tools:ignore="AccessibilityPolicy">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
Expand All @@ -72,7 +71,6 @@
android:resource="@xml/blocker_configuration" />
</service>

<!-- android:process=":locker_process"-->
<service
android:name=".accessibility.FocusModeService"
android:exported="false"
Expand Down Expand Up @@ -106,37 +104,3 @@
</provider>
</application>
</manifest>

<!--
Marked routine ac28f5f5-35bd-47a1-9713-92479d0a2914 as active, start time: 1767810600000
2026-01-08 21:44:51.283 13948-13948 RoutineScheduler dev.pranav.reef D Scheduled stop deactivation with WorkManager for Thu Jan 08 23:59:00 GMT+05:30 2026
2026-01-08 21:44:51.283 13948-13948 RoutineExecutor dev.pranav.reef D Activating routine: stop
2026-01-08 21:44:51.283 13948-13948 RoutineLimits dev.pranav.reef D Setting routine limits for routine: ac28f5f5-35bd-47a1-9713-92479d0a2914
2026-01-08 21:44:51.283 13948-13948 RoutineLimits dev.pranav.reef D Set limit for com.instafel.android: 0m (0ms)
2026-01-08 21:44:51.283 13948-13948 RoutineLimits dev.pranav.reef D Set limit for com.instagram.android: 0m (0ms)
2026-01-08 21:44:51.283 13948-13948 RoutineLimits dev.pranav.reef D Marked routine ac28f5f5-35bd-47a1-9713-92479d0a2914 as active, start time: 1767810600000
2026-01-08 21:44:51.286 13948-13948 RoutineScheduler dev.pranav.reef D Scheduled stop deactivation with WorkManager for Thu Jan 08 23:59:00 GMT+05:30 2026
2026-01-08 21:44:51.299 13948-13999 WM-SystemJobScheduler dev.pranav.reef D Scheduling work ID 538c7065-17aa-42e9-a56a-8e7ff9a765a2Job ID 41
2026-01-08 21:44:51.303 16164-16164 BlockerService dev.pranav.reef D dev.pranav.reef, true, false
2026-01-08 21:44:51.304 13948-14006 WM-Processor dev.pranav.reef D Processor cancelling 538c7065-17aa-42e9-a56a-8e7ff9a765a2
2026-01-08 21:44:51.304 13948-14006 WM-Processor dev.pranav.reef D WorkerWrapper could not be found for 538c7065-17aa-42e9-a56a-8e7ff9a765a2
2026-01-08 21:44:51.304 16164-16164 BlockerService dev.pranav.reef D dev.pranav.reef, true, false
2026-01-08 21:44:51.305 16164-16164 BlockerService dev.pranav.reef D dev.pranav.reef, true, false
2026-01-08 21:44:51.306 16164-16164 BlockerService dev.pranav.reef D dev.pranav.reef, true, false
2026-01-08 21:44:51.308 13948-14006 WM-GreedyScheduler dev.pranav.reef D Cancelling work ID 538c7065-17aa-42e9-a56a-8e7ff9a765a2
2026-01-08 21:44:51.314 13948-14006 WM-SystemJobScheduler dev.pranav.reef D Scheduling work ID 7b302f38-bda8-4675-9763-10515456b226Job ID 42
2026-01-08 21:44:51.402 16164-16164 BlockerService dev.pranav.reef D dev.pranav.reef, true, false
2026-01-08 21:44:51.404 16164-16164 BlockerService dev.pranav.reef D dev.pranav.reef, true, false
2026-01-08 21:44:51.497 3728-3728 NotifAttentionHelper system_server E Muting recently noisy 0|dev.pranav.reef|100|null|10871
2026-01-08 21:44:51.514 16164-16164 BlockerService dev.pranav.reef D dev.pranav.reef, true, false
2026-01-08 21:44:51.515 16164-16164 BlockerService dev.pranav.reef D dev.pranav.reef, true, false
2026-01-08 21:44:51.527 16164-16164 BlockerService dev.pranav.reef D com.android.systemui, true, false
2026-01-08 21:44:51.611 16164-16164 BlockerService dev.pranav.reef D dev.pranav.reef, true, false
2026-01-08 21:44:51.611 16164-16164 BlockerService dev.pranav.reef D dev.pranav.reef, true, false
2026-01-08 21:45:09.681 16164-16164 BlockerService dev.pranav.reef D com.instafel.android, false, false
2026-01-08 21:45:09.867 16164-16164 BlockerService dev.pranav.reef D com.instafel.android, false, false
2026-01-08 21:45:09.928 16164-16164 BlockerService dev.pranav.reef D com.instafel.android, false, false
2026-01-08 21:45:34.714 16164-16164 BlockerService dev.pranav.reef D com.instafel.android, false, false
2026-01-08 21:45:34.834 16164-16164 BlockerService dev.pranav.reef D com.instafel.android, false, false
2026-01-08 21:45:34.924 16164-16164 BlockerService dev.pranav.reef D com.instafel.android, false, false
-->
14 changes: 7 additions & 7 deletions Reef/src/main/java/dev/pranav/reef/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,17 @@ class MainActivity: ComponentActivity() {
R.string.hour_min_short_suffix,
hours,
minutes
) + " today"
) + " " + getString(R.string.today)

hours > 0 -> getString(
R.string.hours_short_format,
hours
) + " today"
) + " " + getString(R.string.today)

minutes > 0 -> getString(
R.string.minutes_short_format,
minutes
) + " today"
) + " " + getString(R.string.today)

else -> getString(R.string.less_than_one_minute)
}
Expand Down Expand Up @@ -761,25 +761,25 @@ private fun ReefBottomNavBar(
) {
BottomNavItem(
icon = Icons.Outlined.Home,
label = "Home",
label = stringResource(R.string.nav_home),
selected = selectedItem == 0,
onClick = { onItemSelected(0) }
)
BottomNavItem(
icon = Icons.Rounded.BarChart,
label = "Stats",
label = stringResource(R.string.nav_stats),
selected = selectedItem == 1,
onClick = { onItemSelected(1) }
)
BottomNavItem(
icon = Icons.Rounded.SelfImprovement,
label = "Focus",
label = stringResource(R.string.nav_focus),
selected = selectedItem == 2,
onClick = { onItemSelected(2) }
)
BottomNavItem(
icon = Icons.Outlined.Settings,
label = "Settings",
label = stringResource(R.string.nav_settings),
selected = selectedItem == 3,
onClick = { onItemSelected(3) }
)
Expand Down
39 changes: 25 additions & 14 deletions Reef/src/main/java/dev/pranav/reef/MainScreen.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.pranav.reef

import android.content.Context
import android.content.Intent
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.animateFloatAsState
Expand Down Expand Up @@ -105,7 +106,8 @@ fun HomeContent(
TimeLimitsCard(
modifier = Modifier.weight(1f),
onClick = onNavigateToWhitelist,
whitelistedCount = whitelistedAppsCount
whitelistedCount = whitelistedAppsCount,
context = context
)
}

Expand Down Expand Up @@ -193,7 +195,7 @@ private fun FocusModeCard(
Spacer(Modifier.height(24.dp))

Text(
text = "Focus Mode",
text = stringResource(R.string.focus_mode),
style = MaterialTheme.typography.headlineLarge.copy(
fontWeight = FontWeight.Bold
),
Expand All @@ -204,7 +206,7 @@ private fun FocusModeCard(
Spacer(Modifier.height(8.dp))

Text(
text = "Slide to start a deep work\nsession",
text = stringResource(R.string.slide_description),
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.7f),
lineHeight = 22.sp,
Expand Down Expand Up @@ -281,7 +283,7 @@ private fun FocusTogglePill(
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "Release",
text = stringResource(R.string.release),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onPrimaryContainer.copy(
alpha = (1f - progress).coerceIn(0.3f, 0.7f)
Expand All @@ -296,7 +298,7 @@ private fun FocusTogglePill(
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "Slide",
text = stringResource(R.string.slide),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onPrimaryContainer.copy(
alpha = (1f - progress).coerceIn(0.3f, 0.7f)
Expand Down Expand Up @@ -368,7 +370,7 @@ private fun AppUsageCard(

Column {
Text(
text = "App Usage",
text = stringResource(R.string.app_usage),
style = MaterialTheme.typography.titleLarge.copy(
fontWeight = FontWeight.Bold
),
Expand All @@ -389,7 +391,8 @@ private fun AppUsageCard(
private fun TimeLimitsCard(
modifier: Modifier = Modifier,
onClick: () -> Unit,
whitelistedCount: Int = 0
whitelistedCount: Int = 0,
context: Context,
) {
Card(
onClick = onClick,
Expand Down Expand Up @@ -423,15 +426,19 @@ private fun TimeLimitsCard(

Column {
Text(
text = "Whitelist",
text = stringResource(R.string.whitelist_apps),
style = MaterialTheme.typography.titleLarge.copy(
fontWeight = FontWeight.Bold
),
fontFamily = Typography.DMSerif,
color = MaterialTheme.colorScheme.onTertiaryContainer
)
Text(
text = "$whitelistedCount apps allowed",
text = context.resources.getQuantityString(
R.plurals.whitelisted_apps,
whitelistedCount,
whitelistedCount
),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onTertiaryContainer.copy(alpha = 0.7f)
)
Expand Down Expand Up @@ -475,14 +482,14 @@ private fun RoutinesCard(onClick: () -> Unit) {

Column(modifier = Modifier.weight(1f)) {
Text(
text = "Routines",
text = stringResource(R.string.routines),
style = MaterialTheme.typography.titleMedium.copy(
fontWeight = FontWeight.Bold
),
color = MaterialTheme.colorScheme.onSurface
)
Text(
text = "Scheduled: \"Deep Work\" at 2:00 PM",
text = stringResource(R.string.sample_routine),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Expand Down Expand Up @@ -565,7 +572,7 @@ private fun PomodoroTimerCard(
text = if (isActive) {
currentTimerState.lowercase().replaceFirstChar { it.uppercase() }
} else {
"Pomodoro Timer"
stringResource(R.string.pomodoro)
},
style = MaterialTheme.typography.titleMedium.copy(
fontWeight = FontWeight.Bold
Expand All @@ -574,9 +581,13 @@ private fun PomodoroTimerCard(
)
Text(
text = if (isActive) {
if (isPaused) "Paused • $currentTimeLeft" else "In progress • $currentTimeLeft"
if (isPaused) {
stringResource(R.string.paused_focus_session, currentTimeLeft)
} else {
stringResource(R.string.in_progress_focus_session, currentTimeLeft)
}
} else {
"Start a focus session"
stringResource(R.string.start_focus_session)
},
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ private fun AppSelectorDialog(
Column {
listOf(
pluralStringResource(R.plurals.minutes_label, 0, 0) to 0,
pluralStringResource(R.plurals.minutes_label, 5, 5) to 5,
pluralStringResource(R.plurals.minutes_label, 15, 15) to 15,
pluralStringResource(R.plurals.minutes_label, 30, 30) to 30,
pluralStringResource(R.plurals.hours_label, 1, 1) to 60,
Expand Down
33 changes: 17 additions & 16 deletions Reef/src/main/java/dev/pranav/reef/ui/appusage/AppUsageViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ class AppUsageViewModel(

repeat(7) { i ->
val cal = Calendar.getInstance()
val daysAgo = (_weekOffset.intValue * 7) + (6 - i)
cal.add(Calendar.DAY_OF_YEAR, -daysAgo)
val daysAgo = (_weekOffset.intValue - 1) * 7 + i + 1
cal.add(Calendar.DAY_OF_YEAR, daysAgo)

cal.set(Calendar.HOUR_OF_DAY, 0)
cal.set(Calendar.MINUTE, 0)
Expand Down Expand Up @@ -316,8 +316,8 @@ class AppUsageViewModel(
private fun checkPreviousWeekData() {
viewModelScope.launch(Dispatchers.IO) {
val calendar = Calendar.getInstance()
val daysToSubtract = ((_weekOffset.intValue - 1) * 7) + 6
calendar.add(Calendar.DAY_OF_YEAR, -daysToSubtract)
val daysToSubtract = (_weekOffset.intValue - 1) * 7
calendar.add(Calendar.DAY_OF_YEAR, daysToSubtract)

val maxWeeksBack = 13
if (_weekOffset.intValue <= -maxWeeksBack) {
Expand All @@ -326,28 +326,29 @@ class AppUsageViewModel(
}

var hasData = false
repeat(7) {
for (i in 0 until 7) {
val start = calendar.clone() as Calendar
start.set(Calendar.HOUR_OF_DAY, 0); start.set(Calendar.MINUTE, 0); start.set(
Calendar.SECOND,
0
); start.set(Calendar.MILLISECOND, 0)
start.set(Calendar.HOUR_OF_DAY, 0)
start.set(Calendar.MINUTE, 0)
start.set(Calendar.SECOND,0)
start.set(Calendar.MILLISECOND, 0)

val end = start.clone() as Calendar
end.set(Calendar.HOUR_OF_DAY, 23); end.set(
Calendar.MINUTE,
59
); end.set(Calendar.SECOND, 59); end.set(Calendar.MILLISECOND, 999)
end.set(Calendar.HOUR_OF_DAY, 23)
end.set(Calendar.MINUTE,59)
end.set(Calendar.SECOND, 59)
end.set(Calendar.MILLISECOND, 999)

if (ScreenUsageHelper.calculateUsage(
context, usageStatsManager,
start.timeInMillis,
end.timeInMillis
).values.sum() > 0
).values.any { it > 0}
) {
hasData = true
return@repeat
break
}
calendar.add(Calendar.DAY_OF_YEAR, 1)
calendar.add(Calendar.DAY_OF_YEAR, -1)
}

withContext(Dispatchers.Main) { _canGoPrevious.value = hasData }
Expand Down
Loading