Skip to content

Commit

Permalink
issue149 & issue153 - Add BSSID and Android S support (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
isuPatches authored Dec 21, 2021
1 parent a2690b9 commit f1deae7
Show file tree
Hide file tree
Showing 96 changed files with 1,560 additions and 829 deletions.
21 changes: 5 additions & 16 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import com.isupatches.android.wisefy.build.BuildVersions
import com.isupatches.android.wisefy.build.Dependencies
import com.isupatches.android.wisefy.build.Versions
import com.isupatches.android.wisefy.build.dagger
import com.isupatches.android.wisefy.build.debug
import com.isupatches.android.wisefy.build.navigation
import com.isupatches.android.wisefy.build.release
import java.util.Properties

plugins {
Expand Down Expand Up @@ -71,30 +69,21 @@ android {
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "${JavaVersion.VERSION_1_8}"
}

buildFeatures {
viewBinding = true
}

jacoco {
version = Versions.JACOCO
testCoverage {
jacocoVersion = Versions.JACOCO
}

lintOptions {
lint {
isCheckAllWarnings = true
isShowAll = true
isExplainIssues = true
isAbortOnError = true
isWarningsAsErrors = true
disable("UnusedIds")
disable("UnusedIds", "ConvertToWebp")
}
}

Expand All @@ -103,7 +92,7 @@ dependencies {
* Toggle these to test release binary vs. source code
*/
implementation(project(":wisefy"))
// implementation("com.isupatches.android:wisefy:5.0.0-RC1") {
// implementation("com.isupatches.android:wisefy:5.0.0-RC2") {
// isChanging = true
// }

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

<!-- Permission to search for networks -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
Expand All @@ -26,6 +27,7 @@

<activity android:name="com.isupatches.android.wisefy.sample.ui.main.MainActivity"
android:screenOrientation="portrait"
android:exported="true"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import androidx.activity.result.ActivityResultLauncher
import androidx.annotation.RequiresApi
import androidx.annotation.RequiresPermission
import com.isupatches.android.wisefy.WisefyApi
import com.isupatches.android.wisefy.addnetwork.entities.OpenNetworkData
import com.isupatches.android.wisefy.addnetwork.entities.WPA2NetworkData
import com.isupatches.android.wisefy.addnetwork.entities.WPA3NetworkData
import com.isupatches.android.wisefy.addnetwork.entities.AddOpenNetworkRequest
import com.isupatches.android.wisefy.addnetwork.entities.AddWPA2NetworkRequest
import com.isupatches.android.wisefy.addnetwork.entities.AddWPA3NetworkRequest
import com.isupatches.android.wisefy.callbacks.AddNetworkCallbacks
import com.isupatches.android.wisefy.sample.internal.scaffolding.BaseModel
import javax.inject.Inject
Expand Down Expand Up @@ -88,7 +88,7 @@ internal class DefaultAddNetworkModel @Inject constructor(
callbacks: AddNetworkCallbacks?
) {
wisefy.addOpenNetwork(
data = OpenNetworkData.Ssid(ssid = ssid),
request = AddOpenNetworkRequest.Ssid(ssid = ssid),
callbacks = callbacks
)
}
Expand All @@ -101,7 +101,7 @@ internal class DefaultAddNetworkModel @Inject constructor(
callbacks: AddNetworkCallbacks?
) {
wisefy.addOpenNetwork(
data = OpenNetworkData.SsidAndActivityResultLauncher(
request = AddOpenNetworkRequest.SsidAndActivityResultLauncher(
ssid = ssid,
activityResultLauncher = activityResultLauncher
),
Expand All @@ -116,7 +116,7 @@ internal class DefaultAddNetworkModel @Inject constructor(
callbacks: AddNetworkCallbacks?
) {
wisefy.addWPA2Network(
data = WPA2NetworkData.SsidAndPassphrase(
request = AddWPA2NetworkRequest.SsidAndPassphrase(
ssid = ssid,
passphrase = passphrase
),
Expand All @@ -133,7 +133,7 @@ internal class DefaultAddNetworkModel @Inject constructor(
callbacks: AddNetworkCallbacks?
) {
wisefy.addWPA2Network(
data = WPA2NetworkData.SsidPassphraseAndActivityResultLauncher(
request = AddWPA2NetworkRequest.SsidPassphraseAndActivityResultLauncher(
ssid = ssid,
passphrase = passphrase,
activityResultLauncher = activityResultLauncher
Expand All @@ -150,7 +150,7 @@ internal class DefaultAddNetworkModel @Inject constructor(
callbacks: AddNetworkCallbacks?
) {
wisefy.addWPA3Network(
data = WPA3NetworkData.SsidAndPassphrase(
request = AddWPA3NetworkRequest.SsidAndPassphrase(
ssid = ssid,
passphrase = passphrase
),
Expand All @@ -167,7 +167,7 @@ internal class DefaultAddNetworkModel @Inject constructor(
callbacks: AddNetworkCallbacks?
) {
wisefy.addWPA3Network(
data = WPA3NetworkData.SsidPassphraseAndActivityResultLauncher(
request = AddWPA3NetworkRequest.SsidPassphraseAndActivityResultLauncher(
ssid = ssid,
passphrase = passphrase,
activityResultLauncher = activityResultLauncher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import android.view.ViewGroup
import androidx.annotation.VisibleForTesting
import com.isupatches.android.viewglu.paste
import com.isupatches.android.wisefy.accesspoints.entities.AccessPointData
import com.isupatches.android.wisefy.frequency.entities.FrequencyData
import com.isupatches.android.wisefy.networkinfo.entities.CurrentNetworkData
import com.isupatches.android.wisefy.networkinfo.entities.CurrentNetworkInfoData
import com.isupatches.android.wisefy.networkinfo.entities.IPData
import com.isupatches.android.wisefy.sample.R
import com.isupatches.android.wisefy.sample.databinding.FragmentMiscBinding
import com.isupatches.android.wisefy.sample.internal.base.BaseFragment
Expand All @@ -50,9 +52,9 @@ internal interface MiscView {
fun displayNoCurrentNetwork()
fun displayCurrentNetworkInfo(currentNetworkInfo: CurrentNetworkInfoData)
fun displayNoCurrentNetworkInfo()
fun displayFrequency(frequency: Int)
fun displayFrequency(frequency: FrequencyData)
fun displayFailureRetrievingFrequency()
fun displayIP(ip: String)
fun displayIP(ip: IPData)
fun displayFailureRetrievingIP()
fun displayNearbyAccessPoints(accessPoints: List<AccessPointData>)
fun displayNoAccessPointsFound()
Expand Down Expand Up @@ -157,16 +159,16 @@ internal class MiscFragment : BaseFragment(), MiscView {
displayInfo(R.string.no_current_network_info, R.string.wisefy_action_result)
}

override fun displayFrequency(frequency: Int) {
displayInfo(getString(R.string.frequency_args, frequency), R.string.wisefy_action_result)
override fun displayFrequency(frequency: FrequencyData) {
displayInfo(getString(R.string.frequency_args, frequency.value), R.string.wisefy_action_result)
}

override fun displayFailureRetrievingFrequency() {
displayInfo(R.string.failure_retrieving_frequency, R.string.wisefy_action_result)
}

override fun displayIP(ip: String) {
displayInfo(getString(R.string.ip_args, ip), R.string.wisefy_action_result)
override fun displayIP(ip: IPData) {
displayInfo(getString(R.string.ip_args, ip.ip), R.string.wisefy_action_result)
}

override fun displayFailureRetrievingIP() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.os.Build
import androidx.annotation.RequiresApi
import androidx.annotation.RequiresPermission
import com.isupatches.android.wisefy.WisefyApi
import com.isupatches.android.wisefy.accesspoints.entities.GetNearbyAccessPointsRequest
import com.isupatches.android.wisefy.callbacks.DisableWifiCallbacks
import com.isupatches.android.wisefy.callbacks.EnableWifiCallbacks
import com.isupatches.android.wisefy.callbacks.GetCurrentNetworkCallbacks
Expand Down Expand Up @@ -90,7 +91,10 @@ internal class DefaultMiscModel @Inject constructor(

@RequiresPermission(ACCESS_FINE_LOCATION)
override fun getNearbyAccessPoints(callbacks: GetNearbyAccessPointCallbacks?) {
return wiseFy.getNearbyAccessPoints(true, callbacks)
return wiseFy.getNearbyAccessPoints(
request = GetNearbyAccessPointsRequest.All(),
callbacks = callbacks
)
}

@RequiresPermission(allOf = [ACCESS_FINE_LOCATION, ACCESS_WIFI_STATE])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ import com.isupatches.android.wisefy.callbacks.GetFrequencyCallbacks
import com.isupatches.android.wisefy.callbacks.GetIPCallbacks
import com.isupatches.android.wisefy.callbacks.GetNearbyAccessPointCallbacks
import com.isupatches.android.wisefy.callbacks.GetSavedNetworksCallbacks
import com.isupatches.android.wisefy.frequency.entities.FrequencyData
import com.isupatches.android.wisefy.networkinfo.entities.CurrentNetworkData
import com.isupatches.android.wisefy.networkinfo.entities.CurrentNetworkInfoData
import com.isupatches.android.wisefy.networkinfo.entities.IPData
import com.isupatches.android.wisefy.sample.internal.scaffolding.BasePresenter
import com.isupatches.android.wisefy.sample.internal.scaffolding.Presenter
import com.isupatches.android.wisefy.savednetworks.entities.SavedNetworkData
Expand Down Expand Up @@ -177,15 +179,21 @@ internal class DefaultMiscPresenter @Inject constructor(
model.getFrequency(
callbacks = object : GetFrequencyCallbacks {
override fun onFailureRetrievingFrequency() {
doSafelyWithView { view -> view.displayFailureRetrievingFrequency() }
doSafelyWithView { view ->
view.displayFailureRetrievingFrequency()
}
}

override fun onFrequencyRetrieved(frequency: Int) {
doSafelyWithView { view -> view.displayFrequency(frequency) }
override fun onFrequencyRetrieved(frequency: FrequencyData) {
doSafelyWithView { view ->
view.displayFrequency(frequency)
}
}

override fun onWisefyAsyncFailure(throwable: Throwable) {
doSafelyWithView { view -> view.displayWisefyAsyncError(throwable) }
doSafelyWithView { view ->
view.displayWisefyAsyncError(throwable)
}
}
}
)
Expand All @@ -201,7 +209,7 @@ internal class DefaultMiscPresenter @Inject constructor(
}
}

override fun onIPRetrieved(ip: String) {
override fun onIPRetrieved(ip: IPData) {
doSafelyWithView { view ->
view.displayIP(ip)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.Manifest.permission.CHANGE_WIFI_STATE
import androidx.annotation.RequiresPermission
import com.isupatches.android.wisefy.WisefyApi
import com.isupatches.android.wisefy.callbacks.RemoveNetworkCallbacks
import com.isupatches.android.wisefy.removenetwork.entities.RemoveNetworkRequest
import com.isupatches.android.wisefy.sample.internal.scaffolding.BaseModel
import javax.inject.Inject

Expand All @@ -39,6 +40,6 @@ internal class DefaultRemoveNetworkModel @Inject constructor(

@RequiresPermission(allOf = [ACCESS_FINE_LOCATION, CHANGE_WIFI_STATE])
override fun removeNetwork(networkName: String, callbacks: RemoveNetworkCallbacks?) {
wiseFy.removeNetwork(networkName)
wiseFy.removeNetwork(RemoveNetworkRequest.SSID(networkName))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.widget.SeekBar
import androidx.annotation.VisibleForTesting
import com.isupatches.android.viewglu.paste
import com.isupatches.android.wisefy.accesspoints.entities.AccessPointData
import com.isupatches.android.wisefy.accesspoints.entities.SSIDData
import com.isupatches.android.wisefy.sample.R
import com.isupatches.android.wisefy.sample.databinding.FragmentSearchBinding
import com.isupatches.android.wisefy.sample.internal.base.BaseFragment
Expand Down Expand Up @@ -61,9 +62,9 @@ internal interface SearchView {
fun displayAccessPointNotFound()
fun displayAccessPoints(accessPoints: List<AccessPointData>)
fun displayNoAccessPointsFound()
fun displaySSID(ssid: String?)
fun displaySSID(ssid: SSIDData?)
fun displaySSIDNotFound()
fun displaySSIDs(ssids: List<String>)
fun displaySSIDs(ssids: List<SSIDData>)
fun displayNoSSIDsFound()
}

Expand Down Expand Up @@ -352,15 +353,15 @@ internal class SearchFragment : BaseFragment(), SearchView {
displayInfo(R.string.no_access_points_found, R.string.search_result)
}

override fun displaySSID(ssid: String?) {
override fun displaySSID(ssid: SSIDData?) {
displayInfoFullScreen(getString(R.string.ssid_args, ssid), R.string.search_result)
}

override fun displaySSIDNotFound() {
displayInfo(R.string.ssid_not_found, R.string.search_result)
}

override fun displaySSIDs(ssids: List<String>) {
override fun displaySSIDs(ssids: List<SSIDData>) {
displayInfoFullScreen(getString(R.string.ssids_args, ssids), R.string.search_result)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ import android.Manifest.permission.ACCESS_FINE_LOCATION
import android.Manifest.permission.ACCESS_WIFI_STATE
import androidx.annotation.RequiresPermission
import com.isupatches.android.wisefy.WisefyApi
import com.isupatches.android.wisefy.accesspoints.entities.SearchForMultipleAccessPointsRequest
import com.isupatches.android.wisefy.accesspoints.entities.SearchForMultipleSSIDsRequest
import com.isupatches.android.wisefy.accesspoints.entities.SearchForSingleAccessPointRequest
import com.isupatches.android.wisefy.accesspoints.entities.SearchForSingleSSIDRequest
import com.isupatches.android.wisefy.callbacks.SearchForAccessPointCallbacks
import com.isupatches.android.wisefy.callbacks.SearchForAccessPointsCallbacks
import com.isupatches.android.wisefy.callbacks.SearchForSSIDCallbacks
import com.isupatches.android.wisefy.callbacks.SearchForSSIDsCallbacks
import com.isupatches.android.wisefy.callbacks.SearchForSavedNetworkCallbacks
import com.isupatches.android.wisefy.callbacks.SearchForSavedNetworksCallbacks
import com.isupatches.android.wisefy.sample.internal.scaffolding.BaseModel
import com.isupatches.android.wisefy.savednetworks.entities.SearchForSavedNetworkRequest
import javax.inject.Inject

internal interface SearchModel {
Expand Down Expand Up @@ -84,9 +89,11 @@ internal class DefaultSearchModel @Inject constructor(
callbacks: SearchForAccessPointCallbacks?
) {
wisefy.searchForAccessPoint(
regexForSSID = regexForSSID,
timeoutInMillis = timeoutInMillis,
filterDuplicates = filterDuplicates,
request = SearchForSingleAccessPointRequest.SSID(
regexForSSID = regexForSSID,
timeoutInMillis = timeoutInMillis,
filterDuplicates = filterDuplicates
),
callbacks = callbacks
)
}
Expand All @@ -98,8 +105,10 @@ internal class DefaultSearchModel @Inject constructor(
callbacks: SearchForAccessPointsCallbacks?
) {
wisefy.searchForAccessPoints(
regexForSSID = regexForSSID,
filterDuplicates = filterDuplicates,
request = SearchForMultipleAccessPointsRequest.SSID(
regexForSSID = regexForSSID,
filterDuplicates = filterDuplicates
),
callbacks = callbacks
)
}
Expand All @@ -110,7 +119,7 @@ internal class DefaultSearchModel @Inject constructor(
callbacks: SearchForSavedNetworkCallbacks?
) {
wisefy.searchForSavedNetwork(
regexForSSID = regexForSSID,
request = SearchForSavedNetworkRequest.SSID(regexForSSID = regexForSSID),
callbacks = callbacks
)
}
Expand All @@ -121,7 +130,7 @@ internal class DefaultSearchModel @Inject constructor(
callbacks: SearchForSavedNetworksCallbacks?
) {
wisefy.searchForSavedNetworks(
regexForSSID = regexForSSID,
request = SearchForSavedNetworkRequest.SSID(regexForSSID = regexForSSID),
callbacks = callbacks
)
}
Expand All @@ -133,8 +142,10 @@ internal class DefaultSearchModel @Inject constructor(
callbacks: SearchForSSIDCallbacks?
) {
wisefy.searchForSSID(
regexForSSID = regexForSSID,
timeoutInMillis = timeoutInMillis,
request = SearchForSingleSSIDRequest.SSID(
regexForSSID = regexForSSID,
timeoutInMillis = timeoutInMillis
),
callbacks = callbacks
)
}
Expand All @@ -145,7 +156,7 @@ internal class DefaultSearchModel @Inject constructor(
callbacks: SearchForSSIDsCallbacks?
) {
wisefy.searchForSSIDs(
regexForSSID = regexForSSID,
request = SearchForMultipleSSIDsRequest.SSID(regexForSSID = regexForSSID),
callbacks = callbacks
)
}
Expand Down
Loading

0 comments on commit f1deae7

Please sign in to comment.