-
Notifications
You must be signed in to change notification settings - Fork 905
Promote live location labs flag [PSF-959] #6350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
9641ff1
b37dce7
13144f0
80abe1f
ab34bb6
320915e
2fe03a0
3ec8c77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Promote live location labs flag |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * 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 | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment | ||
| import im.vector.app.databinding.BottomSheetLiveLocationLabsFlagPromotionBinding | ||
|
|
||
| /** | ||
| * Bottom sheet to warn users that feature is still in active development. Users are able to enable labs flag by using the switch in this bottom sheet. | ||
| * This should not be shown if the user already enabled the labs flag. | ||
| */ | ||
| class LiveLocationLabsFlagPromotionBottomSheet : | ||
| VectorBaseBottomSheetDialogFragment<BottomSheetLiveLocationLabsFlagPromotionBinding>() { | ||
|
|
||
| override val showExpanded = true | ||
|
|
||
| override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetLiveLocationLabsFlagPromotionBinding { | ||
| return BottomSheetLiveLocationLabsFlagPromotionBinding.inflate(inflater, container, false) | ||
| } | ||
|
|
||
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
| super.onViewCreated(view, savedInstanceState) | ||
| initOkButton() | ||
| } | ||
|
|
||
| private fun initOkButton() { | ||
| views.promoteLiveLocationFlagOkButton.debouncedClicks { | ||
| val enableLabsFlag = views.promoteLiveLocationFlagSwitch.isChecked | ||
| resultListener?.onBottomSheetResult(ResultListener.RESULT_OK, enableLabsFlag) | ||
| dismiss() | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| fun newInstance(resultListener: ResultListener): LiveLocationLabsFlagPromotionBottomSheet { | ||
| return LiveLocationLabsFlagPromotionBottomSheet().also { | ||
| it.resultListener = resultListener | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a big big deal, but we will loose the listener if the Fragment is recreated by system
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch. Fixed. |
||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1047,6 +1047,12 @@ class VectorPreferences @Inject constructor( | |
| return defaultPrefs.getBoolean(SETTINGS_LABS_ENABLE_LIVE_LOCATION, false) | ||
| } | ||
|
|
||
| fun setLiveLocationLabsEnabled() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add parameter?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| defaultPrefs.edit { | ||
| putBoolean(SETTINGS_LABS_ENABLE_LIVE_LOCATION, true) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Indicates whether or not thread messages are enabled. | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:background="?colorSurface" | ||
| android:orientation="vertical" | ||
| android:paddingHorizontal="16dp" | ||
| android:paddingBottom="8dp"> | ||
|
|
||
| <ImageView | ||
| android:layout_width="60dp" | ||
| android:layout_height="60dp" | ||
| android:layout_gravity="center_horizontal" | ||
| android:layout_marginTop="30dp" | ||
| android:background="@drawable/circle" | ||
| android:backgroundTint="?vctr_live_location" | ||
| android:importantForAccessibility="no" | ||
| android:padding="4dp" | ||
| android:src="@drawable/ic_attachment_location_live_white" /> | ||
|
|
||
| <TextView | ||
| style="@style/TextAppearance.Vector.Headline.Medium" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_gravity="center" | ||
| android:layout_marginTop="24dp" | ||
| android:text="@string/live_location_labs_promotion_title" /> | ||
|
|
||
| <TextView | ||
| style="@style/TextAppearance.Vector.Body" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_gravity="center" | ||
| android:layout_marginTop="24dp" | ||
| android:gravity="center" | ||
| android:text="@string/live_location_labs_promotion_description" /> | ||
|
|
||
| <com.google.android.material.switchmaterial.SwitchMaterial | ||
| android:id="@+id/promoteLiveLocationFlagSwitch" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_gravity="center" | ||
| android:layout_marginTop="40dp" | ||
| android:text="@string/live_location_labs_promotion_switch_title" | ||
| app:switchPadding="8dp" /> | ||
|
|
||
| <Button | ||
| android:id="@+id/promoteLiveLocationFlagOkButton" | ||
| style="@style/Widget.Vector.Button.Positive" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="32dp" | ||
| android:text="@string/ok" /> | ||
|
|
||
| </LinearLayout> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3088,4 +3088,10 @@ | |
| <string name="settings_troubleshoot_test_current_endpoint_failed">Cannot find the endpoint.</string> | ||
| <string name="settings_troubleshoot_test_current_gateway_title">Gateway</string> | ||
| <string name="settings_troubleshoot_test_current_gateway">Current gateway: %s</string> | ||
|
|
||
| <!-- Live Location Sharing Labs Flag Promotional BottomSheet --> | ||
| <string name="live_location_labs_promotion_title">Live location sharing</string> | ||
| <string name="live_location_labs_promotion_description">Please note: this is a labs feature using a temporary implementation. This means you will not be able to delete your location history, and advanced users will be able to see your location history even after you stop sharing your live location with this room.</string> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this the final copy? it's a little bit techy~
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it is. I think it is not so hard to understand for users. |
||
| <string name="live_location_labs_promotion_switch_title">Enable location sharing</string> | ||
|
|
||
| </resources> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment above could be replaced by extracting this condition to its own function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, done.