Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
rock3r committed Sep 20, 2023
1 parent 3f0f85c commit 3127bef
Show file tree
Hide file tree
Showing 30 changed files with 148 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RobertoFoldTest {
OnboardingScreen(
viewModel = OnboardingViewModel(FakePreferences()),
needsPermission = true,
onOpenNotificationPreferencesClick = { /*TODO*/ }
onOpenNotificationPreferencesClick = { /*TODO*/ },
) { }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ internal class OnboardingAndroidUiTest : ScreenshotTest {
composeTestRule.setContent {
TestHarness(
darkMode = true,
size = DpSize(250.dp, 140.dp)
size = DpSize(250.dp, 140.dp),
) {
BundelYouTheme {
var crashReportingEnabled by remember { mutableStateOf(false) }
IntroPage(
IntroPageState(crashReportingEnabled) { crashReportingEnabled = !crashReportingEnabled }
IntroPageState(crashReportingEnabled) { crashReportingEnabled = !crashReportingEnabled },
)
}
}
Expand All @@ -70,12 +70,12 @@ internal class OnboardingAndroidUiTest : ScreenshotTest {
fun intro_page_should_toggle_state_correctly() {
composeTestRule.setContent {
TestHarness(
size = DpSize(1920.dp, 1080.dp)
size = DpSize(1920.dp, 1080.dp),
) {
BundelYouTheme {
var crashReportingEnabled by remember { mutableStateOf(false) }
IntroPage(
IntroPageState(crashReportingEnabled) { crashReportingEnabled = !crashReportingEnabled }
IntroPageState(crashReportingEnabled) { crashReportingEnabled = !crashReportingEnabled },
)
}
}
Expand All @@ -96,7 +96,7 @@ internal class OnboardingAndroidUiTest : ScreenshotTest {
BundelYouTheme {
var crashReportingEnabled by remember { mutableStateOf(true) }
IntroPage(
IntroPageState(crashReportingEnabled) { crashReportingEnabled = !crashReportingEnabled }
IntroPageState(crashReportingEnabled) { crashReportingEnabled = !crashReportingEnabled },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import com.google.android.glance.tools.viewer.GlanceViewerActivity
class GlanceDebugActivity : GlanceViewerActivity() {

override suspend fun getGlanceSnapshot(
receiver: Class<out GlanceAppWidgetReceiver>
receiver: Class<out GlanceAppWidgetReceiver>,
): GlanceSnapshot {
return when (receiver) {
BundelAppWidgetReceiver::class.java -> GlanceSnapshot(
instance = CannoliWidget(null),
state = mutablePreferencesOf()
state = mutablePreferencesOf(),
)
else -> throw IllegalArgumentException()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,21 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.PlainTooltipBox
import androidx.compose.material3.PlainTooltipState
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.windowsizeclass.WindowSizeClass
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ fun TestWidgetScreen() {
GlanceAppWidgetHostPreview(
modifier = Modifier.fillMaxSize(),
glanceAppWidget = instance,
displaySize = displaySize
displaySize = displaySize,
)
}
10 changes: 5 additions & 5 deletions app/src/main/java/dev/sebastiano/bundel/history/HistoryScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ private val persistableNotification = PersistableNotification(
key = "123",
timestamp = 12345678L,
text = "Hello Ivan",
appInfo = PersistableNotification.SenderAppInfo("com.yeah", "Yeah!")
appInfo = PersistableNotification.SenderAppInfo("com.yeah", "Yeah!"),
)

@Preview
@Composable
fun NotificationsHistoryLightPreview() {
BundelYouTheme {
NotificationsHistoryScreen(
persistableNotifications = listOf(persistableNotification)
persistableNotifications = listOf(persistableNotification),
)
}
}
Expand All @@ -58,21 +58,21 @@ fun NotificationsHistoryLightPreview() {
fun NotificationsHistoryDarkPreview() {
BundelYouTheme(darkTheme = true) {
NotificationsHistoryScreen(
persistableNotifications = listOf(persistableNotification)
persistableNotifications = listOf(persistableNotification),
)
}
}

@Composable
internal fun NotificationsHistoryScreen(
innerPadding: PaddingValues = PaddingValues(0.dp),
persistableNotifications: List<PersistableNotification>
persistableNotifications: List<PersistableNotification>,
) {
if (persistableNotifications.isNotEmpty()) {
Column(
Modifier
.fillMaxSize()
.padding(innerPadding)
.padding(innerPadding),
) {
NotificationsLazyColumn(persistableNotifications)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ import kotlinx.coroutines.launch
@OptIn(
ExperimentalComposeUiApi::class,
ExperimentalMaterialNavigationApi::class,
ExperimentalAnimationApi::class
ExperimentalAnimationApi::class,
)
internal fun NavGraphBuilder.preferencesGraph(
navController: NavHostController,
onUrlClick: (String) -> Unit
onUrlClick: (String) -> Unit,
) {
navigation(
route = NavigationRoute.PreferencesGraph.route,
startDestination = NavigationRoute.PreferencesGraph.PreferencesScreen.route
startDestination = NavigationRoute.PreferencesGraph.PreferencesScreen.route,
) {
composable(
route = NavigationRoute.PreferencesGraph.PreferencesScreen.route
route = NavigationRoute.PreferencesGraph.PreferencesScreen.route,
) {
PreferencesScreen(
versionInfo = VersionInfo(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE.toString()),
Expand All @@ -63,24 +63,24 @@ internal fun NavGraphBuilder.preferencesGraph(
onLicensesLinkClick = { navController.navigate(NavigationRoute.PreferencesGraph.Licenses.route) },
onSourcesLinkClick = { onUrlClick("https://github.com/rock3r/bundel") },
onTestWidgetClick = { navController.navigate(NavigationRoute.PreferencesGraph.TestWidget.route) },
onBackPress = { navController.popBackStack() }
onBackPress = { navController.popBackStack() },
)
}

composable(
route = NavigationRoute.PreferencesGraph.SelectApps.route
route = NavigationRoute.PreferencesGraph.SelectApps.route,
) {
AppsListScreen(onBackPress = { navController.popBackStack() })
}

composable(
route = NavigationRoute.PreferencesGraph.Licenses.route
route = NavigationRoute.PreferencesGraph.Licenses.route,
) {
LicensesScreen(onBackPress = { navController.popBackStack() })
}

composable(
route = NavigationRoute.PreferencesGraph.TestWidget.route
route = NavigationRoute.PreferencesGraph.TestWidget.route,
) {
TestWidgetScreen()
}
Expand All @@ -91,7 +91,7 @@ internal fun NavGraphBuilder.preferencesGraph(

dialog(
route = NavigationRoute.PreferencesGraph.SelectTimeRanges.route,
dialogProperties = DialogProperties(usePlatformDefaultWidth = false)
dialogProperties = DialogProperties(usePlatformDefaultWidth = false),
) {
SelectTimeRangesDialog(onDialogDismiss = { navController.popBackStack() })
}
Expand All @@ -104,11 +104,11 @@ internal fun NavGraphBuilder.mainScreenGraph(
lifecycle: Lifecycle,
repository: DataRepository,
preferences: Preferences,
windowSizeClass: WindowSizeClass
windowSizeClass: WindowSizeClass,
) {
navigation(
route = NavigationRoute.MainScreenGraph.route,
startDestination = NavigationRoute.MainScreenGraph.MainScreen.route
startDestination = NavigationRoute.MainScreenGraph.MainScreen.route,
) {
composable(route = NavigationRoute.MainScreenGraph.MainScreen.route) {
MainScreenWithBottomNav(lifecycle, repository, preferences, windowSizeClass) {
Expand All @@ -123,11 +123,11 @@ internal fun NavGraphBuilder.onboardingGraph(
navController: NavHostController,
needsNotificationsPermissionFlow: Flow<Boolean>,
preferences: Preferences,
onOpenNotificationPreferencesClick: () -> Unit
onOpenNotificationPreferencesClick: () -> Unit,
) {
navigation(
route = NavigationRoute.OnboardingGraph.route,
startDestination = NavigationRoute.OnboardingGraph.OnboardingScreen.route
startDestination = NavigationRoute.OnboardingGraph.OnboardingScreen.route,
) {
composable(NavigationRoute.OnboardingGraph.OnboardingScreen.route) {
val needsNotificationsPermission by needsNotificationsPermissionFlow.collectAsState(true)
Expand All @@ -140,13 +140,13 @@ internal fun NavGraphBuilder.onboardingGraph(
onOnboardingDoneClicked = {
scope.launch { preferences.setIsOnboardingSeen(true) }
navController.navigate(
route = NavigationRoute.MainScreenGraph.MainScreen.route
route = NavigationRoute.MainScreenGraph.MainScreen.route,
) {
popUpTo(NavigationRoute.OnboardingGraph.route) {
inclusive = true
}
}
}
},
)
}
}
Expand All @@ -155,14 +155,14 @@ internal fun NavGraphBuilder.onboardingGraph(
@ExperimentalAnimationApi
internal fun NavGraphBuilder.splashScreenGraph(
preferences: Preferences,
onPizzaReady: (NavigationRoute) -> Unit
onPizzaReady: (NavigationRoute) -> Unit,
) {
composable(NavigationRoute.SplashoScreenButWithAWeirdNameNotToTriggerLint.route) {
SetupTransparentSystemUi(actualBackgroundColor = MaterialTheme.colorScheme.primaryContainer)

Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
contentAlignment = Alignment.Center,
) {
CircularProgressIndicator()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal data class ActiveNotification(
val persistableNotification: PersistableNotification,
val icons: Icons = Icons(),
val interactions: Interactions = Interactions(),
val isSnoozed: Boolean
val isSnoozed: Boolean,
) {

val isNotEmpty: Boolean =
Expand All @@ -19,7 +19,7 @@ internal data class ActiveNotification(
val appIcon: Icon? = null,
val small: Icon? = null,
val large: Icon? = null,
val extraLarge: Icon? = null
val extraLarge: Icon? = null,
) {

val isNotEmpty: Boolean = appIcon != null || small != null || large != null || extraLarge != null
Expand All @@ -28,13 +28,13 @@ internal data class ActiveNotification(
data class Interactions(
val main: PendingIntent? = null,
val dismiss: PendingIntent? = null,
val actions: List<ActionItem> = emptyList()
val actions: List<ActionItem> = emptyList(),
) {

data class ActionItem(
val text: CharSequence,
val icon: Icon? = null,
val pendingIntent: PendingIntent? = null
val pendingIntent: PendingIntent? = null,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ internal class BundelNotificationListenerService : NotificationListenerService()

private data class SnoozedNotification(
val kettle: String, // aka fuck you kettles, it's supposed to be the notification key
val durationMillis: Int
val durationMillis: Int,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@file:Suppress("ktlint:filename")
@file:Suppress("ktlint:standard:filename")

package dev.sebastiano.bundel.notifications

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal data class PersistableNotification(
val title: String? = null,
val subText: String? = null,
val titleBig: String? = null,
val appInfo: SenderAppInfo
val appInfo: SenderAppInfo,
) {

val uniqueId = "${appInfo.packageName}_${id}_$timestamp"
Expand All @@ -27,6 +27,6 @@ internal data class PersistableNotification(
data class SenderAppInfo(
val packageName: String,
val name: String? = null,
val iconPath: String? = null
val iconPath: String? = null,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ internal fun StatusBarNotification.toActiveNotification(context: Context): Activ
title = title,
subText = subText,
titleBig = titleBig,
appInfo = extractAppInfo(applicationInfo, packageManager)
appInfo = extractAppInfo(applicationInfo, packageManager),
),
icons = extractIcons(applicationInfo),
interactions = extractInteractions(),
isSnoozed = false
isSnoozed = false,
)
}

Expand All @@ -43,12 +43,12 @@ private fun StatusBarNotification.extractIcons(applicationInfo: ApplicationInfo)
appIcon = Icon.createWithResource(packageName, applicationInfo.icon),
small = notification.smallIcon,
large = notification.getLargeIcon(),
extraLarge = notification.extras.getParcelable(Notification.EXTRA_LARGE_ICON_BIG)
extraLarge = notification.extras.getParcelable(Notification.EXTRA_LARGE_ICON_BIG),
)

private fun StatusBarNotification.extractAppInfo(
applicationInfo: ApplicationInfo,
packageManager: PackageManager
packageManager: PackageManager,
): PersistableNotification.SenderAppInfo =
PersistableNotification.SenderAppInfo(
packageName = packageName,
Expand All @@ -58,15 +58,15 @@ private fun StatusBarNotification.extractAppInfo(
Firebase.crashlytics.log("Application ${applicationInfo.packageName} has no label")
applicationInfo.packageName
},
iconPath = null
iconPath = null,
)

private fun StatusBarNotification.extractInteractions() = ActiveNotification.Interactions(
main = notification.contentIntent,
dismiss = notification.deleteIntent,
actions = notification.actions
?.map { ActiveNotification.Interactions.ActionItem(it.title, it.getIcon(), it.actionIntent) }
.orEmpty()
.orEmpty(),
)

internal val StatusBarNotification.text: String?
Expand Down
Loading

0 comments on commit 3127bef

Please sign in to comment.