mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-24 01:32:16 -05:00
Add and use CertifyKeySpinner
This commit is contained in:
parent
00286744f2
commit
a6118877ff
@ -34,6 +34,7 @@ import android.support.v7.app.ActionBarActivity;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
@ -56,6 +57,8 @@ import org.sufficientlysecure.keychain.service.OperationResultParcel;
|
|||||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
|
||||||
|
import org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner;
|
||||||
|
import org.sufficientlysecure.keychain.ui.widget.KeySpinner;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.Notify;
|
import org.sufficientlysecure.keychain.util.Notify;
|
||||||
|
|
||||||
@ -64,18 +67,17 @@ import java.util.ArrayList;
|
|||||||
/**
|
/**
|
||||||
* Signs the specified public key with the specified secret master key
|
* Signs the specified public key with the specified secret master key
|
||||||
*/
|
*/
|
||||||
public class CertifyKeyActivity extends ActionBarActivity implements
|
public class CertifyKeyActivity extends ActionBarActivity implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
SelectSecretKeyLayoutFragment.SelectSecretKeyCallback, LoaderManager.LoaderCallbacks<Cursor> {
|
|
||||||
private View mCertifyButton;
|
private View mCertifyButton;
|
||||||
private ImageView mActionCertifyImage;
|
private ImageView mActionCertifyImage;
|
||||||
private CheckBox mUploadKeyCheckbox;
|
private CheckBox mUploadKeyCheckbox;
|
||||||
private Spinner mSelectKeyserverSpinner;
|
private Spinner mSelectKeyserverSpinner;
|
||||||
|
|
||||||
private SelectSecretKeyLayoutFragment mSelectKeyFragment;
|
private CertifyKeySpinner mCertifyKeySpinner;
|
||||||
|
|
||||||
private Uri mDataUri;
|
private Uri mDataUri;
|
||||||
private long mPubKeyId = 0;
|
private long mPubKeyId = Constants.key.none;
|
||||||
private long mMasterKeyId = 0;
|
private long mMasterKeyId = Constants.key.none;
|
||||||
|
|
||||||
private ListView mUserIds;
|
private ListView mUserIds;
|
||||||
private UserIdsAdapter mUserIdsAdapter;
|
private UserIdsAdapter mUserIdsAdapter;
|
||||||
@ -89,8 +91,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements
|
|||||||
|
|
||||||
setContentView(R.layout.certify_key_activity);
|
setContentView(R.layout.certify_key_activity);
|
||||||
|
|
||||||
mSelectKeyFragment = (SelectSecretKeyLayoutFragment) getSupportFragmentManager()
|
mCertifyKeySpinner = (CertifyKeySpinner) findViewById(R.id.certify_key_spinner);
|
||||||
.findFragmentById(R.id.sign_key_select_key_fragment);
|
|
||||||
mSelectKeyserverSpinner = (Spinner) findViewById(R.id.upload_key_keyserver);
|
mSelectKeyserverSpinner = (Spinner) findViewById(R.id.upload_key_keyserver);
|
||||||
mUploadKeyCheckbox = (CheckBox) findViewById(R.id.sign_key_upload_checkbox);
|
mUploadKeyCheckbox = (CheckBox) findViewById(R.id.sign_key_upload_checkbox);
|
||||||
mCertifyButton = findViewById(R.id.certify_key_certify_button);
|
mCertifyButton = findViewById(R.id.certify_key_certify_button);
|
||||||
@ -101,8 +102,12 @@ public class CertifyKeyActivity extends ActionBarActivity implements
|
|||||||
mActionCertifyImage.setColorFilter(getResources().getColor(R.color.tertiary_text_light),
|
mActionCertifyImage.setColorFilter(getResources().getColor(R.color.tertiary_text_light),
|
||||||
PorterDuff.Mode.SRC_IN);
|
PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
mSelectKeyFragment.setCallback(this);
|
mCertifyKeySpinner.setOnKeyChangedListener(new KeySpinner.OnKeyChangedListener() {
|
||||||
mSelectKeyFragment.setFilterCertify(true);
|
@Override
|
||||||
|
public void onKeyChanged(long masterKeyId) {
|
||||||
|
mMasterKeyId = masterKeyId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
|
||||||
android.R.layout.simple_spinner_item, Preferences.getPreferences(this)
|
android.R.layout.simple_spinner_item, Preferences.getPreferences(this)
|
||||||
@ -135,7 +140,6 @@ public class CertifyKeyActivity extends ActionBarActivity implements
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (mPubKeyId != 0) {
|
if (mPubKeyId != 0) {
|
||||||
if (mMasterKeyId == 0) {
|
if (mMasterKeyId == 0) {
|
||||||
mSelectKeyFragment.setError(getString(R.string.select_key_to_certify));
|
|
||||||
Notify.showNotify(CertifyKeyActivity.this, getString(R.string.select_key_to_certify),
|
Notify.showNotify(CertifyKeyActivity.this, getString(R.string.select_key_to_certify),
|
||||||
Notify.Style.ERROR);
|
Notify.Style.ERROR);
|
||||||
} else {
|
} else {
|
||||||
@ -367,14 +371,6 @@ public class CertifyKeyActivity extends ActionBarActivity implements
|
|||||||
startService(intent);
|
startService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* callback from select key fragment
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onKeySelected(long secretKeyId) {
|
|
||||||
mMasterKeyId = secretKeyId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package org.sufficientlysecure.keychain.ui.widget;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.support.v4.content.CursorLoader;
|
||||||
|
import android.support.v4.content.Loader;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
|
|
||||||
|
public class CertifyKeySpinner extends KeySpinner {
|
||||||
|
public CertifyKeySpinner(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CertifyKeySpinner(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CertifyKeySpinner(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Loader<Cursor> onCreateLoader() {
|
||||||
|
// This is called when a new Loader needs to be created. This
|
||||||
|
// sample only has one Loader, so we don't care about the ID.
|
||||||
|
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingsUri();
|
||||||
|
|
||||||
|
// These are the rows that we will retrieve.
|
||||||
|
String[] projection = new String[]{
|
||||||
|
KeychainContract.KeyRings._ID,
|
||||||
|
KeychainContract.KeyRings.MASTER_KEY_ID,
|
||||||
|
KeychainContract.KeyRings.KEY_ID,
|
||||||
|
KeychainContract.KeyRings.USER_ID,
|
||||||
|
KeychainContract.KeyRings.IS_EXPIRED,
|
||||||
|
KeychainContract.KeyRings.HAS_CERTIFY,
|
||||||
|
KeychainContract.KeyRings.HAS_ANY_SECRET
|
||||||
|
};
|
||||||
|
|
||||||
|
String where = KeychainContract.KeyRings.HAS_ANY_SECRET + " = 1 AND " + KeychainContract.KeyRings.HAS_CERTIFY + " NOT NULL AND "
|
||||||
|
+ KeychainContract.KeyRings.IS_REVOKED + " = 0 AND " + KeychainContract.KeyRings.IS_EXPIRED + " = 0";
|
||||||
|
|
||||||
|
// Now create and return a CursorLoader that will take care of
|
||||||
|
// creating a Cursor for the data being displayed.
|
||||||
|
return new CursorLoader(getContext(), baseUri, projection, where, null, null);
|
||||||
|
}
|
||||||
|
}
|
@ -26,14 +26,10 @@
|
|||||||
android:layout_marginTop="14dp"
|
android:layout_marginTop="14dp"
|
||||||
android:text="@string/section_certification_key" />
|
android:text="@string/section_certification_key" />
|
||||||
|
|
||||||
<fragment
|
<org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner
|
||||||
android:id="@+id/sign_key_select_key_fragment"
|
android:id="@+id/certify_key_spinner"
|
||||||
android:name="org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content" />
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="4dp"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
tools:layout="@layout/select_secret_key_layout_fragment" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/SectionHeader"
|
style="@style/SectionHeader"
|
||||||
|
Loading…
Reference in New Issue
Block a user