Identity refresh main setting page.

This commit is contained in:
Benoit Marty 2020-05-11 14:24:24 +02:00
parent 84a3754c9f
commit 7afc7bdb31
4 changed files with 18 additions and 10 deletions

View file

@ -29,7 +29,10 @@ interface IdentityService {
*/
fun getDefaultIdentityServer(callback: MatrixCallback<String?>): Cancelable
fun getCurrentIdentityServer(): String?
/**
* Return the current identity server URL used by this account. Returns null if no identity server is configured.
*/
fun getCurrentIdentityServerUrl(): String?
/**
* Check if the identity server is valid

View file

@ -118,7 +118,7 @@ internal class DefaultIdentityService @Inject constructor(
return NoOpCancellable
}
override fun getCurrentIdentityServer(): String? {
override fun getCurrentIdentityServerUrl(): String? {
return identityServiceStore.getIdentityServerDetails()?.identityServerUrl
}
@ -177,7 +177,7 @@ internal class DefaultIdentityService @Inject constructor(
}
return GlobalScope.launchToCallback(coroutineDispatchers.main, callback) {
val current = getCurrentIdentityServer()
val current = getCurrentIdentityServerUrl()
when (urlCandidate) {
current ->
// Nothing to do

View file

@ -58,7 +58,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
private val identityServerManagerListener = object : IdentityServiceListener {
override fun onIdentityServerChange() = withState { state ->
val identityServerUrl = identityService.getCurrentIdentityServer()
val identityServerUrl = identityService.getCurrentIdentityServerUrl()
val currentIS = state.identityServer()
setState {
copy(identityServer = Success(identityServerUrl))
@ -69,7 +69,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
init {
setState {
copy(identityServer = Success(identityService.getCurrentIdentityServer()))
copy(identityServer = Success(identityService.getCurrentIdentityServerUrl()))
}
startListenToIdentityManager()
observeThreePids()

View file

@ -79,6 +79,9 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
private val mPasswordPreference by lazy {
findPreference<VectorPreference>(VectorPreferences.SETTINGS_CHANGE_PASSWORD_PREFERENCE_KEY)!!
}
private val mIdentityServerPreference by lazy {
findPreference<VectorPreference>(VectorPreferences.SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY)!!
}
// Local contacts
private val mContactSettingsCategory by lazy {
@ -168,11 +171,6 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
findPreference<VectorPreference>(VectorPreferences.SETTINGS_HOME_SERVER_PREFERENCE_KEY)!!
.summary = session.sessionParams.homeServerConnectionConfig.homeServerUri.toString()
// identity server
// TODO Handle refresh of the value
findPreference<VectorPreference>(VectorPreferences.SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY)!!
.summary = session.identityService().getCurrentIdentityServer() ?: getString(R.string.identity_server_not_defined)
refreshEmailsList()
refreshPhoneNumbersList()
// Contacts
@ -241,6 +239,13 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
}
}
override fun onResume() {
super.onResume()
// Refresh identity server summary
mIdentityServerPreference.summary = session.identityService().getCurrentIdentityServerUrl() ?: getString(R.string.identity_server_not_defined)
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
if (allGranted(grantResults)) {
if (requestCode == PERMISSION_REQUEST_CODE_LAUNCH_CAMERA) {