use notification uris mostly correctly
This commit is contained in:
@@ -4,14 +4,25 @@ package org.sufficientlysecure.keychain.livedata;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.provider.DatabaseNotifyManager;
|
||||||
import org.sufficientlysecure.keychain.ui.keyview.loader.AsyncTaskLiveData;
|
import org.sufficientlysecure.keychain.ui.keyview.loader.AsyncTaskLiveData;
|
||||||
|
|
||||||
|
|
||||||
public class GenericLiveData<T> extends AsyncTaskLiveData<T> {
|
public class GenericLiveData<T> extends AsyncTaskLiveData<T> {
|
||||||
private GenericDataLoader<T> genericDataLoader;
|
private GenericDataLoader<T> genericDataLoader;
|
||||||
|
|
||||||
public GenericLiveData(Context context, Uri uri, GenericDataLoader<T> genericDataLoader) {
|
public GenericLiveData(Context context, GenericDataLoader<T> genericDataLoader) {
|
||||||
super(context, uri);
|
super(context, null);
|
||||||
|
this.genericDataLoader = genericDataLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GenericLiveData(Context context, Uri notifyUri, GenericDataLoader<T> genericDataLoader) {
|
||||||
|
super(context, notifyUri);
|
||||||
|
this.genericDataLoader = genericDataLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GenericLiveData(Context context, long notifyMasterKeyId, GenericDataLoader<T> genericDataLoader) {
|
||||||
|
super(context, DatabaseNotifyManager.getNotifyUriMasterKeyId(notifyMasterKeyId));
|
||||||
this.genericDataLoader = genericDataLoader;
|
this.genericDataLoader = genericDataLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class RemoteDeduplicateActivity extends FragmentActivity {
|
|||||||
|
|
||||||
public LiveData<List<UnifiedKeyInfo>> getKeyInfoLiveData(Context context) {
|
public LiveData<List<UnifiedKeyInfo>> getKeyInfoLiveData(Context context) {
|
||||||
if (keyInfoLiveData == null) {
|
if (keyInfoLiveData == null) {
|
||||||
keyInfoLiveData = new GenericLiveData<>(context, null, () -> {
|
keyInfoLiveData = new GenericLiveData<>(context, () -> {
|
||||||
KeyRepository keyRepository = KeyRepository.create(context);
|
KeyRepository keyRepository = KeyRepository.create(context);
|
||||||
return keyRepository.getUnifiedKeyInfosByMailAddress(duplicateAddress);
|
return keyRepository.getUnifiedKeyInfosByMailAddress(duplicateAddress);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class RemoteSelectAuthenticationKeyActivity extends FragmentActivity {
|
|||||||
|
|
||||||
public LiveData<List<UnifiedKeyInfo>> getKeyInfoLiveData(Context context) {
|
public LiveData<List<UnifiedKeyInfo>> getKeyInfoLiveData(Context context) {
|
||||||
if (keyInfoLiveData == null) {
|
if (keyInfoLiveData == null) {
|
||||||
keyInfoLiveData = new GenericLiveData<>(context, null, () -> {
|
keyInfoLiveData = new GenericLiveData<>(context, () -> {
|
||||||
KeyRepository keyRepository = KeyRepository.create(context);
|
KeyRepository keyRepository = KeyRepository.create(context);
|
||||||
return keyRepository.getAllUnifiedKeyInfoWithSecret();
|
return keyRepository.getAllUnifiedKeyInfoWithSecret();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public class RemoteSelectIdKeyActivity extends FragmentActivity {
|
|||||||
public LiveData<List<UnifiedKeyInfo>> getSecretUnifiedKeyInfo(Context context) {
|
public LiveData<List<UnifiedKeyInfo>> getSecretUnifiedKeyInfo(Context context) {
|
||||||
if (keyInfo == null) {
|
if (keyInfo == null) {
|
||||||
KeyRepository keyRepository = KeyRepository.create(context);
|
KeyRepository keyRepository = KeyRepository.create(context);
|
||||||
keyInfo = new GenericLiveData<>(context, null, keyRepository::getAllUnifiedKeyInfoWithSecret);
|
keyInfo = new GenericLiveData<>(context, keyRepository::getAllUnifiedKeyInfoWithSecret);
|
||||||
}
|
}
|
||||||
return keyInfo;
|
return keyInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ public abstract class DecryptFragment extends Fragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unifiedKeyInfoLiveData = new GenericLiveData<>(requireContext(), null, () -> {
|
unifiedKeyInfoLiveData = new GenericLiveData<>(requireContext(), () -> {
|
||||||
KeyRepository keyRepository = KeyRepository.create(requireContext());
|
KeyRepository keyRepository = KeyRepository.create(requireContext());
|
||||||
Long masterKeyId = keyRepository.getMasterKeyIdBySubkeyId(mSignatureResult.getKeyId());
|
Long masterKeyId = keyRepository.getMasterKeyIdBySubkeyId(mSignatureResult.getKeyId());
|
||||||
return keyRepository.getUnifiedKeyInfo(masterKeyId);
|
return keyRepository.getUnifiedKeyInfo(masterKeyId);
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
|
|||||||
|
|
||||||
LiveData<List<UnifiedKeyInfo>> getSignKeyLiveData(Context context) {
|
LiveData<List<UnifiedKeyInfo>> getSignKeyLiveData(Context context) {
|
||||||
if (signKeyLiveData == null) {
|
if (signKeyLiveData == null) {
|
||||||
signKeyLiveData = new GenericLiveData<>(context, null, () -> {
|
signKeyLiveData = new GenericLiveData<>(context, () -> {
|
||||||
KeyRepository keyRepository = KeyRepository.create(context);
|
KeyRepository keyRepository = KeyRepository.create(context);
|
||||||
return keyRepository.getAllUnifiedKeyInfoWithSecret();
|
return keyRepository.getAllUnifiedKeyInfoWithSecret();
|
||||||
});
|
});
|
||||||
@@ -165,7 +165,7 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
|
|||||||
|
|
||||||
LiveData<List<Chip>> getEncryptRecipientLiveData(Context context) {
|
LiveData<List<Chip>> getEncryptRecipientLiveData(Context context) {
|
||||||
if (encryptRecipientLiveData == null) {
|
if (encryptRecipientLiveData == null) {
|
||||||
encryptRecipientLiveData = new GenericLiveData<>(context, null, () -> {
|
encryptRecipientLiveData = new GenericLiveData<>(context, () -> {
|
||||||
KeyRepository keyRepository = KeyRepository.create(context);
|
KeyRepository keyRepository = KeyRepository.create(context);
|
||||||
List<UnifiedKeyInfo> keyInfos = keyRepository.getAllUnifiedKeyInfo();
|
List<UnifiedKeyInfo> keyInfos = keyRepository.getAllUnifiedKeyInfo();
|
||||||
ArrayList<Chip> result = new ArrayList<>();
|
ArrayList<Chip> result = new ArrayList<>();
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class MultiUserIdsFragment extends Fragment {
|
|||||||
|
|
||||||
KeyRepository keyRepository = KeyRepository.create(activity);
|
KeyRepository keyRepository = KeyRepository.create(activity);
|
||||||
LiveData<List<UserId>> userIdLiveData =
|
LiveData<List<UserId>> userIdLiveData =
|
||||||
new GenericLiveData<>(getContext(), null, () -> keyRepository.getUserIds(pubMasterKeyIds));
|
new GenericLiveData<>(getContext(), () -> keyRepository.getUserIds(pubMasterKeyIds));
|
||||||
userIdLiveData.observe(this, this::onUserIdsLoaded);
|
userIdLiveData.observe(this, this::onUserIdsLoaded);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
|
|||||||
}
|
}
|
||||||
if (unifiedKeyInfoLiveData == null) {
|
if (unifiedKeyInfoLiveData == null) {
|
||||||
KeyRepository keyRepository = KeyRepository.create(context);
|
KeyRepository keyRepository = KeyRepository.create(context);
|
||||||
unifiedKeyInfoLiveData = new GenericLiveData<>(context, null,
|
unifiedKeyInfoLiveData = new GenericLiveData<>(context, masterKeyId,
|
||||||
() -> keyRepository.getUnifiedKeyInfo(masterKeyId));
|
() -> keyRepository.getUnifiedKeyInfo(masterKeyId));
|
||||||
}
|
}
|
||||||
return unifiedKeyInfoLiveData;
|
return unifiedKeyInfoLiveData;
|
||||||
@@ -137,7 +137,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
|
|||||||
if (subKeyLiveData == null) {
|
if (subKeyLiveData == null) {
|
||||||
KeyRepository keyRepository = KeyRepository.create(context);
|
KeyRepository keyRepository = KeyRepository.create(context);
|
||||||
subKeyLiveData = Transformations.switchMap(getUnifiedKeyInfoLiveData(context),
|
subKeyLiveData = Transformations.switchMap(getUnifiedKeyInfoLiveData(context),
|
||||||
(unifiedKeyInfo) -> new GenericLiveData<>(context, null,
|
(unifiedKeyInfo) -> new GenericLiveData<>(context,
|
||||||
() -> keyRepository.getSubKeysByMasterKeyId(unifiedKeyInfo.master_key_id())));
|
() -> keyRepository.getSubKeysByMasterKeyId(unifiedKeyInfo.master_key_id())));
|
||||||
}
|
}
|
||||||
return subKeyLiveData;
|
return subKeyLiveData;
|
||||||
@@ -147,7 +147,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
|
|||||||
if (userIdsLiveData == null) {
|
if (userIdsLiveData == null) {
|
||||||
KeyRepository keyRepository = KeyRepository.create(context);
|
KeyRepository keyRepository = KeyRepository.create(context);
|
||||||
userIdsLiveData = Transformations.switchMap(getUnifiedKeyInfoLiveData(context),
|
userIdsLiveData = Transformations.switchMap(getUnifiedKeyInfoLiveData(context),
|
||||||
(unifiedKeyInfo) -> new GenericLiveData<>(context, null,
|
(unifiedKeyInfo) -> new GenericLiveData<>(context,
|
||||||
() -> keyRepository.getUserIds(unifiedKeyInfo.master_key_id())));
|
() -> keyRepository.getUserIds(unifiedKeyInfo.master_key_id())));
|
||||||
}
|
}
|
||||||
return userIdsLiveData;
|
return userIdsLiveData;
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ public class ViewKeyAdvShareFragment extends Fragment {
|
|||||||
unifiedKeyInfoLiveData.observe(this, this::onLoadUnifiedKeyInfo);
|
unifiedKeyInfoLiveData.observe(this, this::onLoadUnifiedKeyInfo);
|
||||||
|
|
||||||
LiveData<Bitmap> qrCodeLiveData = Transformations.switchMap(unifiedKeyInfoLiveData,
|
LiveData<Bitmap> qrCodeLiveData = Transformations.switchMap(unifiedKeyInfoLiveData,
|
||||||
(unifiedKeyInfo) -> new GenericLiveData<>(getContext(), null,
|
(unifiedKeyInfo) -> new GenericLiveData<>(getContext(),
|
||||||
() -> {
|
() -> {
|
||||||
String fingerprintHex = KeyFormattingUtils.convertFingerprintToHex(unifiedKeyInfo.fingerprint());
|
String fingerprintHex = KeyFormattingUtils.convertFingerprintToHex(unifiedKeyInfo.fingerprint());
|
||||||
Uri uri = new Uri.Builder().scheme(Constants.FINGERPRINT_SCHEME).opaquePart(fingerprintHex).build();
|
Uri uri = new Uri.Builder().scheme(Constants.FINGERPRINT_SCHEME).opaquePart(fingerprintHex).build();
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class KeyFragmentViewModel extends ViewModel {
|
|||||||
if (identityInfo == null) {
|
if (identityInfo == null) {
|
||||||
IdentityDao identityDao = IdentityDao.getInstance(context);
|
IdentityDao identityDao = IdentityDao.getInstance(context);
|
||||||
identityInfo = Transformations.switchMap(unifiedKeyInfoLiveData,
|
identityInfo = Transformations.switchMap(unifiedKeyInfoLiveData,
|
||||||
(unifiedKeyInfo) -> new GenericLiveData<>(context, null,
|
(unifiedKeyInfo) -> new GenericLiveData<>(context,
|
||||||
() -> identityDao.getIdentityInfos(unifiedKeyInfo.master_key_id(), showLinkedIds)));
|
() -> identityDao.getIdentityInfos(unifiedKeyInfo.master_key_id(), showLinkedIds)));
|
||||||
}
|
}
|
||||||
return identityInfo;
|
return identityInfo;
|
||||||
@@ -41,7 +41,7 @@ public class KeyFragmentViewModel extends ViewModel {
|
|||||||
if (subkeyStatus == null) {
|
if (subkeyStatus == null) {
|
||||||
SubkeyStatusDao subkeyStatusDao = SubkeyStatusDao.getInstance(context);
|
SubkeyStatusDao subkeyStatusDao = SubkeyStatusDao.getInstance(context);
|
||||||
subkeyStatus = Transformations.switchMap(unifiedKeyInfoLiveData,
|
subkeyStatus = Transformations.switchMap(unifiedKeyInfoLiveData,
|
||||||
(unifiedKeyInfo) -> new GenericLiveData<>(context, null,
|
(unifiedKeyInfo) -> new GenericLiveData<>(context,
|
||||||
() -> subkeyStatusDao.getSubkeyStatus(unifiedKeyInfo.master_key_id())));
|
() -> subkeyStatusDao.getSubkeyStatus(unifiedKeyInfo.master_key_id())));
|
||||||
}
|
}
|
||||||
return subkeyStatus;
|
return subkeyStatus;
|
||||||
@@ -51,7 +51,7 @@ public class KeyFragmentViewModel extends ViewModel {
|
|||||||
if (systemContactInfo == null) {
|
if (systemContactInfo == null) {
|
||||||
SystemContactDao systemContactDao = SystemContactDao.getInstance(context);
|
SystemContactDao systemContactDao = SystemContactDao.getInstance(context);
|
||||||
systemContactInfo = Transformations.switchMap(unifiedKeyInfoLiveData,
|
systemContactInfo = Transformations.switchMap(unifiedKeyInfoLiveData,
|
||||||
(unifiedKeyInfo) -> new GenericLiveData<>(context, null,
|
(unifiedKeyInfo) -> new GenericLiveData<>(context,
|
||||||
() -> systemContactDao.getSystemContactInfo(unifiedKeyInfo.master_key_id(),
|
() -> systemContactDao.getSystemContactInfo(unifiedKeyInfo.master_key_id(),
|
||||||
unifiedKeyInfo.has_any_secret())));
|
unifiedKeyInfo.has_any_secret())));
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ public class KeyFragmentViewModel extends ViewModel {
|
|||||||
if (keyserverStatus == null) {
|
if (keyserverStatus == null) {
|
||||||
KeyMetadataDao keyMetadataDao = KeyMetadataDao.create(context);
|
KeyMetadataDao keyMetadataDao = KeyMetadataDao.create(context);
|
||||||
keyserverStatus = Transformations.switchMap(unifiedKeyInfoLiveData,
|
keyserverStatus = Transformations.switchMap(unifiedKeyInfoLiveData,
|
||||||
(unifiedKeyInfo) -> new GenericLiveData<>(context, null,
|
(unifiedKeyInfo) -> new GenericLiveData<>(context,
|
||||||
() -> keyMetadataDao.getKeyMetadata(unifiedKeyInfo.master_key_id())));
|
() -> keyMetadataDao.getKeyMetadata(unifiedKeyInfo.master_key_id())));
|
||||||
}
|
}
|
||||||
return keyserverStatus;
|
return keyserverStatus;
|
||||||
|
|||||||
@@ -497,7 +497,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements OnB
|
|||||||
|
|
||||||
LiveData<List<UnifiedKeyInfo>> getCertifyingKeys(Context context) {
|
LiveData<List<UnifiedKeyInfo>> getCertifyingKeys(Context context) {
|
||||||
if (certifyingKeysLiveData == null) {
|
if (certifyingKeysLiveData == null) {
|
||||||
certifyingKeysLiveData = new GenericLiveData<>(context, null, () -> {
|
certifyingKeysLiveData = new GenericLiveData<>(context, () -> {
|
||||||
KeyRepository keyRepository = KeyRepository.create(context);
|
KeyRepository keyRepository = KeyRepository.create(context);
|
||||||
return keyRepository.getAllUnifiedKeyInfoWithSecret();
|
return keyRepository.getAllUnifiedKeyInfoWithSecret();
|
||||||
});
|
});
|
||||||
@@ -508,7 +508,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements OnB
|
|||||||
LiveData<CertDetails> getCertDetails(Context context, long masterKeyId, int lidRank) {
|
LiveData<CertDetails> getCertDetails(Context context, long masterKeyId, int lidRank) {
|
||||||
if (certDetailsLiveData == null) {
|
if (certDetailsLiveData == null) {
|
||||||
CertificationDao certificationDao = CertificationDao.getInstance(context);
|
CertificationDao certificationDao = CertificationDao.getInstance(context);
|
||||||
certDetailsLiveData = new GenericLiveData<>(context, null,
|
certDetailsLiveData = new GenericLiveData<>(context, masterKeyId,
|
||||||
() -> certificationDao.getVerifyingCertDetails(masterKeyId, lidRank));
|
() -> certificationDao.getVerifyingCertDetails(masterKeyId, lidRank));
|
||||||
}
|
}
|
||||||
return certDetailsLiveData;
|
return certDetailsLiveData;
|
||||||
@@ -517,7 +517,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements OnB
|
|||||||
public LiveData<LinkedIdInfo> getLinkedIdInfo(Context context, long masterKeyId, int lidRank) {
|
public LiveData<LinkedIdInfo> getLinkedIdInfo(Context context, long masterKeyId, int lidRank) {
|
||||||
if (linkedIfInfoLiveData == null) {
|
if (linkedIfInfoLiveData == null) {
|
||||||
IdentityDao identityDao = IdentityDao.getInstance(context);
|
IdentityDao identityDao = IdentityDao.getInstance(context);
|
||||||
linkedIfInfoLiveData = new GenericLiveData<>(context, null,
|
linkedIfInfoLiveData = new GenericLiveData<>(context, masterKeyId,
|
||||||
() -> identityDao.getLinkedIdInfo(masterKeyId, lidRank));
|
() -> identityDao.getLinkedIdInfo(masterKeyId, lidRank));
|
||||||
}
|
}
|
||||||
return linkedIfInfoLiveData;
|
return linkedIfInfoLiveData;
|
||||||
|
|||||||
Reference in New Issue
Block a user