diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle index ff6f603f4..c18c4865c 100644 --- a/OpenKeychain/build.gradle +++ b/OpenKeychain/build.gradle @@ -29,7 +29,6 @@ dependencies { testCompile 'com.squareup:fest-android:1.0.8' testCompile 'com.google.android:android:4.1.1.4' // compile dependencies are automatically also included in testCompile - } android { @@ -79,6 +78,11 @@ android { htmlReport true htmlOutput file("lint-report.html") } + + // Disable preDexing, causes com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000) on some systems + dexOptions { + preDexLibraries = false + } } // NOTE: This disables Lint! diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java index 29ab06264..0ca6f07fd 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java @@ -42,6 +42,9 @@ public class KeybaseKeyserver extends Keyserver { // cut off "0x" if a user is searching for a key id query = query.substring(2); } + if (query.isEmpty()) { + throw new QueryTooShortException(); + } mQuery = query; try { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java index dac19a0c3..ac4390eac 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java @@ -47,6 +47,7 @@ import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter; import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; import org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment; +import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment; import org.sufficientlysecure.keychain.util.Log; public class EditKeyFragment extends LoaderFragment implements @@ -135,69 +136,6 @@ public class EditKeyFragment extends LoaderFragment implements loadData(dataUri); } - private void editUserId(final String userId) { - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - switch (message.what) { - case EditUserIdDialogFragment.MESSAGE_CHANGE_PRIMARY_USER_ID: - // toggle - if (mSaveKeyringParcel.changePrimaryUserId != null - && mSaveKeyringParcel.changePrimaryUserId.equals(userId)) { - mSaveKeyringParcel.changePrimaryUserId = null; - } else { - mSaveKeyringParcel.changePrimaryUserId = userId; - } - break; - case EditUserIdDialogFragment.MESSAGE_REVOKE: - // toggle - if (mSaveKeyringParcel.revokeUserIds.contains(userId)) { - mSaveKeyringParcel.revokeUserIds.remove(userId); - } else { - mSaveKeyringParcel.revokeUserIds.add(userId); - } - break; - } - getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, EditKeyFragment.this); - } - }; - - // Create a new Messenger for the communication back - final Messenger messenger = new Messenger(returnHandler); - - DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { - public void run() { - EditUserIdDialogFragment dialogFragment = - EditUserIdDialogFragment.newInstance(messenger); - - dialogFragment.show(getActivity().getSupportFragmentManager(), "editUserIdDialog"); - } - }); - } - - private void addUserId() { - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == AddUserIdDialogFragment.MESSAGE_OK) { - - } -// getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, EditKeyFragment.this); - } - }; - - // Create a new Messenger for the communication back - final Messenger messenger = new Messenger(returnHandler); - - DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { - public void run() { - AddUserIdDialogFragment dialogFragment = - AddUserIdDialogFragment.newInstance(messenger); - - dialogFragment.show(getActivity().getSupportFragmentManager(), "addUserIdDialog"); - } - }); - } private void loadData(Uri dataUri) { mDataUri = dataUri; @@ -217,6 +155,13 @@ public class EditKeyFragment extends LoaderFragment implements getActivity().finish(); } + mChangePassphrase.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + changePassphrase(); + } + }); + mAddUserId.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -296,6 +241,105 @@ public class EditKeyFragment extends LoaderFragment implements } } + private void changePassphrase() { + // Message is received after passphrase is cached + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == SetPassphraseDialogFragment.MESSAGE_OKAY) { + Bundle data = message.getData(); + + // set new returned passphrase! + String newPassphrase = data + .getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE); + +// updatePassphraseButtonText(); +// somethingChanged(); + mSaveKeyringParcel.newPassphrase = newPassphrase; + } + } + }; + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(returnHandler); + + // set title based on isPassphraseSet() +// int title; +// if (isPassphraseSet()) { +// title = R.string.title_change_passphrase; +// } else { +// title = R.string.title_set_passphrase; +// } + + SetPassphraseDialogFragment setPassphraseDialog = SetPassphraseDialogFragment.newInstance( + messenger, R.string.title_change_passphrase); + + setPassphraseDialog.show(getActivity().getSupportFragmentManager(), "setPassphraseDialog"); + } + + private void editUserId(final String userId) { + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + switch (message.what) { + case EditUserIdDialogFragment.MESSAGE_CHANGE_PRIMARY_USER_ID: + // toggle + if (mSaveKeyringParcel.changePrimaryUserId != null + && mSaveKeyringParcel.changePrimaryUserId.equals(userId)) { + mSaveKeyringParcel.changePrimaryUserId = null; + } else { + mSaveKeyringParcel.changePrimaryUserId = userId; + } + break; + case EditUserIdDialogFragment.MESSAGE_REVOKE: + // toggle + if (mSaveKeyringParcel.revokeUserIds.contains(userId)) { + mSaveKeyringParcel.revokeUserIds.remove(userId); + } else { + mSaveKeyringParcel.revokeUserIds.add(userId); + } + break; + } + getLoaderManager().getLoader(LOADER_ID_USER_IDS).forceLoad(); + } + }; + + // Create a new Messenger for the communication back + final Messenger messenger = new Messenger(returnHandler); + + DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { + public void run() { + EditUserIdDialogFragment dialogFragment = + EditUserIdDialogFragment.newInstance(messenger); + + dialogFragment.show(getActivity().getSupportFragmentManager(), "editUserIdDialog"); + } + }); + } + + private void addUserId() { + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == AddUserIdDialogFragment.MESSAGE_OK) { + + } + } + }; + + // Create a new Messenger for the communication back + final Messenger messenger = new Messenger(returnHandler); + + DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { + public void run() { + AddUserIdDialogFragment dialogFragment = + AddUserIdDialogFragment.newInstance(messenger); + + dialogFragment.show(getActivity().getSupportFragmentManager(), "addUserIdDialog"); + } + }); + } + private void save() { getActivity().finish(); // TODO diff --git a/build.gradle b/build.gradle index e0da6b52f..fa6c7278e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { dependencies { // NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information classpath 'com.android.tools.build:gradle:0.11.1' - classpath 'org.robolectric:robolectric-gradle-plugin:0.11.0' + classpath 'org.robolectric:robolectric-gradle-plugin:0.11.0' } }