mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-01-12 05:58:07 -05:00
if there is only one private key, use it fo certification by default
This commit is contained in:
parent
0738a38bbe
commit
a73abf57f1
@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.ui.widget;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@ -48,7 +49,7 @@ public class CertifyKeySpinner extends KeySpinner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader() {
|
public Loader<Cursor> onCreateLoader(int loaderId, Bundle data) {
|
||||||
// This is called when a new Loader needs to be created. This
|
// 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.
|
// sample only has one Loader, so we don't care about the ID.
|
||||||
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingsUri();
|
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingsUri();
|
||||||
@ -74,4 +75,14 @@ public class CertifyKeySpinner extends KeySpinner {
|
|||||||
// creating a Cursor for the data being displayed.
|
// creating a Cursor for the data being displayed.
|
||||||
return new CursorLoader(getContext(), baseUri, projection, where, null, null);
|
return new CursorLoader(getContext(), baseUri, projection, where, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||||
|
super.onLoadFinished(loader, data);
|
||||||
|
// If there is only one choice, pick it by default
|
||||||
|
if (mAdapter.getCount() == 2) {
|
||||||
|
setSelection(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,14 +40,14 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
public abstract class KeySpinner extends Spinner {
|
public abstract class KeySpinner extends Spinner implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
public interface OnKeyChangedListener {
|
public interface OnKeyChangedListener {
|
||||||
public void onKeyChanged(long masterKeyId);
|
public void onKeyChanged(long masterKeyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long mSelectedKeyId;
|
protected long mSelectedKeyId;
|
||||||
private SelectKeyAdapter mAdapter = new SelectKeyAdapter();
|
protected SelectKeyAdapter mAdapter = new SelectKeyAdapter();
|
||||||
private OnKeyChangedListener mListener;
|
protected OnKeyChangedListener mListener;
|
||||||
|
|
||||||
public KeySpinner(Context context) {
|
public KeySpinner(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -83,8 +83,6 @@ public abstract class KeySpinner extends Spinner {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Loader<Cursor> onCreateLoader();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
|
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
@ -102,27 +100,22 @@ public abstract class KeySpinner extends Spinner {
|
|||||||
|
|
||||||
public void reload() {
|
public void reload() {
|
||||||
if (getContext() instanceof FragmentActivity) {
|
if (getContext() instanceof FragmentActivity) {
|
||||||
((FragmentActivity) getContext()).getSupportLoaderManager().restartLoader(hashCode(), null, new LoaderManager.LoaderCallbacks<Cursor>() {
|
((FragmentActivity) getContext()).getSupportLoaderManager().restartLoader(0, null, this);
|
||||||
@Override
|
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
|
||||||
return KeySpinner.this.onCreateLoader();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
|
||||||
mAdapter.swapCursor(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoaderReset(Loader<Cursor> loader) {
|
|
||||||
mAdapter.swapCursor(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
Log.e(Constants.TAG, "KeySpinner must be attached to FragmentActivity, this is " + getContext().getClass());
|
Log.e(Constants.TAG, "KeySpinner must be attached to FragmentActivity, this is " + getContext().getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||||
|
mAdapter.swapCursor(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoaderReset(Loader<Cursor> loader) {
|
||||||
|
mAdapter.swapCursor(null);
|
||||||
|
}
|
||||||
|
|
||||||
public long getSelectedKeyId() {
|
public long getSelectedKeyId() {
|
||||||
return mSelectedKeyId;
|
return mSelectedKeyId;
|
||||||
}
|
}
|
||||||
@ -131,7 +124,7 @@ public abstract class KeySpinner extends Spinner {
|
|||||||
this.mSelectedKeyId = selectedKeyId;
|
this.mSelectedKeyId = selectedKeyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SelectKeyAdapter extends BaseAdapter implements SpinnerAdapter {
|
protected class SelectKeyAdapter extends BaseAdapter implements SpinnerAdapter {
|
||||||
private CursorAdapter inner;
|
private CursorAdapter inner;
|
||||||
private int mIndexUserId;
|
private int mIndexUserId;
|
||||||
private int mIndexKeyId;
|
private int mIndexKeyId;
|
||||||
|
@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.ui.widget;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@ -39,7 +40,7 @@ public class SignKeySpinner extends KeySpinner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader() {
|
public Loader<Cursor> onCreateLoader(int loaderId, Bundle data) {
|
||||||
// This is called when a new Loader needs to be created. This
|
// 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.
|
// sample only has one Loader, so we don't care about the ID.
|
||||||
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingsUri();
|
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingsUri();
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:padding="4dp"
|
android:padding="4dp"
|
||||||
|
android:minHeight="24dp"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<TextView android:id="@android:id/title"
|
<TextView android:id="@android:id/title"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
@ -11,7 +12,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"/>
|
android:ellipsize="end"
|
||||||
|
/>
|
||||||
<TextView android:id="@android:id/text1"
|
<TextView android:id="@android:id/text1"
|
||||||
android:textColor="?android:attr/textColorTertiary"
|
android:textColor="?android:attr/textColorTertiary"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
@ -19,7 +21,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:layout_marginTop="-4dip"/>
|
android:layout_marginTop="-4dip"
|
||||||
|
android:text=".com"/>
|
||||||
<TextView android:id="@android:id/text2"
|
<TextView android:id="@android:id/text2"
|
||||||
android:textColor="?android:attr/textColorTertiary"
|
android:textColor="?android:attr/textColorTertiary"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
@ -27,5 +30,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:layout_marginTop="-4dip"/>
|
android:layout_marginTop="-4dip"
|
||||||
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user