From c6d3abf4210b0f9ebb63899d3a0ac5c948d23879 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 11 May 2021 14:54:57 +0200 Subject: [PATCH 01/66] add entry to share location Signed-off-by: Marcel Hibbe --- .../talk/controllers/ChatController.kt | 4 +++ .../talk/ui/dialog/AttachmentDialog.kt | 9 ++++++ .../drawable/ic_baseline_location_on_24.xml | 10 ++++++ app/src/main/res/layout/dialog_attachment.xml | 32 +++++++++++++++++++ app/src/main/res/values/strings.xml | 3 ++ 5 files changed, 58 insertions(+) create mode 100644 app/src/main/res/drawable/ic_baseline_location_on_24.xml diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 18d560ef2..dfbfc1df8 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -793,6 +793,10 @@ class ChatController(args: Bundle) : ) } + fun showShareLocationScreen(){ + Log.d(TAG, "showShareLocationScreen") + } + private fun showConversationInfoScreen() { val bundle = Bundle() bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, conversationUser) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/AttachmentDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/AttachmentDialog.kt index 29e47b131..a292b376a 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/AttachmentDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/AttachmentDialog.kt @@ -35,6 +35,10 @@ import com.nextcloud.talk.models.database.CapabilitiesUtil class AttachmentDialog(val activity: Activity, var chatController: ChatController) : BottomSheetDialog(activity) { + @BindView(R.id.txt_share_location) + @JvmField + var shareLocation: AppCompatTextView? = null + @BindView(R.id.txt_attach_file_from_local) @JvmField var attachFromLocal: AppCompatTextView? = null @@ -60,6 +64,11 @@ class AttachmentDialog(val activity: Activity, var chatController: ChatControlle String.format(it.getString(R.string.nc_upload_from_cloud), serverName) } + shareLocation?.setOnClickListener { + chatController.showShareLocationScreen() + dismiss() + } + attachFromLocal?.setOnClickListener { chatController.sendSelectLocalFileIntent() dismiss() diff --git a/app/src/main/res/drawable/ic_baseline_location_on_24.xml b/app/src/main/res/drawable/ic_baseline_location_on_24.xml new file mode 100644 index 000000000..5c29525a4 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_location_on_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/dialog_attachment.xml b/app/src/main/res/layout/dialog_attachment.xml index 70ccc5e38..c2b170f3f 100644 --- a/app/src/main/res/layout/dialog_attachment.xml +++ b/app/src/main/res/layout/dialog_attachment.xml @@ -38,6 +38,38 @@ android:textColor="@color/medium_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> + + + + + + + + Send this file to %1$s? Uploading + + Share location + phone_book_integration Match contacts based on phone number to integrate Talk shortcut into system contacts app From 0742afe58ca1181e52c5a6726abdcf6d9b3497ce Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Thu, 20 May 2021 15:51:19 +0200 Subject: [PATCH 02/66] add map via osmdroid Signed-off-by: Marcel Hibbe --- app/build.gradle | 2 + app/src/main/AndroidManifest.xml | 2 + .../talk/controllers/ChatController.kt | 9 ++ .../talk/controllers/LocationController.kt | 142 ++++++++++++++++++ .../res/drawable/ic_baseline_gps_fixed_24.xml | 10 ++ .../main/res/layout/controller_location.xml | 24 +++ 6 files changed, 189 insertions(+) create mode 100644 app/src/main/java/com/nextcloud/talk/controllers/LocationController.kt create mode 100644 app/src/main/res/drawable/ic_baseline_gps_fixed_24.xml create mode 100644 app/src/main/res/layout/controller_location.xml diff --git a/app/build.gradle b/app/build.gradle index 2e7549fb1..277bc92b4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -286,6 +286,8 @@ dependencies { implementation 'com.github.tobiaskaminsky:ImagePicker:extraFile-SNAPSHOT' implementation 'com.elyeproj.libraries:loaderviewlibrary:2.0.0' + implementation 'org.osmdroid:osmdroid-android:6.1.10' + testImplementation 'junit:junit:4.13.2' testImplementation 'org.mockito:mockito-core:3.11.0' testImplementation "org.powermock:powermock-core:${powermockVersion}" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b92c45f31..c5b1af412 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -70,6 +70,8 @@ + + = Build.VERSION_CODES.M) { + if (PermissionChecker.checkSelfPermission( + context!!, + Manifest.permission.ACCESS_FINE_LOCATION + ) == PermissionChecker.PERMISSION_GRANTED + ) { + Log.d(TAG, "Permission is granted") + return true + } else { + Log.d(TAG, "Permission is revoked") + return false + } + } else { //permission is automatically granted on sdk<23 upon installation + Log.d(TAG, "Permission is granted") + return true + } + } + + private fun requestFineLocationPermission() { + requestPermissions( + arrayOf( + Manifest.permission.ACCESS_FINE_LOCATION + ), + REQUEST_PERMISSIONS_REQUEST_CODE + ) + } + + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { + if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE && grantResults.size > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + drawMap() + } else { + Toast.makeText(context, "location permission required!", Toast.LENGTH_LONG).show() + } + } + + companion object { + private val TAG = "LocationController" + private val REQUEST_PERMISSIONS_REQUEST_CODE = 1; + } +} diff --git a/app/src/main/res/drawable/ic_baseline_gps_fixed_24.xml b/app/src/main/res/drawable/ic_baseline_gps_fixed_24.xml new file mode 100644 index 000000000..b05033003 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_gps_fixed_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/controller_location.xml b/app/src/main/res/layout/controller_location.xml new file mode 100644 index 000000000..014589912 --- /dev/null +++ b/app/src/main/res/layout/controller_location.xml @@ -0,0 +1,24 @@ + + + + + + + + + \ No newline at end of file From 965692ce7e3afe227f09d6d235dc4745630453ae Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Sat, 22 May 2021 00:16:13 +0200 Subject: [PATCH 03/66] set location picker icon over map show location when clicked on button Signed-off-by: Marcel Hibbe --- .../talk/controllers/LocationController.kt | 37 ++++++--- .../nextcloud/talk/utils/DisplayUtils.java | 28 +++---- .../res/drawable/current_location_circle.xml | 12 +++ .../ic_baseline_location_on_red_24.xml | 9 ++ .../main/res/layout/controller_location.xml | 82 +++++++++++++++---- 5 files changed, 126 insertions(+), 42 deletions(-) create mode 100644 app/src/main/res/drawable/current_location_circle.xml create mode 100644 app/src/main/res/drawable/ic_baseline_location_on_red_24.xml diff --git a/app/src/main/java/com/nextcloud/talk/controllers/LocationController.kt b/app/src/main/java/com/nextcloud/talk/controllers/LocationController.kt index b9fff4a8a..dd5872ad9 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/LocationController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/LocationController.kt @@ -9,6 +9,7 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Button import android.widget.ImageButton import android.widget.Toast import androidx.core.content.PermissionChecker @@ -47,9 +48,13 @@ class LocationController(args: Bundle) : BaseController(args) { @JvmField var btCenterMap: ImageButton? = null + @BindView(R.id.btn_select_location) + @JvmField + var btnSelectLocation: Button? = null + init { NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this) - getInstance().load(context, PreferenceManager.getDefaultSharedPreferences(context)); + getInstance().load(context, PreferenceManager.getDefaultSharedPreferences(context)) } override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { @@ -61,24 +66,34 @@ class LocationController(args: Bundle) : BaseController(args) { drawMap() } + override fun onViewBound(view: View) { + btnSelectLocation?.setOnClickListener { + val selectedLat: Double? = map?.mapCenter?.latitude + val selectedLon: Double? = map?.mapCenter?.longitude + Toast.makeText(activity, "Lat: $selectedLat Lon: $selectedLon", Toast.LENGTH_LONG).show() + } + } + fun drawMap(){ if (!isFineLocationPermissionGranted()) { - requestFineLocationPermission(); + requestFineLocationPermission() } - map?.setTileSource(TileSourceFactory.MAPNIK); + map?.setTileSource(TileSourceFactory.MAPNIK) - map?.onResume(); + map?.onResume() - val copyrightOverlay = CopyrightOverlay(context); - map?.overlays?.add(copyrightOverlay); + val copyrightOverlay = CopyrightOverlay(context) + map?.overlays?.add(copyrightOverlay) - map?.setMultiTouchControls(true); - map?.isTilesScaledToDpi = true; + map?.setMultiTouchControls(true) + map?.isTilesScaledToDpi = true - val locationOverlay = MyLocationNewOverlay(GpsMyLocationProvider(context), map); - locationOverlay.enableFollowLocation(); - locationOverlay.enableMyLocation(); + val locationOverlay = MyLocationNewOverlay(GpsMyLocationProvider(context), map) + locationOverlay.enableFollowLocation() + locationOverlay.enableMyLocation() + // locationOverlay.setPersonIcon( + // DisplayUtils.getBitmap(ResourcesCompat.getDrawable(resources!!, R.drawable.current_location_circle, null))) map?.overlays?.add(locationOverlay) val mapController = map?.controller diff --git a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java index 397c084ea..48408670a 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java @@ -55,19 +55,6 @@ import android.view.Window; import android.widget.EditText; import android.widget.TextView; -import androidx.annotation.ColorInt; -import androidx.annotation.ColorRes; -import androidx.annotation.DrawableRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.XmlRes; -import androidx.appcompat.widget.AppCompatDrawableManager; -import androidx.appcompat.widget.SearchView; -import androidx.core.content.ContextCompat; -import androidx.core.graphics.ColorUtils; -import androidx.core.graphics.drawable.DrawableCompat; -import androidx.emoji.text.EmojiCompat; - import com.facebook.common.executors.UiThreadImmediateExecutorService; import com.facebook.common.references.CloseableReference; import com.facebook.datasource.DataSource; @@ -102,6 +89,19 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import androidx.annotation.ColorInt; +import androidx.annotation.ColorRes; +import androidx.annotation.DrawableRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.XmlRes; +import androidx.appcompat.widget.AppCompatDrawableManager; +import androidx.appcompat.widget.SearchView; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.ColorUtils; +import androidx.core.graphics.drawable.DrawableCompat; +import androidx.emoji.text.EmojiCompat; + public class DisplayUtils { private static final String TAG = "DisplayUtils"; @@ -160,7 +160,7 @@ public class DisplayUtils { return new BitmapDrawable(getRoundedBitmapFromVectorDrawableResource(resources, resource)); } - private static Bitmap getBitmap(Drawable drawable) { + public static Bitmap getBitmap(Drawable drawable) { Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); diff --git a/app/src/main/res/drawable/current_location_circle.xml b/app/src/main/res/drawable/current_location_circle.xml new file mode 100644 index 000000000..310a104ab --- /dev/null +++ b/app/src/main/res/drawable/current_location_circle.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_baseline_location_on_red_24.xml b/app/src/main/res/drawable/ic_baseline_location_on_red_24.xml new file mode 100644 index 000000000..d8b0f5f0c --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_location_on_red_24.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/controller_location.xml b/app/src/main/res/layout/controller_location.xml index 014589912..03fc40916 100644 --- a/app/src/main/res/layout/controller_location.xml +++ b/app/src/main/res/layout/controller_location.xml @@ -1,24 +1,72 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> - + + + - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + \ No newline at end of file From 73becd432dc5bcadfff8a4a3e4c79fe27a6f4805 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Wed, 26 May 2021 14:47:54 +0200 Subject: [PATCH 04/66] add logic for geolocation message Signed-off-by: Marcel Hibbe --- .../MagicPreviewMessageViewHolder.java | 3 ++- .../talk/models/json/chat/ChatMessage.java | 19 +++++++++++++++++++ .../talk/models/json/chat/ChatUtils.kt | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicPreviewMessageViewHolder.java b/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicPreviewMessageViewHolder.java index 6f899c11a..7043a5cc2 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicPreviewMessageViewHolder.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicPreviewMessageViewHolder.java @@ -177,7 +177,8 @@ public class MagicPreviewMessageViewHolder extends MessageHolders.IncomingImageM } catch (ExecutionException | InterruptedException e) { Log.e(TAG, "Error when checking if worker already exists", e); } - + } else if (message.getMessageType() == ChatMessage.MessageType.SINGLE_NC_GEOLOCATION_MESSAGE) { + Log.d(TAG, "handle geolocation here"); } else if (message.getMessageType() == ChatMessage.MessageType.SINGLE_LINK_GIPHY_MESSAGE) { messageText.setText("GIPHY"); DisplayUtils.setClickableString("GIPHY", "https://giphy.com", messageText); diff --git a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java index aa704cb35..676ace0ac 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java @@ -103,6 +103,19 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent return false; } + private boolean hasGeoLocation() { + if (messageParameters != null && messageParameters.size() > 0) { + for (String key : messageParameters.keySet()) { + Map individualHashMap = messageParameters.get(key); + if (individualHashMap.get("type").equals("geo-location")) { + return true; + } + } + } + + return false; + } + @Nullable @Override public String getImageUrl() { @@ -133,6 +146,11 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent return MessageType.SINGLE_NC_ATTACHMENT_MESSAGE; } + if (hasGeoLocation()) { + return MessageType.SINGLE_NC_GEOLOCATION_MESSAGE; + } + + return TextMatchers.getMessageTypeFromString(getText()); } @@ -548,6 +566,7 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent SINGLE_LINK_IMAGE_MESSAGE, SINGLE_LINK_AUDIO_MESSAGE, SINGLE_NC_ATTACHMENT_MESSAGE, + SINGLE_NC_GEOLOCATION_MESSAGE, } public enum SystemMessageType { diff --git a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatUtils.kt b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatUtils.kt index 9e060409f..0117b2842 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatUtils.kt @@ -33,6 +33,8 @@ class ChatUtils { val type = individualHashMap?.get("type") if (type == "user" || type == "guest" || type == "call") { resultMessage = resultMessage?.replace("{$key}", "@" + individualHashMap["name"]) + } else if(type == "geo-location"){ + resultMessage = individualHashMap.get("name") } else if (individualHashMap?.containsKey("link") == true) { resultMessage = if (type == "file") { resultMessage?.replace("{$key}", individualHashMap["name"].toString()) From 1e2960a72afec622aa2c8d54831d460877ed549e Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Wed, 26 May 2021 22:20:23 +0200 Subject: [PATCH 05/66] add example for leaflet in WebView Signed-off-by: Marcel Hibbe --- app/src/main/AndroidManifest.xml | 4 ++ app/src/main/assets/index.html | 38 +++++++++++++++++++ .../talk/activities/LeafletWebView.kt | 32 ++++++++++++++++ .../talk/controllers/ChatController.kt | 22 +++++++---- app/src/main/res/layout/leaflet_webview.xml | 13 +++++++ 5 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 app/src/main/assets/index.html create mode 100644 app/src/main/java/com/nextcloud/talk/activities/LeafletWebView.kt create mode 100644 app/src/main/res/layout/leaflet_webview.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c5b1af412..4001a9a0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -141,6 +141,10 @@ android:configChanges="orientation|keyboardHidden|screenSize"> + + + diff --git a/app/src/main/assets/index.html b/app/src/main/assets/index.html new file mode 100644 index 000000000..b830f6d00 --- /dev/null +++ b/app/src/main/assets/index.html @@ -0,0 +1,38 @@ + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/talk/activities/LeafletWebView.kt b/app/src/main/java/com/nextcloud/talk/activities/LeafletWebView.kt new file mode 100644 index 000000000..559d5b1b2 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/activities/LeafletWebView.kt @@ -0,0 +1,32 @@ +package com.nextcloud.talk.activities + +import android.annotation.SuppressLint +import android.os.Bundle +import android.webkit.WebView +import android.webkit.WebViewClient +import androidx.appcompat.app.AppCompatActivity +import com.nextcloud.talk.databinding.LeafletWebviewBinding + +class LeafletWebView : AppCompatActivity() { + lateinit var binding: LeafletWebviewBinding + + + @SuppressLint("SetJavaScriptEnabled") + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + binding = LeafletWebviewBinding.inflate(layoutInflater) + setContentView(binding.root) + + binding.webview.settings.javaScriptEnabled = true + + binding.webview.webViewClient = object : WebViewClient() { + override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean { + view?.loadUrl(url) + return true + } + } + binding.webview.loadUrl("file:///android_asset/index.html?51.5263,13.0384"); + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 404ce0eb7..1b7afd498 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -77,6 +77,7 @@ import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber import com.facebook.imagepipeline.image.CloseableImage import com.google.android.flexbox.FlexboxLayout import com.nextcloud.talk.R +import com.nextcloud.talk.activities.LeafletWebView import com.nextcloud.talk.activities.MagicCallActivity import com.nextcloud.talk.adapters.messages.MagicIncomingTextMessageViewHolder import com.nextcloud.talk.adapters.messages.MagicOutcomingTextMessageViewHolder @@ -121,7 +122,6 @@ import com.nextcloud.talk.utils.NotificationUtils import com.nextcloud.talk.utils.UriUtils import com.nextcloud.talk.utils.bundle.BundleKeys import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ACTIVE_CONVERSATION -import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_NEW_CONVERSATION import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_ID import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY @@ -797,13 +797,19 @@ class ChatController(args: Bundle) : fun showShareLocationScreen(){ Log.d(TAG, "showShareLocationScreen") - val bundle = Bundle() - bundle.putBoolean(KEY_NEW_CONVERSATION, true) - router.pushController( - RouterTransaction.with(LocationController(bundle)) - .pushChangeHandler(HorizontalChangeHandler()) - .popChangeHandler(HorizontalChangeHandler()) - ) + // val bundle = Bundle() + // bundle.putBoolean(KEY_NEW_CONVERSATION, true) + // router.pushController( + // RouterTransaction.with(LocationController(bundle)) + // .pushChangeHandler(HorizontalChangeHandler()) + // .popChangeHandler(HorizontalChangeHandler()) + // ) + + val leafletIntent = Intent(context, LeafletWebView::class.java) + leafletIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + // fullScreenImageIntent.putExtra("FILE_NAME", filename) + // fullScreenImageIntent.putExtra("IS_GIF", isGif(mimetype)) + context!!.startActivity(leafletIntent) } private fun showConversationInfoScreen() { diff --git a/app/src/main/res/layout/leaflet_webview.xml b/app/src/main/res/layout/leaflet_webview.xml new file mode 100644 index 000000000..67f0dbf55 --- /dev/null +++ b/app/src/main/res/layout/leaflet_webview.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file From 4d29a4b63866ad85f8acef87b11426b755fdfbae Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Thu, 27 May 2021 17:35:19 +0200 Subject: [PATCH 06/66] add LocationMessageViewHolder for ChatKit Signed-off-by: Marcel Hibbe --- .../messages/LocationMessageViewHolder.java | 78 +++++++++++++++++++ .../talk/controllers/ChatController.kt | 36 +++++++-- .../talk/interfaces/ExtendedIMessage.kt | 11 +++ .../talk/models/json/chat/ChatMessage.java | 23 ++++-- .../layout/item_custom_location_message.xml | 45 +++++++++++ 5 files changed, 183 insertions(+), 10 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.java create mode 100644 app/src/main/java/com/nextcloud/talk/interfaces/ExtendedIMessage.kt create mode 100644 app/src/main/res/layout/item_custom_location_message.xml diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.java b/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.java new file mode 100644 index 000000000..8c146296e --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.java @@ -0,0 +1,78 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * @author Marcel Hibbe + * Copyright (C) 2017-2018 Mario Danic + * Copyright (C) 2021 Marcel Hibbe + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.nextcloud.talk.adapters.messages; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.util.Log; +import android.view.View; +import android.widget.TextView; + +import com.nextcloud.talk.R; +import com.nextcloud.talk.application.NextcloudTalkApplication; +import com.nextcloud.talk.models.json.chat.ChatMessage; +import com.stfalcon.chatkit.messages.MessageHolders; + +import javax.inject.Inject; + +import autodagger.AutoInjector; +import butterknife.BindView; +import butterknife.ButterKnife; +import okhttp3.OkHttpClient; + +@AutoInjector(NextcloudTalkApplication.class) +public class LocationMessageViewHolder extends MessageHolders.IncomingTextMessageViewHolder { + + private static String TAG = "LocationMessageViewHolder"; + + @BindView(R.id.locationText) + TextView messageText; + + View progressBar; + + @Inject + Context context; + + @Inject + OkHttpClient okHttpClient; + + public LocationMessageViewHolder(View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + progressBar = itemView.findViewById(R.id.progress_bar); + NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this); + } + + @SuppressLint("SetTextI18n") + @Override + public void onBind(ChatMessage message) { + super.onBind(message); + + if (message.getMessageType() == ChatMessage.MessageType.SINGLE_NC_GEOLOCATION_MESSAGE) { + Log.d(TAG, "handle geolocation here"); + messageText.setText("geolocation..."); + } + +// text.setText("bbbbbb"); + } +} diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 1b7afd498..435ed4a17 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -79,6 +79,7 @@ import com.google.android.flexbox.FlexboxLayout import com.nextcloud.talk.R import com.nextcloud.talk.activities.LeafletWebView import com.nextcloud.talk.activities.MagicCallActivity +import com.nextcloud.talk.adapters.messages.LocationMessageViewHolder import com.nextcloud.talk.adapters.messages.MagicIncomingTextMessageViewHolder import com.nextcloud.talk.adapters.messages.MagicOutcomingTextMessageViewHolder import com.nextcloud.talk.adapters.messages.MagicPreviewMessageViewHolder @@ -134,6 +135,9 @@ import com.otaliastudios.autocomplete.Autocomplete import com.stfalcon.chatkit.commons.ImageLoader import com.stfalcon.chatkit.commons.models.IMessage import com.stfalcon.chatkit.messages.MessageHolders +import com.stfalcon.chatkit.messages.MessageHolders.ContentChecker +import com.stfalcon.chatkit.messages.MessageInput +import com.stfalcon.chatkit.messages.MessagesList import com.stfalcon.chatkit.messages.MessagesListAdapter import com.stfalcon.chatkit.utils.DateFormatter import com.vanniktech.emoji.EmojiPopup @@ -164,7 +168,7 @@ class ChatController(args: Bundle) : MessagesListAdapter.OnLoadMoreListener, MessagesListAdapter.Formatter, MessagesListAdapter.OnMessageViewLongClickListener, - MessageHolders.ContentChecker { + ContentChecker { private val binding: ControllerChatBinding by viewBinding(ControllerChatBinding::bind) @Inject @@ -406,9 +410,20 @@ class ChatController(args: Bundle) : R.layout.item_custom_outcoming_preview_message ) + // messageHolders.setIncomingLocationConfig( + // LocationMessageViewHolder::class.java, + // R.layout.item_custom_location_message + // ) + // messageHolders.setOutcomingLocationConfig( + // LocationMessageViewHolder::class.java, + // R.layout.item_custom_location_message + // ) + messageHolders.registerContentType( - CONTENT_TYPE_SYSTEM_MESSAGE, MagicSystemMessageViewHolder::class.java, - R.layout.item_system_message, MagicSystemMessageViewHolder::class.java, + CONTENT_TYPE_SYSTEM_MESSAGE, + MagicSystemMessageViewHolder::class.java, + R.layout.item_system_message, + MagicSystemMessageViewHolder::class.java, R.layout.item_system_message, this ) @@ -421,6 +436,15 @@ class ChatController(args: Bundle) : R.layout.item_date_header, this ) + messageHolders.registerContentType( + CONTENT_TYPE_LOCATION, + LocationMessageViewHolder::class.java, + R.layout.item_custom_location_message, + LocationMessageViewHolder::class.java, + R.layout.item_custom_location_message, + this + ) + var senderId = "" if (!conversationUser?.userId.equals("?")) { senderId = "users/" + conversationUser?.userId @@ -794,7 +818,7 @@ class ChatController(args: Bundle) : ) } - fun showShareLocationScreen(){ + fun showShareLocationScreen() { Log.d(TAG, "showShareLocationScreen") // val bundle = Bundle() @@ -1897,8 +1921,9 @@ class ChatController(args: Bundle) : return true } - override fun hasContentFor(message: IMessage, type: Byte): Boolean { + override fun hasContentFor(message: ChatMessage, type: Byte): Boolean { return when (type) { + CONTENT_TYPE_LOCATION -> return message.isLocationMessage() CONTENT_TYPE_SYSTEM_MESSAGE -> !TextUtils.isEmpty(message.systemMessage) CONTENT_TYPE_UNREAD_NOTICE_MESSAGE -> message.id == "-1" else -> false @@ -2004,6 +2029,7 @@ class ChatController(args: Bundle) : private const val TAG = "ChatController" private const val CONTENT_TYPE_SYSTEM_MESSAGE: Byte = 1 private const val CONTENT_TYPE_UNREAD_NOTICE_MESSAGE: Byte = 2 + private const val CONTENT_TYPE_LOCATION: Byte = 3 private const val NEW_MESSAGES_POPUP_BUBBLE_DELAY: Long = 200 private const val POP_CURRENT_CONTROLLER_DELAY: Long = 100 private const val LOBBY_TIMER_DELAY: Long = 5000 diff --git a/app/src/main/java/com/nextcloud/talk/interfaces/ExtendedIMessage.kt b/app/src/main/java/com/nextcloud/talk/interfaces/ExtendedIMessage.kt new file mode 100644 index 000000000..5af22bb37 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/interfaces/ExtendedIMessage.kt @@ -0,0 +1,11 @@ +package com.nextcloud.talk.interfaces + +import com.stfalcon.chatkit.commons.models.IMessage + +interface ExtendedIMessage : IMessage { + + // var isLocationMessage: Boolean + + fun isLocationMessage() : Boolean + +} \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java index 676ace0ac..7d7158ed7 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java @@ -20,17 +20,18 @@ package com.nextcloud.talk.models.json.chat; import android.text.TextUtils; +import android.util.Log; import com.bluelinelabs.logansquare.annotation.JsonField; import com.bluelinelabs.logansquare.annotation.JsonIgnore; import com.bluelinelabs.logansquare.annotation.JsonObject; import com.nextcloud.talk.R; import com.nextcloud.talk.application.NextcloudTalkApplication; +import com.nextcloud.talk.interfaces.ExtendedIMessage; import com.nextcloud.talk.models.database.UserEntity; import com.nextcloud.talk.models.json.converters.EnumSystemMessageTypeConverter; import com.nextcloud.talk.utils.ApiUtils; import com.nextcloud.talk.utils.TextMatchers; -import com.stfalcon.chatkit.commons.models.IMessage; import com.stfalcon.chatkit.commons.models.IUser; import com.stfalcon.chatkit.commons.models.MessageContentType; @@ -46,7 +47,9 @@ import androidx.annotation.Nullable; @Parcel @JsonObject -public class ChatMessage implements IMessage, MessageContentType, MessageContentType.Image { +public class ChatMessage implements ExtendedIMessage, MessageContentType, MessageContentType.Image { + private final String TAG = "ChatMessage"; + @JsonIgnore public boolean isGrouped; @JsonIgnore @@ -87,9 +90,13 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent public Enum readStatus = ReadStatus.NONE; @JsonIgnore - List messageTypesToIgnore = Arrays.asList(MessageType.REGULAR_TEXT_MESSAGE, - MessageType.SYSTEM_MESSAGE, MessageType.SINGLE_LINK_VIDEO_MESSAGE, - MessageType.SINGLE_LINK_AUDIO_MESSAGE, MessageType.SINGLE_LINK_MESSAGE); + List messageTypesToIgnore = Arrays.asList( + MessageType.REGULAR_TEXT_MESSAGE, + MessageType.SYSTEM_MESSAGE, + MessageType.SINGLE_LINK_VIDEO_MESSAGE, + MessageType.SINGLE_LINK_AUDIO_MESSAGE, + MessageType.SINGLE_LINK_MESSAGE, + MessageType.SINGLE_NC_GEOLOCATION_MESSAGE); public boolean hasFileAttachment() { if (messageParameters != null && messageParameters.size() > 0) { @@ -108,6 +115,7 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent for (String key : messageParameters.keySet()) { Map individualHashMap = messageParameters.get(key); if (individualHashMap.get("type").equals("geo-location")) { + Log.d(TAG, "is geo-location"); return true; } } @@ -555,6 +563,11 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent return "ChatMessage(isGrouped=" + this.isGrouped() + ", isOneToOneConversation=" + this.isOneToOneConversation() + ", activeUser=" + this.getActiveUser() + ", selectedIndividualHashMap=" + this.getSelectedIndividualHashMap() + ", isLinkPreviewAllowed=" + this.isLinkPreviewAllowed() + ", isDeleted=" + this.isDeleted() + ", jsonMessageId=" + this.getJsonMessageId() + ", token=" + this.getToken() + ", actorType=" + this.getActorType() + ", actorId=" + this.getActorId() + ", actorDisplayName=" + this.getActorDisplayName() + ", timestamp=" + this.getTimestamp() + ", message=" + this.getMessage() + ", messageParameters=" + this.getMessageParameters() + ", systemMessageType=" + this.getSystemMessageType() + ", replyable=" + this.isReplyable() + ", parentMessage=" + this.getParentMessage() + ", readStatus=" + this.getReadStatus() + ", messageTypesToIgnore=" + this.getMessageTypesToIgnore() + ")"; } + @Override + public boolean isLocationMessage() { + return hasGeoLocation(); + } + public enum MessageType { REGULAR_TEXT_MESSAGE, SYSTEM_MESSAGE, diff --git a/app/src/main/res/layout/item_custom_location_message.xml b/app/src/main/res/layout/item_custom_location_message.xml new file mode 100644 index 000000000..ae10d7579 --- /dev/null +++ b/app/src/main/res/layout/item_custom_location_message.xml @@ -0,0 +1,45 @@ + + + + + + + From ba7bfe315027537a49dcad5fb2ecbc92b2d2cbf8 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Thu, 27 May 2021 23:30:35 +0200 Subject: [PATCH 07/66] chnage LocationMessageViewHolder to kotlin Signed-off-by: Marcel Hibbe --- .../messages/LocationMessageViewHolder.java | 78 ------------------- .../messages/LocationMessageViewHolder.kt | 54 +++++++++++++ 2 files changed, 54 insertions(+), 78 deletions(-) delete mode 100644 app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.java create mode 100644 app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.kt diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.java b/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.java deleted file mode 100644 index 8c146296e..000000000 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * @author Marcel Hibbe - * Copyright (C) 2017-2018 Mario Danic - * Copyright (C) 2021 Marcel Hibbe - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.nextcloud.talk.adapters.messages; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.util.Log; -import android.view.View; -import android.widget.TextView; - -import com.nextcloud.talk.R; -import com.nextcloud.talk.application.NextcloudTalkApplication; -import com.nextcloud.talk.models.json.chat.ChatMessage; -import com.stfalcon.chatkit.messages.MessageHolders; - -import javax.inject.Inject; - -import autodagger.AutoInjector; -import butterknife.BindView; -import butterknife.ButterKnife; -import okhttp3.OkHttpClient; - -@AutoInjector(NextcloudTalkApplication.class) -public class LocationMessageViewHolder extends MessageHolders.IncomingTextMessageViewHolder { - - private static String TAG = "LocationMessageViewHolder"; - - @BindView(R.id.locationText) - TextView messageText; - - View progressBar; - - @Inject - Context context; - - @Inject - OkHttpClient okHttpClient; - - public LocationMessageViewHolder(View itemView) { - super(itemView); - ButterKnife.bind(this, itemView); - progressBar = itemView.findViewById(R.id.progress_bar); - NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this); - } - - @SuppressLint("SetTextI18n") - @Override - public void onBind(ChatMessage message) { - super.onBind(message); - - if (message.getMessageType() == ChatMessage.MessageType.SINGLE_NC_GEOLOCATION_MESSAGE) { - Log.d(TAG, "handle geolocation here"); - messageText.setText("geolocation..."); - } - -// text.setText("bbbbbb"); - } -} diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.kt new file mode 100644 index 000000000..db2eb4f9f --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.kt @@ -0,0 +1,54 @@ +package com.nextcloud.talk.adapters.messages + +import android.annotation.SuppressLint +import android.content.Context +import android.util.Log +import android.view.View +import android.widget.TextView +import autodagger.AutoInjector +import butterknife.BindView +import butterknife.ButterKnife +import com.nextcloud.talk.R +import com.nextcloud.talk.application.NextcloudTalkApplication +import com.nextcloud.talk.models.json.chat.ChatMessage +import com.stfalcon.chatkit.messages.MessageHolders +import javax.inject.Inject + +@AutoInjector(NextcloudTalkApplication::class) +class LocationMessageViewHolder(incomingView: View) : MessageHolders +.IncomingTextMessageViewHolder(incomingView) { + + private val TAG = "LocationMessageViewHolder" + + @JvmField + @BindView(R.id.locationText) + var messageText: TextView? = null + + @JvmField + @Inject + var context: Context? = null + + init { + ButterKnife.bind( + this, + itemView + ) + } + + @SuppressLint("SetTextI18n") + override fun onBind(message: ChatMessage) { + super.onBind(message) + if (message.messageType == ChatMessage.MessageType.SINGLE_NC_GEOLOCATION_MESSAGE) { + Log.d(TAG, "handle geolocation here") + messageText!!.text = "geolocation..." + } + if (message.messageParameters != null && message.messageParameters.size > 0) { + for (key in message.messageParameters.keys) { + val individualHashMap: Map = message.messageParameters[key]!! + val lon = individualHashMap["longitude"] + val lat = individualHashMap["latitude"] + Log.d(TAG, "lon $lon lat $lat") + } + } + } +} \ No newline at end of file From 5da43d1760ac75abfd1c10a408b33d5378a669d7 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 28 May 2021 00:27:43 +0200 Subject: [PATCH 08/66] wip. show leaflet inside webview in message Signed-off-by: Marcel Hibbe --- app/src/main/assets/index.html | 10 ++--- .../messages/LocationMessageViewHolder.kt | 42 +++++++++++++++---- .../talk/controllers/ChatController.kt | 25 ++++++----- .../layout/item_custom_location_message.xml | 8 +++- 4 files changed, 58 insertions(+), 27 deletions(-) diff --git a/app/src/main/assets/index.html b/app/src/main/assets/index.html index b830f6d00..fe167caf1 100644 --- a/app/src/main/assets/index.html +++ b/app/src/main/assets/index.html @@ -20,19 +20,19 @@ var queryString = window.location.search; queryString = queryString.substring(1); - var coords = queryString.split(","); + var params = queryString.split(","); + var lat = params[0] + var lon = params[1] - var map = L.map('map', { zoomControl: false }).setView([coords[0], coords[1]], 13); + var map = L.map('map', { zoomControl: false }).setView([lat, lon], 13); map.dragging.disable(); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); - L.marker([coords[0], coords[1]]).addTo(map) - .bindPopup('popup') - .openPopup(); + L.marker([lat, lon]).addTo(map); \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.kt index db2eb4f9f..e77d21a73 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/LocationMessageViewHolder.kt @@ -4,6 +4,8 @@ import android.annotation.SuppressLint import android.content.Context import android.util.Log import android.view.View +import android.webkit.WebView +import android.webkit.WebViewClient import android.widget.TextView import autodagger.AutoInjector import butterknife.BindView @@ -20,10 +22,19 @@ class LocationMessageViewHolder(incomingView: View) : MessageHolders private val TAG = "LocationMessageViewHolder" + var lon : String? = "" + var lat : String? = "" + var name : String? = "" + var id : String? = "" + @JvmField @BindView(R.id.locationText) var messageText: TextView? = null + @JvmField + @BindView(R.id.webview) + var webview: WebView? = null + @JvmField @Inject var context: Context? = null @@ -35,20 +46,35 @@ class LocationMessageViewHolder(incomingView: View) : MessageHolders ) } - @SuppressLint("SetTextI18n") + @SuppressLint("SetTextI18n", "SetJavaScriptEnabled") override fun onBind(message: ChatMessage) { super.onBind(message) - if (message.messageType == ChatMessage.MessageType.SINGLE_NC_GEOLOCATION_MESSAGE) { - Log.d(TAG, "handle geolocation here") - messageText!!.text = "geolocation..." - } + // if (message.messageType == ChatMessage.MessageType.SINGLE_NC_GEOLOCATION_MESSAGE) { + // Log.d(TAG, "handle geolocation here") + // messageText!!.text = "geolocation..." + // } if (message.messageParameters != null && message.messageParameters.size > 0) { for (key in message.messageParameters.keys) { val individualHashMap: Map = message.messageParameters[key]!! - val lon = individualHashMap["longitude"] - val lat = individualHashMap["latitude"] - Log.d(TAG, "lon $lon lat $lat") + if (individualHashMap["type"] == "geo-location") { + lon = individualHashMap["longitude"] + lat = individualHashMap["latitude"] + name = individualHashMap["name"] + id = individualHashMap["id"] + Log.d(TAG, "lon $lon lat $lat name $name id $id") + } } } + + + webview?.settings?.javaScriptEnabled = true + + webview?.webViewClient = object : WebViewClient() { + override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean { + view?.loadUrl(url) + return true + } + } + webview?.loadUrl("file:///android_asset/index.html?$lat,$lon,$name"); } } \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 435ed4a17..9c386e038 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -77,7 +77,6 @@ import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber import com.facebook.imagepipeline.image.CloseableImage import com.google.android.flexbox.FlexboxLayout import com.nextcloud.talk.R -import com.nextcloud.talk.activities.LeafletWebView import com.nextcloud.talk.activities.MagicCallActivity import com.nextcloud.talk.adapters.messages.LocationMessageViewHolder import com.nextcloud.talk.adapters.messages.MagicIncomingTextMessageViewHolder @@ -821,19 +820,19 @@ class ChatController(args: Bundle) : fun showShareLocationScreen() { Log.d(TAG, "showShareLocationScreen") - // val bundle = Bundle() - // bundle.putBoolean(KEY_NEW_CONVERSATION, true) - // router.pushController( - // RouterTransaction.with(LocationController(bundle)) - // .pushChangeHandler(HorizontalChangeHandler()) - // .popChangeHandler(HorizontalChangeHandler()) - // ) + val bundle = Bundle() + // bundle.putBoolean(, true) + router.pushController( + RouterTransaction.with(LocationController(bundle)) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()) + ) - val leafletIntent = Intent(context, LeafletWebView::class.java) - leafletIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - // fullScreenImageIntent.putExtra("FILE_NAME", filename) - // fullScreenImageIntent.putExtra("IS_GIF", isGif(mimetype)) - context!!.startActivity(leafletIntent) + // val leafletIntent = Intent(context, LeafletWebView::class.java) + // leafletIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + // // fullScreenImageIntent.putExtra("FILE_NAME", filename) + // // fullScreenImageIntent.putExtra("IS_GIF", isGif(mimetype)) + // context!!.startActivity(leafletIntent) } private fun showConversationInfoScreen() { diff --git a/app/src/main/res/layout/item_custom_location_message.xml b/app/src/main/res/layout/item_custom_location_message.xml index ae10d7579..9a2ea51dd 100644 --- a/app/src/main/res/layout/item_custom_location_message.xml +++ b/app/src/main/res/layout/item_custom_location_message.xml @@ -22,7 +22,7 @@ + + Date: Fri, 28 May 2021 10:23:30 +0200 Subject: [PATCH 09/66] pass java to javascript params with URLEncoder Signed-off-by: Marcel Hibbe --- .idea/codeStyles/Project.xml | 9 ------- ...dex.html => leafletMapMessagePreview.html} | 17 +++++++------ .../talk/activities/LeafletWebView.kt | 2 +- .../messages/LocationMessageViewHolder.kt | 24 ++++++++++++++++--- 4 files changed, 32 insertions(+), 20 deletions(-) rename app/src/main/assets/{index.html => leafletMapMessagePreview.html} (64%) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index dfeadc6bc..c7725a218 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -59,15 +59,6 @@ -