wip. show leaflet inside webview in message

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2021-05-28 00:27:43 +02:00 committed by Andy Scherzinger
parent ba7bfe3150
commit 5da43d1760
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
4 changed files with 58 additions and 27 deletions

View File

@ -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: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([coords[0], coords[1]]).addTo(map)
.bindPopup('popup')
.openPopup();
L.marker([lat, lon]).addTo(map);
</script>
</body>
</html>

View File

@ -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<String, String> = 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");
}
}

View File

@ -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() {

View File

@ -22,7 +22,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="200dp"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginStart="16dp"
@ -30,6 +30,12 @@
android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<TextView
android:id="@+id/locationText"
android:layout_width="wrap_content"