Skip to content

Commit

Permalink
Ktlint fixes (auto)
Browse files Browse the repository at this point in the history
  • Loading branch information
nain-F49FF806 committed Aug 14, 2024
1 parent 371dda7 commit 92769a0
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 94 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
defaultConfig {
minSdk = rootProject.extra["minSdkVersion"] as Int
targetSdk = rootProject.extra["targetSdkVersion"] as Int
versionCode = 1723635000
versionCode = 1723649000
versionName = "2024.08.14"
applicationId = "alt.nainapps.aer"
vectorDrawables {
Expand Down Expand Up @@ -93,6 +93,7 @@ dependencies {
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.reorderable)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
Expand Down
49 changes: 29 additions & 20 deletions app/src/main/java/alt/nainapps/aer/config/ConfigurationActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
*/
package alt.nainapps.aer.config

import alt.nainapps.aer.R
import alt.nainapps.aer.config.password.ChangePasswordDialog
import alt.nainapps.aer.config.password.SetPasswordDialog
import alt.nainapps.aer.lock.LockStore
import alt.nainapps.aer.lock.UnlockActivity
import alt.nainapps.aer.shell.AnemoShell
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.CompoundButton
import android.widget.Switch
import android.widget.TextView
import alt.nainapps.aer.R
import alt.nainapps.aer.config.password.ChangePasswordDialog
import alt.nainapps.aer.config.password.SetPasswordDialog
import alt.nainapps.aer.lock.LockStore
import alt.nainapps.aer.lock.UnlockActivity
import alt.nainapps.aer.shell.AnemoShell
import java.util.function.Consumer

class ConfigurationActivity : Activity() {
Expand All @@ -40,15 +40,19 @@ class ConfigurationActivity : Activity() {
shortcutSwitch.isChecked = AnemoShell.isEnabled(application)
shortcutSwitch.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
AnemoShell.setEnabled(
application, isChecked
application,
isChecked,
)
}

changeLockView = findViewById(R.id.configuration_lock)
changeLockView!!.setText(
if (lockStore.isLocked
) R.string.configuration_storage_unlock
else R.string.configuration_storage_lock
) {
R.string.configuration_storage_unlock
} else {
R.string.configuration_storage_lock
},
)
changeLockView!!.setOnClickListener {
if (lockStore.isLocked) {
Expand Down Expand Up @@ -84,7 +88,8 @@ class ConfigurationActivity : Activity() {
passwordSetView!!.setText(R.string.configuration_password_change)
passwordSetView!!.setOnClickListener {
ChangePasswordDialog(
this, lockStore
this,
lockStore,
) { this.setupPasswordViews() }
.show()
}
Expand All @@ -93,7 +98,7 @@ class ConfigurationActivity : Activity() {
passwordSetView!!.setOnClickListener {
SetPasswordDialog(
this,
lockStore
lockStore,
) { this.setupPasswordViews() }.show()
}
}
Expand All @@ -102,13 +107,17 @@ class ConfigurationActivity : Activity() {
biometricSwitch!!.isEnabled = enableViews
}

private val onLockChanged = Consumer { isLocked: Boolean ->
passwordSetView!!.isEnabled = !isLocked
biometricSwitch!!.isEnabled = !isLocked
changeLockView!!.setText(
if (isLocked
) R.string.configuration_storage_unlock
else R.string.configuration_storage_lock
)
}
private val onLockChanged =
Consumer { isLocked: Boolean ->
passwordSetView!!.isEnabled = !isLocked
biometricSwitch!!.isEnabled = !isLocked
changeLockView!!.setText(
if (isLocked
) {
R.string.configuration_storage_unlock
} else {
R.string.configuration_storage_lock
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import java.nio.file.Files
import java.nio.file.Path
import kotlin.concurrent.Volatile

class HomeEnvironment private constructor(context: Context) {
val baseDir: Path = getSelectExternalFilesDir(context)?.toPath() ?:
context.filesDir.toPath() // internal
class HomeEnvironment private constructor(
context: Context,
) {
val baseDir: Path =
getSelectExternalFilesDir(context)?.toPath()
?: context.filesDir.toPath() // internal

init {
if (!Files.exists(baseDir)) {
Expand All @@ -24,16 +27,14 @@ class HomeEnvironment private constructor(context: Context) {
}
}

fun isRoot(path: Path): Boolean {
return baseDir == path
}
fun isRoot(path: Path): Boolean = baseDir == path

private fun getSelectExternalFilesDir(context: Context): File? {
val externalFilesDirs = context.getExternalFilesDirs(null)
// The first few (in forward order) may be on primary storage,
// so we traverse in reverse order to find first available externalFilesDir
for (i in externalFilesDirs.indices.reversed()) {
if (externalFilesDirs[i]!= null) {
if (externalFilesDirs[i] != null) {
if (Environment.getExternalStorageState(externalFilesDirs[i]) == Environment.MEDIA_MOUNTED) {
return externalFilesDirs[i]
}
Expand Down
Loading

0 comments on commit 92769a0

Please sign in to comment.