Skip to content

Commit

Permalink
Merge pull request #1 from zacharee/master
Browse files Browse the repository at this point in the history
Fork Sync: Update from parent repository
  • Loading branch information
github-actions[bot] authored Apr 21, 2024
2 parents dd2b9c7 + 25e0eae commit 0533488
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 78 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "11"
jvmTarget = "17"
}
buildFeatures {
compose = true
Expand Down
27 changes: 19 additions & 8 deletions app/src/main/java/tk/zwander/wifilist/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.expandIn
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkOut
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
Expand Down Expand Up @@ -57,6 +61,7 @@ import tk.zwander.wifilist.util.Preferences.cachedInfo
import tk.zwander.wifilist.util.Preferences.updateCachedInfo
import tk.zwander.wifilist.util.hasShizukuPermission
import tk.zwander.wifilist.util.launchUrl
import tk.zwander.wifilist.util.plus

class MainActivity : AppCompatActivity(),
Shizuku.OnRequestPermissionResultListener,
Expand Down Expand Up @@ -274,19 +279,21 @@ fun MainContent(networks: List<WifiConfiguration>) {
val exportLaunchers = rememberExportChoiceLaunchers(choices = exportChoices)

WiFiListTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize()
.navigationBarsPadding()
.imePadding(),
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
Scaffold(
bottomBar = {
BottomAppBar(
modifier = Modifier.fillMaxWidth(),
modifier = Modifier.fillMaxWidth()
.imePadding(),
) {
AnimatedVisibility(visible = !searchExpanded) {
AnimatedVisibility(
visible = !searchExpanded,
enter = fadeIn() + expandIn(expandFrom = Alignment.CenterStart),
exit = fadeOut() + shrinkOut(shrinkTowards = Alignment.CenterStart),
) {
Text(
text = stringResource(id = R.string.saved_wifi_networks),
modifier = Modifier.padding(start = 16.dp),
Expand All @@ -312,7 +319,11 @@ fun MainContent(networks: List<WifiConfiguration>) {
tint = MaterialTheme.colorScheme.onSurface,
)

AnimatedVisibility(visible = !searchExpanded) {
AnimatedVisibility(
visible = !searchExpanded,
enter = fadeIn() + expandIn(expandFrom = Alignment.CenterEnd),
exit = fadeOut() + shrinkOut(shrinkTowards = Alignment.CenterEnd),
) {
IconButton(onClick = { showingPopup = !showingPopup }) {
Icon(
imageVector = Icons.Default.Menu,
Expand All @@ -334,7 +345,7 @@ fun MainContent(networks: List<WifiConfiguration>) {
},
) { padding ->
LazyVerticalStaggeredGrid(
contentPadding = padding,
contentPadding = padding + PaddingValues(horizontal = 8.dp),
columns = StaggeredGridCells.Adaptive(minSize = 400.dp),
) {
items(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package tk.zwander.wifilist.ui.components

import androidx.compose.animation.Crossfade
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.expandIn
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkOut
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
Expand All @@ -31,39 +37,43 @@ fun ExpandableSearchView(
expandedInitially: Boolean = false,
tint: Color = MaterialTheme.colorScheme.onPrimary
) {
val (expanded, onExpandedChanged) = remember {
var expanded by remember {
mutableStateOf(expandedInitially)
}

Crossfade(
targetState = expanded,
modifier = Modifier.animateContentSize(),
label = "SearchIconCrossfade",
) { isSearchFieldVisible ->
Box(
contentAlignment = Alignment.CenterStart,
modifier = modifier
.fillMaxHeight()
Box(
contentAlignment = Alignment.CenterStart,
modifier = modifier
.fillMaxHeight(),
) {
AnimatedVisibility(
visible = expanded,
enter = fadeIn() + expandIn(expandFrom = Alignment.CenterEnd),
exit = fadeOut() + shrinkOut(shrinkTowards = Alignment.CenterEnd),
) {
when (isSearchFieldVisible) {
true -> ExpandedSearchView(
searchDisplay = searchDisplay,
onSearchDisplayChanged = onSearchDisplayChanged,
onSearchDisplayClosed = onSearchDisplayClosed,
onExpandedChanged = onExpandedChanged,
tint = tint
)
ExpandedSearchView(
searchDisplay = searchDisplay,
onSearchDisplayChanged = onSearchDisplayChanged,
onSearchDisplayClosed = onSearchDisplayClosed,
onExpandedChanged = { expanded = it },
tint = tint,
)
}

false -> CollapsedSearchView(
onExpandedChanged = {
onExpandedChanged(it)
if (it) {
onSearchDisplayOpened()
}
},
tint = tint
)
}
AnimatedVisibility(
visible = !expanded,
enter = fadeIn(),
exit = fadeOut(),
) {
CollapsedSearchView(
onExpandedChanged = {
expanded = it
if (it) {
onSearchDisplayOpened()
}
},
tint = tint,
)
}
}
}
Expand Down Expand Up @@ -118,17 +128,20 @@ fun ExpandedSearchView(
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically
) {
IconButton(onClick = {
onExpandedChanged(false)
onSearchDisplayClosed()
keyboardController?.hide()
}) {
IconButton(
onClick = {
onExpandedChanged(false)
onSearchDisplayClosed()
keyboardController?.hide()
},
) {
Icon(
painter = painterResource(id = R.drawable.ic_back),
contentDescription = stringResource(id = R.string.back),
tint = tint
tint = tint,
)
}

TextField(
value = searchDisplay,
onValueChange = {
Expand All @@ -147,15 +160,34 @@ fun ExpandedSearchView(
keyboardActions = KeyboardActions(
onDone = {
focusManager.clearFocus()
}
},
),
colors = TextFieldDefaults.colors(
focusedContainerColor = Color.Transparent,
unfocusedContainerColor = Color.Transparent,
disabledContainerColor = Color.Transparent,
errorContainerColor = Color.Transparent,
),
singleLine = true
singleLine = true,
trailingIcon = {
IconButton(
onClick = {
onSearchDisplayChanged("")
},
enabled = searchDisplay.isNotEmpty(),
) {
val iconColor by animateColorAsState(
targetValue = if (searchDisplay.isNotEmpty()) tint else tint.copy(alpha = LocalContentColor.current.alpha),
label = "SearchClearIconColor",
)

Icon(
imageVector = Icons.Default.Clear,
contentDescription = stringResource(id = R.string.clear),
tint = iconColor,
)
}
},
)
}
}
11 changes: 6 additions & 5 deletions app/src/main/java/tk/zwander/wifilist/ui/components/WiFiCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ fun WiFiCard(
) {
val cbm = LocalClipboardManager.current
val key = config.simpleKey ?: stringResource(id = R.string.no_password)
val securityParams = config.securityParamsObj
val insecure = securityParams?.type == ExportSecurityType.OPEN
val hasKey = config.simpleKey != null

Card(
modifier = modifier,
Expand All @@ -49,8 +52,6 @@ fun WiFiCard(
Row(
verticalAlignment = Alignment.CenterVertically,
) {
val insecure = config.authType == WifiConfiguration.KeyMgmt.NONE

Icon(
painter = painterResource(id = if (insecure) R.drawable.ic_unlocked else R.drawable.ic_locked),
contentDescription = null,
Expand All @@ -70,7 +71,7 @@ fun WiFiCard(

FlowRow(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceAround,
horizontalArrangement = Arrangement.SpaceBetween,
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
TwoLineText(
Expand All @@ -84,10 +85,10 @@ fun WiFiCard(
TwoLineText(
label = stringResource(id = R.string.password),
value = key,
secure = config.authType != WifiConfiguration.KeyMgmt.NONE,
secure = hasKey,
)

if (config.authType != WifiConfiguration.KeyMgmt.NONE) {
if (hasKey) {
IconButton(
onClick = {
cbm.setClip(ClipEntry(ClipData.newPlainText(config.SSID, key)))
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/tk/zwander/wifilist/util/PaddingValues.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package tk.zwander.wifilist.util

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.calculateEndPadding
import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.ui.unit.LayoutDirection

// https://stackoverflow.com/a/77030528/5496177
operator fun PaddingValues.plus(other: PaddingValues): PaddingValues = PaddingValues(
start = this.calculateStartPadding(LayoutDirection.Ltr) +
other.calculateStartPadding(LayoutDirection.Ltr),
top = this.calculateTopPadding() + other.calculateTopPadding(),
end = this.calculateEndPadding(LayoutDirection.Ltr) +
other.calculateEndPadding(LayoutDirection.Ltr),
bottom = this.calculateBottomPadding() + other.calculateBottomPadding(),
)
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<string name="plmn">PLMN</string>
<string name="realm">Realm</string>
<string name="cert_suite">Cert Suite</string>
<string name="clear">Clear</string>

<string name="menu">Menu</string>
<string name="patreon">Patreon</string>
Expand Down
10 changes: 1 addition & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
buildscript {
repositories {
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}

plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.bugsnag) apply false
alias(libs.plugins.kotlin) apply false
}

tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
delete(rootProject.layout.buildDirectory)
}
22 changes: 11 additions & 11 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
[versions]
activityCompose = "1.8.2"
androidGradlePlugin = "8.2.2"
activityCompose = "1.9.0"
androidGradlePlugin = "8.3.2"
shizuku = "13.1.5"
bugsnagAndroid = "6.4.0"
bugsnagGradlePlugin = "8.1.0"
compose = "1.7.0-alpha06"
composeCompiler = "1.5.11"
coreKtx = "1.12.0"
datastorePreferences = "1.1.0-rc01"
compose = "1.7.0-alpha07"
composeCompiler = "1.5.12"
compose-material3 = "1.3.0-alpha05"
coreKtx = "1.13.0"
datastorePreferences = "1.1.0"
fastcsv = "3.1.0"
fragmentKtx = "1.6.2"
fragmentKtx = "1.8.0-alpha02"
gson = "2.10.1"
hiddenapibypass = "4.3"
kotlin = "1.9.23"
lifecycleRuntimeKtx = "2.7.0"
material = "1.11.0"
material3 = "1.2.1"
lifecycleRuntimeKtx = "2.8.0-beta01"
material = "1.13.0-alpha01"
patreonsupportersretrieval = "8436bbdbdc"
relinker = "1.4.5"

[libraries]
activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
bugsnag-android = { module = "com.bugsnag:bugsnag-android", version.ref = "bugsnagAndroid" }
compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "composeCompiler" }
compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "material3" }
compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" }
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" }
Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Aug 07 13:47:43 EDT 2021
#Sun Apr 21 17:23:04 EDT 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("UnstableApiUsage")

pluginManagement {
repositories {
gradlePluginPortal()
Expand All @@ -11,7 +13,6 @@ dependencyResolutionManagement {
google()
mavenCentral()
maven("https://jitpack.io")
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}
rootProject.name = "WiFiList"
Expand Down

0 comments on commit 0533488

Please sign in to comment.