Search in sources :

Example 1 with BarcodeScanIntegrator

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();
}
Also used : BarcodeScanIntegrator(de.geeksfactory.opacclient.barcode.BarcodeScanIntegrator)

Example 2 with BarcodeScanIntegrator

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);
    }
}
Also used : BarcodeScanIntegrator(de.geeksfactory.opacclient.barcode.BarcodeScanIntegrator) AccountDataSource(de.geeksfactory.opacclient.storage.AccountDataSource) RadioGroup(android.widget.RadioGroup) JSONException(org.json.JSONException) Intent(android.content.Intent) IOException(java.io.IOException) RadioButton(android.widget.RadioButton) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) ActivityNotFoundException(android.content.ActivityNotFoundException) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TextInputLayout(android.support.design.widget.TextInputLayout)

Aggregations

BarcodeScanIntegrator (de.geeksfactory.opacclient.barcode.BarcodeScanIntegrator)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Intent (android.content.Intent)1 TextInputLayout (android.support.design.widget.TextInputLayout)1 KeyEvent (android.view.KeyEvent)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 ImageView (android.widget.ImageView)1 RadioButton (android.widget.RadioButton)1 RadioGroup (android.widget.RadioGroup)1 TextView (android.widget.TextView)1 AccountDataSource (de.geeksfactory.opacclient.storage.AccountDataSource)1 IOException (java.io.IOException)1 JSONException (org.json.JSONException)1