Skip to content

Commit

Permalink
style(format): run `./gradlew --init-script gradle/init.gradle.kts --…
Browse files Browse the repository at this point in the history
…no-configuration-cache spotlessApply` to fix spotless lint + format errors in project

Commands ran:
- ./gradlew --init-script gradle/init.gradle.kts --no-configuration-cache spotlessCheck
- ./gradlew --init-script gradle/init.gradle.kts --no-configuration-cache spotlessApply
  • Loading branch information
deepanchal committed Aug 21, 2023
1 parent a55f283 commit 01ce3d5
Show file tree
Hide file tree
Showing 474 changed files with 2,255 additions and 1,819 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class ExampleInstrumentedTest {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
Assert.assertEquals("com.crisiscleanup.demo.debug", appContext.packageName)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CrisisCleanupAppStateTest {
windowSizeClass = getCompactWindowClass(),
navController = navController,
networkMonitor = networkMonitor,
coroutineScope = backgroundScope
coroutineScope = backgroundScope,
)
}

Expand Down Expand Up @@ -89,7 +89,7 @@ class CrisisCleanupAppStateTest {
for (i in destinations.indices) {
assertEquals(
destinations[i],
state.topLevelDestinations[i].name.lowercase(Locale.getDefault())
state.topLevelDestinations[i].name.lowercase(Locale.getDefault()),
)
}
}
Expand All @@ -101,7 +101,7 @@ class CrisisCleanupAppStateTest {
windowSizeClass = getCompactWindowClass(),
navController = NavHostController(LocalContext.current),
networkMonitor = networkMonitor,
coroutineScope = backgroundScope
coroutineScope = backgroundScope,
)
}

Expand All @@ -116,7 +116,7 @@ class CrisisCleanupAppStateTest {
windowSizeClass = WindowSizeClass.calculateFromSize(DpSize(800.dp, 800.dp)),
navController = NavHostController(LocalContext.current),
networkMonitor = networkMonitor,
coroutineScope = backgroundScope
coroutineScope = backgroundScope,
)
}

Expand All @@ -126,13 +126,12 @@ class CrisisCleanupAppStateTest {

@Test
fun CrisisCleanupAppState_showNavRail_large() = runTest {

composeTestRule.setContent {
state = CrisisCleanupAppState(
windowSizeClass = WindowSizeClass.calculateFromSize(DpSize(900.dp, 1200.dp)),
navController = NavHostController(LocalContext.current),
networkMonitor = networkMonitor,
coroutineScope = backgroundScope
coroutineScope = backgroundScope,
)
}

Expand All @@ -142,21 +141,20 @@ class CrisisCleanupAppStateTest {

@Test
fun stateIsOfflineWhenNetworkMonitorIsOffline() = runTest(UnconfinedTestDispatcher()) {

composeTestRule.setContent {
state = CrisisCleanupAppState(
windowSizeClass = WindowSizeClass.calculateFromSize(DpSize(900.dp, 1200.dp)),
navController = NavHostController(LocalContext.current),
networkMonitor = networkMonitor,
coroutineScope = backgroundScope
coroutineScope = backgroundScope,
)
}

backgroundScope.launch { state.isOffline.collect() }
networkMonitor.setConnected(false)
assertEquals(
true,
state.isOffline.value
state.isOffline.value,
)
}

Expand Down
1 change: 0 additions & 1 deletion app/src/demo/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
Expand Down
4 changes: 0 additions & 4 deletions app/src/demoDebug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<!-- The application element should be a copy of the prod manifest with the additional attribute
android:usesCleartextTraffic="true"
This allows for http (non-secure) requests. The server must whitelist the device/emulator host.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

Expand Down
1 change: 0 additions & 1 deletion app/src/demoDebug/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
Expand Down
1 change: 0 additions & 1 deletion app/src/demoDebug/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name_short">ccu</string>
</resources>
1 change: 0 additions & 1 deletion app/src/earlybird/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ class AndroidLocationProvider @Inject constructor(
}
return null
}
}
}
16 changes: 11 additions & 5 deletions app/src/main/java/com/crisiscleanup/AndroidPermissionManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ class AndroidPermissionManager @Inject constructor(
private var activityWr: WeakReference<ComponentActivity> = WeakReference(null)

private val screenshotReadPermission =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) READ_MEDIA_IMAGES
else READ_EXTERNAL_STORAGE
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
READ_MEDIA_IMAGES
} else {
READ_EXTERNAL_STORAGE
}

override fun onCreate(owner: LifecycleOwner) {
(owner as? ComponentActivity)?.let { activity ->
Expand All @@ -50,8 +53,11 @@ class AndroidPermissionManager @Inject constructor(
// Assume unchanged permission since requested
val permission = permissionChanges.value.first
val status =
if (isGranted) PermissionStatus.Granted
else PermissionStatus.Denied
if (isGranted) {
PermissionStatus.Granted
} else {
PermissionStatus.Denied
}
permissionChanges.value = Pair(permission, status)

if (permission == ACCESS_COARSE_LOCATION || permission == ACCESS_FINE_LOCATION) {
Expand All @@ -67,7 +73,7 @@ class AndroidPermissionManager @Inject constructor(

private fun publishLocationPermission() {
hasLocationPermission.value = hasPermission(ACCESS_COARSE_LOCATION) ||
hasPermission(ACCESS_FINE_LOCATION)
hasPermission(ACCESS_FINE_LOCATION)
}

private fun hasPermission(permission: String): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class AppVisualAlertManager @Inject constructor() : VisualAlertManager {
override fun setNonProductionAppAlert(show: Boolean) {
showNonProductionAlert.set(show)
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/crisiscleanup/CrisisCleanupAppEnv.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class CrisisCleanupAppEnv @Inject constructor() : AppEnv {
block()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class FirebaseFeedbackReceiver @Inject constructor(

Firebase.appDistribution.startFeedback("Do share O_o")
}
}
}
9 changes: 6 additions & 3 deletions app/src/main/java/com/crisiscleanup/MainActivityViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ class MainActivityViewModel @Inject constructor(
.map {
isAccountExpired.value = !it.areTokensValid

if (it.hasAuthenticated) AuthState.Authenticated(it)
else AuthState.NotAuthenticated
if (it.hasAuthenticated) {
AuthState.Authenticated(it)
} else {
AuthState.NotAuthenticated
}
}
.stateIn(
scope = viewModelScope,
Expand Down Expand Up @@ -200,4 +203,4 @@ sealed interface AuthState {
data object Loading : AuthState
data class Authenticated(val accountData: AccountData) : AuthState
data object NotAuthenticated : AuthState
}
}
6 changes: 3 additions & 3 deletions app/src/main/java/com/crisiscleanup/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ interface AppModule {
@Singleton
@Binds
fun bindsCrisisCleanupAuthInterceptorProvider(
provider: CrisisCleanupAuthInterceptorProvider
provider: CrisisCleanupAuthInterceptorProvider,
): AuthInterceptorProvider

@Singleton
@Binds
fun bindsCrisisCleanupInterceptorProvider(
provider: CrisisCleanupInterceptorProvider
provider: CrisisCleanupInterceptorProvider,
): RetrofitInterceptorProvider

@Singleton
Expand Down Expand Up @@ -84,4 +84,4 @@ object AppObjectModule {
fun firebaseAnalytics(
@ApplicationContext context: Context,
): FirebaseAnalytics = FirebaseAnalytics.getInstance(context)
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/crisiscleanup/di/JankStatsModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object JankStatsModule {
@Provides
fun providesJankStats(
window: Window,
frameListener: JankStats.OnFrameListener
frameListener: JankStats.OnFrameListener,
): JankStats {
return JankStats.createAndTrack(window, frameListener)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ class CrisisCleanupAppLogger @Inject constructor(
crashlytics.log(message)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class CrisisCleanupNavigationObserver @Inject constructor(
override fun onRouteChange(route: String?, arguments: Bundle?) {
navigationRoute.value = Pair(navigationRoute.value.second, route)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ enum class TopLevelDestination(
selectedIcon = ImageVectorIcon(CrisisCleanupIcons.Menu),
unselectedIcon = ImageVectorIcon(CrisisCleanupIcons.Menu),
titleTranslateKey = "nav.menu",
)
),
}
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,4 @@ class CrisisCleanupAuthInterceptorProvider @Inject constructor() : AuthIntercept
}
}

private class NetworkAuthException(message: String) : IOException(message)
private class NetworkAuthException(message: String) : IOException(message)
35 changes: 23 additions & 12 deletions app/src/main/java/com/crisiscleanup/ui/CrisisCleanupApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ fun CrisisCleanupApp(
) {
CrisisCleanupBackground {
Box(Modifier.fillMaxSize()) {

val snackbarHostState = remember { SnackbarHostState() }

val isOffline by appState.isOffline.collectAsStateWithLifecycle()
Expand All @@ -104,11 +103,13 @@ fun CrisisCleanupApp(

LaunchedEffect(isOffline) {
val notConnectedMessage = translator("info.no_internet")
if (isOffline) snackbarHostState.showSnackbar(
message = notConnectedMessage,
duration = SnackbarDuration.Indefinite,
withDismissAction = true,
)
if (isOffline) {
snackbarHostState.showSnackbar(
message = notConnectedMessage,
duration = SnackbarDuration.Indefinite,
withDismissAction = true,
)
}
}

val authState by viewModel.authState.collectAsStateWithLifecycle()
Expand Down Expand Up @@ -320,8 +321,11 @@ private fun NavigableContent(
.padding(padding)
.consumeWindowInsets(padding)
.windowInsetsPadding(
if (isFullscreen) WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)
else WindowInsets.safeDrawing,
if (isFullscreen) {
WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)
} else {
WindowInsets.safeDrawing
},
),
) {
if (showNavigation && appState.shouldShowNavRail) {
Expand All @@ -341,7 +345,11 @@ private fun NavigableContent(
if (!showNavigation &&
snackbarHostState.currentSnackbarData != null &&
keyboardVisibility == ScreenKeyboardVisibility.NotVisible
) 64.dp else 0.dp
) {
64.dp
} else {
0.dp
}

CompositionLocalProvider(
LocalAppLayout provides AppLayoutArea(snackbarHostState),
Expand Down Expand Up @@ -431,8 +439,11 @@ private fun AppHeader(

@Composable
private fun TopLevelDestination.Icon(isSelected: Boolean, description: String) {
val icon = if (isSelected) selectedIcon
else unselectedIcon
val icon = if (isSelected) {
selectedIcon
} else {
unselectedIcon
}
when (icon) {
is ImageVectorIcon -> Icon(
imageVector = icon.imageVector,
Expand Down Expand Up @@ -489,7 +500,7 @@ private fun CrisisCleanupBottomBar(
selected = selected,
onClick = { onNavigateToDestination(destination) },
icon = { destination.Icon(selected, title) },
modifier = Modifier.testTag("navItem_${title}"),
modifier = Modifier.testTag("navItem_$title"),
label = {
Text(
title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class CrisisCleanupAppHeaderUiState @Inject constructor(
override fun setTitle(title: String) {
this.title.value = title
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fun rememberCrisisCleanupAppState(
networkMonitor: NetworkMonitor,
navigationObserver: NavigationObserver,
coroutineScope: CoroutineScope = rememberCoroutineScope(),
navController: NavHostController = rememberNavController()
navController: NavHostController = rememberNavController(),
): CrisisCleanupAppState {
NavigationTrackingSideEffect(navController)
NavigationObserverSideEffect(navController, navigationObserver)
Expand Down Expand Up @@ -97,7 +97,7 @@ class CrisisCleanupAppState(
.stateIn(
scope = coroutineScope,
started = SharingStarted.WhileSubscribed(5_000),
initialValue = false
initialValue = false,
)

val hideLoginAlert: Boolean
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/crisiscleanup/ui/EndOfLifeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ internal fun EndOfLifeView(
)
}
}
}
}
1 change: 0 additions & 1 deletion app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_beta_foreground"/>
Expand Down
7 changes: 0 additions & 7 deletions app/src/main/res/xml/backup_rules.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older that API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/res/xml/data_extraction_rules.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
Expand Down
Loading

0 comments on commit 01ce3d5

Please sign in to comment.