-
Notifications
You must be signed in to change notification settings - Fork 709
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 #5375 from vector-im/feature/adm/display-personali…
…sation-based-on-capabilities FTUE - Capability based personalisation flow
- Loading branch information
Showing
27 changed files
with
615 additions
and
66 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 @@ | ||
Dynamically showing/hiding onboarding personalisation screens based on the users homeserver capabilities |
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
vector/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.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 (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.debug.settings | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.Gravity | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.widget.AdapterView | ||
import android.widget.ArrayAdapter | ||
import android.widget.LinearLayout | ||
import im.vector.app.R | ||
import im.vector.app.databinding.ViewBooleanDropdownBinding | ||
|
||
class OverrideDropdownView @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null | ||
) : LinearLayout(context, attrs) { | ||
|
||
private val binding = ViewBooleanDropdownBinding.inflate( | ||
LayoutInflater.from(context), | ||
this | ||
) | ||
|
||
init { | ||
orientation = HORIZONTAL | ||
gravity = Gravity.CENTER_VERTICAL | ||
} | ||
|
||
fun <T : OverrideOption> bind(feature: OverrideDropdown<T>, listener: Listener<T>) { | ||
binding.overrideLabel.text = feature.label | ||
|
||
binding.overrideOptions.apply { | ||
val arrayAdapter = ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item) | ||
val options = listOf("Inactive") + feature.options.map { it.label } | ||
arrayAdapter.addAll(options) | ||
adapter = arrayAdapter | ||
|
||
feature.activeOption?.let { | ||
setSelection(options.indexOf(it.label), false) | ||
} | ||
|
||
onItemSelectedListener = object : AdapterView.OnItemSelectedListener { | ||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { | ||
when (position) { | ||
0 -> listener.onOverrideSelected(option = null) | ||
else -> listener.onOverrideSelected(feature.options[position - 1]) | ||
} | ||
} | ||
|
||
override fun onNothingSelected(parent: AdapterView<*>?) { | ||
// do nothing | ||
} | ||
} | ||
} | ||
} | ||
|
||
fun interface Listener<T> { | ||
fun onOverrideSelected(option: T?) | ||
} | ||
|
||
data class OverrideDropdown<T : OverrideOption>( | ||
val label: String, | ||
val options: List<T>, | ||
val activeOption: T?, | ||
) | ||
} | ||
|
||
interface OverrideOption { | ||
val label: String | ||
} |
42 changes: 42 additions & 0 deletions
42
vector/src/debug/java/im/vector/app/features/debug/settings/PrivateSettingOverrides.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,42 @@ | ||
/* | ||
* 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.debug.settings | ||
|
||
sealed interface BooleanHomeserverCapabilitiesOverride : OverrideOption { | ||
|
||
companion object { | ||
fun from(value: Boolean?) = when (value) { | ||
null -> null | ||
true -> ForceEnabled | ||
false -> ForceDisabled | ||
} | ||
} | ||
|
||
object ForceEnabled : BooleanHomeserverCapabilitiesOverride { | ||
override val label = "Force enabled" | ||
} | ||
|
||
object ForceDisabled : BooleanHomeserverCapabilitiesOverride { | ||
override val label = "Force disabled" | ||
} | ||
} | ||
|
||
fun BooleanHomeserverCapabilitiesOverride?.toBoolean() = when (this) { | ||
null -> null | ||
BooleanHomeserverCapabilitiesOverride.ForceDisabled -> false | ||
BooleanHomeserverCapabilitiesOverride.ForceEnabled -> true | ||
} |
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,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<merge xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:parentTag="android.widget.LinearLayout"> | ||
|
||
<TextView | ||
android:id="@+id/overrideLabel" | ||
style="@style/Widget.Vector.TextView.Subtitle" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_weight="1" | ||
android:gravity="center" | ||
android:textColor="?vctr_content_primary" | ||
tools:text="Login version" /> | ||
|
||
<androidx.appcompat.widget.AppCompatSpinner | ||
android:id="@+id/overrideOptions" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" /> | ||
|
||
</merge> |
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
Oops, something went wrong.