Skip to content

Commit

Permalink
Merge pull request #13 from Nuvoex/ManualInput
Browse files Browse the repository at this point in the history
ManualInput
  • Loading branch information
anshulagarwal06 authored Jan 9, 2017
2 parents fd7ee8e + a6f1622 commit 1d105a7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 35 deletions.
4 changes: 2 additions & 2 deletions scanner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 3
versionName "2.1"
versionCode 4
versionName "2.2"
}
buildTypes {
release {
Expand Down
71 changes: 38 additions & 33 deletions scanner/src/main/java/nuvoex/com/scanner/BarCodeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class BarCodeActivity extends MarshmallowSupportActivity {
public static final String BUNDLE_USE_INPUT_ALPHA_NUMERIC = "bundle_use_input_type_alpha_numeric";
public static final String BUNDLE_ALLOW_EMPTY_RESULT = "bundle_allow_empty_result";
public static final String BUNDLE_SUPPORTED_FORMAT_LIST = "bundle_supported_format_list";
public static final String BUNDLE_SHOW_MANUAL_INPUT = "bundle_show_manual_input";
private static final int PHOTO_ACTIVITY_REQUEST_CARMERA_AND_READ_WRITE = 50;
private static final String[] PHOTO_ACTIVITY_CAMERA_PERMISSIONS = {Manifest.permission.CAMERA};
FrameLayout mScannerContainer;
Expand Down Expand Up @@ -75,6 +76,7 @@ public class BarCodeActivity extends MarshmallowSupportActivity {
private boolean mSkipChecksum;
private boolean mIsInputAlphaNumeric;
private boolean mAllowEmptyResult;
private boolean mIsShowingManualInput;

private enum ValidationResult {
INVALID,
Expand All @@ -99,6 +101,7 @@ public void onCreate(Bundle savedInstanceState) {
mSkipChecksum = getIntent().getBooleanExtra(BUNDLE_SKIP_CHECKSUM, false);
mIsInputAlphaNumeric = getIntent().getBooleanExtra(BUNDLE_USE_INPUT_ALPHA_NUMERIC, false);
mAllowEmptyResult = getIntent().getBooleanExtra(BUNDLE_ALLOW_EMPTY_RESULT, false);
mIsShowingManualInput = getIntent().getBooleanExtra(BUNDLE_SHOW_MANUAL_INPUT, true);

setContentView(R.layout.activity_bar_code);
initView();
Expand All @@ -124,42 +127,42 @@ public void onClick(View v) {
}
});

mBarCodeEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
String barcode = v.getText().toString();
if (!TextUtils.isEmpty(barcode)) {
mScanner.stopCameraPreview();
addBarcode(barcode);
v.setText("");
if (mIsShowingManualInput) {
mBarCodeEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
String barcode = v.getText().toString();
if (!TextUtils.isEmpty(barcode)) {
mScanner.stopCameraPreview();
addBarcode(barcode);
v.setText("");
}
return false;
}
return false;
}
});
});
mBarCodeEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

mBarCodeEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
enableSubmitButton(!TextUtils.isEmpty(s));
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
enableSubmitButton(!TextUtils.isEmpty(s));
}

@Override
public void afterTextChanged(Editable s) {
@Override
public void afterTextChanged(Editable s) {

}
});

mBtnSubmitCode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onSubmitClicked();
}
});
}
});
mBtnSubmitCode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onSubmitClicked();
}
});
}

updateBarcodeInfo();
if (!hasPermissions(PHOTO_ACTIVITY_CAMERA_PERMISSIONS)) {
Expand All @@ -180,8 +183,10 @@ private void initView() {
mBarCodeEditText = (EditText) findViewById(R.id.qrCodeValue);
mBarcodeCountInfo = (TextView) findViewById(R.id.barcode_count);
mEditTextContainer = (LinearLayout) findViewById(R.id.editTextContainer);

if(mIsInputAlphaNumeric) {
if (!mIsShowingManualInput) {
mEditTextContainer.setVisibility(View.GONE);
}
if (mIsInputAlphaNumeric) {
mBarCodeEditText.setInputType(InputType.TYPE_CLASS_TEXT);
}

Expand Down

0 comments on commit 1d105a7

Please sign in to comment.