Skip to content

Commit 9264cb2

Browse files
author
Simon Schubert
committed
Add spotless and apply
1 parent 526c9d1 commit 9264cb2

File tree

50 files changed

+330
-293
lines changed

Some content is hidden

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

50 files changed

+330
-293
lines changed

android/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ android {
4848
isMinifyEnabled = true
4949
proguardFiles(
5050
getDefaultProguardFile("proguard-android-optimize.txt"),
51-
"proguard-rules.pro"
51+
"proguard-rules.pro",
5252
)
5353
}
5454
getByName("debug") {
@@ -78,4 +78,4 @@ android {
7878
abortOnError = false
7979
}
8080
namespace = "com.inspiredandroid.linuxcommandbibliotheca"
81-
}
81+
}

android/src/androidTest/java/com/inspiredandroid/linuxcommandbibliotheca/ComposeDeeplinkTests.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import org.junit.Rule
1717
import org.junit.Test
1818
import org.junit.runner.RunWith
1919

20-
2120
/**
2221
* Test if deeplinks from/to website open correct screens. If test started the first time
2322
* "Always open urls with app" dialog has to be accepted. Or the app has to be signed with the
@@ -86,4 +85,4 @@ class ComposeDeeplinkTests {
8685
composeTestRule.onNodeWithContentDescription("TopAppBarTitle")
8786
.assertTextEquals("2048")
8887
}
89-
}
88+
}

android/src/androidTest/java/com/inspiredandroid/linuxcommandbibliotheca/ComposeScreenshots.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import org.junit.Test
2222
import org.junit.runner.RunWith
2323
import java.io.FileOutputStream
2424

25-
2625
/**
2726
* Take screenshots of Phone and Tablet.
2827
* Phone = Pixel 2 1080x1920
@@ -127,4 +126,4 @@ class ComposeScreenshots {
127126
compress(Bitmap.CompressFormat.PNG, 100, out)
128127
}
129128
}
130-
}
129+
}

android/src/androidTest/java/com/inspiredandroid/linuxcommandbibliotheca/ComposeTests.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import org.junit.Rule
1313
import org.junit.Test
1414
import org.junit.runner.RunWith
1515

16-
1716
/**
1817
* Test for navigation, search and booksmarks. More tests to come
1918
*/
@@ -112,5 +111,4 @@ class ComposeTests {
112111
// Check if commands of group expanded and therefore share icon(s) are visible
113112
composeTestRule.onAllNodesWithContentDescription("Share").assertAny(isEnabled())
114113
}
115-
116-
}
114+
}

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/ExtensionFunctions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ fun NavBackStackEntry.getCategoryId(): Long? {
2727
categoryId = categories.firstOrNull { it.getHtmlFileName() == categoryName }?.id
2828
}
2929
return categoryId
30-
}
30+
}

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/IconResources.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,4 @@ fun BasicCategory.getIconResource(): Int {
265265
"Fun" -> R.drawable.ic_icon_fun
266266
else -> R.drawable.ic_icon_mouse
267267
}
268-
}
268+
}

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/InitializeDatabaseActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ class InitializeDatabaseActivity : AppCompatActivity() {
3636
}
3737
}
3838
}
39-
}
39+
}

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/LinuxApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ class LinuxApplication : Application() {
3333

3434
single { PreferenceUtil(androidContext()) }
3535
}
36-
}
36+
}

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/MainActivity.kt

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import com.inspiredandroid.linuxcommandbibliotheca.ui.theme.LinuxTheme
3434
import com.linuxcommandlibrary.shared.hasDatabase
3535
import com.linuxcommandlibrary.shared.initDatabase
3636
import org.koin.android.ext.android.inject
37-
import org.koin.androidx.compose.getViewModel
37+
import org.koin.androidx.compose.koinViewModel
3838
import org.koin.core.parameter.parametersOf
3939

4040
/* Copyright 2022 Simon Schubert
@@ -52,8 +52,6 @@ import org.koin.core.parameter.parametersOf
5252
* limitations under the License.
5353
*/
5454

55-
const val deepLinkUri = "https://linuxcommandlibrary.com"
56-
5755
class MainActivity : AppCompatActivity() {
5856

5957
private val preferenceManager by inject<PreferenceUtil>()
@@ -76,13 +74,15 @@ class MainActivity : AppCompatActivity() {
7674
}
7775
}
7876

77+
const val DEEPLINK_URI = "https://linuxcommandlibrary.com"
78+
7979
@Composable
8080
fun LinuxApp() {
8181
val navController = rememberNavController()
8282
val navBackStackEntry = navController.currentBackStackEntryAsState()
8383
val searchTextValue = remember {
8484
mutableStateOf(
85-
TextFieldValue(text = "", selection = TextRange(0))
85+
TextFieldValue(text = "", selection = TextRange(0)),
8686
)
8787
}
8888
val onNavigate: (String) -> Unit = {
@@ -92,67 +92,74 @@ fun LinuxApp() {
9292
LinuxTheme {
9393
Scaffold(
9494
topBar = {
95-
TopBar(navBackStackEntry,
95+
TopBar(
96+
navBackStackEntry,
9697
searchTextValue,
9798
onNavigateBack = {
9899
navController.popBackStack()
99-
})
100+
},
101+
)
100102
},
101103
bottomBar = {
102104
BottomBar(navController)
103-
}) { innerPadding ->
105+
},
106+
) { innerPadding ->
104107

105108
NavHost(
106109
navController,
107110
startDestination = Screen.Basics.route,
108-
Modifier.padding(innerPadding)
111+
Modifier.padding(innerPadding),
109112
) {
110-
111113
composable(
112114
Screen.Basics.route,
113115
deepLinks = listOf(
114-
navDeepLink { uriPattern = "$deepLinkUri/basics" },
115-
navDeepLink { uriPattern = "$deepLinkUri/basics.html" })
116+
navDeepLink { uriPattern = "$DEEPLINK_URI/basics" },
117+
navDeepLink { uriPattern = "$DEEPLINK_URI/basics.html" },
118+
),
116119
) {
117120
BasicCategoriesScreen(onNavigate)
118121
}
119122
composable(
120123
Screen.Commands.route,
121124
deepLinks = listOf(
122-
navDeepLink { uriPattern = "$deepLinkUri/" },
123-
navDeepLink { uriPattern = "$deepLinkUri/index.html" })
125+
navDeepLink { uriPattern = "$DEEPLINK_URI/" },
126+
navDeepLink { uriPattern = "$DEEPLINK_URI/index.html" },
127+
),
124128
) {
125-
val viewModel = getViewModel<CommandListViewModel>()
129+
val viewModel = koinViewModel<CommandListViewModel>()
126130

127131
CommandListScreen(
128132
searchTextValue.value.text,
129133
viewModel,
130-
onNavigate
134+
onNavigate,
131135
)
132136
}
133137
composable(
134138
Screen.Tips.route,
135139
deepLinks = listOf(
136-
navDeepLink { uriPattern = "$deepLinkUri/tips" },
137-
navDeepLink { uriPattern = "$deepLinkUri/tips.html" })
140+
navDeepLink { uriPattern = "$DEEPLINK_URI/tips" },
141+
navDeepLink { uriPattern = "$DEEPLINK_URI/tips.html" },
142+
),
138143
) {
139144
TipsScreen(onNavigate)
140145
}
141146
composable(
142147
"basicgroups?categoryId={categoryId}&categoryName={categoryName}",
143148
arguments = listOf(
144149
navArgument("categoryId") { defaultValue = "" },
145-
navArgument("categoryName") {}),
150+
navArgument("categoryName") {},
151+
),
146152
deepLinks = listOf(
147153
navDeepLink {
148-
uriPattern = "$deepLinkUri/basic/{categoryName}.html"
154+
uriPattern = "$DEEPLINK_URI/basic/{categoryName}.html"
149155
},
150-
navDeepLink { uriPattern = "$deepLinkUri/basic/{categoryName}" })
156+
navDeepLink { uriPattern = "$DEEPLINK_URI/basic/{categoryName}" },
157+
),
151158
) { backStackEntry ->
152159
val categoryId = backStackEntry.getCategoryId()
153160
if (categoryId != null) {
154-
val viewModel = getViewModel<BasicGroupsViewModel>(
155-
parameters = { parametersOf(categoryId) }
161+
val viewModel = koinViewModel<BasicGroupsViewModel>(
162+
parameters = { parametersOf(categoryId) },
156163
)
157164
BasicGroupsScreen(onNavigate, viewModel)
158165
} else {
@@ -164,15 +171,17 @@ fun LinuxApp() {
164171
"command?commandId={commandId}&commandName={commandName}",
165172
arguments = listOf(
166173
navArgument("commandId") { defaultValue = "" },
167-
navArgument("commandName") {}),
174+
navArgument("commandName") {},
175+
),
168176
deepLinks = listOf(
169-
navDeepLink { uriPattern = "$deepLinkUri/man/{commandName}.html" },
170-
navDeepLink { uriPattern = "$deepLinkUri/man/{commandName}" })
177+
navDeepLink { uriPattern = "$DEEPLINK_URI/man/{commandName}.html" },
178+
navDeepLink { uriPattern = "$DEEPLINK_URI/man/{commandName}" },
179+
),
171180
) { backStackEntry ->
172181
val commandId = backStackEntry.getCommandId()
173182
if (commandId != null) {
174-
val viewModel = getViewModel<CommandDetailViewModel>(
175-
parameters = { parametersOf(commandId) }
183+
val viewModel = koinViewModel<CommandDetailViewModel>(
184+
parameters = { parametersOf(commandId) },
176185
)
177186
CommandDetailScreen(onNavigate, viewModel)
178187
} else {
@@ -188,9 +197,9 @@ fun LinuxApp() {
188197
sealed class Screen(
189198
val route: String,
190199
@StringRes val resourceId: Int,
191-
@DrawableRes val drawableRes: Int
200+
@DrawableRes val drawableRes: Int,
192201
) {
193202
data object Commands : Screen("commands", R.string.commands, R.drawable.ic_search_40dp)
194203
data object Basics : Screen("basics", R.string.basics, R.drawable.ic_puzzle)
195204
data object Tips : Screen("tips", R.string.tips, R.drawable.ic_idea)
196-
}
205+
}

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/PreferenceUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ class PreferenceUtil(private val context: Context) {
4949
const val KEY_DATABASE_VERSION = "DATABASE_VERSION"
5050
const val CURRENT_DATABASE_VERSION = 7
5151
}
52-
}
52+
}

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/ui/composables/BottomBar.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fun BottomBar(navController: NavHostController) {
3737
val items = listOf(
3838
Screen.Basics,
3939
Screen.Tips,
40-
Screen.Commands
40+
Screen.Commands,
4141
)
4242
// TODO: read current route from navcontroller
4343
val selectedRoute = rememberSaveable { mutableStateOf(Screen.Basics.route) }
@@ -49,7 +49,7 @@ fun BottomBar(navController: NavHostController) {
4949
Icon(
5050
painterResource(id = screen.drawableRes),
5151
null,
52-
modifier = Modifier.size(24.dp)
52+
modifier = Modifier.size(24.dp),
5353
)
5454
},
5555
label = { Text(stringResource(screen.resourceId)) },
@@ -65,9 +65,8 @@ fun BottomBar(navController: NavHostController) {
6565
launchSingleTop = true
6666
restoreState = true
6767
}
68-
}
68+
},
6969
)
7070
}
7171
}
7272
}
73-

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/ui/composables/CommandView.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import com.linuxcommandlibrary.shared.databaseHelper
4646
fun CommandView(
4747
command: String,
4848
elements: List<CommandElement>,
49-
onNavigate: (String) -> Unit = {}
49+
onNavigate: (String) -> Unit = {},
5050
) {
5151
val codeColor = MaterialTheme.colors.primary
5252
val annotatedString = remember(codeColor) {
@@ -88,7 +88,7 @@ fun CommandView(
8888
annotatedString.getStringAnnotations(
8989
tag = "$index",
9090
start = offset,
91-
end = offset
91+
end = offset,
9292
)
9393
.firstOrNull()
9494
?.let {
@@ -99,7 +99,7 @@ fun CommandView(
9999
annotatedString.getStringAnnotations(
100100
tag = "$index",
101101
start = offset,
102-
end = offset
102+
end = offset,
103103
)
104104
.firstOrNull()
105105
?.let {
@@ -110,17 +110,19 @@ fun CommandView(
110110
}
111111
}
112112
}
113-
})
113+
},
114+
)
114115

115116
val context = LocalContext.current
116117
IconButton(
117118
modifier = Modifier.align(Alignment.CenterVertically),
118119
onClick = {
119120
shareCommand(context, command)
120-
}) {
121+
},
122+
) {
121123
Icon(
122124
imageVector = Icons.Filled.Share,
123-
contentDescription = stringResource(R.string.share)
125+
contentDescription = stringResource(R.string.share),
124126
)
125127
}
126128
}
@@ -131,7 +133,7 @@ fun shareCommand(context: Context, command: String) {
131133
intent.type = "text/plain"
132134
intent.putExtra(
133135
Intent.EXTRA_TEXT,
134-
command.dropWhile { it == '$' || it.isWhitespace() }.replace("\\n", "")
136+
command.dropWhile { it == '$' || it.isWhitespace() }.replace("\\n", ""),
135137
)
136138
try {
137139
context.startActivity(Intent.createChooser(intent, "Share command"))
@@ -140,7 +142,6 @@ fun shareCommand(context: Context, command: String) {
140142
}
141143
}
142144

143-
144145
@Composable
145146
@Preview
146147
fun CommandViewPreview() {
@@ -150,8 +151,8 @@ fun CommandViewPreview() {
150151
elements = listOf(
151152
CommandElement.Text("$ "),
152153
CommandElement.Man("find"),
153-
CommandElement.Text(" ex?mple.txt")
154+
CommandElement.Text(" ex?mple.txt"),
154155
),
155156
)
156157
}
157-
}
158+
}

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/ui/composables/HighlightedText.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fun HighlightedText(text: String, pattern: String) {
4646
text = annotatedString,
4747
maxLines = 1,
4848
softWrap = false,
49-
overflow = TextOverflow.Ellipsis
49+
overflow = TextOverflow.Ellipsis,
5050
)
5151
}
5252

@@ -56,7 +56,7 @@ fun HighlightedTextPreview() {
5656
LinuxTheme {
5757
HighlightedText(
5858
text = "pacman",
59-
pattern = "cm"
59+
pattern = "cm",
6060
)
6161
}
62-
}
62+
}

0 commit comments

Comments
 (0)