use of de.geeksfactory.opacclient.barcode.BarcodeScanIntegrator in project opacclient by opacapp.
the class MainActivity method scanBarcode.
@Override
public void scanBarcode() {
BarcodeScanIntegrator integrator = new BarcodeScanIntegrator(this);
integrator.initiateScan();
}
use of de.geeksfactory.opacclient.barcode.BarcodeScanIntegrator in project opacclient by opacapp.
the class AccountEditActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResource());
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ImageView image = (ImageView) findViewById(R.id.ivBarcode);
image.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
BarcodeScanIntegrator integrator = new BarcodeScanIntegrator(AccountEditActivity.this);
integrator.initiateScan();
}
});
etLabel = (EditText) findViewById(R.id.etLabel);
etName = (EditText) findViewById(R.id.etName);
etPassword = (EditText) findViewById(R.id.etPassword);
usernameContainer = findViewById(R.id.llBarcode);
tilUsername = (TextInputLayout) findViewById(R.id.tilUsername);
passwordContainer = findViewById(R.id.llPassword);
tilPassword = (TextInputLayout) findViewById(R.id.tilPassword);
rgType = (RadioGroup) findViewById(R.id.rgType);
AccountDataSource data = new AccountDataSource(this);
account = data.getAccount(getIntent().getLongExtra(EXTRA_ACCOUNT_ID, -1));
if (account == null) {
finish();
return;
}
if (account.getLabel().equals(getString(R.string.default_account_name))) {
etLabel.setText("");
} else {
etLabel.setText(account.getLabel());
}
etName.setText(account.getName());
etPassword.setText(account.getPassword());
etPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
saveAndCheck();
return false;
}
});
try {
lib = ((OpacClient) getApplication()).getLibrary(account.getLibrary());
if (findViewById(R.id.tvCity) != null) {
TextView tvCity = (TextView) findViewById(R.id.tvCity);
tvCity.setText(lib.getDisplayName());
}
if (lib.getReplacedBy() != null && !"".equals(lib.getReplacedBy()) && findViewById(R.id.rlReplaced) != null && ((OpacClient) getApplication()).promotePlusApps()) {
findViewById(R.id.rlReplaced).setVisibility(View.VISIBLE);
findViewById(R.id.ivReplacedStore).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(lib.getReplacedBy().replace("https://play.google.com/store/apps/details?id=", "market://details?id=")));
startActivity(i);
} catch (ActivityNotFoundException e) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(lib.getReplacedBy()));
startActivity(i);
}
}
});
} else if (findViewById(R.id.rlReplaced) != null) {
findViewById(R.id.rlReplaced).setVisibility(View.GONE);
}
refreshSslWarning();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
ErrorReporter.handleException(e);
e.printStackTrace();
}
rgType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
if (i == R.id.rbAnonymous) {
passwordContainer.setVisibility(View.GONE);
usernameContainer.setVisibility(View.GONE);
} else if (i == R.id.rbWithCredentials) {
passwordContainer.setVisibility(View.VISIBLE);
usernameContainer.setVisibility(View.VISIBLE);
}
refreshSslWarning();
}
});
if ((account.getName() == null || account.getPassword() == null || account.getName().equals("") || account.getPassword().equals("")) && (getIntent().getBooleanExtra(EXTRA_EDITING, false) || !lib.isAccountSupported())) {
((RadioButton) findViewById(R.id.rbAnonymous)).setChecked(true);
}
if (account.getPassword() == null || account.getPassword().equals("")) {
((TextInputLayout) findViewById(R.id.tilPassword)).setPasswordVisibilityToggleEnabled(true);
} else {
((TextInputLayout) findViewById(R.id.tilPassword)).setPasswordVisibilityToggleEnabled(false);
}
}
Aggregations