Skip to content
Snippets Groups Projects
Commit c4a3fccc authored by Adrien Béraud's avatar Adrien Béraud
Browse files

location sharing: route intent through HomeActivity

Change-Id: Ifc79e09642326f161ad562dfc325757f2d587c2a
parent ba2ca6ec
Branches
Tags
No related merge requests found
...@@ -239,7 +239,7 @@ class HomeActivity : AppCompatActivity(), ContactPickerFragment.OnContactedPicke ...@@ -239,7 +239,7 @@ class HomeActivity : AppCompatActivity(), ContactPickerFragment.OnContactedPicke
DRingService.ACTION_CONV_ACCEPT -> { DRingService.ACTION_CONV_ACCEPT -> {
val path = ConversationPath.fromIntent(intent) val path = ConversationPath.fromIntent(intent)
if (path != null) if (path != null)
startConversation(path) startConversation(path, intent)
} }
} }
if (Intent.ACTION_SEARCH == action) { if (Intent.ACTION_SEARCH == action) {
......
...@@ -40,7 +40,7 @@ import androidx.core.app.ActivityCompat ...@@ -40,7 +40,7 @@ import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import cx.ring.R import cx.ring.R
import cx.ring.application.JamiApplication import cx.ring.application.JamiApplication
import cx.ring.client.ConversationActivity import cx.ring.client.HomeActivity
import cx.ring.fragments.ConversationFragment import cx.ring.fragments.ConversationFragment
import cx.ring.services.NotificationServiceImpl import cx.ring.services.NotificationServiceImpl
import cx.ring.utils.ContentUri import cx.ring.utils.ContentUri
...@@ -92,13 +92,12 @@ class LocationSharingService : Service(), LocationListener { ...@@ -92,13 +92,12 @@ class LocationSharingService : Service(), LocationListener {
val contactSharing: Observable<Set<ConversationPath>> val contactSharing: Observable<Set<ConversationPath>>
get() = mContactSharingSubject get() = mContactSharingSubject
fun getContactSharingExpiration(path: ConversationPath): Observable<Long> { fun getContactSharingExpiration(path: ConversationPath): Observable<Long> =
return Observable.timer(1, TimeUnit.SECONDS, AndroidSchedulers.mainThread()) Observable.timer(1, TimeUnit.SECONDS, AndroidSchedulers.mainThread())
.startWithItem(0L) .startWithItem(0L)
.repeat() .repeat()
.map { contactLocationShare[path]!!.time - SystemClock.elapsedRealtime() } .map { contactLocationShare[path]!!.time - SystemClock.elapsedRealtime() }
.onErrorComplete() .onErrorComplete()
}
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
...@@ -159,19 +158,17 @@ class LocationSharingService : Service(), LocationListener { ...@@ -159,19 +158,17 @@ class LocationSharingService : Service(), LocationListener {
}) })
mDisposableBag.add(mMyLocationSubject mDisposableBag.add(mMyLocationSubject
.throttleLatest(10, TimeUnit.SECONDS) .throttleLatest(10, TimeUnit.SECONDS)
.map { location -> .map { location -> JSONObject().apply {
val out = JSONObject() put("type", AccountService.Location.Type.Position.toString())
out.put("type", AccountService.Location.Type.Position.toString()) put("lat", location.latitude)
out.put("lat", location.latitude) put("long", location.longitude)
out.put("long", location.longitude) put("alt", location.altitude)
out.put("alt", location.altitude) put("time", location.elapsedRealtimeNanos / 1000000L)
out.put("time", location.elapsedRealtimeNanos / 1000000L)
val bearing = location.bearing val bearing = location.bearing
if (bearing != 0f) out.put("bearing", bearing.toDouble()) if (bearing != 0f) put("bearing", bearing.toDouble())
val speed = location.speed val speed = location.speed
if (speed != 0f) out.put("speed", speed.toDouble()) if (speed != 0f) put("speed", speed.toDouble())
out } }
}
.subscribe { location: JSONObject -> .subscribe { location: JSONObject ->
Log.w(TAG, "location send " + location + " to " + contactLocationShare.size) Log.w(TAG, "location send " + location + " to " + contactLocationShare.size)
val msgs = StringMap() val msgs = StringMap()
...@@ -260,7 +257,7 @@ class LocationSharingService : Service(), LocationListener { ...@@ -260,7 +257,7 @@ class LocationSharingService : Service(), LocationListener {
Intent.ACTION_VIEW, Intent.ACTION_VIEW,
firsPath.toUri(), firsPath.toUri(),
applicationContext, applicationContext,
ConversationActivity::class.java HomeActivity::class.java
) )
.putExtra(ConversationFragment.EXTRA_SHOW_MAP, true) .putExtra(ConversationFragment.EXTRA_SHOW_MAP, true)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment