mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
wip. show leaflet inside webview in message
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
ba7bfe3150
commit
5da43d1760
@ -20,19 +20,19 @@
|
|||||||
|
|
||||||
var queryString = window.location.search;
|
var queryString = window.location.search;
|
||||||
queryString = queryString.substring(1);
|
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();
|
map.dragging.disable();
|
||||||
|
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
L.marker([coords[0], coords[1]]).addTo(map)
|
L.marker([lat, lon]).addTo(map);
|
||||||
.bindPopup('popup')
|
|
||||||
.openPopup();
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -4,6 +4,8 @@ import android.annotation.SuppressLint
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.webkit.WebView
|
||||||
|
import android.webkit.WebViewClient
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import autodagger.AutoInjector
|
import autodagger.AutoInjector
|
||||||
import butterknife.BindView
|
import butterknife.BindView
|
||||||
@ -20,10 +22,19 @@ class LocationMessageViewHolder(incomingView: View) : MessageHolders
|
|||||||
|
|
||||||
private val TAG = "LocationMessageViewHolder"
|
private val TAG = "LocationMessageViewHolder"
|
||||||
|
|
||||||
|
var lon : String? = ""
|
||||||
|
var lat : String? = ""
|
||||||
|
var name : String? = ""
|
||||||
|
var id : String? = ""
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
@BindView(R.id.locationText)
|
@BindView(R.id.locationText)
|
||||||
var messageText: TextView? = null
|
var messageText: TextView? = null
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
@BindView(R.id.webview)
|
||||||
|
var webview: WebView? = null
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
@Inject
|
@Inject
|
||||||
var context: Context? = null
|
var context: Context? = null
|
||||||
@ -35,20 +46,35 @@ class LocationMessageViewHolder(incomingView: View) : MessageHolders
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n", "SetJavaScriptEnabled")
|
||||||
override fun onBind(message: ChatMessage) {
|
override fun onBind(message: ChatMessage) {
|
||||||
super.onBind(message)
|
super.onBind(message)
|
||||||
if (message.messageType == ChatMessage.MessageType.SINGLE_NC_GEOLOCATION_MESSAGE) {
|
// if (message.messageType == ChatMessage.MessageType.SINGLE_NC_GEOLOCATION_MESSAGE) {
|
||||||
Log.d(TAG, "handle geolocation here")
|
// Log.d(TAG, "handle geolocation here")
|
||||||
messageText!!.text = "geolocation..."
|
// messageText!!.text = "geolocation..."
|
||||||
}
|
// }
|
||||||
if (message.messageParameters != null && message.messageParameters.size > 0) {
|
if (message.messageParameters != null && message.messageParameters.size > 0) {
|
||||||
for (key in message.messageParameters.keys) {
|
for (key in message.messageParameters.keys) {
|
||||||
val individualHashMap: Map<String, String> = message.messageParameters[key]!!
|
val individualHashMap: Map<String, String> = message.messageParameters[key]!!
|
||||||
val lon = individualHashMap["longitude"]
|
if (individualHashMap["type"] == "geo-location") {
|
||||||
val lat = individualHashMap["latitude"]
|
lon = individualHashMap["longitude"]
|
||||||
Log.d(TAG, "lon $lon lat $lat")
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
@ -77,7 +77,6 @@ import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber
|
|||||||
import com.facebook.imagepipeline.image.CloseableImage
|
import com.facebook.imagepipeline.image.CloseableImage
|
||||||
import com.google.android.flexbox.FlexboxLayout
|
import com.google.android.flexbox.FlexboxLayout
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.activities.LeafletWebView
|
|
||||||
import com.nextcloud.talk.activities.MagicCallActivity
|
import com.nextcloud.talk.activities.MagicCallActivity
|
||||||
import com.nextcloud.talk.adapters.messages.LocationMessageViewHolder
|
import com.nextcloud.talk.adapters.messages.LocationMessageViewHolder
|
||||||
import com.nextcloud.talk.adapters.messages.MagicIncomingTextMessageViewHolder
|
import com.nextcloud.talk.adapters.messages.MagicIncomingTextMessageViewHolder
|
||||||
@ -821,19 +820,19 @@ class ChatController(args: Bundle) :
|
|||||||
fun showShareLocationScreen() {
|
fun showShareLocationScreen() {
|
||||||
Log.d(TAG, "showShareLocationScreen")
|
Log.d(TAG, "showShareLocationScreen")
|
||||||
|
|
||||||
// val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
// bundle.putBoolean(KEY_NEW_CONVERSATION, true)
|
// bundle.putBoolean(, true)
|
||||||
// router.pushController(
|
router.pushController(
|
||||||
// RouterTransaction.with(LocationController(bundle))
|
RouterTransaction.with(LocationController(bundle))
|
||||||
// .pushChangeHandler(HorizontalChangeHandler())
|
.pushChangeHandler(HorizontalChangeHandler())
|
||||||
// .popChangeHandler(HorizontalChangeHandler())
|
.popChangeHandler(HorizontalChangeHandler())
|
||||||
// )
|
)
|
||||||
|
|
||||||
val leafletIntent = Intent(context, LeafletWebView::class.java)
|
// val leafletIntent = Intent(context, LeafletWebView::class.java)
|
||||||
leafletIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
// leafletIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
// fullScreenImageIntent.putExtra("FILE_NAME", filename)
|
// // fullScreenImageIntent.putExtra("FILE_NAME", filename)
|
||||||
// fullScreenImageIntent.putExtra("IS_GIF", isGif(mimetype))
|
// // fullScreenImageIntent.putExtra("IS_GIF", isGif(mimetype))
|
||||||
context!!.startActivity(leafletIntent)
|
// context!!.startActivity(leafletIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showConversationInfoScreen() {
|
private fun showConversationInfoScreen() {
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="200dp"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
@ -30,6 +30,12 @@
|
|||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginBottom="8dp">
|
android:layout_marginBottom="8dp">
|
||||||
|
|
||||||
|
<WebView
|
||||||
|
android:id="@+id/webview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/locationText"
|
android:id="@+id/locationText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
Loading…
Reference in New Issue
Block a user