Fix Display Key in UploadKeyActivity, Issue #506
This commit is contained in:
@@ -28,6 +28,7 @@ import org.sufficientlysecure.keychain.ui.base.BaseActivity;
|
|||||||
public class CertifyKeyActivity extends BaseActivity {
|
public class CertifyKeyActivity extends BaseActivity {
|
||||||
|
|
||||||
public static final String EXTRA_RESULT = "operation_result";
|
public static final String EXTRA_RESULT = "operation_result";
|
||||||
|
// For sending masterKeyIds to MultiUserIdsFragment to display list of keys
|
||||||
public static final String EXTRA_KEY_IDS = MultiUserIdsFragment.EXTRA_KEY_IDS ;
|
public static final String EXTRA_KEY_IDS = MultiUserIdsFragment.EXTRA_KEY_IDS ;
|
||||||
public static final String EXTRA_CERTIFY_KEY_ID = "certify_key_id";
|
public static final String EXTRA_CERTIFY_KEY_ID = "certify_key_id";
|
||||||
|
|
||||||
|
|||||||
@@ -74,13 +74,14 @@ public class CertifyKeyFragment
|
|||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
if (savedInstanceState == null){
|
if (savedInstanceState == null) {
|
||||||
// preselect certify key id if given
|
// preselect certify key id if given
|
||||||
long certifyKeyId = getActivity().getIntent()
|
long certifyKeyId = getActivity().getIntent()
|
||||||
.getLongExtra(CertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, Constants.key.none);
|
.getLongExtra(CertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, Constants.key.none);
|
||||||
if (certifyKeyId != Constants.key.none) {
|
if (certifyKeyId != Constants.key.none) {
|
||||||
try {
|
try {
|
||||||
CachedPublicKeyRing key = (new ProviderHelper(getActivity())).getCachedPublicKeyRing(certifyKeyId);
|
CachedPublicKeyRing key = (new ProviderHelper(getActivity()))
|
||||||
|
.getCachedPublicKeyRing(certifyKeyId);
|
||||||
if (key.canCertify()) {
|
if (key.canCertify()) {
|
||||||
mCertifyKeySpinner.setPreSelectedKeyId(certifyKeyId);
|
mCertifyKeySpinner.setPreSelectedKeyId(certifyKeyId);
|
||||||
}
|
}
|
||||||
@@ -88,7 +89,6 @@ public class CertifyKeyFragment
|
|||||||
Log.e(Constants.TAG, "certify certify check failed", e);
|
Log.e(Constants.TAG, "certify certify check failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OperationResult result = getActivity().getIntent().getParcelableExtra(CertifyKeyActivity.EXTRA_RESULT);
|
OperationResult result = getActivity().getIntent().getParcelableExtra(CertifyKeyActivity.EXTRA_RESULT);
|
||||||
|
|||||||
@@ -26,12 +26,10 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by durgeshchoudhary on 07/03/16.
|
|
||||||
*/
|
|
||||||
public class MultiUserIdsFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor>{
|
public class MultiUserIdsFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor>{
|
||||||
public static final String ARG_CHECK_STATES = "check_states";
|
public static final String ARG_CHECK_STATES = "check_states";
|
||||||
public static final String EXTRA_KEY_IDS = "extra_key_ids";
|
public static final String EXTRA_KEY_IDS = "extra_key_ids";
|
||||||
|
private boolean checkboxVisibility = true;
|
||||||
|
|
||||||
ListView mUserIds;
|
ListView mUserIds;
|
||||||
private MultiUserIdsAdapter mUserIdsAdapter;
|
private MultiUserIdsAdapter mUserIdsAdapter;
|
||||||
@@ -78,7 +76,7 @@ public class MultiUserIdsFragment extends Fragment implements LoaderManager.Load
|
|||||||
checkedStates = (ArrayList<Boolean>) savedInstanceState.getSerializable(ARG_CHECK_STATES);
|
checkedStates = (ArrayList<Boolean>) savedInstanceState.getSerializable(ARG_CHECK_STATES);
|
||||||
}
|
}
|
||||||
|
|
||||||
mUserIdsAdapter = new MultiUserIdsAdapter(getActivity(), null, 0, checkedStates);
|
mUserIdsAdapter = new MultiUserIdsAdapter(getActivity(), null, 0, checkedStates, checkboxVisibility);
|
||||||
mUserIds.setAdapter(mUserIdsAdapter);
|
mUserIds.setAdapter(mUserIdsAdapter);
|
||||||
mUserIds.setDividerHeight(0);
|
mUserIds.setDividerHeight(0);
|
||||||
|
|
||||||
@@ -95,6 +93,10 @@ public class MultiUserIdsFragment extends Fragment implements LoaderManager.Load
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<CertifyActionsParcel.CertifyAction> getSelectedCertifyActions() {
|
public ArrayList<CertifyActionsParcel.CertifyAction> getSelectedCertifyActions() {
|
||||||
|
if (!checkboxVisibility) {
|
||||||
|
throw new AssertionError("Item selection not allowed");
|
||||||
|
}
|
||||||
|
|
||||||
return mUserIdsAdapter.getSelectedCertifyActions();
|
return mUserIdsAdapter.getSelectedCertifyActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,4 +216,8 @@ public class MultiUserIdsFragment extends Fragment implements LoaderManager.Load
|
|||||||
public void onLoaderReset(Loader<Cursor> loader) {
|
public void onLoaderReset(Loader<Cursor> loader) {
|
||||||
mUserIdsAdapter.swapCursor(null);
|
mUserIdsAdapter.swapCursor(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCheckboxVisibility(boolean checkboxVisibility) {
|
||||||
|
this.checkboxVisibility = checkboxVisibility;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,10 +31,7 @@ import android.widget.Spinner;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.UploadResult;
|
import org.sufficientlysecure.keychain.operations.results.UploadResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
|
||||||
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
|
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
|
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||||
@@ -53,7 +50,6 @@ public class UploadKeyActivity extends BaseActivity
|
|||||||
|
|
||||||
// CryptoOperationHelper.Callback vars
|
// CryptoOperationHelper.Callback vars
|
||||||
private String mKeyserver;
|
private String mKeyserver;
|
||||||
private long mMasterKeyId;
|
|
||||||
private CryptoOperationHelper<UploadKeyringParcel, UploadResult> mUploadOpHelper;
|
private CryptoOperationHelper<UploadKeyringParcel, UploadResult> mUploadOpHelper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -63,6 +59,10 @@ public class UploadKeyActivity extends BaseActivity
|
|||||||
mUploadButton = findViewById(R.id.upload_key_action_upload);
|
mUploadButton = findViewById(R.id.upload_key_action_upload);
|
||||||
mKeyServerSpinner = (Spinner) findViewById(R.id.upload_key_keyserver);
|
mKeyServerSpinner = (Spinner) findViewById(R.id.upload_key_keyserver);
|
||||||
|
|
||||||
|
MultiUserIdsFragment mMultiUserIdsFragment = (MultiUserIdsFragment)
|
||||||
|
getSupportFragmentManager().findFragmentById(R.id.multi_user_ids_fragment);
|
||||||
|
mMultiUserIdsFragment.setCheckboxVisibility(false);
|
||||||
|
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
||||||
android.R.layout.simple_spinner_item, Preferences.getPreferences(this)
|
android.R.layout.simple_spinner_item, Preferences.getPreferences(this)
|
||||||
.getKeyServers()
|
.getKeyServers()
|
||||||
@@ -89,15 +89,6 @@ public class UploadKeyActivity extends BaseActivity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
mMasterKeyId = new ProviderHelper(this).getCachedPublicKeyRing(
|
|
||||||
KeyRings.buildUnifiedKeyRingUri(mDataUri)).getMasterKeyId();
|
|
||||||
} catch (PgpKeyNotFoundException e) {
|
|
||||||
Log.e(Constants.TAG, "Intent data pointed to bad key!");
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -136,7 +127,9 @@ public class UploadKeyActivity extends BaseActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UploadKeyringParcel createOperationInput() {
|
public UploadKeyringParcel createOperationInput() {
|
||||||
return new UploadKeyringParcel(mKeyserver, mMasterKeyId);
|
long[] masterKeyIds = getIntent().getLongArrayExtra(MultiUserIdsFragment.EXTRA_KEY_IDS);
|
||||||
|
|
||||||
|
return new UploadKeyringParcel(mKeyserver, masterKeyIds[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -455,8 +455,19 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void uploadToKeyserver() {
|
private void uploadToKeyserver() {
|
||||||
|
long keyId;
|
||||||
|
try {
|
||||||
|
keyId = new ProviderHelper(getActivity())
|
||||||
|
.getCachedPublicKeyRing(mDataUri)
|
||||||
|
.extractOrGetMasterKeyId();
|
||||||
|
} catch (PgpKeyNotFoundException e) {
|
||||||
|
Log.e(Constants.TAG, "key not found!", e);
|
||||||
|
Notify.create(getActivity(), "key not found", Style.ERROR).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
Intent uploadIntent = new Intent(getActivity(), UploadKeyActivity.class);
|
Intent uploadIntent = new Intent(getActivity(), UploadKeyActivity.class);
|
||||||
uploadIntent.setData(mDataUri);
|
uploadIntent.setData(mDataUri);
|
||||||
|
uploadIntent.putExtra(MultiUserIdsFragment.EXTRA_KEY_IDS, new long[]{keyId});
|
||||||
startActivityForResult(uploadIntent, 0);
|
startActivityForResult(uploadIntent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import java.util.ArrayList;
|
|||||||
public class MultiUserIdsAdapter extends CursorAdapter {
|
public class MultiUserIdsAdapter extends CursorAdapter {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private final ArrayList<Boolean> mCheckStates;
|
private final ArrayList<Boolean> mCheckStates;
|
||||||
|
private boolean checkboxVisibility = true;
|
||||||
|
|
||||||
public MultiUserIdsAdapter(Context context, Cursor c, int flags, ArrayList<Boolean> preselectStates) {
|
public MultiUserIdsAdapter(Context context, Cursor c, int flags, ArrayList<Boolean> preselectStates) {
|
||||||
super(context, c, flags);
|
super(context, c, flags);
|
||||||
@@ -46,6 +47,11 @@ public class MultiUserIdsAdapter extends CursorAdapter {
|
|||||||
mCheckStates = preselectStates == null ? new ArrayList<Boolean>() : preselectStates;
|
mCheckStates = preselectStates == null ? new ArrayList<Boolean>() : preselectStates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MultiUserIdsAdapter(Context context, Cursor c, int flags, ArrayList<Boolean> preselectStates, boolean checkboxVisibility) {
|
||||||
|
this(context,c,flags,preselectStates);
|
||||||
|
this.checkboxVisibility = checkboxVisibility;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor swapCursor(Cursor newCursor) {
|
public Cursor swapCursor(Cursor newCursor) {
|
||||||
if (newCursor != null) {
|
if (newCursor != null) {
|
||||||
@@ -138,6 +144,7 @@ public class MultiUserIdsAdapter extends CursorAdapter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
vCheckBox.setClickable(false);
|
vCheckBox.setClickable(false);
|
||||||
|
vCheckBox.setVisibility(checkboxVisibility?View.VISIBLE:View.GONE);
|
||||||
|
|
||||||
View vUidBody = view.findViewById(R.id.user_id_body);
|
View vUidBody = view.findViewById(R.id.user_id_body);
|
||||||
vUidBody.setClickable(true);
|
vUidBody.setClickable(true);
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:layout_marginLeft="8dip"
|
|
||||||
android:layout_marginTop="8dip"/>
|
android:layout_marginTop="8dip"/>
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/user_id_body"
|
<LinearLayout android:id="@+id/user_id_body"
|
||||||
@@ -21,7 +20,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:layout_marginLeft="8dip"
|
|
||||||
android:layout_marginTop="4dip">
|
android:layout_marginTop="4dip">
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
|
|||||||
@@ -41,6 +41,12 @@
|
|||||||
android:layout_marginBottom="4dp"
|
android:layout_marginBottom="4dp"
|
||||||
android:layout_marginTop="4dp" />
|
android:layout_marginTop="4dp" />
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/multi_user_ids_fragment"
|
||||||
|
android:name="org.sufficientlysecure.keychain.ui.MultiUserIdsFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/SectionHeader"
|
style="@style/SectionHeader"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
Reference in New Issue
Block a user