mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-14 12:55:08 -05:00
parent
fb96b6dfa9
commit
b62ad4d79c
@ -711,7 +711,8 @@ public abstract class OperationResult implements Parcelable {
|
|||||||
|
|
||||||
MSG_ACC_SAVED (LogLevel.INFO, R.string.api_settings_save_msg),
|
MSG_ACC_SAVED (LogLevel.INFO, R.string.api_settings_save_msg),
|
||||||
|
|
||||||
MSG_WRONG_QR_CODE (LogLevel.INFO, R.string.import_qr_code_wrong),
|
MSG_WRONG_QR_CODE (LogLevel.ERROR, R.string.import_qr_code_wrong),
|
||||||
|
MSG_WRONG_QR_CODE_FP(LogLevel.ERROR, R.string.import_qr_code_fp),
|
||||||
|
|
||||||
MSG_NO_VALID_ENC (LogLevel.ERROR, R.string.error_invalid_data),
|
MSG_NO_VALID_ENC (LogLevel.ERROR, R.string.error_invalid_data),
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ import org.sufficientlysecure.keychain.intents.OpenKeychainIntents;
|
|||||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.SingletonResult;
|
import org.sufficientlysecure.keychain.operations.results.SingletonResult;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
|
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
|
||||||
@ -141,24 +142,35 @@ public class ImportKeysProxyActivity extends FragmentActivity {
|
|||||||
Log.d(Constants.TAG, "scanned: " + uri);
|
Log.d(Constants.TAG, "scanned: " + uri);
|
||||||
|
|
||||||
// example: openpgp4fpr:73EE2314F65FA92EC2390D3A718C070100012282
|
// example: openpgp4fpr:73EE2314F65FA92EC2390D3A718C070100012282
|
||||||
if (uri != null && uri.getScheme() != null && uri.getScheme().toLowerCase(Locale.ENGLISH).equals(Constants.FINGERPRINT_SCHEME)) {
|
if (uri == null || uri.getScheme() == null ||
|
||||||
String fingerprint = uri.getEncodedSchemeSpecificPart().toLowerCase(Locale.ENGLISH);
|
!uri.getScheme().toLowerCase(Locale.ENGLISH).equals(Constants.FINGERPRINT_SCHEME)) {
|
||||||
|
|
||||||
if (ACTION_SCAN_WITH_RESULT.equals(action)) {
|
|
||||||
Intent result = new Intent();
|
|
||||||
result.putExtra(EXTRA_FINGERPRINT, fingerprint);
|
|
||||||
setResult(RESULT_OK, result);
|
|
||||||
finish();
|
|
||||||
} else {
|
|
||||||
importKeys(fingerprint);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SingletonResult result = new SingletonResult(
|
SingletonResult result = new SingletonResult(
|
||||||
SingletonResult.RESULT_ERROR, OperationResult.LogType.MSG_WRONG_QR_CODE);
|
SingletonResult.RESULT_ERROR, LogType.MSG_WRONG_QR_CODE);
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(SingletonResult.EXTRA_RESULT, result);
|
intent.putExtra(SingletonResult.EXTRA_RESULT, result);
|
||||||
returnResult(intent);
|
returnResult(intent);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String fingerprint = uri.getEncodedSchemeSpecificPart().toLowerCase(Locale.ENGLISH);
|
||||||
|
if (fingerprint.matches("[a-fA-F0-9]{40}")) {
|
||||||
|
SingletonResult result = new SingletonResult(
|
||||||
|
SingletonResult.RESULT_ERROR, LogType.MSG_WRONG_QR_CODE_FP);
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra(SingletonResult.EXTRA_RESULT, result);
|
||||||
|
returnResult(intent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ACTION_SCAN_WITH_RESULT.equals(action)) {
|
||||||
|
Intent result = new Intent();
|
||||||
|
result.putExtra(EXTRA_FINGERPRINT, fingerprint);
|
||||||
|
setResult(RESULT_OK, result);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
importKeys(fingerprint);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void returnResult(Intent data) {
|
public void returnResult(Intent data) {
|
||||||
|
@ -408,7 +408,8 @@
|
|||||||
<string name="import_tab_qr_code">"QR Code/NFC"</string>
|
<string name="import_tab_qr_code">"QR Code/NFC"</string>
|
||||||
<string name="import_import">"Import selected keys"</string>
|
<string name="import_import">"Import selected keys"</string>
|
||||||
<string name="import_qr_code_wrong">"QR Code malformed! Please try again!"</string>
|
<string name="import_qr_code_wrong">"QR Code malformed! Please try again!"</string>
|
||||||
<string name="import_qr_code_too_short_fingerprint">"Fingerprint is too short (< 16 characters)"</string>
|
<string name="import_qr_code_fp">"Fingerprint is malformed or too short!"</string>
|
||||||
|
<string name="import_qr_code_too_short_fingerprint">"Fingerprint is too short!"</string>
|
||||||
<string name="import_qr_code_button">"Scan QR Code"</string>
|
<string name="import_qr_code_button">"Scan QR Code"</string>
|
||||||
<string name="import_qr_code_text">"Place your camera over the QR Code!"</string>
|
<string name="import_qr_code_text">"Place your camera over the QR Code!"</string>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user