diff options
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget')
3 files changed, 33 insertions, 0 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 1122fc522..e9a5674cd 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -125,6 +125,14 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { super.onFinishInflate(); } + public void setCanEdit(boolean bCanEdit) { + if (!bCanEdit) { + mDeleteButton.setVisibility(View.INVISIBLE); + mUsage.setEnabled(false); + mExpiryDateButton.setEnabled(false); + } + } + public void setValue(PGPSecretKey key, boolean isMasterKey, int usage) { mKey = key; diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 7142e4426..898b05372 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -45,6 +45,7 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.EditText; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.Spinner; import android.widget.TextView; @@ -55,12 +56,14 @@ import java.util.Vector; public class SectionView extends LinearLayout implements OnClickListener, EditorListener { private LayoutInflater mInflater; private View mAdd; + private ImageView mPlusButton; private ViewGroup mEditors; private TextView mTitle; private int mType = 0; private Choice mNewKeyAlgorithmChoice; private int mNewKeySize; + private boolean canEdit = true; private SherlockFragmentActivity mActivity; @@ -99,6 +102,14 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor } } + public void setCanEdit(boolean bCanEdit) { + canEdit = bCanEdit; + mPlusButton = (ImageView)findViewById(R.id.plusbutton); + if (!canEdit) { + mPlusButton.setVisibility(View.INVISIBLE); + } + } + /** {@inheritDoc} */ @Override protected void onFinishInflate() { @@ -129,6 +140,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor /** {@inheritDoc} */ public void onClick(View v) { + if (canEdit) { switch (mType) { case Id.type.user_id: { UserIdEditor view = (UserIdEditor) mInflater.inflate(R.layout.edit_key_user_id_item, @@ -205,6 +217,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor } } this.updateEditorsVisible(); + } } public void setUserIds(Vector<String> list) { @@ -221,6 +234,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor if (mEditors.getChildCount() == 0) { view.setIsMainUserId(true); } + view.setCanEdit(canEdit); mEditors.addView(view); } @@ -241,6 +255,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor view.setEditorListener(this); boolean isMasterKey = (mEditors.getChildCount() == 0); view.setValue(list.get(i), isMasterKey, usages.get(i)); + view.setCanEdit(canEdit); mEditors.addView(view); } diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 2215d29e7..5b43ebbd9 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -56,6 +56,16 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene } } + public void setCanEdit(boolean bCanEdit) { + if (!bCanEdit) { + mDeleteButton.setVisibility(View.INVISIBLE); + mName.setEnabled(false); + mIsMainUserId.setEnabled(false); + mEmail.setEnabled(false); + mComment.setEnabled(false); + } + } + public static class NoEmailException extends Exception { static final long serialVersionUID = 0xf812773344L; |