Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Detekt autofix #2580

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 3 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ android {
isMinifyEnabled = false
isShrinkResources = false


isDebuggable = true
isDefault = true

Expand Down Expand Up @@ -124,15 +123,15 @@ android {
}

packagingOptions {
//Exclude this files so Jetpack Compose UI tests can build
// Exclude this files so Jetpack Compose UI tests can build
resources.excludes.add("META-INF/AL2.0")
resources.excludes.add("META-INF/LGPL2.1")
//-------------------------------------------------------
// -------------------------------------------------------
}

testOptions {
unitTests.all {
//Required by Kotest
// Required by Kotest
it.useJUnitPlatform()
}
}
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/java/com/ivy/wallet/AppModuleDI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ object AppModuleDI {
return SharedPrefs(appContext)
}


@Provides
@Singleton
fun provideIvyRoomDatabase(
Expand Down Expand Up @@ -83,7 +82,6 @@ object AppModuleDI {
fun provideTrnRecurringRuleDao(db: IvyRoomDatabase): PlannedPaymentRuleDao =
db.plannedPaymentRuleDao()


@Provides
fun provideWalletAccountLogic(
transactionDao: TransactionDao,
Expand Down Expand Up @@ -235,12 +233,11 @@ object AppModuleDI {
)
}


@Provides
fun loanTransactionsLogic(loanTransactionsCore: LoanTransactionsCore): LoanTransactionsLogic {
return LoanTransactionsLogic(
Loan = LTLoanMapper(ltCore = loanTransactionsCore),
LoanRecord = LTLoanRecordMapper(ltCore = loanTransactionsCore)
)
}
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/ivy/wallet/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object Constants {
const val URL_GITHUB_SPONSORS =
"https://github.com/sponsors/Ivy-Apps"

const val USER_INACTIVITY_TIME_LIMIT = 60 //Time in seconds
const val USER_INACTIVITY_TIME_LIMIT = 60 // Time in seconds

const val SWIPE_DOWN_THRESHOLD_OPEN_MORE_MENU = 200

Expand All @@ -42,4 +42,4 @@ object Constants {
const val SUPPORT_EMAIL = "[email protected]"

const val PAGE_TRANSACTIONS_SIZE = 100
}
}
5 changes: 2 additions & 3 deletions app/src/main/java/com/ivy/wallet/IvyAndroidApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class IvyAndroidApp : Application(), Configuration.Provider {
lateinit var appContext: Context
}


@Inject
lateinit var workerFactory: HiltWorkerFactory

Expand All @@ -49,7 +48,7 @@ fun stringRes(
@StringRes id: Int,
vararg args: String
): String {
//I don't want strings.xml to handle something different than String at this point
// I don't want strings.xml to handle something different than String at this point
return IvyAndroidApp.appContext.getString(id, *args)
}

Expand All @@ -67,4 +66,4 @@ fun refreshWidget(widgetReceiver: Class<out AppWidgetProvider>) {
updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)

IvyAndroidApp.appContext.sendBroadcast(updateIntent)
}
}
11 changes: 5 additions & 6 deletions app/src/main/java/com/ivy/wallet/android/billing/IvyBilling.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import com.ivy.wallet.utils.sendToCrashlytics
import timber.log.Timber
import javax.inject.Inject

class IvyBilling @Inject constructor(

) {
class IvyBilling @Inject constructor() {
companion object {
private const val MONTHLY_V1 = "monthly_v1"
private const val SIX_MONTH_V1 = "six_month_v1"
Expand Down Expand Up @@ -69,7 +67,6 @@ class IvyBilling @Inject constructor(
} else {
onError(billingResult.responseCode, billingResult.debugMessage)
}

}

billingClient = BillingClient.newBuilder(activity)
Expand Down Expand Up @@ -214,8 +211,10 @@ class IvyBilling @Inject constructor(
.build()
)
}
Timber.i("Acknowledge purchase result, code=${acknowledgeResult.responseCode}: ${acknowledgeResult.debugMessage}")
Timber.i(
"Acknowledge purchase result, code=${acknowledgeResult.responseCode}: ${acknowledgeResult.debugMessage}"
)
}
}
}
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/ivy/wallet/android/billing/Plan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ data class Plan(
} catch (e: Exception) {
return null
}

}

fun freePeriod(): String = when (skuDetails.freeTrialPeriod) {
Expand All @@ -41,4 +40,4 @@ data class Plan(
val amount: Double,
val currency: String
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.ivy.wallet.android.billing

enum class PlanType {
MONTHLY, SIX_MONTH, YEARLY, LIFETIME
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import androidx.core.app.NotificationCompat
class IvyNotification(
context: Context,
val ivyChannel: IvyNotificationChannel
) : NotificationCompat.Builder(context, ivyChannel.channelId)
) : NotificationCompat.Builder(context, ivyChannel.channelId)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ enum class IvyNotificationChannel(
bypassDnd = false
);


@SuppressLint("WrongConstant")
fun create(context: Context): NotificationChannel {
// Create the NotificationChannel, but only on API 26+ because
Expand All @@ -40,4 +39,4 @@ enum class IvyNotificationChannel(
channel.setBypassDnd(false)
return channel
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class NotificationService @Inject constructor(
return ivyNotification
}


fun showNotification(
notification: NotificationCompat.Builder,
notificationId: Int
Expand All @@ -53,4 +52,4 @@ class NotificationService @Inject constructor(
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.cancel(notificationId)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class GitHubAutoBackupManager @Inject constructor(

fun scheduleAutoBackups() {
val dailyWorkRequest = PeriodicWorkRequestBuilder<GitHubBackupWorker>(
6, TimeUnit.HOURS
6,
TimeUnit.HOURS
).setInitialDelay(30, TimeUnit.MINUTES)
.setConstraints(
Constraints.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ class GitHubBackup @Inject constructor(
get() = "Failed to commit: $error."
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import kotlinx.serialization.Serializable
import timber.log.Timber
import javax.inject.Inject


class GitHubClient @Inject constructor(
private val httpClient: Lazy<HttpClient>,
) {
Expand Down Expand Up @@ -138,7 +137,6 @@ class GitHubClient @Inject constructor(
githubToken(credentials)
}
}.body<GitHubFileResponse>()

}) {
null
}
Expand All @@ -157,4 +155,4 @@ class GitHubClient @Inject constructor(
): String {
return "https://api.github.com/repos/${credentials.owner}/${credentials.repo}/contents/$path"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ data class GitHubCredentials(
val owner: String,
val repo: String,
val gitHubPAT: String,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,3 @@ class GitHubCredentialsManager @Inject constructor(
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,11 @@ private fun LastBackup(
fontWeight = FontWeight.Bold,
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Start,
color = if (backup.indicateDanger)
MaterialTheme.colorScheme.error else LocalContentColor.current
color = if (backup.indicateDanger) {
MaterialTheme.colorScheme.error
} else {
LocalContentColor.current
}
)
Spacer(modifier = Modifier.width(12.dp))
val uriHandler = LocalUriHandler.current
Expand Down Expand Up @@ -217,4 +220,4 @@ private fun GitHubIcon(
contentScale = ContentScale.Fit,
colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ private fun WarningCardInfo() {
val text = buildAnnotatedString {
append(
"To ensure Ivy Wallet can automatically backup your data you must do the below:" +
"\n" +
"\n" +
"1. Disable "
"\n" +
"\n" +
"1. Disable "
)

withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)) {
Expand All @@ -86,7 +86,7 @@ private fun WarningCardInfo() {

append(
" for this app in the app's settings.\n" +
"2. In some mobile models like Xiaomi and Vivo the "
"2. In some mobile models like Xiaomi and Vivo the "
)

withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,4 @@ private fun ColumnScope.HeaderInfo() {
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Start,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ fun GitHubBackupStatus(
val status by viewModel.backupStatus.collectAsState()
if (status == null) return


when (val stat = status) {
is GitHubBackupStatus.Error -> {
Spacer(modifier = Modifier.height(8.dp))
Expand Down Expand Up @@ -71,4 +70,4 @@ fun GitHubBackupStatus(

null -> {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class GitHubBackupViewModel @Inject constructor(
private val backupLogic: BackupLogic,
) : ViewModel() {


val enabled = gitHubBackup.enabled

val lastBackupInfo: Flow<LastBackupInfo?> = gitHubBackup.lastBackupTime.map { instant ->
Expand All @@ -46,8 +45,9 @@ class GitHubBackupViewModel @Inject constructor(
indicateDanger = Instant.now().epochSecond - instant.epochSecond > H24_IN_SECONDS,
)
}
} else null

} else {
null
}
}

val backupStatus = MutableStateFlow<GitHubBackupStatus?>(null)
Expand Down Expand Up @@ -106,7 +106,7 @@ class GitHubBackupViewModel @Inject constructor(
}

private fun GitHubCredentials.toRepoUrl(): String {
return "https://github.com/${owner}/${repo}"
return "https://github.com/$owner/$repo"
}

private var backupImportInProgress = false
Expand Down Expand Up @@ -146,8 +146,7 @@ class GitHubBackupViewModel @Inject constructor(
).show()
}


companion object {
private const val H24_IN_SECONDS = 86400
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ivy.wallet.backup.github.ui


sealed interface GitHubBackupStatus {
object Loading : GitHubBackupStatus
data class Error(val error: String) : GitHubBackupStatus
Expand All @@ -15,4 +14,4 @@ data class GitHubBackupInput(
data class LastBackupInfo(
val time: String,
val indicateDanger: Boolean
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ object EncryptedSharedPrefsModule {
object EncryptedPrefsKeys {
@Deprecated("Use DataStoreKeys.GITHUB_PAT instead")
const val BACKUP_GITHUB_PAT = "github_backup_pat"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ object DatastoreKeys {
val GITHUB_PAT = stringPreferencesKey("github_backup_pat")
val GITHUB_LAST_BACKUP_EPOCH_SEC =
longPreferencesKey("github_backup_last_backup_time_epoch_sec")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ class AccTrnsAct @Inject constructor(
val range: ClosedTimeRange
)
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class AccountByIdAct @Inject constructor(
private val accountDao: AccountDao
) : FPAction<UUID, Account?>() {
override suspend fun UUID.compose(): suspend () -> Account? = suspend {
this //accountId
this // accountId
} then accountDao::findById then {
it?.toDomain()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class AccountsAct @Inject constructor(
override suspend fun Unit.compose(): suspend () -> List<Account> = suspend {
io { accountDao.findAll().map { it.toDomain() } }
}
}
}
Loading