mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 16:38:50 -05:00
Merge commit '0b7fb70'
Conflicts: OpenKeychain/src/main/res/values/strings.xml
This commit is contained in:
commit
30207ee11f
@ -247,6 +247,7 @@ public class EncryptAsymmetricFragment extends Fragment {
|
|||||||
|
|
||||||
private void selectSecretKey() {
|
private void selectSecretKey() {
|
||||||
Intent intent = new Intent(getActivity(), SelectSecretKeyActivity.class);
|
Intent intent = new Intent(getActivity(), SelectSecretKeyActivity.class);
|
||||||
|
intent.putExtra(SelectSecretKeyActivity.EXTRA_FILTER_SIGN, true);
|
||||||
startActivityForResult(intent, REQUEST_CODE_SECRET_KEYS);
|
startActivityForResult(intent, REQUEST_CODE_SECRET_KEYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,10 +28,10 @@ import org.sufficientlysecure.keychain.R;
|
|||||||
public class SelectSecretKeyActivity extends ActionBarActivity {
|
public class SelectSecretKeyActivity extends ActionBarActivity {
|
||||||
|
|
||||||
public static final String EXTRA_FILTER_CERTIFY = "filter_certify";
|
public static final String EXTRA_FILTER_CERTIFY = "filter_certify";
|
||||||
|
public static final String EXTRA_FILTER_SIGN = "filter_sign";
|
||||||
|
|
||||||
public static final String RESULT_EXTRA_MASTER_KEY_ID = "master_key_id";
|
public static final String RESULT_EXTRA_MASTER_KEY_ID = "master_key_id";
|
||||||
|
|
||||||
private boolean mFilterCertify;
|
|
||||||
private SelectSecretKeyFragment mSelectFragment;
|
private SelectSecretKeyFragment mSelectFragment;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -45,7 +45,8 @@ public class SelectSecretKeyActivity extends ActionBarActivity {
|
|||||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||||
actionBar.setHomeButtonEnabled(false);
|
actionBar.setHomeButtonEnabled(false);
|
||||||
|
|
||||||
mFilterCertify = getIntent().getBooleanExtra(EXTRA_FILTER_CERTIFY, false);
|
boolean filterCertify = getIntent().getBooleanExtra(EXTRA_FILTER_CERTIFY, false);
|
||||||
|
boolean filterSign = getIntent().getBooleanExtra(EXTRA_FILTER_SIGN, false);
|
||||||
|
|
||||||
// Check that the activity is using the layout version with
|
// Check that the activity is using the layout version with
|
||||||
// the fragment_container FrameLayout
|
// the fragment_container FrameLayout
|
||||||
@ -59,7 +60,7 @@ public class SelectSecretKeyActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create an instance of the fragment
|
// Create an instance of the fragment
|
||||||
mSelectFragment = SelectSecretKeyFragment.newInstance(mFilterCertify);
|
mSelectFragment = SelectSecretKeyFragment.newInstance(filterCertify, filterSign);
|
||||||
|
|
||||||
// Add the fragment to the 'fragment_container' FrameLayout
|
// Add the fragment to the 'fragment_container' FrameLayout
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
@ -41,18 +41,22 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
|||||||
private SelectSecretKeyActivity mActivity;
|
private SelectSecretKeyActivity mActivity;
|
||||||
private SelectKeyCursorAdapter mAdapter;
|
private SelectKeyCursorAdapter mAdapter;
|
||||||
|
|
||||||
private boolean mFilterCertify;
|
private boolean mFilterCertify, mFilterSign;
|
||||||
|
|
||||||
private static final String ARG_FILTER_CERTIFY = "filter_certify";
|
private static final String ARG_FILTER_CERTIFY = "filter_certify";
|
||||||
|
private static final String ARG_FILTER_SIGN = "filter_sign";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new instance of this fragment
|
* Creates new instance of this fragment
|
||||||
|
*
|
||||||
|
* filterCertify and filterSign must not both be set!
|
||||||
*/
|
*/
|
||||||
public static SelectSecretKeyFragment newInstance(boolean filterCertify) {
|
public static SelectSecretKeyFragment newInstance(boolean filterCertify, boolean filterSign) {
|
||||||
SelectSecretKeyFragment frag = new SelectSecretKeyFragment();
|
SelectSecretKeyFragment frag = new SelectSecretKeyFragment();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putBoolean(ARG_FILTER_CERTIFY, filterCertify);
|
args.putBoolean(ARG_FILTER_CERTIFY, filterCertify);
|
||||||
|
args.putBoolean(ARG_FILTER_CERTIFY, filterSign);
|
||||||
frag.setArguments(args);
|
frag.setArguments(args);
|
||||||
|
|
||||||
return frag;
|
return frag;
|
||||||
@ -63,6 +67,7 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mFilterCertify = getArguments().getBoolean(ARG_FILTER_CERTIFY);
|
mFilterCertify = getArguments().getBoolean(ARG_FILTER_CERTIFY);
|
||||||
|
mFilterSign = getArguments().getBoolean(ARG_FILTER_SIGN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,9 +120,10 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
|||||||
KeyRings.USER_ID,
|
KeyRings.USER_ID,
|
||||||
KeyRings.EXPIRY,
|
KeyRings.EXPIRY,
|
||||||
KeyRings.IS_REVOKED,
|
KeyRings.IS_REVOKED,
|
||||||
|
// can certify info only related to master key
|
||||||
KeyRings.CAN_CERTIFY,
|
KeyRings.CAN_CERTIFY,
|
||||||
|
// has sign may be any subkey
|
||||||
KeyRings.HAS_SIGN,
|
KeyRings.HAS_SIGN,
|
||||||
KeyRings.HAS_SECRET,
|
|
||||||
KeyRings.HAS_ANY_SECRET
|
KeyRings.HAS_ANY_SECRET
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -152,7 +158,7 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
|||||||
|
|
||||||
private class SelectSecretKeyCursorAdapter extends SelectKeyCursorAdapter {
|
private class SelectSecretKeyCursorAdapter extends SelectKeyCursorAdapter {
|
||||||
|
|
||||||
private int mIndexHasSecret, mIndexHasSign, mIndexCanCertify;
|
private int mIndexHasSign, mIndexCanCertify;
|
||||||
|
|
||||||
public SelectSecretKeyCursorAdapter(Context context, Cursor c, int flags, ListView listView) {
|
public SelectSecretKeyCursorAdapter(Context context, Cursor c, int flags, ListView listView) {
|
||||||
super(context, c, flags, listView);
|
super(context, c, flags, listView);
|
||||||
@ -162,7 +168,6 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
|||||||
protected void initIndex(Cursor cursor) {
|
protected void initIndex(Cursor cursor) {
|
||||||
super.initIndex(cursor);
|
super.initIndex(cursor);
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
mIndexHasSecret = cursor.getColumnIndexOrThrow(KeyRings.HAS_SECRET);
|
|
||||||
mIndexCanCertify = cursor.getColumnIndexOrThrow(KeyRings.CAN_CERTIFY);
|
mIndexCanCertify = cursor.getColumnIndexOrThrow(KeyRings.CAN_CERTIFY);
|
||||||
mIndexHasSign = cursor.getColumnIndexOrThrow(KeyRings.HAS_SIGN);
|
mIndexHasSign = cursor.getColumnIndexOrThrow(KeyRings.HAS_SIGN);
|
||||||
}
|
}
|
||||||
@ -179,23 +184,26 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
|||||||
// Special from superclass: Te
|
// Special from superclass: Te
|
||||||
boolean enabled = false;
|
boolean enabled = false;
|
||||||
if((Boolean) h.status.getTag()) {
|
if((Boolean) h.status.getTag()) {
|
||||||
if (cursor.getInt(mIndexHasSecret) == 0) {
|
|
||||||
h.status.setText(R.string.no_subkey);
|
|
||||||
// Check if key is viable for our purposes (certify or sign)
|
// Check if key is viable for our purposes (certify or sign)
|
||||||
} else if(mFilterCertify) {
|
if(mFilterCertify) {
|
||||||
|
// Only enable if can certify
|
||||||
if (cursor.getInt(mIndexCanCertify) == 0) {
|
if (cursor.getInt(mIndexCanCertify) == 0) {
|
||||||
h.status.setText(R.string.can_certify_not);
|
h.status.setText(R.string.can_certify_not);
|
||||||
} else {
|
} else {
|
||||||
h.status.setText(R.string.can_certify);
|
h.status.setText(R.string.can_certify);
|
||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else if(mFilterSign) {
|
||||||
|
// Only enable if can sign
|
||||||
if (cursor.getInt(mIndexHasSign) == 0) {
|
if (cursor.getInt(mIndexHasSign) == 0) {
|
||||||
h.status.setText(R.string.no_key);
|
h.status.setText(R.string.can_sign_not);
|
||||||
} else {
|
} else {
|
||||||
h.status.setText(R.string.can_sign);
|
h.status.setText(R.string.can_sign);
|
||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// No filters, just enable
|
||||||
|
enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h.setEnabled(enabled);
|
h.setEnabled(enabled);
|
||||||
|
@ -45,7 +45,7 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan
|
|||||||
private TextView mKeyMasterKeyIdHex;
|
private TextView mKeyMasterKeyIdHex;
|
||||||
private TextView mNoKeySelected;
|
private TextView mNoKeySelected;
|
||||||
private BootstrapButton mSelectKeyButton;
|
private BootstrapButton mSelectKeyButton;
|
||||||
private Boolean mFilterCertify;
|
private Boolean mFilterCertify, mFilterSign;
|
||||||
|
|
||||||
private Uri mReceivedUri = null;
|
private Uri mReceivedUri = null;
|
||||||
|
|
||||||
@ -72,10 +72,14 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan
|
|||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilterCertify(Boolean filterCertify) {
|
public void setFilterCertify(boolean filterCertify) {
|
||||||
mFilterCertify = filterCertify;
|
mFilterCertify = filterCertify;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFilterSign(boolean filterSign) {
|
||||||
|
mFilterSign = filterSign;
|
||||||
|
}
|
||||||
|
|
||||||
public void setNoKeySelected() {
|
public void setNoKeySelected() {
|
||||||
mNoKeySelected.setVisibility(View.VISIBLE);
|
mNoKeySelected.setVisibility(View.VISIBLE);
|
||||||
mKeyUserId.setVisibility(View.GONE);
|
mKeyUserId.setVisibility(View.GONE);
|
||||||
@ -115,6 +119,7 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan
|
|||||||
mSelectKeyButton = (BootstrapButton) view
|
mSelectKeyButton = (BootstrapButton) view
|
||||||
.findViewById(R.id.select_secret_key_select_key_button);
|
.findViewById(R.id.select_secret_key_select_key_button);
|
||||||
mFilterCertify = false;
|
mFilterCertify = false;
|
||||||
|
mFilterSign = false;
|
||||||
mSelectKeyButton.setOnClickListener(new OnClickListener() {
|
mSelectKeyButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -135,6 +140,7 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan
|
|||||||
private void startSelectKeyActivity() {
|
private void startSelectKeyActivity() {
|
||||||
Intent intent = new Intent(getActivity(), SelectSecretKeyActivity.class);
|
Intent intent = new Intent(getActivity(), SelectSecretKeyActivity.class);
|
||||||
intent.putExtra(SelectSecretKeyActivity.EXTRA_FILTER_CERTIFY, mFilterCertify);
|
intent.putExtra(SelectSecretKeyActivity.EXTRA_FILTER_CERTIFY, mFilterCertify);
|
||||||
|
intent.putExtra(SelectSecretKeyActivity.EXTRA_FILTER_SIGN, mFilterSign);
|
||||||
startActivityForResult(intent, REQUEST_CODE_SELECT_KEY);
|
startActivityForResult(intent, REQUEST_CODE_SELECT_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,5 +499,6 @@
|
|||||||
<string name="secret_cannot_multiple">Secret keys can only be deleted individually!</string>
|
<string name="secret_cannot_multiple">Secret keys can only be deleted individually!</string>
|
||||||
<string name="title_view_cert">View Certificate Details</string>
|
<string name="title_view_cert">View Certificate Details</string>
|
||||||
<string name="unknown_algorithm">unknown</string>
|
<string name="unknown_algorithm">unknown</string>
|
||||||
|
<string name="can_sign_not">cannot sign</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user