Skip to content

Commit

Permalink
Update kotlinter and change formatting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartuzen committed Jul 6, 2024
1 parent 0032f82 commit 14024bc
Show file tree
Hide file tree
Showing 127 changed files with 514 additions and 499 deletions.
9 changes: 5 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ root = true
max_line_length = 125
indent_size = 4
insert_final_newline = true
ij_kotlin_line_break_after_multiline_when_entry = false
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false
ktlint_experimental = enabled
ij_kotlin_line_break_after_multiline_when_entry = true

ktlint_code_style = intellij_idea
ktlint_standard_class-signature = disabled
ktlint_standard_function-expression-body = disabled
2 changes: 1 addition & 1 deletion app/src/main/java/dev/bartuzen/qbitcontroller/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class App : Application(), Configuration.Provider, ImageLoaderFactory {
lateinit var workerFactory: HiltWorkerFactory

@Inject
@Suppress("ktlint:standard:property-naming")
@Suppress("ktlint:standard:backing-property-naming")
lateinit var _settingsManager: Lazy<SettingsManager>
private val settingsManager: SettingsManager get() = _settingsManager.get()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import javax.inject.Singleton

@Singleton
class ConfigMigrator @Inject constructor(
@ApplicationContext private val context: Context
@ApplicationContext private val context: Context,
) {
private val currentVersion = 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import javax.inject.Singleton

@Singleton
class ServerManager @Inject constructor(
@ApplicationContext context: Context
@ApplicationContext context: Context,
) {
private val sharedPref = context.getSharedPreferences("servers", Context.MODE_PRIVATE)

Expand All @@ -23,7 +23,7 @@ class ServerManager @Inject constructor(
}

private fun readServerConfigs() = json.decodeFromString<Map<Int, ServerConfig>>(
sharedPref.getString(Keys.SERVER_CONFIGS, null) ?: "{}"
sharedPref.getString(Keys.SERVER_CONFIGS, null) ?: "{}",
).toSortedMap()

private val _serversFlow = MutableStateFlow(readServerConfigs())
Expand All @@ -38,9 +38,7 @@ class ServerManager @Inject constructor(
val serverConfigs = readServerConfigs()
val serverId = sharedPref.getInt(Keys.LAST_SERVER_ID, -1) + 1

val newServerConfig = serverConfig.copy(
id = serverId
)
val newServerConfig = serverConfig.copy(id = serverId)
serverConfigs[serverId] = newServerConfig

val isSuccess = sharedPref.edit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.inject.Singleton

@Singleton
class SettingsManager @Inject constructor(
@ApplicationContext context: Context
@ApplicationContext context: Context,
) {
private val sharedPref = context.getSharedPreferences("settings", Context.MODE_PRIVATE)

Expand All @@ -34,7 +34,7 @@ class SettingsManager @Inject constructor(
enum class Theme {
LIGHT,
DARK,
SYSTEM_DEFAULT
SYSTEM_DEFAULT,
}

enum class TorrentSort {
Expand All @@ -54,15 +54,15 @@ enum class TorrentSort {
TOTAL_LEECHES,
ADDITION_DATE,
COMPLETION_DATE,
LAST_ACTIVITY
LAST_ACTIVITY,
}

enum class SearchSort {
NAME,
SIZE,
SEEDERS,
LEECHERS,
SEARCH_ENGINE
SEARCH_ENGINE,
}

fun Theme.toDelegate() = when (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import javax.inject.Singleton
@Singleton
class AppNotificationManager @Inject constructor(
private val serverManager: ServerManager,
@ApplicationContext private val context: Context
@ApplicationContext private val context: Context,
) {
private val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

Expand Down Expand Up @@ -54,7 +54,7 @@ class AppNotificationManager @Inject constructor(
.setConstraints(
Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
.build(),
).build()

workManager.enqueueUniqueWork("torrent_downloaded", ExistingWorkPolicy.KEEP, work)
Expand All @@ -78,7 +78,7 @@ class AppNotificationManager @Inject constructor(
val downloadedChannel = NotificationChannel(
"channel_server_${serverConfig.id}_downloaded",
context.getString(R.string.notification_channel_download_completed),
NotificationManager.IMPORTANCE_HIGH
NotificationManager.IMPORTANCE_HIGH,
).apply {
group = "group_server_${serverConfig.id}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import javax.inject.Singleton
@Singleton
class TorrentDownloadedNotifier @Inject constructor(
@ApplicationContext private val context: Context,
private val serverManager: ServerManager
private val serverManager: ServerManager,
) {
private val json = Json {
ignoreUnknownKeys = true
Expand All @@ -39,7 +39,7 @@ class TorrentDownloadedNotifier @Inject constructor(
TorrentState.PAUSED_UP,
TorrentState.FORCED_UP,
TorrentState.QUEUED_UP,
TorrentState.CHECKING_UP
TorrentState.CHECKING_UP,
)

private val downloadingStates = listOf(
Expand All @@ -50,7 +50,7 @@ class TorrentDownloadedNotifier @Inject constructor(
TorrentState.META_DL,
TorrentState.FORCED_DL,
TorrentState.PAUSED_DL,
TorrentState.STALLED_DL
TorrentState.STALLED_DL,
)

private val notificationManager =
Expand Down Expand Up @@ -121,7 +121,7 @@ class TorrentDownloadedNotifier @Inject constructor(
context,
0,
torrentIntent,
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) PendingIntent.FLAG_IMMUTABLE else 0
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) PendingIntent.FLAG_IMMUTABLE else 0,
)

val notification = NotificationCompat.Builder(context, "channel_server_${serverId}_downloaded")
Expand Down Expand Up @@ -155,7 +155,7 @@ class TorrentDownloadedNotifier @Inject constructor(
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
} else {
PendingIntent.FLAG_UPDATE_CURRENT
}
},
)

val serverConfig = serverManager.getServer(serverId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TorrentDownloadedWorker @AssistedInject constructor(
private val requestManager: RequestManager,
private val serverManager: ServerManager,
private val settingsManager: SettingsManager,
private val notifier: TorrentDownloadedNotifier
private val notifier: TorrentDownloadedNotifier,
) : CoroutineWorker(appContext, workParams) {

override suspend fun doWork(): Result {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.inject.Singleton

@Singleton
class AddTorrentRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun createTorrent(
serverId: Int,
Expand All @@ -30,13 +30,13 @@ class AddTorrentRepository @Inject constructor(
skipHashChecking: Boolean,
isAutoTorrentManagementEnabled: Boolean?,
isSequentialDownloadEnabled: Boolean,
isFirstLastPiecePrioritized: Boolean
isFirstLastPiecePrioritized: Boolean,
): RequestResult<String> {
val filePart = if (fileBytes != null) {
MultipartBody.Part.createFormData(
"filename",
"torrent",
fileBytes.toRequestBody("application/x-bittorrent".toMediaTypeOrNull(), 0)
fileBytes.toRequestBody("application/x-bittorrent".toMediaTypeOrNull(), 0),
)
} else {
null
Expand All @@ -60,7 +60,7 @@ class AddTorrentRepository @Inject constructor(
skipHashChecking,
isAutoTorrentManagementEnabled,
isSequentialDownloadEnabled,
isFirstLastPiecePrioritized
isFirstLastPiecePrioritized,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class TorrentListRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getMainData(serverId: Int) = requestManager.request(serverId) { service ->
service.getMainData()
Expand Down Expand Up @@ -54,7 +54,7 @@ class TorrentListRepository @Inject constructor(
name: String,
savePath: String,
downloadPathEnabled: Boolean?,
downloadPath: String
downloadPath: String,
) = requestManager.request(serverId) { service ->
service.createCategory(name, savePath, downloadPathEnabled, downloadPath)
}
Expand All @@ -69,7 +69,7 @@ class TorrentListRepository @Inject constructor(
name: String,
savePath: String,
downloadPathEnabled: Boolean?,
downloadPath: String
downloadPath: String,
) = requestManager.request(serverId) { service ->
service.editCategory(name, savePath, downloadPathEnabled, downloadPath)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class LogRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getLog(serverId: Int) = requestManager.request(serverId) { service ->
service.getLog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class EditRssRuleRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getRssRules(serverId: Int) = requestManager.request(serverId) { service ->
service.getRssRules()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class RssArticlesRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getRssFeeds(serverId: Int) = requestManager.request(serverId) { service ->
service.getRssFeeds(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class RssFeedRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getRssFeeds(serverId: Int) = requestManager.request(serverId) { service ->
service.getRssFeeds(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class RssRulesRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getRssRules(serverId: Int) = requestManager.request(serverId) { service ->
service.getRssRules()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class SearchPluginsRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getPlugins(serverId: Int) = requestManager.request(serverId) { service ->
service.getPlugins()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class SearchResultRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun startSearch(serverId: Int, pattern: String, category: String, plugins: String) =
requestManager.request(serverId) { service ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class SearchStartRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getPlugins(serverId: Int) = requestManager.request(serverId) { service ->
service.getPlugins()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class TorrentCategoryRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getCategories(serverId: Int) = requestManager.request(serverId) { service ->
service.getCategories()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import javax.inject.Singleton

@Singleton
class TorrentFilesRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getFiles(serverId: Int, hash: String) = requestManager.request(serverId) { service ->
service.getFiles(hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class TorrentOverviewRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getTorrent(serverId: Int, hash: String) = requestManager.request(serverId) { service ->
service.getTorrentList(hash)
Expand Down Expand Up @@ -97,7 +97,7 @@ class TorrentOverviewRepository @Inject constructor(
hash: String,
ratioLimit: Double,
seedingTimeLimit: Int,
inactiveSeedingTimeLimit: Int
inactiveSeedingTimeLimit: Int,
) = requestManager.request(serverId) { service ->
service.setShareLimit(hash, ratioLimit, seedingTimeLimit, inactiveSeedingTimeLimit)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class TorrentPeersRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getPeers(serverId: Int, hash: String) = requestManager.request(serverId) { service ->
service.getPeers(hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class TorrentPiecesRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getPieces(serverId: Int, hash: String) = requestManager.request(serverId) { service ->
service.getTorrentPieces(hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class TorrentTagsRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getTags(serverId: Int) = requestManager.request(serverId) { service ->
service.getTags()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class TorrentTrackersRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getTrackers(serverId: Int, hash: String) = requestManager.request(serverId) { service ->
service.getTorrentTrackers(hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.Singleton

@Singleton
class TorrentWebSeedsRepository @Inject constructor(
private val requestManager: RequestManager
private val requestManager: RequestManager,
) {
suspend fun getWebSeeds(serverId: Int, hash: String) = requestManager.request(serverId) { service ->
service.getWebSeeds(hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ data class Article(
val torrentUrl: String,
val isRead: Boolean,
val date: Long,
val path: List<String>
val path: List<String>,
)
Loading

0 comments on commit 14024bc

Please sign in to comment.