mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added custom settings to directly go to third party sip account login & pre-fill some fields
This commit is contained in:
parent
ef32dac910
commit
5ce7a5524a
8 changed files with 91 additions and 12 deletions
|
|
@ -220,6 +220,22 @@ class CorePreferences @UiThread constructor(private val context: Context) {
|
|||
val useUsernameAsSingleSignOnLoginHint: Boolean
|
||||
get() = config.getBool("ui", "use_username_as_sso_login_hint", true)
|
||||
|
||||
@get:WorkerThread
|
||||
val thirdPartySipAccountDefaultTransport: String
|
||||
get() = config.getString("ui", "assistant_third_party_sip_account_transport", "tls")!!
|
||||
|
||||
@get:WorkerThread
|
||||
val thirdPartySipAccountDefaultDomain: String
|
||||
get() = config.getString("ui", "assistant_third_party_sip_account_domain", "")!!
|
||||
|
||||
@get:WorkerThread
|
||||
val assistantDirectlyGoToThirdPartySipAccountLogin: Boolean
|
||||
get() = config.getBool(
|
||||
"ui",
|
||||
"assistant_go_directly_to_third_party_sip_account_login",
|
||||
false
|
||||
)
|
||||
|
||||
@get:WorkerThread
|
||||
val automaticallyShowDialpad: Boolean
|
||||
get() = config.getBool("ui", "automatically_show_dialpad", false)
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ class TelecomAndroidAutoService : CarAppService() {
|
|||
|
||||
override fun createHostValidator(): HostValidator {
|
||||
val host = hostInfo
|
||||
Log.e("$TAG Host is [${host?.packageName}] with UID [${host?.uid}]")
|
||||
Log.i("$TAG Host is [${host?.packageName}] with UID [${host?.uid}]")
|
||||
|
||||
val validator = HostValidator.Builder(applicationContext)
|
||||
.addAllowedHosts(R.array.hosts_allowlist_sample_copy) // androidx.car.app.R.array.hosts_allowlist_sampl
|
||||
.addAllowedHosts(R.array.hosts_allowlist_sample_copy) // androidx.car.app.R.array.hosts_allowlist_sample
|
||||
.build()
|
||||
if (host != null) {
|
||||
val allowed = validator.isValidHost(host)
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class LandingFragment : GenericFragment() {
|
|||
|
||||
binding.setThirdPartySipAccountLoginClickListener {
|
||||
if (viewModel.conditionsAndPrivacyPolicyAccepted) {
|
||||
goToLoginThirdPartySipAccountFragment()
|
||||
goToLoginThirdPartySipAccountFragment(false)
|
||||
} else {
|
||||
showAcceptConditionsAndPrivacyDialog(goToThirdPartySipAccountLogin = true)
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ class LandingFragment : GenericFragment() {
|
|||
}
|
||||
|
||||
viewModel.accountLoggedInEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { firstAccount ->
|
||||
it.consume {
|
||||
Log.i("$TAG Account successfully logged-in, leaving assistant")
|
||||
requireActivity().finish()
|
||||
}
|
||||
|
|
@ -131,6 +131,12 @@ class LandingFragment : GenericFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.skipLandingToThirdPartySipAccountEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
goToLoginThirdPartySipAccountFragment(true)
|
||||
}
|
||||
}
|
||||
|
||||
coreContext.postOnCoreThread {
|
||||
val dialPlan = PhoneNumberUtils.getDeviceDialPlan(requireContext())
|
||||
if (dialPlan != null) {
|
||||
|
|
@ -145,8 +151,12 @@ class LandingFragment : GenericFragment() {
|
|||
findNavController().navigate(action)
|
||||
}
|
||||
|
||||
private fun goToLoginThirdPartySipAccountFragment() {
|
||||
val action = LandingFragmentDirections.actionLandingFragmentToThirdPartySipAccountWarningFragment()
|
||||
private fun goToLoginThirdPartySipAccountFragment(skipWarning: Boolean) {
|
||||
val action = if (skipWarning) {
|
||||
LandingFragmentDirections.actionLandingFragmentToThirdPartySipAccountLoginFragment()
|
||||
} else {
|
||||
LandingFragmentDirections.actionLandingFragmentToThirdPartySipAccountWarningFragment()
|
||||
}
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +187,7 @@ class LandingFragment : GenericFragment() {
|
|||
if (goToAccountCreate) {
|
||||
goToRegisterFragment()
|
||||
} else if (goToThirdPartySipAccountLogin) {
|
||||
goToLoginThirdPartySipAccountFragment()
|
||||
goToLoginThirdPartySipAccountFragment(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ class ThirdPartySipAccountLoginFragment : GenericFragment() {
|
|||
adapter.setDropDownViewResource(R.layout.generic_dropdown_cell)
|
||||
binding.transport.adapter = adapter
|
||||
binding.transport.onItemSelectedListener = dropdownListener
|
||||
binding.transport.setSelection(viewModel.availableTransports.size - 1)
|
||||
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
|
@ -120,6 +119,12 @@ class ThirdPartySipAccountLoginFragment : GenericFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.defaultTransportIndexEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { index ->
|
||||
binding.transport.setSelection(index)
|
||||
}
|
||||
}
|
||||
|
||||
coreContext.bearerAuthenticationRequestedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val serverUrl = pair.first
|
||||
|
|
|
|||
|
|
@ -73,6 +73,10 @@ open class AccountLoginViewModel @UiThread constructor() : GenericViewModel() {
|
|||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val skipLandingToThirdPartySipAccountEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
var conditionsAndPrivacyPolicyAccepted = false
|
||||
|
||||
private lateinit var newlyCreatedAuthInfo: AuthInfo
|
||||
|
|
@ -129,6 +133,10 @@ open class AccountLoginViewModel @UiThread constructor() : GenericViewModel() {
|
|||
hideScanQrCode.postValue(corePreferences.hideAssistantScanQrCode)
|
||||
hideThirdPartyAccount.postValue(corePreferences.hideAssistantThirdPartySipAccount)
|
||||
conditionsAndPrivacyPolicyAccepted = corePreferences.conditionsAndPrivacyPolicyAccepted
|
||||
|
||||
if (corePreferences.assistantDirectlyGoToThirdPartySipAccountLogin) {
|
||||
skipLandingToThirdPartySipAccountEvent.postValue(Event(true))
|
||||
}
|
||||
}
|
||||
|
||||
showPassword.value = false
|
||||
|
|
|
|||
|
|
@ -67,9 +67,17 @@ class ThirdPartySipAccountLoginViewModel @UiThread constructor() : GenericViewMo
|
|||
|
||||
val registrationInProgress = MutableLiveData<Boolean>()
|
||||
|
||||
val accountLoggedInEvent = MutableLiveData<Event<Boolean>>()
|
||||
val accountLoggedInEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val accountLoginErrorEvent = MutableLiveData<Event<String>>()
|
||||
val accountLoginErrorEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val defaultTransportIndexEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
val availableTransports = arrayListOf<String>()
|
||||
|
||||
|
|
@ -135,6 +143,20 @@ class ThirdPartySipAccountLoginViewModel @UiThread constructor() : GenericViewMo
|
|||
availableTransports.add(TransportType.Udp.name.uppercase(Locale.getDefault()))
|
||||
availableTransports.add(TransportType.Tcp.name.uppercase(Locale.getDefault()))
|
||||
availableTransports.add(TransportType.Tls.name.uppercase(Locale.getDefault()))
|
||||
|
||||
coreContext.postOnCoreThread {
|
||||
domain.postValue(corePreferences.thirdPartySipAccountDefaultDomain)
|
||||
|
||||
val defaultTransport = corePreferences.thirdPartySipAccountDefaultTransport.uppercase(
|
||||
Locale.getDefault()
|
||||
)
|
||||
val index = if (defaultTransport.isNotEmpty()) {
|
||||
availableTransports.indexOf(defaultTransport)
|
||||
} else {
|
||||
availableTransports.size - 1
|
||||
}
|
||||
defaultTransportIndexEvent.postValue(Event(index))
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
|
|||
|
|
@ -134,6 +134,16 @@
|
|||
app:popEnterAnim="@anim/slide_in_left"
|
||||
app:popExitAnim="@anim/slide_out_right"
|
||||
app:launchSingleTop="true" />
|
||||
<action
|
||||
android:id="@+id/action_landingFragment_to_thirdPartySipAccountLoginFragment"
|
||||
app:destination="@id/thirdPartySipAccountLoginFragment"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:exitAnim="@anim/slide_out_left"
|
||||
app:popEnterAnim="@anim/slide_in_left"
|
||||
app:popExitAnim="@anim/slide_out_right"
|
||||
app:launchSingleTop="true"
|
||||
app:popUpTo="@id/landingFragment"
|
||||
app:popUpToInclusive="true"/>
|
||||
|
||||
</fragment>
|
||||
|
||||
|
|
|
|||
|
|
@ -855,8 +855,7 @@
|
|||
<string name="content_description_ldap_save">Save LDAP configuration</string>
|
||||
<string name="content_description_play_call_recording">Plays the call recording</string>
|
||||
|
||||
<!-- Copy of private hosts_allowlist_sample in androidx.car.app:app:1.7.0-beta01, as they recommend it.
|
||||
I removed android automotive hosts to only keep Android Auto ones for now -->
|
||||
<!-- Copy of private hosts_allowlist_sample in androidx.car.app:app:1.7.0-beta01, as they recommend it -->
|
||||
<string-array name="hosts_allowlist_sample_copy" translatable="false">
|
||||
<item>fdb00c43dbde8b51cb312aa81d3b5fa17713adb94b28f598d77f8eb89daceedf,
|
||||
com.google.android.projection.gearhead</item>
|
||||
|
|
@ -866,5 +865,14 @@
|
|||
|
||||
<item>1975b2f17177bc89a5dff31f9e64a6cae281a53dc1d1d59b1d147fe1c82afa00,
|
||||
com.google.android.projection.gearhead</item>
|
||||
|
||||
<item>c241ffbc8e287c4e9a4ad19632ba1b1351ad361d5177b7d7b29859bd2b7fc631,
|
||||
com.google.android.apps.automotive.templates.host</item>
|
||||
|
||||
<item>dd66deaf312d8daec7adbe85a218ecc8c64f3b152f9b5998d5b29300c2623f61,
|
||||
com.google.android.apps.automotive.templates.host</item>
|
||||
|
||||
<item>50e603d333c6049a37bd751375d08f3bd0abebd33facd30bd17b64b89658b421,
|
||||
com.google.android.apps.automotive.templates.host</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
Loading…
Add table
Reference in a new issue