فهرست منبع

decrease spotbugs warnings

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 4 سال پیش
والد
کامیت
fdf6b04fb8

+ 0 - 2
app/src/main/java/com/nextcloud/talk/adapters/GeocodingAdapter.kt

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

+ 4 - 2
app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt

@@ -182,7 +182,9 @@ class IncomingLocationMessageViewHolder(incomingView: View) : MessageHolders
             for (key in messageParameters.keys) {
                 val individualHashMap = message.messageParameters[key]
                 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) {
                             messageString = DisplayUtils.searchAndReplaceWithMentionSpan(
                                 messageText!!.context,
@@ -318,4 +320,4 @@ class IncomingLocationMessageViewHolder(incomingView: View) : MessageHolders
     private fun addMarkerToGeoLink(locationGeoLink: String): String {
         return locationGeoLink.replace("geo:", "geo:0,0?q=")
     }
-}
+}

+ 10 - 5
app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingLocationMessageViewHolder.kt

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

+ 29 - 23
app/src/main/java/com/nextcloud/talk/controllers/LocationPickerController.kt

@@ -69,7 +69,9 @@ import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay
 import javax.inject.Inject
 
 @AutoInjector(NextcloudTalkApplication::class)
-class LocationPickerController(args: Bundle) : BaseController(args), SearchView.OnQueryTextListener,
+class LocationPickerController(args: Bundle) :
+    BaseController(args),
+    SearchView.OnQueryTextListener,
     GeocodingController.GeocodingResultListener {
 
     @Inject
@@ -257,27 +259,30 @@ class LocationPickerController(args: Bundle) : BaseController(args), SearchView.
             moveToCurrentLocationWasClicked = true
         }
 
-        map?.addMapListener(DelayedMapListener(object : MapListener {
-            override fun onScroll(paramScrollEvent: ScrollEvent): Boolean {
-                if (moveToCurrentLocationWasClicked) {
-                    setLocationDescription(true, false)
-                    moveToCurrentLocationWasClicked = false
-                } else if (receivedChosenGeocodingResult) {
-                    shareLocation?.isClickable = true
-                    setLocationDescription(false, true)
-                    receivedChosenGeocodingResult = false
-                } else {
-                    shareLocation?.isClickable = true
-                    setLocationDescription(false, false)
-                }
-                readyToShareLocation = true
-                return true
-            }
-
-            override fun onZoom(event: ZoomEvent): Boolean {
-                return false
-            }
-        }))
+        map?.addMapListener(
+            DelayedMapListener(
+                object : MapListener {
+                    override fun onScroll(paramScrollEvent: ScrollEvent): Boolean {
+                        if (moveToCurrentLocationWasClicked) {
+                            setLocationDescription(true, false)
+                            moveToCurrentLocationWasClicked = false
+                        } else if (receivedChosenGeocodingResult) {
+                            shareLocation?.isClickable = true
+                            setLocationDescription(false, true)
+                            receivedChosenGeocodingResult = false
+                        } else {
+                            shareLocation?.isClickable = true
+                            setLocationDescription(false, false)
+                        }
+                        readyToShareLocation = true
+                        return true
+                    }
+
+                    override fun onZoom(event: ZoomEvent): Boolean {
+                        return false
+                    }
+                })
+        )
     }
 
     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) {
             initMap()
         } 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()
         }
     }
 

+ 0 - 2
app/src/main/java/com/nextcloud/talk/interfaces/ExtendedIMessage.kt

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

+ 7 - 6
app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java

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