Merge pull request #1907 from vector-im/feature/display_device_key
Feature/display device key
This commit is contained in:
commit
5a3894036c
|
@ -6,6 +6,7 @@ Features ✨:
|
||||||
|
|
||||||
Improvements 🙌:
|
Improvements 🙌:
|
||||||
- Give user the possibility to prevent accidental call (#1869)
|
- Give user the possibility to prevent accidental call (#1869)
|
||||||
|
- Display device information (name, id and key) in Cryptography setting screen (#1784)
|
||||||
- Ensure users do not accidentally ignore other users (#1890)
|
- Ensure users do not accidentally ignore other users (#1890)
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
|
|
|
@ -34,12 +34,6 @@ import androidx.preference.PreferenceCategory
|
||||||
import androidx.preference.SwitchPreference
|
import androidx.preference.SwitchPreference
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
import org.matrix.android.sdk.api.MatrixCallback
|
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.isVerified
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.ImportRoomKeysResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.DevicesListResponse
|
|
||||||
import org.matrix.android.sdk.rx.SecretsSynchronisationInfo
|
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.di.ActiveSessionHolder
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
import im.vector.app.core.dialogs.ExportKeysDialog
|
import im.vector.app.core.dialogs.ExportKeysDialog
|
||||||
|
@ -50,6 +44,7 @@ import im.vector.app.core.intent.getFilenameFromUri
|
||||||
import im.vector.app.core.platform.SimpleTextWatcher
|
import im.vector.app.core.platform.SimpleTextWatcher
|
||||||
import im.vector.app.core.preference.VectorPreference
|
import im.vector.app.core.preference.VectorPreference
|
||||||
import im.vector.app.core.preference.VectorPreferenceCategory
|
import im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
|
import im.vector.app.core.utils.copyToClipboard
|
||||||
import im.vector.app.core.utils.openFileSelection
|
import im.vector.app.core.utils.openFileSelection
|
||||||
import im.vector.app.core.utils.toast
|
import im.vector.app.core.utils.toast
|
||||||
import im.vector.app.features.crypto.keys.KeysExporter
|
import im.vector.app.features.crypto.keys.KeysExporter
|
||||||
|
@ -65,6 +60,13 @@ import im.vector.app.features.themes.ThemeUtils
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
import me.gujun.android.span.span
|
import me.gujun.android.span.span
|
||||||
|
import org.matrix.android.sdk.api.MatrixCallback
|
||||||
|
import org.matrix.android.sdk.api.extensions.getFingerprintHumanReadable
|
||||||
|
import org.matrix.android.sdk.internal.crypto.crosssigning.isVerified
|
||||||
|
import org.matrix.android.sdk.internal.crypto.model.ImportRoomKeysResult
|
||||||
|
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
||||||
|
import org.matrix.android.sdk.internal.crypto.model.rest.DevicesListResponse
|
||||||
|
import org.matrix.android.sdk.rx.SecretsSynchronisationInfo
|
||||||
import org.matrix.android.sdk.rx.rx
|
import org.matrix.android.sdk.rx.rx
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -85,6 +87,18 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||||
findPreference<PreferenceCategory>(VectorPreferences.SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY)!!
|
findPreference<PreferenceCategory>(VectorPreferences.SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val cryptoInfoDeviceNamePreference by lazy {
|
||||||
|
findPreference<VectorPreference>("SETTINGS_ENCRYPTION_INFORMATION_DEVICE_NAME_PREFERENCE_KEY")!!
|
||||||
|
}
|
||||||
|
|
||||||
|
private val cryptoInfoDeviceIdPreference by lazy {
|
||||||
|
findPreference<VectorPreference>("SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY")!!
|
||||||
|
}
|
||||||
|
|
||||||
|
private val cryptoInfoDeviceKeyPreference by lazy {
|
||||||
|
findPreference<VectorPreference>("SETTINGS_ENCRYPTION_INFORMATION_DEVICE_KEY_PREFERENCE_KEY")!!
|
||||||
|
}
|
||||||
|
|
||||||
private val mCrossSigningStatePreference by lazy {
|
private val mCrossSigningStatePreference by lazy {
|
||||||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_ENCRYPTION_CROSS_SIGNING_PREFERENCE_KEY)!!
|
findPreference<VectorPreference>(VectorPreferences.SETTINGS_ENCRYPTION_CROSS_SIGNING_PREFERENCE_KEY)!!
|
||||||
}
|
}
|
||||||
|
@ -225,9 +239,6 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bindPref() {
|
override fun bindPref() {
|
||||||
// Push target
|
|
||||||
refreshPushersList()
|
|
||||||
|
|
||||||
// Refresh Key Management section
|
// Refresh Key Management section
|
||||||
refreshKeysManagementSection()
|
refreshKeysManagementSection()
|
||||||
|
|
||||||
|
@ -488,58 +499,48 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the cryptography preference section.
|
* Build the cryptography preference section.
|
||||||
*
|
|
||||||
* @param aMyDeviceInfo the device info
|
|
||||||
*/
|
*/
|
||||||
private fun refreshCryptographyPreference(devices: List<DeviceInfo>) {
|
private fun refreshCryptographyPreference(devices: List<DeviceInfo>) {
|
||||||
showDeviceListPref.isEnabled = devices.isNotEmpty()
|
showDeviceListPref.isEnabled = devices.isNotEmpty()
|
||||||
showDeviceListPref.summary = resources.getQuantityString(R.plurals.settings_active_sessions_count, devices.size, devices.size)
|
showDeviceListPref.summary = resources.getQuantityString(R.plurals.settings_active_sessions_count, devices.size, devices.size)
|
||||||
// val userId = session.myUserId
|
|
||||||
// val deviceId = session.sessionParams.deviceId
|
|
||||||
|
|
||||||
// device name
|
val userId = session.myUserId
|
||||||
// if (null != aMyDeviceInfo) {
|
val deviceId = session.sessionParams.deviceId
|
||||||
// cryptoInfoDeviceNamePreference.summary = aMyDeviceInfo.displayName
|
|
||||||
//
|
val aMyDeviceInfo = devices.find { it.deviceId == deviceId }
|
||||||
// cryptoInfoDeviceNamePreference.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
|
||||||
// // TODO device can be rename only from the device list screen for the moment
|
// crypto section: device name
|
||||||
// // displayDeviceRenameDialog(aMyDeviceInfo)
|
if (aMyDeviceInfo != null) {
|
||||||
// true
|
cryptoInfoDeviceNamePreference.summary = aMyDeviceInfo.displayName
|
||||||
// }
|
|
||||||
//
|
cryptoInfoDeviceNamePreference.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||||
// cryptoInfoDeviceNamePreference.onPreferenceLongClickListener = object : VectorPreference.OnPreferenceLongClickListener {
|
copyToClipboard(requireActivity(), aMyDeviceInfo.displayName ?: "")
|
||||||
// override fun onPreferenceLongClick(preference: Preference): Boolean {
|
true
|
||||||
// activity?.let { copyToClipboard(it, aMyDeviceInfo.displayName!!) }
|
}
|
||||||
// return true
|
}
|
||||||
// }
|
|
||||||
// }
|
// crypto section: device ID
|
||||||
// }
|
if (!deviceId.isNullOrEmpty()) {
|
||||||
//
|
cryptoInfoDeviceIdPreference.summary = deviceId
|
||||||
// // crypto section: device ID
|
|
||||||
// if (!deviceId.isNullOrEmpty()) {
|
cryptoInfoDeviceIdPreference.setOnPreferenceClickListener {
|
||||||
// cryptoInfoDeviceIdPreference.summary = deviceId
|
copyToClipboard(requireActivity(), deviceId)
|
||||||
//
|
true
|
||||||
// cryptoInfoDeviceIdPreference.setOnPreferenceClickListener {
|
}
|
||||||
// activity?.let { copyToClipboard(it, deviceId) }
|
}
|
||||||
// true
|
|
||||||
// }
|
// crypto section: device key (fingerprint)
|
||||||
// }
|
val deviceInfo = session.cryptoService().getDeviceInfo(userId, deviceId)
|
||||||
//
|
|
||||||
// // crypto section: device key (fingerprint)
|
val fingerprint = deviceInfo?.fingerprint()
|
||||||
// if (!deviceId.isNullOrEmpty() && userId.isNotEmpty()) {
|
if (fingerprint?.isNotEmpty() == true) {
|
||||||
// val deviceInfo = session.getDeviceInfo(userId, deviceId)
|
cryptoInfoDeviceKeyPreference.summary = deviceInfo.getFingerprintHumanReadable()
|
||||||
//
|
|
||||||
// if (null != deviceInfo && !deviceInfo.fingerprint().isNullOrEmpty()) {
|
cryptoInfoDeviceKeyPreference.setOnPreferenceClickListener {
|
||||||
// cryptoInfoTextPreference.summary = deviceInfo.getFingerprintHumanReadable()
|
copyToClipboard(requireActivity(), fingerprint)
|
||||||
//
|
true
|
||||||
// cryptoInfoTextPreference.setOnPreferenceClickListener {
|
}
|
||||||
// deviceInfo.fingerprint()?.let {
|
}
|
||||||
// copyToClipboard(requireActivity(), it)
|
|
||||||
// }
|
|
||||||
// true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
sendToUnverifiedDevicesPref.isChecked = session.cryptoService().getGlobalBlacklistUnverifiedDevices()
|
sendToUnverifiedDevicesPref.isChecked = session.cryptoService().getGlobalBlacklistUnverifiedDevices()
|
||||||
|
|
||||||
|
@ -580,103 +581,8 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==============================================================================================================
|
|
||||||
// pushers list management
|
|
||||||
// ==============================================================================================================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Refresh the pushers list
|
|
||||||
*/
|
|
||||||
private fun refreshPushersList() {
|
|
||||||
activity?.let { _ ->
|
|
||||||
/* TODO
|
|
||||||
val pushManager = Matrix.getInstance(activity).pushManager
|
|
||||||
val pushersList = ArrayList(pushManager.mPushersList)
|
|
||||||
|
|
||||||
if (pushersList.isEmpty()) {
|
|
||||||
preferenceScreen.removePreference(mPushersSettingsCategory)
|
|
||||||
preferenceScreen.removePreference(mPushersSettingsDivider)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// check first if there is an update
|
|
||||||
var isNewList = true
|
|
||||||
if (pushersList.size == mDisplayedPushers.size) {
|
|
||||||
isNewList = !mDisplayedPushers.containsAll(pushersList)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isNewList) {
|
|
||||||
// remove the displayed one
|
|
||||||
mPushersSettingsCategory.removeAll()
|
|
||||||
|
|
||||||
// add new emails list
|
|
||||||
mDisplayedPushers = pushersList
|
|
||||||
|
|
||||||
var index = 0
|
|
||||||
|
|
||||||
for (pushRule in mDisplayedPushers) {
|
|
||||||
if (null != pushRule.lang) {
|
|
||||||
val isThisDeviceTarget = TextUtils.equals(pushManager.currentRegistrationToken, pushRule.pushkey)
|
|
||||||
|
|
||||||
val preference = VectorPreference(activity).apply {
|
|
||||||
mTypeface = if (isThisDeviceTarget) Typeface.BOLD else Typeface.NORMAL
|
|
||||||
}
|
|
||||||
preference.title = pushRule.deviceDisplayName
|
|
||||||
preference.summary = pushRule.appDisplayName
|
|
||||||
preference.key = PUSHER_PREFERENCE_KEY_BASE + index
|
|
||||||
index++
|
|
||||||
mPushersSettingsCategory.addPreference(preference)
|
|
||||||
|
|
||||||
// the user cannot remove the self device target
|
|
||||||
if (!isThisDeviceTarget) {
|
|
||||||
preference.onPreferenceLongClickListener = object : VectorPreference.OnPreferenceLongClickListener {
|
|
||||||
override fun onPreferenceLongClick(preference: Preference): Boolean {
|
|
||||||
AlertDialog.Builder(activity)
|
|
||||||
.setTitle(R.string.dialog_title_confirmation)
|
|
||||||
.setMessage(R.string.settings_delete_notification_targets_confirmation)
|
|
||||||
.setPositiveButton(R.string.remove)
|
|
||||||
{ _, _ ->
|
|
||||||
displayLoadingView()
|
|
||||||
pushManager.unregister(session, pushRule, object : MatrixCallback<Unit> {
|
|
||||||
override fun onSuccess(info: Void?) {
|
|
||||||
refreshPushersList()
|
|
||||||
onCommonDone(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNetworkError(e: Exception) {
|
|
||||||
onCommonDone(e.localizedMessage)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onMatrixError(e: MatrixError) {
|
|
||||||
onCommonDone(e.localizedMessage)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUnexpectedError(e: Exception) {
|
|
||||||
onCommonDone(e.localizedMessage)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
.setNegativeButton(R.string.cancel, null)
|
|
||||||
.show()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val REQUEST_E2E_FILE_REQUEST_CODE = 123
|
private const val REQUEST_E2E_FILE_REQUEST_CODE = 123
|
||||||
private const val REQUEST_CODE_SAVE_MEGOLM_EXPORT = 124
|
private const val REQUEST_CODE_SAVE_MEGOLM_EXPORT = 124
|
||||||
|
|
||||||
private const val PUSHER_PREFERENCE_KEY_BASE = "PUSHER_PREFERENCE_KEY_BASE"
|
|
||||||
private const val DEVICES_PREFERENCE_KEY_BASE = "DEVICES_PREFERENCE_KEY_BASE"
|
|
||||||
|
|
||||||
// TODO i18n
|
|
||||||
const val LABEL_UNAVAILABLE_DATA = "none"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1054,7 +1054,7 @@
|
||||||
<string name="encryption_information_device_name_with_warning">Public name (visible to people you communicate with)</string>
|
<string name="encryption_information_device_name_with_warning">Public name (visible to people you communicate with)</string>
|
||||||
<string name="device_name_warning">"A session's public name is visible to people you communicate with"</string>
|
<string name="device_name_warning">"A session's public name is visible to people you communicate with"</string>
|
||||||
<string name="encryption_information_name">Public name</string>
|
<string name="encryption_information_name">Public name</string>
|
||||||
<string name="encryption_information_device_id">ID</string>
|
<string name="encryption_information_device_id">Session ID</string>
|
||||||
<string name="encryption_information_device_key">Session key</string>
|
<string name="encryption_information_device_key">Session key</string>
|
||||||
<string name="encryption_information_verification">Verification</string>
|
<string name="encryption_information_verification">Verification</string>
|
||||||
<string name="encryption_information_ed25519_fingerprint">Ed25519 fingerprint</string>
|
<string name="encryption_information_ed25519_fingerprint">Ed25519 fingerprint</string>
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
android:icon="@drawable/ic_notification_privacy_warning"
|
android:icon="@drawable/ic_notification_privacy_warning"
|
||||||
android:key="SETTINGS_CRYPTOGRAPHY_HS_ADMIN_DISABLED_E2E_DEFAULT"
|
android:key="SETTINGS_CRYPTOGRAPHY_HS_ADMIN_DISABLED_E2E_DEFAULT"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
tools:summary="@string/settings_hs_admin_e2e_disabled"
|
|
||||||
app:isPreferenceVisible="false"
|
app:isPreferenceVisible="false"
|
||||||
tools:isPreferenceVisible="true">
|
tools:isPreferenceVisible="true"
|
||||||
|
tools:summary="@string/settings_hs_admin_e2e_disabled">
|
||||||
|
|
||||||
</im.vector.app.core.preference.VectorPreference>
|
</im.vector.app.core.preference.VectorPreference>
|
||||||
|
|
||||||
|
@ -25,18 +25,23 @@
|
||||||
tools:icon="@drawable/ic_shield_trusted"
|
tools:icon="@drawable/ic_shield_trusted"
|
||||||
tools:summary="@string/encryption_information_dg_xsigning_complete" />
|
tools:summary="@string/encryption_information_dg_xsigning_complete" />
|
||||||
|
|
||||||
|
<im.vector.app.core.preference.VectorPreference
|
||||||
|
android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_NAME_PREFERENCE_KEY"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/encryption_information_device_name"
|
||||||
|
tools:summary="My public device name" />
|
||||||
|
|
||||||
<!-- <im.vector.app.core.preference.VectorPreference-->
|
<im.vector.app.core.preference.VectorPreference
|
||||||
<!-- android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_NAME_PREFERENCE_KEY"-->
|
android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY"
|
||||||
<!-- android:title="@string/encryption_information_device_name" />-->
|
android:persistent="false"
|
||||||
|
android:title="@string/encryption_information_device_id"
|
||||||
|
tools:summary="VZRHETBEER" />
|
||||||
|
|
||||||
<!-- <im.vector.app.core.preference.VectorPreference-->
|
<im.vector.app.core.preference.VectorPreference
|
||||||
<!-- android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY"-->
|
android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_KEY_PREFERENCE_KEY"
|
||||||
<!-- android:title="@string/encryption_information_device_id" />-->
|
android:persistent="false"
|
||||||
|
android:title="@string/encryption_information_device_key"
|
||||||
<!-- <im.vector.app.core.preference.VectorPreference-->
|
tools:summary="3To0 8c/K VRJd 4Njb DUgv 6r8A SNp9 ETZt pMwU CpE4 XJE" />
|
||||||
<!-- android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_KEY_PREFERENCE_KEY"-->
|
|
||||||
<!-- android:title="@string/encryption_information_device_key" />-->
|
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorSwitchPreference
|
<im.vector.app.core.preference.VectorSwitchPreference
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
|
Loading…
Reference in New Issue