Add to FetchContactDetails support of multiple vcard types parsed for the same result object. Fix the probm of contact details not being displayed at first view.
MAILAND-1286
This commit is contained in:
parent
5254d84a86
commit
2b58169059
|
@ -654,7 +654,7 @@ public class ContactDetailsActivity extends BaseActivity implements AppBarLayout
|
|||
try {
|
||||
type2Verify = crypto.verify(mVCardType2, mVCardType2Signature).isSignatureValid();
|
||||
} catch (Exception e) {
|
||||
Logger.doLogException(e);
|
||||
Timber.w(e, "VCard type2 verification error");
|
||||
}
|
||||
} else {
|
||||
type2Verify = true;
|
||||
|
@ -664,7 +664,7 @@ public class ContactDetailsActivity extends BaseActivity implements AppBarLayout
|
|||
try {
|
||||
type3Verify = crypto.verify(mVCardType3, mVCardType3Signature).isSignatureValid();
|
||||
} catch (Exception e) {
|
||||
Logger.doLogException(e);
|
||||
Timber.w(e, "VCard type3 verification error");
|
||||
}
|
||||
} else {
|
||||
type3Verify = true;
|
||||
|
@ -697,7 +697,7 @@ public class ContactDetailsActivity extends BaseActivity implements AppBarLayout
|
|||
}
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Timber.w(e, "VCard file operation error");
|
||||
}
|
||||
|
||||
fabWeb.setOnClickListener(v -> {
|
||||
|
@ -990,7 +990,7 @@ public class ContactDetailsActivity extends BaseActivity implements AppBarLayout
|
|||
return isEmpty;
|
||||
}
|
||||
|
||||
private View.OnClickListener mUpgradeClickListener = v -> {
|
||||
private final View.OnClickListener mUpgradeClickListener = v -> {
|
||||
Intent upgradeIntent = new Intent(ContactDetailsActivity.this, UpsellingActivity.class);
|
||||
upgradeIntent.putExtra(UpsellingActivity.EXTRA_OPEN_UPGRADE_CONTAINER, true);
|
||||
startActivityForResult(AppUtil.decorInAppIntent(upgradeIntent), REQUEST_CODE_UPGRADE);
|
||||
|
|
|
@ -32,6 +32,7 @@ import ch.protonmail.android.crypto.UserCrypto
|
|||
import ch.protonmail.android.domain.entity.Name
|
||||
import ch.protonmail.android.usecase.model.FetchContactDetailsResult
|
||||
import me.proton.core.util.kotlin.DispatcherProvider
|
||||
import me.proton.core.util.kotlin.EMPTY_STRING
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -81,28 +82,35 @@ class FetchContactDetails @Inject constructor(
|
|||
|
||||
if (!encryptedDataList.isNullOrEmpty()) {
|
||||
val crypto = UserCrypto(userManager, userManager.openPgp, Name(userManager.username))
|
||||
var decryptedVCardType0: String = EMPTY_STRING
|
||||
var decryptedVCardType2: String = EMPTY_STRING
|
||||
var decryptedVCardType3: String = EMPTY_STRING
|
||||
var vCardType2Signature: String = EMPTY_STRING
|
||||
var vCardType3Signature: String = EMPTY_STRING
|
||||
|
||||
for (contactEncryptedData in encryptedDataList) {
|
||||
return when (getCardTypeFromInt(contactEncryptedData.type)) {
|
||||
when (getCardTypeFromInt(contactEncryptedData.type)) {
|
||||
Constants.VCardType.SIGNED_ENCRYPTED -> {
|
||||
val tct = CipherText(contactEncryptedData.data)
|
||||
FetchContactDetailsResult.Data(
|
||||
decryptedVCardType3 = crypto.decrypt(tct).decryptedData,
|
||||
vCardType3Signature = contactEncryptedData.signature
|
||||
)
|
||||
decryptedVCardType3 = crypto.decrypt(tct).decryptedData
|
||||
vCardType3Signature = contactEncryptedData.signature
|
||||
}
|
||||
Constants.VCardType.SIGNED -> {
|
||||
FetchContactDetailsResult.Data(
|
||||
decryptedVCardType2 = contactEncryptedData.data,
|
||||
vCardType2Signature = contactEncryptedData.signature
|
||||
)
|
||||
decryptedVCardType2 = contactEncryptedData.data
|
||||
vCardType2Signature = contactEncryptedData.signature
|
||||
}
|
||||
Constants.VCardType.UNSIGNED -> {
|
||||
FetchContactDetailsResult.Data(
|
||||
decryptedVCardType0 = contactEncryptedData.data
|
||||
)
|
||||
decryptedVCardType0 = contactEncryptedData.data
|
||||
}
|
||||
}
|
||||
}
|
||||
return FetchContactDetailsResult.Data(
|
||||
decryptedVCardType0,
|
||||
decryptedVCardType2,
|
||||
decryptedVCardType3,
|
||||
vCardType2Signature,
|
||||
vCardType3Signature
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ kotlinCompilerArgs(
|
|||
"-Xuse-experimental=kotlin.Experimental",
|
||||
// Enables unsigned types, like `UInt`, `ULong`, etc
|
||||
"-Xopt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
// Enables experimental Coroutines from coroutines-test artifact, like `runBlockingTest`
|
||||
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
// Enables experimental kotlin.time
|
||||
"-Xopt-in=kotlin.time.ExperimentalTime"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue