decrease spotbugs warnings

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2021-06-07 13:54:53 +02:00 committed by Andy Scherzinger
parent 60827afe5c
commit fdf6b04fb8
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
6 changed files with 49 additions and 39 deletions

View File

@ -36,5 +36,3 @@ class GeocodingAdapter(context: Context, val dataSource: List<Address>) : BaseAd
return rowView return rowView
} }
} }

View File

@ -182,7 +182,9 @@ class IncomingLocationMessageViewHolder(incomingView: View) : MessageHolders
for (key in messageParameters.keys) { for (key in messageParameters.keys) {
val individualHashMap = message.messageParameters[key] val individualHashMap = message.messageParameters[key]
if (individualHashMap != null) { if (individualHashMap != null) {
if (individualHashMap["type"] == "user" || individualHashMap["type"] == "guest" || individualHashMap["type"] == "call") { if (individualHashMap["type"] == "user"
|| individualHashMap["type"] == "guest"
|| individualHashMap["type"] == "call") {
if (individualHashMap["id"] == message.activeUser!!.userId) { if (individualHashMap["id"] == message.activeUser!!.userId) {
messageString = DisplayUtils.searchAndReplaceWithMentionSpan( messageString = DisplayUtils.searchAndReplaceWithMentionSpan(
messageText!!.context, messageText!!.context,

View File

@ -107,8 +107,7 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
val individualHashMap: HashMap<String, String>? = message.messageParameters[key] val individualHashMap: HashMap<String, String>? = message.messageParameters[key]
if (individualHashMap != null) { if (individualHashMap != null) {
if (individualHashMap["type"] == "user" || ( if (individualHashMap["type"] == "user" || (
individualHashMap["type"] == "guest" individualHashMap["type"] == "guest") || individualHashMap["type"] == "call"
) || individualHashMap["type"] == "call"
) { ) {
messageString = DisplayUtils.searchAndReplaceWithMentionSpan( messageString = DisplayUtils.searchAndReplaceWithMentionSpan(
messageText!!.context, messageText!!.context,
@ -242,8 +241,14 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
val urlStringBuffer = StringBuffer("file:///android_asset/leafletMapMessagePreview.html") val urlStringBuffer = StringBuffer("file:///android_asset/leafletMapMessagePreview.html")
urlStringBuffer.append("?mapProviderUrl=" + URLEncoder.encode(context!!.getString(R.string.osm_tile_server_url))) urlStringBuffer.append("?mapProviderUrl=" + URLEncoder.encode(context!!.getString(R.string.osm_tile_server_url)))
urlStringBuffer.append("&mapProviderAttribution=" + URLEncoder.encode(context!!.getString(R.string urlStringBuffer.append(
.osm_tile_server_attributation))) "&mapProviderAttribution=" + URLEncoder.encode(
context!!.getString(
R.string
.osm_tile_server_attributation
)
)
)
urlStringBuffer.append("&locationLat=" + URLEncoder.encode(locationLat)) urlStringBuffer.append("&locationLat=" + URLEncoder.encode(locationLat))
urlStringBuffer.append("&locationLon=" + URLEncoder.encode(locationLon)) urlStringBuffer.append("&locationLon=" + URLEncoder.encode(locationLon))
urlStringBuffer.append("&locationName=" + URLEncoder.encode(locationName)) urlStringBuffer.append("&locationName=" + URLEncoder.encode(locationName))

View File

@ -69,7 +69,9 @@ import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay
import javax.inject.Inject import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class) @AutoInjector(NextcloudTalkApplication::class)
class LocationPickerController(args: Bundle) : BaseController(args), SearchView.OnQueryTextListener, class LocationPickerController(args: Bundle) :
BaseController(args),
SearchView.OnQueryTextListener,
GeocodingController.GeocodingResultListener { GeocodingController.GeocodingResultListener {
@Inject @Inject
@ -257,27 +259,30 @@ class LocationPickerController(args: Bundle) : BaseController(args), SearchView.
moveToCurrentLocationWasClicked = true moveToCurrentLocationWasClicked = true
} }
map?.addMapListener(DelayedMapListener(object : MapListener { map?.addMapListener(
override fun onScroll(paramScrollEvent: ScrollEvent): Boolean { DelayedMapListener(
if (moveToCurrentLocationWasClicked) { object : MapListener {
setLocationDescription(true, false) override fun onScroll(paramScrollEvent: ScrollEvent): Boolean {
moveToCurrentLocationWasClicked = false if (moveToCurrentLocationWasClicked) {
} else if (receivedChosenGeocodingResult) { setLocationDescription(true, false)
shareLocation?.isClickable = true moveToCurrentLocationWasClicked = false
setLocationDescription(false, true) } else if (receivedChosenGeocodingResult) {
receivedChosenGeocodingResult = false shareLocation?.isClickable = true
} else { setLocationDescription(false, true)
shareLocation?.isClickable = true receivedChosenGeocodingResult = false
setLocationDescription(false, false) } else {
} shareLocation?.isClickable = true
readyToShareLocation = true setLocationDescription(false, false)
return true }
} readyToShareLocation = true
return true
}
override fun onZoom(event: ZoomEvent): Boolean { override fun onZoom(event: ZoomEvent): Boolean {
return false return false
} }
})) })
)
} }
private fun setLocationDescription(isGpsLocation: Boolean, isGeocodedResult: Boolean) { private fun setLocationDescription(isGpsLocation: Boolean, isGeocodedResult: Boolean) {
@ -376,7 +381,8 @@ class LocationPickerController(args: Bundle) : BaseController(args), SearchView.
if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE && grantResults.size > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE && grantResults.size > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
initMap() initMap()
} else { } else {
Toast.makeText(context, context!!.getString(R.string.nc_location_permission_required), Toast.LENGTH_LONG).show() Toast.makeText(context, context!!.getString(R.string.nc_location_permission_required), Toast.LENGTH_LONG)
.show()
} }
} }

View File

@ -4,8 +4,6 @@ import com.stfalcon.chatkit.commons.models.IMessage
interface ExtendedIMessage : IMessage { interface ExtendedIMessage : IMessage {
// var isLocationMessage: Boolean
fun isLocationMessage() : Boolean fun isLocationMessage() : Boolean
} }

View File

@ -45,6 +45,7 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import kotlin.text.Charsets;
@Parcel @Parcel
@JsonObject @JsonObject
@ -104,8 +105,8 @@ public class ChatMessage implements ExtendedIMessage, MessageContentType, Messag
for (HashMap.Entry<String, HashMap<String, String>> entry : messageParameters.entrySet()) { for (HashMap.Entry<String, HashMap<String, String>> entry : messageParameters.entrySet()) {
Map<String, String> individualHashMap = entry.getValue(); Map<String, String> individualHashMap = entry.getValue();
if(MessageDigest.isEqual( if(MessageDigest.isEqual(
Objects.requireNonNull(individualHashMap.get("type")).getBytes(), Objects.requireNonNull(individualHashMap.get("type")).getBytes(Charsets.UTF_8),
("file").getBytes())) { ("file").getBytes(Charsets.UTF_8))) {
return true; return true;
} }
} }
@ -119,8 +120,8 @@ public class ChatMessage implements ExtendedIMessage, MessageContentType, Messag
Map<String, String> individualHashMap = entry.getValue(); Map<String, String> individualHashMap = entry.getValue();
if(MessageDigest.isEqual( if(MessageDigest.isEqual(
Objects.requireNonNull(individualHashMap.get("type")).getBytes(), Objects.requireNonNull(individualHashMap.get("type")).getBytes(Charsets.UTF_8),
("geo-location").getBytes())) { ("geo-location").getBytes(Charsets.UTF_8))) {
return true; return true;
} }
} }
@ -136,8 +137,8 @@ public class ChatMessage implements ExtendedIMessage, MessageContentType, Messag
for (HashMap.Entry<String, HashMap<String, String>> entry : messageParameters.entrySet()) { for (HashMap.Entry<String, HashMap<String, String>> entry : messageParameters.entrySet()) {
Map<String, String> individualHashMap = entry.getValue(); Map<String, String> individualHashMap = entry.getValue();
if(MessageDigest.isEqual( if(MessageDigest.isEqual(
Objects.requireNonNull(individualHashMap.get("type")).getBytes(), Objects.requireNonNull(individualHashMap.get("type")).getBytes(Charsets.UTF_8),
("file").getBytes())) { ("file").getBytes(Charsets.UTF_8))) {
selectedIndividualHashMap = individualHashMap; selectedIndividualHashMap = individualHashMap;
return (ApiUtils.getUrlForFilePreviewWithFileId(getActiveUser().getBaseUrl(), return (ApiUtils.getUrlForFilePreviewWithFileId(getActiveUser().getBaseUrl(),
individualHashMap.get("id"), NextcloudTalkApplication.Companion.getSharedApplication().getResources().getDimensionPixelSize(R.dimen.maximum_file_preview_size))); individualHashMap.get("id"), NextcloudTalkApplication.Companion.getSharedApplication().getResources().getDimensionPixelSize(R.dimen.maximum_file_preview_size)));