mirror of
https://gitlab.com/fdroid/fdroidclient.git
synced 2024-10-07 17:08:31 +02:00
[app] add ktlint checking and fix complaints it has
This commit is contained in:
parent
eb367041a3
commit
c2b021a39a
8 changed files with 60 additions and 61 deletions
|
@ -138,7 +138,7 @@ app lint pmd checkstyle:
|
|||
# always report on lint errors to the build log
|
||||
- sed -i -e 's,textReport .*,textReport true,' app/build.gradle
|
||||
# the tasks "lint", "test", etc don't always include everything
|
||||
- ./gradlew :app:lint :app:pmd :app:checkstyle
|
||||
- ./gradlew :app:lint :app:pmd :app:checkstyle :app:ktlintCheck
|
||||
|
||||
libs lint ktlintCheck:
|
||||
<<: *test-template
|
||||
|
@ -201,6 +201,7 @@ app errorprone:
|
|||
- changes:
|
||||
- app/**/*
|
||||
script:
|
||||
- sed -i "s@plugins {@plugins{\nid 'net.ltgt.errorprone' version '3.1.0'@" app/build.gradle
|
||||
- cat config/errorprone.gradle >> app/build.gradle
|
||||
- ./gradlew -Dorg.gradle.dependency.verification=lenient assembleDebug
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
id "org.jlleitschuh.gradle.ktlint" version "10.2.1"
|
||||
}
|
||||
|
||||
// add -Pstrict.release to the gradle command line to enable
|
||||
if (project.hasProperty('strict.release')) {
|
||||
|
@ -246,3 +249,5 @@ android.productFlavors.all { flavor ->
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
apply from: "${rootProject.rootDir}/gradle/ktlint.gradle"
|
||||
|
|
|
@ -33,11 +33,11 @@ class NotificationManager(
|
|||
msg: String? = null,
|
||||
progress: Int? = null,
|
||||
) = NotificationCompat.Builder(context, CHANNEL_UPDATES)
|
||||
.setSmallIcon(R.drawable.ic_refresh)
|
||||
.setCategory(CATEGORY_SERVICE)
|
||||
.setContentTitle(context.getString(R.string.banner_updating_repositories))
|
||||
.setContentText(msg)
|
||||
.setOngoing(true)
|
||||
.setProgress(100, progress ?: 0, progress == null)
|
||||
.setSmallIcon(R.drawable.ic_refresh)
|
||||
.setCategory(CATEGORY_SERVICE)
|
||||
.setContentTitle(context.getString(R.string.banner_updating_repositories))
|
||||
.setContentText(msg)
|
||||
.setOngoing(true)
|
||||
.setProgress(100, progress ?: 0, progress == null)
|
||||
|
||||
}
|
||||
|
|
|
@ -149,8 +149,11 @@ fun IpfsGatewayAddScreen(
|
|||
text = stringResource(R.string.ipfsgw_add_add),
|
||||
onClick = l@{
|
||||
errorMsg = ""
|
||||
val inputUri =
|
||||
if (textState.value.text.endsWith("/")) textState.value.text else "${textState.value.text}/"
|
||||
val inputUri = if (textState.value.text.endsWith("/")) {
|
||||
textState.value.text
|
||||
} else {
|
||||
"${textState.value.text}/"
|
||||
}
|
||||
|
||||
try {
|
||||
val uri = Uri.parse(inputUri)
|
||||
|
@ -182,4 +185,4 @@ fun IpfsGatewayAddScreenPreview() {
|
|||
onAddUserGateway = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ import androidx.lifecycle.Lifecycle
|
|||
import org.fdroid.fdroid.IPreferencesIpfs
|
||||
import org.fdroid.fdroid.Preferences
|
||||
import org.fdroid.fdroid.R
|
||||
import org.fdroid.fdroid.compose.ComposeUtils
|
||||
import org.fdroid.fdroid.compose.ComposeUtils.CaptionText
|
||||
import org.fdroid.fdroid.compose.ComposeUtils.FDroidContent
|
||||
import org.fdroid.fdroid.compose.ComposeUtils.LifecycleEventListener
|
||||
|
||||
|
@ -74,32 +74,34 @@ fun IpfsGatewaySettingsScreen(
|
|||
val context = LocalContext.current
|
||||
var ipfsEnabled by remember { mutableStateOf(prefs.isIpfsEnabled) }
|
||||
|
||||
Scaffold(topBar = {
|
||||
TopAppBar(
|
||||
elevation = 4.dp,
|
||||
backgroundColor = MaterialTheme.colors.primarySurface,
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onBackClicked) {
|
||||
Icon(Icons.Filled.ArrowBack, stringResource(R.string.back))
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
elevation = 4.dp,
|
||||
backgroundColor = MaterialTheme.colors.primarySurface,
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onBackClicked) {
|
||||
Icon(Icons.Filled.ArrowBack, stringResource(R.string.back))
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text(
|
||||
text = stringResource(R.string.ipfsgw_title),
|
||||
modifier = Modifier.alpha(ContentAlpha.high),
|
||||
)
|
||||
},
|
||||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
// it doesn't seam to be supported to disable FABs, so just hide it for now.
|
||||
if (ipfsEnabled) {
|
||||
FloatingActionButton(onClick = {
|
||||
context.startActivity(Intent(context, IpfsGatewayAddActivity::class.java))
|
||||
}) {
|
||||
Icon(Icons.Filled.Add, stringResource(id = R.string.ipfsgw_add_add))
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text(
|
||||
text = stringResource(R.string.ipfsgw_title),
|
||||
modifier = Modifier.alpha(ContentAlpha.high),
|
||||
)
|
||||
},
|
||||
)
|
||||
}, floatingActionButton = {
|
||||
// it doesn't seam to be supported to disable FABs, so just hide it for now.
|
||||
if (ipfsEnabled) {
|
||||
FloatingActionButton(onClick = {
|
||||
context.startActivity(Intent(context, IpfsGatewayAddActivity::class.java))
|
||||
}) {
|
||||
Icon(Icons.Filled.Add, stringResource(id = R.string.ipfsgw_add_add))
|
||||
}
|
||||
}
|
||||
}) { paddingValues ->
|
||||
}) { paddingValues ->
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(paddingValues)
|
||||
|
@ -139,7 +141,9 @@ fun DefaultGatewaysSettings(
|
|||
var disabledDefaultGateways by remember { mutableStateOf(prefs.ipfsGwDisabledDefaults) }
|
||||
|
||||
Column {
|
||||
ComposeUtils.CaptionText(text = stringResource(id = R.string.ipfsgw_caption_official_gateways))
|
||||
CaptionText(
|
||||
text = stringResource(id = R.string.ipfsgw_caption_official_gateways),
|
||||
)
|
||||
for (gatewayUrl in Preferences.DEFAULT_IPFS_GATEWAYS) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
|
@ -191,7 +195,7 @@ fun UserGatewaysSettings(
|
|||
|
||||
Column {
|
||||
if (userGateways.isNotEmpty()) {
|
||||
ComposeUtils.CaptionText(text = stringResource(id = R.string.ipfsgw_caption_custom_gateways))
|
||||
CaptionText(text = stringResource(id = R.string.ipfsgw_caption_custom_gateways))
|
||||
}
|
||||
for (gatewayUrl in userGateways) {
|
||||
Row(
|
||||
|
@ -249,4 +253,4 @@ fun IpfsGatewaySettingsScreenPreview() {
|
|||
onBackClicked = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.Column
|
|||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
|
@ -74,9 +73,9 @@ fun RepoPreviewScreen(
|
|||
item {
|
||||
RepoPreviewHeader(state, onAddRepo, localeList)
|
||||
}
|
||||
if (state.fetchResult == null
|
||||
|| state.fetchResult is IsNewRepository
|
||||
|| state.fetchResult is IsNewRepoAndNewMirror
|
||||
if (state.fetchResult == null ||
|
||||
state.fetchResult is IsNewRepository ||
|
||||
state.fetchResult is IsNewRepoAndNewMirror
|
||||
) {
|
||||
item {
|
||||
Row(
|
||||
|
|
|
@ -76,11 +76,11 @@ class RepoUpdateWorker(
|
|||
fun scheduleOrCancel(context: Context) {
|
||||
val prefs = Preferences.get()
|
||||
val workManager = WorkManager.getInstance(context)
|
||||
val doUpdateChecks = prefs.updateInterval != UPDATE_INTERVAL_DISABLED
|
||||
&& !(prefs.overData == OVER_NETWORK_NEVER && prefs.overWifi == OVER_NETWORK_NEVER)
|
||||
val doUpdateChecks = prefs.updateInterval != UPDATE_INTERVAL_DISABLED &&
|
||||
!(prefs.overData == OVER_NETWORK_NEVER && prefs.overWifi == OVER_NETWORK_NEVER)
|
||||
if (doUpdateChecks) {
|
||||
val networkType = if (prefs.overData == OVER_NETWORK_ALWAYS
|
||||
&& prefs.overWifi == OVER_NETWORK_ALWAYS
|
||||
val networkType = if (prefs.overData == OVER_NETWORK_ALWAYS &&
|
||||
prefs.overWifi == OVER_NETWORK_ALWAYS
|
||||
) {
|
||||
NetworkType.CONNECTED
|
||||
} else {
|
||||
|
|
|
@ -1,18 +1,5 @@
|
|||
import net.ltgt.gradle.errorprone.CheckSeverity
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath "net.ltgt.gradle:gradle-errorprone-plugin:3.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "net.ltgt.errorprone"
|
||||
|
||||
dependencies {
|
||||
errorprone("com.google.errorprone:error_prone_core:2.24.1")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue