Skip to content

Commit

Permalink
fix scheduling issue with determining which buttons visible on ScanDi…
Browse files Browse the repository at this point in the history
…stanceFragment
  • Loading branch information
imbissbudenaesthetik committed Dec 11, 2024
1 parent f1f6063 commit 78c4359
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,10 @@ class ScanDistanceFragment : Fragment() {
}

private fun determineDeviceTypeButtonVisible() {
if (latestWrappedScanResult != null) {
val savedGoogleSubType = ScanFragment.googleSubDeviceTypeMap[latestWrappedScanResult!!.uniqueIdentifier]
if (deviceType == DeviceType.GOOGLE_FIND_MY_NETWORK && savedGoogleSubType != null) {
binding.performActionButton.visibility = View.GONE
binding.retrieveOwnerInformationButton.visibility = if (savedGoogleSubType == GoogleFindMyNetworkType.TAG) {
defineRetrieveOwnerOnClickBehaviour()
View.VISIBLE
} else {
View.GONE
}
return
}
} else {
if (latestWrappedScanResult == null) {
binding.performActionButton.visibility = View.GONE
binding.retrieveOwnerInformationButton.visibility = View.GONE
return
}

binding.performActionButton.visibility = if (deviceType == DeviceType.SAMSUNG_TRACKER) {
Expand Down Expand Up @@ -227,17 +217,22 @@ class ScanDistanceFragment : Fragment() {
}
} else if (deviceType == DeviceType.GOOGLE_FIND_MY_NETWORK) {
val deviceName = ScanFragment.deviceNameMap[latestWrappedScanResult!!.uniqueIdentifier]

if (deviceName == null || deviceName == "") {
if (latestWrappedScanResult!!.connectionState !in DeviceManager.unsafeConnectionState && ScanFragment.googleSubDeviceTypeMap[latestWrappedScanResult!!.uniqueIdentifier] == null) {
binding.performActionButton.text = getString(R.string.tracker_or_phone)
View.VISIBLE
} else if (latestWrappedScanResult!!.connectionState in DeviceManager.unsafeConnectionState) {
val subType = GoogleFindMyNetwork.getSubType(latestWrappedScanResult!!)
ScanFragment.googleSubDeviceTypeMap[latestWrappedScanResult!!.uniqueIdentifier] = subType

if (subType == GoogleFindMyNetworkType.TAG) {
val savedGoogleExactTag = ScanFragment.googleExactTagDeterminedMap[latestWrappedScanResult!!.uniqueIdentifier]
val deviceNameEmpty = deviceName == null || deviceName == ""
val showPerformActionButton = deviceNameEmpty || savedGoogleExactTag == null || savedGoogleExactTag == false
if (showPerformActionButton) {
binding.retrieveOwnerInformationButton.visibility = View.GONE
View.VISIBLE
} else {
binding.retrieveOwnerInformationButton.visibility = View.VISIBLE
View.GONE
}
} else {
binding.retrieveOwnerInformationButton.visibility = View.GONE
View.GONE
}
} else {
Expand Down Expand Up @@ -471,6 +466,7 @@ class ScanDistanceFragment : Fragment() {
} else {
viewModel.displayName.postValue(deviceName)
if (subTypeGoogle == GoogleFindMyNetworkType.TAG) {
ScanFragment.googleExactTagDeterminedMap[latestWrappedScanResult!!.uniqueIdentifier] = true
defineRetrieveOwnerOnClickBehaviour()
binding.retrieveOwnerInformationButton.visibility = View.VISIBLE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class ScanFragment : Fragment() {
private const val SCAN_DURATION = 60_000L
val samsungSubDeviceTypeMap: MutableMap<String, SamsungTrackerType> = HashMap()
val googleSubDeviceTypeMap: MutableMap<String, GoogleFindMyNetworkType> = HashMap()
val googleExactTagDeterminedMap: MutableMap<String, Boolean> = HashMap()
val deviceNameMap: MutableMap<String, String> = HashMap()
}
}

0 comments on commit 78c4359

Please sign in to comment.