-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6092 from vector-im/feature/mna/PSF-888-navigation
[Location sharing] - Navigation to Map view from live location message (PSF-888)
- Loading branch information
Showing
10 changed files
with
180 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Live location sharing: navigation from timeline to map screen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.features.location.live.map | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Parcelable | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import im.vector.app.R | ||
import im.vector.app.core.extensions.addFragment | ||
import im.vector.app.core.platform.VectorBaseActivity | ||
import im.vector.app.databinding.ActivityLocationSharingBinding | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
data class LocationLiveMapViewArgs( | ||
val roomId: String | ||
) : Parcelable | ||
|
||
@AndroidEntryPoint | ||
class LocationLiveMapViewActivity : VectorBaseActivity<ActivityLocationSharingBinding>() { | ||
|
||
override fun getBinding() = ActivityLocationSharingBinding.inflate(layoutInflater) | ||
|
||
override fun initUiAndData() { | ||
val mapViewArgs: LocationLiveMapViewArgs? = intent?.extras?.getParcelable(EXTRA_LOCATION_LIVE_MAP_VIEW_ARGS) | ||
if (mapViewArgs == null) { | ||
finish() | ||
return | ||
} | ||
setupToolbar(views.toolbar) | ||
.setTitle(getString(R.string.location_activity_title_preview)) | ||
.allowBack() | ||
|
||
if (isFirstCreation()) { | ||
addFragment( | ||
views.fragmentContainer, | ||
LocationLiveMapViewFragment::class.java, | ||
mapViewArgs | ||
) | ||
} | ||
} | ||
|
||
companion object { | ||
|
||
private const val EXTRA_LOCATION_LIVE_MAP_VIEW_ARGS = "EXTRA_LOCATION_LIVE_MAP_VIEW_ARGS" | ||
|
||
fun getIntent(context: Context, locationLiveMapViewArgs: LocationLiveMapViewArgs): Intent { | ||
return Intent(context, LocationLiveMapViewActivity::class.java).apply { | ||
putExtra(EXTRA_LOCATION_LIVE_MAP_VIEW_ARGS, locationLiveMapViewArgs) | ||
} | ||
} | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.features.location.live.map | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.lifecycle.lifecycleScope | ||
import com.airbnb.mvrx.args | ||
import com.mapbox.mapboxsdk.maps.MapboxMapOptions | ||
import com.mapbox.mapboxsdk.maps.SupportMapFragment | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import im.vector.app.R | ||
import im.vector.app.core.extensions.addChildFragment | ||
import im.vector.app.core.platform.VectorBaseFragment | ||
import im.vector.app.databinding.FragmentSimpleContainerBinding | ||
import im.vector.app.features.location.UrlMapProvider | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Screen showing a map with all the current users sharing their live location in room. | ||
*/ | ||
@AndroidEntryPoint | ||
class LocationLiveMapViewFragment : VectorBaseFragment<FragmentSimpleContainerBinding>() { | ||
|
||
@Inject | ||
lateinit var urlMapProvider: UrlMapProvider | ||
|
||
private val args: LocationLiveMapViewArgs by args() | ||
|
||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentSimpleContainerBinding { | ||
return FragmentSimpleContainerBinding.inflate(layoutInflater, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
setupMap() | ||
} | ||
|
||
private fun setupMap() { | ||
val mapFragment = getOrCreateSupportMapFragment() | ||
|
||
mapFragment.getMapAsync { mapBoxMap -> | ||
lifecycleScope.launchWhenCreated { | ||
mapBoxMap.setStyle(urlMapProvider.getMapUrl()) | ||
} | ||
} | ||
} | ||
|
||
private fun getOrCreateSupportMapFragment() = | ||
childFragmentManager.findFragmentByTag(MAP_FRAGMENT_TAG) as? SupportMapFragment | ||
?: run { | ||
val options = MapboxMapOptions.createFromAttributes(requireContext(), null) | ||
SupportMapFragment.newInstance(options) | ||
.also { addChildFragment(R.id.fragmentContainer, it, tag = MAP_FRAGMENT_TAG) } | ||
} | ||
|
||
companion object { | ||
private const val MAP_FRAGMENT_TAG = "im.vector.app.features.location.live.map" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/fragmentContainer" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> |