Skip to content

Commit

Permalink
fix: issue179 & issue173 - Fix r8 config and search validation (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
isuPatches authored Dec 28, 2022
1 parent c895237 commit 2f1b6d0
Show file tree
Hide file tree
Showing 34 changed files with 276 additions and 107 deletions.
10 changes: 5 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ android {
applicationIdSuffix = ".debug"
enableUnitTestCoverage = true
enableAndroidTestCoverage = true
isMinifyEnabled = false
isShrinkResources = false
isMinifyEnabled = System.getenv("MINIFY_DEBUG_BUILDS").toBoolean()
isShrinkResources = System.getenv("MINIFY_DEBUG_BUILDS").toBoolean()
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"$rootDir/proguard/r8-app-debug.pro"
Expand All @@ -72,8 +72,8 @@ android {
release {
enableUnitTestCoverage = false
enableAndroidTestCoverage = false
isMinifyEnabled = false
isShrinkResources = false
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"$rootDir/proguard/r8-app-release.pro"
Expand Down Expand Up @@ -123,7 +123,7 @@ android {
}

composeOptions {
kotlinCompilerExtensionVersion = Versions.ANDROIDX_COMPOSE
kotlinCompilerExtensionVersion = Versions.ANDROIDX_COMPOSE_COMPILER
}
}

Expand Down
38 changes: 19 additions & 19 deletions app/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ androidx.autofill:autofill:1.0.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.cardview:cardview:1.0.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.collection:collection-ktx:1.1.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.collection:collection:1.1.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.animation:animation-core:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.animation:animation:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.animation:animation-core:1.3.2=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.animation:animation:1.3.2=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.foundation:foundation-layout:1.2.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.foundation:foundation:1.2.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.material:material-icons-core:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.material:material-icons-extended:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.material:material-ripple:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.material:material:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.runtime:runtime-saveable:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.runtime:runtime:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-geometry:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-graphics:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-text:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-tooling-data:1.3.0=debugRuntimeClasspath
androidx.compose.ui:ui-tooling-preview:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-tooling:1.3.0=debugRuntimeClasspath
androidx.compose.ui:ui-unit:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-util:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui:1.3.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.material:material-icons-core:1.3.1=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.material:material-icons-extended:1.3.1=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.material:material-ripple:1.3.1=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.material:material:1.3.1=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.runtime:runtime-saveable:1.3.2=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.runtime:runtime:1.3.2=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-geometry:1.3.2=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-graphics:1.3.2=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-text:1.3.2=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-tooling-data:1.3.2=debugRuntimeClasspath
androidx.compose.ui:ui-tooling-preview:1.3.2=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-tooling:1.3.2=debugRuntimeClasspath
androidx.compose.ui:ui-unit:1.3.2=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui-util:1.3.2=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.compose.ui:ui:1.3.2=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.concurrent:concurrent-futures:1.0.0=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.constraintlayout:constraintlayout-solver:2.0.1=debugRuntimeClasspath,releaseRuntimeClasspath
androidx.constraintlayout:constraintlayout:2.0.1=debugRuntimeClasspath,releaseRuntimeClasspath
Expand Down Expand Up @@ -112,10 +112,10 @@ com.isupatches.android.wisefy:wifi:5.0.0=debugRuntimeClasspath,releaseRuntimeCla
com.isupatches.android.wisefy:wisefy:5.0.0=debugRuntimeClasspath,releaseRuntimeClasspath
javax.inject:javax.inject:1=debugRuntimeClasspath,releaseRuntimeClasspath
org.jacoco:org.jacoco.agent:0.8.8=debugRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=debugRuntimeClasspath,releaseRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.20=debugRuntimeClasspath,releaseRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21=debugRuntimeClasspath,releaseRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21=debugRuntimeClasspath,releaseRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=debugRuntimeClasspath,releaseRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:1.7.20=debugRuntimeClasspath,releaseRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4=debugRuntimeClasspath,releaseRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4=debugRuntimeClasspath,releaseRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=debugRuntimeClasspath,releaseRuntimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ internal fun MiscScreenContent(
rememberLauncherForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { result ->
if (result.all { it.value }) {
scope.launch {
@Suppress("MissingPermission")
viewModel.getSavedNetworks()
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.isupatches.android.wisefy.accesspoints.entities.AccessPointData
Expand All @@ -44,21 +45,37 @@ internal fun NearbyAccessPointsScreenContent(
accessPoints: () -> List<AccessPointUIData>
) {
WisefySampleTheme {
val listState = rememberLazyListState()
LazyColumn(
state = listState,
verticalArrangement = Arrangement.spacedBy(WisefySampleSizes.Large),
contentPadding = PaddingValues(
top = WisefySampleSizes.WisefySampleTopMargin,
bottom = WisefySampleSizes.WisefySampleBottomMargin,
start = WisefySampleSizes.WisefySampleHorizontalMargins,
end = WisefySampleSizes.WisefySampleHorizontalMargins
)
) {
items(accessPoints()) { accessPoint ->
@OptIn(ExperimentalFoundationApi::class)
Row(modifier = Modifier.animateItemPlacement()) {
AccessPointRow(accessPoint = accessPoint)
val accessPointsValue = accessPoints()
if (accessPointsValue.isNotEmpty()) {
val listState = rememberLazyListState()
LazyColumn(
state = listState,
verticalArrangement = Arrangement.spacedBy(WisefySampleSizes.Large),
contentPadding = PaddingValues(
top = WisefySampleSizes.WisefySampleTopMargin,
bottom = WisefySampleSizes.WisefySampleBottomMargin,
start = WisefySampleSizes.WisefySampleHorizontalMargins,
end = WisefySampleSizes.WisefySampleHorizontalMargins
)
) {
items(accessPointsValue) { accessPoint ->
@OptIn(ExperimentalFoundationApi::class)
Row(modifier = Modifier.animateItemPlacement()) {
AccessPointRow(accessPoint = accessPoint)
}
}
}
} else {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Row(
modifier = Modifier.padding(
top = WisefySampleSizes.WisefySampleTopMargin,
bottom = WisefySampleSizes.WisefySampleBottomMargin,
start = WisefySampleSizes.WisefySampleHorizontalMargins,
end = WisefySampleSizes.WisefySampleHorizontalMargins
)
) {
WisefySampleBodyLabel(stringResId = R.string.no_access_points_found)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ internal fun RemoveNetworkScreenContent(viewModel: RemoveNetworkViewModel) {
rememberLauncherForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { result ->
if (result.all { it.value }) {
scope.launch {
@Suppress("MissingPermission")
viewModel.removeNetwork()
}
} else {
Expand Down Expand Up @@ -101,7 +102,7 @@ private fun RemoveNetworkInputRows(
onTextChange = { newText ->
viewModel.onInputChanged(newText)
},
labelResId = R.string.regex_for_network,
labelResId = R.string.ssid_or_bssid_of_network,
error = when (currentInputState.networkInputValidityState) {
is RemoveNetworkInputValidityState.SSID.Invalid.Empty -> {
WisefySampleEditTextError(R.string.ssid_input_empty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ internal fun SearchScreenContent(viewModel: SearchViewModel) {
rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
if (isGranted) {
scope.launch {
@Suppress("MissingPermission")
viewModel.searchForAccessPoint()
}
} else {
Expand All @@ -81,6 +82,7 @@ internal fun SearchScreenContent(viewModel: SearchViewModel) {
rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
if (isGranted) {
scope.launch {
@Suppress("MissingPermission")
viewModel.searchForAccessPoints()
}
} else {
Expand All @@ -93,6 +95,7 @@ internal fun SearchScreenContent(viewModel: SearchViewModel) {
rememberLauncherForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { result ->
if (result.all { it.value }) {
scope.launch {
@Suppress("MissingPermission")
viewModel.searchForSavedNetwork()
}
} else {
Expand All @@ -105,6 +108,7 @@ internal fun SearchScreenContent(viewModel: SearchViewModel) {
rememberLauncherForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { result ->
if (result.all { it.value }) {
scope.launch {
@Suppress("MissingPermission")
viewModel.searchForSavedNetworks()
}
} else {
Expand All @@ -117,6 +121,7 @@ internal fun SearchScreenContent(viewModel: SearchViewModel) {
rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
if (isGranted) {
scope.launch {
@Suppress("MissingPermission")
viewModel.searchForSSID()
}
} else {
Expand All @@ -129,6 +134,7 @@ internal fun SearchScreenContent(viewModel: SearchViewModel) {
rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
if (isGranted) {
scope.launch {
@Suppress("MissingPermission")
viewModel.searchForSSIDs()
}
} else {
Expand Down Expand Up @@ -194,6 +200,12 @@ internal fun SearchScreenContent(viewModel: SearchViewModel) {
ssidType = { viewModel.uiState.value.ssidType },
onSSIDTypeChanged = { ssidType -> viewModel.onSSIDTypeChanged(ssidType) }
)
SearchScreenUseRegexForSearchInputRows(
useRegexForSearch = { viewModel.uiState.value.useRegexForSearch },
onUseRegexForSearchChanged = { useRegexForSearch ->
viewModel.onUseRegexForSearchChanged(useRegexForSearch)
}
)
SearchScreenReturnFullListInputRows(
returnFullList = { viewModel.uiState.value.returnFullList },
viewModel = viewModel
Expand Down Expand Up @@ -298,6 +310,43 @@ private fun SearchScreenSearchTypeInputRows(
}
}

@Composable
internal fun SearchScreenUseRegexForSearchInputRows(
useRegexForSearch: () -> Boolean,
onUseRegexForSearchChanged: (Boolean) -> Unit
) {
WisefySampleTheme {
Column {
val currentValue = useRegexForSearch()
Row {
WisefySampleSubHeaderLabel(
modifier = Modifier.padding(top = WisefySampleSizes.Large),
stringResId = R.string.use_regex_for_search
)
}
Row(
modifier = Modifier.padding(top = WisefySampleSizes.Medium),
verticalAlignment = Alignment.CenterVertically
) {
WisefySampleRadioButton(
isSelected = currentValue,
onClick = {
onUseRegexForSearchChanged(true)
}
)
WisefySampleBodyLabel(stringResId = R.string.yes)
WisefySampleRadioButton(
isSelected = !currentValue,
onClick = {
onUseRegexForSearchChanged(false)
}
)
WisefySampleBodyLabel(stringResId = R.string.no)
}
}
}
}

@Composable
private fun SearchScreenReturnFullListInputRows(
returnFullList: () -> Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal data class SearchUIState(
val inputState: SearchInputState,
val searchType: SearchType,
val ssidType: SSIDType,
val useRegexForSearch: Boolean,
val returnFullList: Boolean,
val filterDuplicates: Boolean,
val timeoutInSeconds: Int?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import kotlinx.coroutines.flow.map
private const val PREF_LAST_USED_NETWORK_INPUT = "last_used_network_input"
private const val PREF_SEARCH_TYPE = "search_type"
private const val PREF_SSID_TYPE = "ssid_type"
private const val PREF_USE_REGEX_FOR_SEARCH = "use_regex_for_search"
private const val PREF_RETURN_FULL_LIST = "return_full_list"
private const val PREF_FILTER_DUPLICATES = "filter_duplicates"
private const val PREF_TIMEOUT = "timeout"
Expand All @@ -41,13 +42,15 @@ internal interface SearchStore {
fun getLastUsedNetworkInput(): Flow<String>
fun getSearchType(): Flow<SearchType>
fun getSSIDType(): Flow<SSIDType>
fun shouldUseRegexForSearch(): Flow<Boolean>
fun shouldReturnFullList(): Flow<Boolean>
fun shouldFilterDuplicates(): Flow<Boolean>
fun getTimeout(): Flow<Int>

suspend fun setLastUsedNetworkInput(lastUsedNetworkInput: String)
suspend fun setSearchType(searchType: SearchType)
suspend fun setSSIDType(ssidType: SSIDType)
suspend fun setUseRegexForSearch(useRegexForSearch: Boolean)
suspend fun setReturnFullList(returnFullList: Boolean)
suspend fun setFilterDuplicates(filterDuplicates: Boolean)
suspend fun setTimeout(timeout: Int)
Expand All @@ -62,6 +65,7 @@ internal class DefaultSearchStore(
private val lastUsedNetworkInputKey = stringPreferencesKey(PREF_LAST_USED_NETWORK_INPUT)
private val searchTypeKey = intPreferencesKey(PREF_SEARCH_TYPE)
private val ssidTypeKey = intPreferencesKey(PREF_SSID_TYPE)
private val useRegexForSearchKey = booleanPreferencesKey(PREF_USE_REGEX_FOR_SEARCH)
private val returnFullListKey = booleanPreferencesKey(PREF_RETURN_FULL_LIST)
private val filterDuplicatesKey = booleanPreferencesKey(PREF_FILTER_DUPLICATES)
private val timeoutKey = intPreferencesKey(PREF_TIMEOUT)
Expand Down Expand Up @@ -119,6 +123,22 @@ internal class DefaultSearchStore(
}
}

/*
* Use regex for search
*/

override fun shouldUseRegexForSearch(): Flow<Boolean> {
return context.searchDataStore.data.map { preferences ->
preferences[useRegexForSearchKey] ?: false
}
}

override suspend fun setUseRegexForSearch(useRegexForSearch: Boolean) {
context.searchDataStore.edit { preferences ->
preferences[useRegexForSearchKey] = useRegexForSearch
}
}

/*
* Return full list
*/
Expand Down
Loading

0 comments on commit 2f1b6d0

Please sign in to comment.