disabled keys for RemoteDeduplicatePresenter
This commit is contained in:
committed by
Vincent Breitmoser
parent
24090cbf18
commit
d0a9cea74e
@@ -24,6 +24,7 @@ import android.arch.lifecycle.LifecycleOwner;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v7.widget.RecyclerView.Adapter;
|
import android.support.v7.widget.RecyclerView.Adapter;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo;
|
import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo;
|
||||||
import org.sufficientlysecure.keychain.remote.AutocryptInteractor;
|
import org.sufficientlysecure.keychain.remote.AutocryptInteractor;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.dialog.RemoteDeduplicateActivity.DeduplicateViewModel;
|
import org.sufficientlysecure.keychain.remote.ui.dialog.RemoteDeduplicateActivity.DeduplicateViewModel;
|
||||||
@@ -62,7 +63,19 @@ class RemoteDeduplicatePresenter {
|
|||||||
|
|
||||||
private void onLoadKeyInfos(List<UnifiedKeyInfo> data) {
|
private void onLoadKeyInfos(List<UnifiedKeyInfo> data) {
|
||||||
if (keyChoiceAdapter == null) {
|
if (keyChoiceAdapter == null) {
|
||||||
keyChoiceAdapter = KeyChoiceAdapter.createSingleChoiceAdapter(data);
|
keyChoiceAdapter = KeyChoiceAdapter.createSingleChoiceAdapter(data, (keyInfo -> {
|
||||||
|
if (keyInfo.is_revoked()) {
|
||||||
|
return R.string.keychoice_revoked;
|
||||||
|
} else if (keyInfo.is_expired()) {
|
||||||
|
return R.string.keychoice_expired;
|
||||||
|
} else if (!keyInfo.is_secure()) {
|
||||||
|
return R.string.keychoice_insecure;
|
||||||
|
} else if (!keyInfo.has_encrypt_key()) {
|
||||||
|
return R.string.keychoice_cannot_encrypt;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}));
|
||||||
view.setKeyListAdapter(keyChoiceAdapter);
|
view.setKeyListAdapter(keyChoiceAdapter);
|
||||||
} else {
|
} else {
|
||||||
keyChoiceAdapter.setUnifiedKeyInfoItems(data);
|
keyChoiceAdapter.setUnifiedKeyInfoItems(data);
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ public class KeyChoiceAdapter extends FlexibleAdapter<KeyChoiceItem> {
|
|||||||
return new KeyChoiceAdapter(items, null, Mode.SINGLE, null);
|
return new KeyChoiceAdapter(items, null, Mode.SINGLE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static KeyChoiceAdapter createSingleChoiceAdapter(List<UnifiedKeyInfo> items, KeyDisabledPredicate keyDisabledPredicate) {
|
||||||
|
return new KeyChoiceAdapter(items, null, Mode.SINGLE, keyDisabledPredicate);
|
||||||
|
}
|
||||||
|
|
||||||
public static KeyChoiceAdapter createMultiChoiceAdapter(List<UnifiedKeyInfo> items, KeyDisabledPredicate keyDisabledPredicate) {
|
public static KeyChoiceAdapter createMultiChoiceAdapter(List<UnifiedKeyInfo> items, KeyDisabledPredicate keyDisabledPredicate) {
|
||||||
return new KeyChoiceAdapter(items, null, Mode.MULTI, keyDisabledPredicate);
|
return new KeyChoiceAdapter(items, null, Mode.MULTI, keyDisabledPredicate);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user