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(), Toast.makeText(getApplicationContext(),
getResources().getString(R.string.msg_bulk_mode_scanned) + " (" + rawResult.getText() + ')', getResources().getString(R.string.msg_bulk_mode_scanned) + " (" + rawResult.getText() + ')',
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
maybeSetClipboard(resultHandler);
// Wait a moment or else it will scan the same barcode continuously about 3 times // Wait a moment or else it will scan the same barcode continuously about 3 times
restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS); restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
} else { } 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. // Put up our own UI for how to handle the decoded contents.
private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) { private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
CharSequence displayContents = resultHandler.getDisplayContents(); maybeSetClipboard(resultHandler);
if (copyToClipboard && !resultHandler.areContentsSecure()) {
ClipboardInterface.setText(displayContents, this);
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); 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); TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view);
contentsTextView.setText(displayContents); contentsTextView.setText(displayContents);
int scaledSize = Math.max(22, 32 - displayContents.length() / 4); 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); statusView.setText(getString(resultHandler.getDisplayTitle()) + " : " + rawResultString);
} }
if (copyToClipboard && !resultHandler.areContentsSecure()) { maybeSetClipboard(resultHandler);
CharSequence text = resultHandler.getDisplayContents();
ClipboardInterface.setText(text, this);
}
if (source == IntentSource.NATIVE_APP_INTENT) { 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) { private void sendReplyMessage(int id, Object arg, long delayMS) {
if (handler != null) { if (handler != null) {