-
Notifications
You must be signed in to change notification settings - Fork 739
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 #5671 from vector-im/feature/mna/PSF-673-live-loc-…
…share-duration #5667: [Location Sharing] - Set duration of live sharing
- Loading branch information
Showing
9 changed files
with
178 additions
and
10 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 @@ | ||
Location sharing: adding possibility to choose duration of live sharing |
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
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
86 changes: 86 additions & 0 deletions
86
.../main/java/im/vector/app/features/location/live/duration/ChooseLiveDurationBottomSheet.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,86 @@ | ||
/* | ||
* Copyright 2019 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.duration | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import im.vector.app.R | ||
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment | ||
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment.ResultListener.Companion.RESULT_OK | ||
import im.vector.app.databinding.BottomSheetChooseLiveLocationShareDurationBinding | ||
|
||
/** | ||
* 15 minutes. | ||
*/ | ||
private const val DURATION_IN_MS_OPTION_1 = 15 * 60_000L | ||
|
||
/** | ||
* 1 hour. | ||
*/ | ||
private const val DURATION_IN_MS_OPTION_2 = 60 * 60_000L | ||
|
||
/** | ||
* 8 hours. | ||
*/ | ||
private const val DURATION_IN_MS_OPTION_3 = 8 * 60 * 60_000L | ||
|
||
/** | ||
* Bottom sheet displaying list of options to choose the duration of the location live sharing. | ||
*/ | ||
@AndroidEntryPoint | ||
class ChooseLiveDurationBottomSheet : | ||
VectorBaseBottomSheetDialogFragment<BottomSheetChooseLiveLocationShareDurationBinding>() { | ||
|
||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetChooseLiveLocationShareDurationBinding { | ||
return BottomSheetChooseLiveLocationShareDurationBinding.inflate(inflater, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
initConfirmButton() | ||
} | ||
|
||
// we are not using state for this one as it's static, so no need to override invalidate() | ||
|
||
private fun initConfirmButton() { | ||
views.liveLocShareChooseDurationConfirm.setOnClickListener { | ||
val currentChoice = getCurrentChoice() | ||
resultListener?.onBottomSheetResult(RESULT_OK, currentChoice) | ||
dismiss() | ||
} | ||
} | ||
|
||
private fun getCurrentChoice(): Long { | ||
return when (views.liveLocShareChooseDurationOptions.checkedRadioButtonId) { | ||
R.id.liveLocShareChooseDurationOption1 -> DURATION_IN_MS_OPTION_1 | ||
R.id.liveLocShareChooseDurationOption2 -> DURATION_IN_MS_OPTION_2 | ||
R.id.liveLocShareChooseDurationOption3 -> DURATION_IN_MS_OPTION_3 | ||
else -> DURATION_IN_MS_OPTION_1 | ||
} | ||
} | ||
|
||
companion object { | ||
fun newInstance(resultListener: ResultListener): ChooseLiveDurationBottomSheet { | ||
val bottomSheet = ChooseLiveDurationBottomSheet() | ||
bottomSheet.resultListener = resultListener | ||
return bottomSheet | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
vector/src/main/res/layout/bottom_sheet_choose_live_location_share_duration.xml
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,64 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:background="?colorSurface" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/liveLocShareChooseDurationTitle" | ||
style="@style/Widget.Vector.TextView.Subtitle.Medium" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center_vertical" | ||
android:paddingHorizontal="15dp" | ||
android:paddingVertical="24dp" | ||
android:text="@string/location_share_live_select_duration_title" | ||
android:textColor="?vctr_content_primary" /> | ||
|
||
<RadioGroup | ||
android:id="@+id/liveLocShareChooseDurationOptions" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:divider="@drawable/divider_horizontal" | ||
android:showDividers="beginning"> | ||
|
||
<RadioButton | ||
android:id="@+id/liveLocShareChooseDurationOption1" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="@dimen/location_sharing_live_duration_choice_margin_horizontal" | ||
android:checked="true" | ||
android:paddingHorizontal="@dimen/location_sharing_live_duration_choice_margin_horizontal" | ||
android:paddingVertical="@dimen/location_sharing_live_duration_choice_margin_vertical" | ||
android:text="@string/location_share_live_select_duration_option_1" /> | ||
|
||
<RadioButton | ||
android:id="@+id/liveLocShareChooseDurationOption2" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="@dimen/location_sharing_live_duration_choice_margin_horizontal" | ||
android:paddingHorizontal="@dimen/location_sharing_live_duration_choice_margin_horizontal" | ||
android:paddingVertical="@dimen/location_sharing_live_duration_choice_margin_vertical" | ||
android:text="@string/location_share_live_select_duration_option_2" /> | ||
|
||
<RadioButton | ||
android:id="@+id/liveLocShareChooseDurationOption3" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="@dimen/location_sharing_live_duration_choice_margin_horizontal" | ||
android:paddingHorizontal="@dimen/location_sharing_live_duration_choice_margin_horizontal" | ||
android:paddingVertical="@dimen/location_sharing_live_duration_choice_margin_vertical" | ||
android:text="@string/location_share_live_select_duration_option_3" /> | ||
</RadioGroup> | ||
|
||
<Button | ||
android:id="@+id/liveLocShareChooseDurationConfirm" | ||
style="@style/Widget.Vector.Button.CallToAction" | ||
android:layout_width="match_parent" | ||
android:layout_height="65dp" | ||
android:layout_marginHorizontal="16dp" | ||
android:layout_marginVertical="12dp" | ||
android:text="@string/action_share" /> | ||
|
||
</LinearLayout> |
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