mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-07 10:30:14 -05:00
change edit key for empty private master keys
This commit is contained in:
parent
650b22d5e9
commit
cf34a1720e
@ -41,6 +41,7 @@
|
|||||||
android:text="Section Name" />
|
android:text="Section Name" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/plusbutton"
|
||||||
style="@style/PlusButton"
|
style="@style/PlusButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -309,6 +309,31 @@ public class PgpMain {
|
|||||||
return secKeyRing;
|
return secKeyRing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void changeSecretKeyPassphrase(Context context,
|
||||||
|
PGPSecretKeyRing keyRing, String oldPassPhrase, String newPassPhrase,
|
||||||
|
ProgressDialogUpdater progress) throws IOException, PGPException, PGPException,
|
||||||
|
NoSuchProviderException {
|
||||||
|
|
||||||
|
updateProgress(progress, R.string.progress_buildingKey, 0, 100);
|
||||||
|
if (oldPassPhrase == null) {
|
||||||
|
oldPassPhrase = "";
|
||||||
|
}
|
||||||
|
if (newPassPhrase == null) {
|
||||||
|
newPassPhrase = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
PGPSecretKeyRing newKeyRing = PGPSecretKeyRing.copyWithNewPassword(keyRing,
|
||||||
|
oldPassPhrase.toCharArray(), newPassPhrase.toCharArray(), keyRing.getSecretKey().getKeyEncryptionAlgorithm(),
|
||||||
|
new SecureRandom(), BOUNCY_CASTLE_PROVIDER_NAME);
|
||||||
|
|
||||||
|
updateProgress(progress, R.string.progress_savingKeyRing, 50, 100);
|
||||||
|
|
||||||
|
ProviderHelper.saveKeyRing(context, newKeyRing);
|
||||||
|
|
||||||
|
updateProgress(progress, R.string.progress_done, 100, 100);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static void buildSecretKey(Context context, ArrayList<String> userIds,
|
public static void buildSecretKey(Context context, ArrayList<String> userIds,
|
||||||
ArrayList<PGPSecretKey> keys, ArrayList<Integer> keysUsages, long masterKeyId,
|
ArrayList<PGPSecretKey> keys, ArrayList<Integer> keysUsages, long masterKeyId,
|
||||||
String oldPassPhrase, String newPassPhrase, ProgressDialogUpdater progress)
|
String oldPassPhrase, String newPassPhrase, ProgressDialogUpdater progress)
|
||||||
|
@ -34,6 +34,7 @@ import org.sufficientlysecure.keychain.helper.PgpMain;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||||
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
@ -494,6 +495,49 @@ public class ProviderHelper {
|
|||||||
return getMasterKeyId(context, queryUri, keyRingRowId);
|
return getMasterKeyId(context, queryUri, keyRingRowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get empty status of master key of keyring by its row id
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param keyRingRowId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getSecretMasterKeyCanSign(Context context, long keyRingRowId) {
|
||||||
|
Uri queryUri = KeyRings.buildSecretKeyRingsUri(String.valueOf(keyRingRowId));
|
||||||
|
return getMasterKeyCanSign(context, queryUri, keyRingRowId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private helper method to get master key private empty status of keyring by its row id
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param queryUri
|
||||||
|
* @param keyRingRowId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static boolean getMasterKeyCanSign(Context context, Uri queryUri, long keyRingRowId) {
|
||||||
|
String[] projection = new String[] { KeyRings.MASTER_KEY_ID, "(SELECT COUNT(sign_keys." +
|
||||||
|
Keys._ID + ") FROM " + Tables.KEYS + " AS sign_keys WHERE sign_keys." + Keys.KEY_RING_ROW_ID + " = "
|
||||||
|
+ KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + " AND sign_keys."
|
||||||
|
+ Keys.CAN_SIGN + " = '1' AND " + Keys.IS_MASTER_KEY + " = 1) AS sign", };
|
||||||
|
|
||||||
|
ContentResolver cr = context.getContentResolver();
|
||||||
|
Cursor cursor = cr.query(queryUri, projection, null, null, null);
|
||||||
|
|
||||||
|
long masterKeyId = -1;
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
int masterKeyIdCol = cursor.getColumnIndex("sign");
|
||||||
|
|
||||||
|
masterKeyId = cursor.getLong(masterKeyIdCol);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cursor != null) {
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (masterKeyId > 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get master key id of keyring by its row id
|
* Get master key id of keyring by its row id
|
||||||
*
|
*
|
||||||
|
@ -123,6 +123,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial
|
|||||||
public static final String SAVE_KEYRING_KEYS = "keys";
|
public static final String SAVE_KEYRING_KEYS = "keys";
|
||||||
public static final String SAVE_KEYRING_KEYS_USAGES = "keysUsages";
|
public static final String SAVE_KEYRING_KEYS_USAGES = "keysUsages";
|
||||||
public static final String SAVE_KEYRING_MASTER_KEY_ID = "masterKeyId";
|
public static final String SAVE_KEYRING_MASTER_KEY_ID = "masterKeyId";
|
||||||
|
public static final String SAVE_KEYRING_CAN_SIGN = "can_sign";
|
||||||
|
|
||||||
// generate key
|
// generate key
|
||||||
public static final String GENERATE_KEY_ALGORITHM = "algorithm";
|
public static final String GENERATE_KEY_ALGORITHM = "algorithm";
|
||||||
@ -523,6 +524,12 @@ public class KeychainIntentService extends IntentService implements ProgressDial
|
|||||||
/* Input */
|
/* Input */
|
||||||
String oldPassPhrase = data.getString(SAVE_KEYRING_CURRENT_PASSPHRASE);
|
String oldPassPhrase = data.getString(SAVE_KEYRING_CURRENT_PASSPHRASE);
|
||||||
String newPassPhrase = data.getString(SAVE_KEYRING_NEW_PASSPHRASE);
|
String newPassPhrase = data.getString(SAVE_KEYRING_NEW_PASSPHRASE);
|
||||||
|
boolean canSign = true;
|
||||||
|
|
||||||
|
if (data.containsKey(SAVE_KEYRING_CAN_SIGN)) {
|
||||||
|
canSign = data.getBoolean(SAVE_KEYRING_CAN_SIGN);
|
||||||
|
}
|
||||||
|
|
||||||
if (newPassPhrase == null) {
|
if (newPassPhrase == null) {
|
||||||
newPassPhrase = oldPassPhrase;
|
newPassPhrase = oldPassPhrase;
|
||||||
}
|
}
|
||||||
@ -533,8 +540,13 @@ public class KeychainIntentService extends IntentService implements ProgressDial
|
|||||||
long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID);
|
long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID);
|
||||||
|
|
||||||
/* Operation */
|
/* Operation */
|
||||||
|
if (!canSign) { //library fails, fix later
|
||||||
|
//PgpMain.changeSecretKeyPassphrase(this, ProviderHelper.getPGPSecretKeyRingByKeyId(this, masterKeyId),
|
||||||
|
//oldPassPhrase, newPassPhrase, this);
|
||||||
|
} else {
|
||||||
PgpMain.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId, oldPassPhrase,
|
PgpMain.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId, oldPassPhrase,
|
||||||
newPassPhrase, this);
|
newPassPhrase, this);
|
||||||
|
}
|
||||||
PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase);
|
PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase);
|
||||||
|
|
||||||
/* Output */
|
/* Output */
|
||||||
|
@ -75,6 +75,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
public static final String EXTRA_NO_PASSPHRASE = "noPassphrase";
|
public static final String EXTRA_NO_PASSPHRASE = "noPassphrase";
|
||||||
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys";
|
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys";
|
||||||
public static final String EXTRA_MASTER_KEY_ID = "masterKeyId";
|
public static final String EXTRA_MASTER_KEY_ID = "masterKeyId";
|
||||||
|
public static final String EXTRA_MASTER_CAN_SIGN = "masterCanSign";
|
||||||
|
|
||||||
// results when saving key
|
// results when saving key
|
||||||
public static final String RESULT_EXTRA_MASTER_KEY_ID = "masterKeyId";
|
public static final String RESULT_EXTRA_MASTER_KEY_ID = "masterKeyId";
|
||||||
@ -97,6 +98,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
Vector<String> mUserIds;
|
Vector<String> mUserIds;
|
||||||
Vector<PGPSecretKey> mKeys;
|
Vector<PGPSecretKey> mKeys;
|
||||||
Vector<Integer> mKeysUsages;
|
Vector<Integer> mKeysUsages;
|
||||||
|
boolean masterCanSign = true;
|
||||||
|
|
||||||
// will be set to false to build layout later in handler
|
// will be set to false to build layout later in handler
|
||||||
private boolean mBuildLayout = true;
|
private boolean mBuildLayout = true;
|
||||||
@ -192,6 +194,13 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//disable key passhphrase changing with empty private keys for no
|
||||||
|
//library fails, fix later
|
||||||
|
if (!masterCanSign) {
|
||||||
|
mChangePassPhrase.setEnabled(false);
|
||||||
|
mNoPassphrase.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (mBuildLayout) {
|
if (mBuildLayout) {
|
||||||
buildLayout();
|
buildLayout();
|
||||||
}
|
}
|
||||||
@ -317,6 +326,9 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (extras != null) {
|
if (extras != null) {
|
||||||
|
if (extras.containsKey(EXTRA_MASTER_CAN_SIGN)) {
|
||||||
|
masterCanSign = extras.getBoolean(EXTRA_MASTER_CAN_SIGN);
|
||||||
|
}
|
||||||
if (extras.containsKey(EXTRA_MASTER_KEY_ID)) {
|
if (extras.containsKey(EXTRA_MASTER_KEY_ID)) {
|
||||||
long masterKeyId = extras.getLong(EXTRA_MASTER_KEY_ID);
|
long masterKeyId = extras.getLong(EXTRA_MASTER_KEY_ID);
|
||||||
|
|
||||||
@ -394,10 +406,12 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
LinearLayout container = (LinearLayout) findViewById(R.id.edit_key_container);
|
LinearLayout container = (LinearLayout) findViewById(R.id.edit_key_container);
|
||||||
mUserIdsView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false);
|
mUserIdsView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false);
|
||||||
mUserIdsView.setType(Id.type.user_id);
|
mUserIdsView.setType(Id.type.user_id);
|
||||||
|
mUserIdsView.setCanEdit(masterCanSign);
|
||||||
mUserIdsView.setUserIds(mUserIds);
|
mUserIdsView.setUserIds(mUserIds);
|
||||||
container.addView(mUserIdsView);
|
container.addView(mUserIdsView);
|
||||||
mKeysView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false);
|
mKeysView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false);
|
||||||
mKeysView.setType(Id.type.key);
|
mKeysView.setType(Id.type.key);
|
||||||
|
mKeysView.setCanEdit(masterCanSign);
|
||||||
mKeysView.setKeys(mKeys, mKeysUsages);
|
mKeysView.setKeys(mKeys, mKeysUsages);
|
||||||
container.addView(mKeysView);
|
container.addView(mKeysView);
|
||||||
|
|
||||||
@ -447,6 +461,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
data.putIntegerArrayList(KeychainIntentService.SAVE_KEYRING_KEYS_USAGES,
|
data.putIntegerArrayList(KeychainIntentService.SAVE_KEYRING_KEYS_USAGES,
|
||||||
getKeysUsages(mKeysView));
|
getKeysUsages(mKeysView));
|
||||||
data.putLong(KeychainIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId());
|
data.putLong(KeychainIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId());
|
||||||
|
data.putBoolean(KeychainIntentService.SAVE_KEYRING_CAN_SIGN, masterCanSign);
|
||||||
|
|
||||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||||
|
|
||||||
|
@ -70,18 +70,19 @@ public class KeyListSecretActivity extends KeyListActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkPassPhraseAndEdit(long masterKeyId) {
|
public void checkPassPhraseAndEdit(long masterKeyId, boolean masterCanSign) {
|
||||||
String passPhrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId);
|
String passPhrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId);
|
||||||
if (passPhrase == null) {
|
if (passPhrase == null) {
|
||||||
showPassphraseDialog(masterKeyId);
|
showPassphraseDialog(masterKeyId, masterCanSign);
|
||||||
} else {
|
} else {
|
||||||
PgpMain.setEditPassPhrase(passPhrase);
|
PgpMain.setEditPassPhrase(passPhrase);
|
||||||
editKey(masterKeyId);
|
editKey(masterKeyId, masterCanSign);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPassphraseDialog(final long masterKeyId) {
|
private void showPassphraseDialog(final long masterKeyId, boolean masterCanSign) {
|
||||||
// Message is received after passphrase is cached
|
// Message is received after passphrase is cached
|
||||||
|
final boolean mCanSign = masterCanSign;
|
||||||
Handler returnHandler = new Handler() {
|
Handler returnHandler = new Handler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message message) {
|
public void handleMessage(Message message) {
|
||||||
@ -89,7 +90,7 @@ public class KeyListSecretActivity extends KeyListActivity {
|
|||||||
String passPhrase = PassphraseCacheService.getCachedPassphrase(
|
String passPhrase = PassphraseCacheService.getCachedPassphrase(
|
||||||
KeyListSecretActivity.this, masterKeyId);
|
KeyListSecretActivity.this, masterKeyId);
|
||||||
PgpMain.setEditPassPhrase(passPhrase);
|
PgpMain.setEditPassPhrase(passPhrase);
|
||||||
editKey(masterKeyId);
|
editKey(masterKeyId, mCanSign);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -115,9 +116,10 @@ public class KeyListSecretActivity extends KeyListActivity {
|
|||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editKey(long masterKeyId) {
|
private void editKey(long masterKeyId, boolean masterCanSign) {
|
||||||
Intent intent = new Intent(EditKeyActivity.ACTION_EDIT_KEY);
|
Intent intent = new Intent(EditKeyActivity.ACTION_EDIT_KEY);
|
||||||
intent.putExtra(EditKeyActivity.EXTRA_MASTER_KEY_ID, masterKeyId);
|
intent.putExtra(EditKeyActivity.EXTRA_MASTER_KEY_ID, masterKeyId);
|
||||||
|
intent.putExtra(EditKeyActivity.EXTRA_MASTER_CAN_SIGN, masterCanSign);
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,9 +91,11 @@ public class KeyListSecretFragment extends KeyListFragment implements
|
|||||||
long masterKeyId = ProviderHelper
|
long masterKeyId = ProviderHelper
|
||||||
.getSecretMasterKeyId(mKeyListSecretActivity, keyRingRowId);
|
.getSecretMasterKeyId(mKeyListSecretActivity, keyRingRowId);
|
||||||
|
|
||||||
|
boolean masterCanSign = ProviderHelper.getSecretMasterKeyCanSign(mKeyListSecretActivity, keyRingRowId);
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case Id.menu.edit:
|
case Id.menu.edit:
|
||||||
mKeyListSecretActivity.checkPassPhraseAndEdit(masterKeyId);
|
mKeyListSecretActivity.checkPassPhraseAndEdit(masterKeyId, masterCanSign);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -125,6 +125,14 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
super.onFinishInflate();
|
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) {
|
public void setValue(PGPSecretKey key, boolean isMasterKey, int usage) {
|
||||||
mKey = key;
|
mKey = key;
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ import android.view.View.OnClickListener;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -55,12 +56,14 @@ import java.util.Vector;
|
|||||||
public class SectionView extends LinearLayout implements OnClickListener, EditorListener {
|
public class SectionView extends LinearLayout implements OnClickListener, EditorListener {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private View mAdd;
|
private View mAdd;
|
||||||
|
private ImageView mPlusButton;
|
||||||
private ViewGroup mEditors;
|
private ViewGroup mEditors;
|
||||||
private TextView mTitle;
|
private TextView mTitle;
|
||||||
private int mType = 0;
|
private int mType = 0;
|
||||||
|
|
||||||
private Choice mNewKeyAlgorithmChoice;
|
private Choice mNewKeyAlgorithmChoice;
|
||||||
private int mNewKeySize;
|
private int mNewKeySize;
|
||||||
|
private boolean canEdit = true;
|
||||||
|
|
||||||
private SherlockFragmentActivity mActivity;
|
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} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
@ -129,6 +140,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
if (canEdit) {
|
||||||
switch (mType) {
|
switch (mType) {
|
||||||
case Id.type.user_id: {
|
case Id.type.user_id: {
|
||||||
UserIdEditor view = (UserIdEditor) mInflater.inflate(R.layout.edit_key_user_id_item,
|
UserIdEditor view = (UserIdEditor) mInflater.inflate(R.layout.edit_key_user_id_item,
|
||||||
@ -206,6 +218,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
}
|
}
|
||||||
this.updateEditorsVisible();
|
this.updateEditorsVisible();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setUserIds(Vector<String> list) {
|
public void setUserIds(Vector<String> list) {
|
||||||
if (mType != Id.type.user_id) {
|
if (mType != Id.type.user_id) {
|
||||||
@ -221,6 +234,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
if (mEditors.getChildCount() == 0) {
|
if (mEditors.getChildCount() == 0) {
|
||||||
view.setIsMainUserId(true);
|
view.setIsMainUserId(true);
|
||||||
}
|
}
|
||||||
|
view.setCanEdit(canEdit);
|
||||||
mEditors.addView(view);
|
mEditors.addView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,6 +255,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
view.setEditorListener(this);
|
view.setEditorListener(this);
|
||||||
boolean isMasterKey = (mEditors.getChildCount() == 0);
|
boolean isMasterKey = (mEditors.getChildCount() == 0);
|
||||||
view.setValue(list.get(i), isMasterKey, usages.get(i));
|
view.setValue(list.get(i), isMasterKey, usages.get(i));
|
||||||
|
view.setCanEdit(canEdit);
|
||||||
mEditors.addView(view);
|
mEditors.addView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 {
|
public static class NoEmailException extends Exception {
|
||||||
static final long serialVersionUID = 0xf812773344L;
|
static final long serialVersionUID = 0xf812773344L;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user