mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-05 08:45:08 -05:00
edit key: work on saving
This commit is contained in:
parent
a66c6b5b7a
commit
3d34eb8ca4
@ -328,8 +328,6 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
Log.d(Constants.TAG, "data: " + mUserIdsAddedAdapter.getDataAsStringList());
|
|
||||||
|
|
||||||
String passphrase = PassphraseCacheService.getCachedPassphrase(getActivity(),
|
String passphrase = PassphraseCacheService.getCachedPassphrase(getActivity(),
|
||||||
mSaveKeyringParcel.mMasterKeyId);
|
mSaveKeyringParcel.mMasterKeyId);
|
||||||
if (passphrase == null) {
|
if (passphrase == null) {
|
||||||
@ -338,17 +336,23 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message message) {
|
public void handleMessage(Message message) {
|
||||||
if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) {
|
if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) {
|
||||||
saveFinal();
|
String passphrase =
|
||||||
|
message.getData().getString(PassphraseDialogFragment.MESSAGE_DATA_PASSPHRASE);
|
||||||
|
Log.d(Constants.TAG, "after caching passphrase");
|
||||||
|
saveFinal(passphrase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
saveFinal(passphrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveFinal() {
|
private void saveFinal(String passphrase) {
|
||||||
|
Log.d(Constants.TAG, "add userids to parcel: " + mUserIdsAddedAdapter.getDataAsStringList());
|
||||||
|
mSaveKeyringParcel.addUserIds = mUserIdsAddedAdapter.getDataAsStringList();
|
||||||
|
|
||||||
// Message is received after importing is done in KeychainIntentService
|
// Message is received after importing is done in KeychainIntentService
|
||||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(
|
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(
|
||||||
getActivity(),
|
getActivity(),
|
||||||
@ -386,6 +390,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
|
|
||||||
// fill values for this action
|
// fill values for this action
|
||||||
Bundle data = new Bundle();
|
Bundle data = new Bundle();
|
||||||
|
data.putString(KeychainIntentService.SAVE_KEYRING_PASSPHRASE, passphrase);
|
||||||
data.putParcelable(KeychainIntentService.SAVE_KEYRING_PARCEL, mSaveKeyringParcel);
|
data.putParcelable(KeychainIntentService.SAVE_KEYRING_PARCEL, mSaveKeyringParcel);
|
||||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||||
|
|
||||||
|
@ -439,7 +439,6 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
private class ItemViewHolder {
|
private class ItemViewHolder {
|
||||||
TextView mMainUserId;
|
TextView mMainUserId;
|
||||||
TextView mMainUserIdRest;
|
TextView mMainUserIdRest;
|
||||||
View mStatusDivider;
|
|
||||||
FrameLayout mStatusLayout;
|
FrameLayout mStatusLayout;
|
||||||
TextView mRevoked;
|
TextView mRevoked;
|
||||||
ImageView mVerified;
|
ImageView mVerified;
|
||||||
@ -451,7 +450,6 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
ItemViewHolder holder = new ItemViewHolder();
|
ItemViewHolder holder = new ItemViewHolder();
|
||||||
holder.mMainUserId = (TextView) view.findViewById(R.id.mainUserId);
|
holder.mMainUserId = (TextView) view.findViewById(R.id.mainUserId);
|
||||||
holder.mMainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
|
holder.mMainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
|
||||||
holder.mStatusDivider = (View) view.findViewById(R.id.status_divider);
|
|
||||||
holder.mStatusLayout = (FrameLayout) view.findViewById(R.id.status_layout);
|
holder.mStatusLayout = (FrameLayout) view.findViewById(R.id.status_layout);
|
||||||
holder.mRevoked = (TextView) view.findViewById(R.id.revoked);
|
holder.mRevoked = (TextView) view.findViewById(R.id.revoked);
|
||||||
holder.mVerified = (ImageView) view.findViewById(R.id.verified);
|
holder.mVerified = (ImageView) view.findViewById(R.id.verified);
|
||||||
@ -489,14 +487,12 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
{ // set edit button and revoked info, specific by key type
|
{ // set edit button and revoked info, specific by key type
|
||||||
|
|
||||||
if (cursor.getInt(KeyListFragment.INDEX_HAS_ANY_SECRET) != 0) {
|
if (cursor.getInt(KeyListFragment.INDEX_HAS_ANY_SECRET) != 0) {
|
||||||
// this is a secret key - show the edit mButton
|
// this is a secret key
|
||||||
h.mStatusDivider.setVisibility(View.VISIBLE);
|
|
||||||
h.mStatusLayout.setVisibility(View.VISIBLE);
|
h.mStatusLayout.setVisibility(View.VISIBLE);
|
||||||
h.mRevoked.setVisibility(View.GONE);
|
h.mRevoked.setVisibility(View.GONE);
|
||||||
h.mVerified.setVisibility(View.GONE);
|
h.mVerified.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
// this is a public key - hide the edit mButton, show if it's revoked
|
// this is a public key - show if it's revoked
|
||||||
h.mStatusDivider.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
|
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
|
||||||
boolean isExpired = !cursor.isNull(INDEX_EXPIRY)
|
boolean isExpired = !cursor.isNull(INDEX_EXPIRY)
|
||||||
|
@ -55,15 +55,12 @@ public class UserIdsAddedAdapter extends ArrayAdapter<UserIdsAddedAdapter.UserId
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String userId = null;
|
String userId = name;
|
||||||
if (!TextUtils.isEmpty(name)) {
|
if (!TextUtils.isEmpty(comment)) {
|
||||||
userId = name;
|
userId += " (" + comment + ")";
|
||||||
if (!TextUtils.isEmpty(comment)) {
|
}
|
||||||
userId += " (" + comment + ")";
|
if (!TextUtils.isEmpty(address)) {
|
||||||
}
|
userId += " <" + address + ">";
|
||||||
if (!TextUtils.isEmpty(address)) {
|
|
||||||
userId += " <" + address + ">";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
@ -84,10 +81,13 @@ public class UserIdsAddedAdapter extends ArrayAdapter<UserIdsAddedAdapter.UserId
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getDataAsStringList() {
|
public ArrayList<String> getDataAsStringList() {
|
||||||
ArrayList<String> out = new ArrayList<String>();
|
ArrayList<String> out = new ArrayList<String>();
|
||||||
for (UserIdModel id : mData) {
|
for (UserIdModel id : mData) {
|
||||||
out.add(id.toString());
|
// ignore empty user ids
|
||||||
|
if (!TextUtils.isEmpty(id.toString())) {
|
||||||
|
out.add(id.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
@ -38,14 +38,6 @@
|
|||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/status_divider"
|
|
||||||
android:layout_width="1dip"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:background="?android:attr/listDivider" />
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/status_layout"
|
android:id="@+id/status_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
Loading…
Reference in New Issue
Block a user