Closes #707 : also copy to clipboard in bulk scan mode

This commit is contained in:
Sean Owen 2016-11-14 10:45:00 +01:00
parent 08a9d74062
commit 64eb07747e
No known key found for this signature in database
GPG key ID: F6CE9695C9318406

View file

@ -472,6 +472,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.msg_bulk_mode_scanned) + " (" + rawResult.getText() + ')',
Toast.LENGTH_SHORT).show();
maybeSetClipboard(resultHandler);
// Wait a moment or else it will scan the same barcode continuously about 3 times
restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
} else {
@ -527,11 +528,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
// Put up our own UI for how to handle the decoded contents.
private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
CharSequence displayContents = resultHandler.getDisplayContents();
if (copyToClipboard && !resultHandler.areContentsSecure()) {
ClipboardInterface.setText(displayContents, this);
}
maybeSetClipboard(resultHandler);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
@ -583,6 +580,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
}
}
CharSequence displayContents = resultHandler.getDisplayContents();
TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view);
contentsTextView.setText(displayContents);
int scaledSize = Math.max(22, 32 - displayContents.length() / 4);
@ -638,10 +636,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
statusView.setText(getString(resultHandler.getDisplayTitle()) + " : " + rawResultString);
}
if (copyToClipboard && !resultHandler.areContentsSecure()) {
CharSequence text = resultHandler.getDisplayContents();
ClipboardInterface.setText(text, this);
}
maybeSetClipboard(resultHandler);
if (source == IntentSource.NATIVE_APP_INTENT) {
@ -699,6 +694,12 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
}
}
private void maybeSetClipboard(ResultHandler resultHandler) {
if (copyToClipboard && !resultHandler.areContentsSecure()) {
ClipboardInterface.setText(resultHandler.getDisplayContents(), this);
}
}
private void sendReplyMessage(int id, Object arg, long delayMS) {
if (handler != null) {