mirror of https://github.com/MISP/misp-bump
87 lines
2.4 KiB
Java
87 lines
2.4 KiB
Java
package de.korrelator.overview.mispauth;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Intent;
|
|
import android.support.v7.app.AppCompatActivity;
|
|
import android.os.Bundle;
|
|
import android.view.Menu;
|
|
import android.view.MenuItem;
|
|
import android.view.View;
|
|
import android.widget.Button;
|
|
import android.widget.TextView;
|
|
|
|
public class MainActivity extends AppCompatActivity {
|
|
|
|
private static final int QR_REQUEST_CODE = 123;
|
|
private TextView qrResult;
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.activity_main);
|
|
|
|
qrResult = findViewById(R.id.text_view_qr_result);
|
|
|
|
Button scanButton = findViewById(R.id.button_scan);
|
|
scanButton.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
startCameraIntent();
|
|
}
|
|
});
|
|
|
|
Button generateButton = findViewById(R.id.button_generate);
|
|
generateButton.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
startQrIntent();
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
private void startCameraIntent(){
|
|
Intent intent = new Intent(this, ReadQrActivity.class);
|
|
startActivityForResult(intent, QR_REQUEST_CODE);
|
|
}
|
|
|
|
|
|
private void startQrIntent(){
|
|
Intent intent = new Intent(this, GenerateQrActivity.class);
|
|
startActivity(intent);
|
|
}
|
|
|
|
@Override
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
if (requestCode == QR_REQUEST_CODE) {
|
|
if(resultCode == Activity.RESULT_OK){
|
|
String result = data.getStringExtra("result");
|
|
qrResult.setText(result);
|
|
}
|
|
|
|
if (resultCode == Activity.RESULT_CANCELED) {
|
|
qrResult.setText("NO QR FOUND");
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
getMenuInflater().inflate(R.menu.menu_main, menu);
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
int id = item.getItemId();
|
|
|
|
if (id == R.id.action_settings) {
|
|
startActivity(new Intent(this, SettingsActivity.class));
|
|
return true;
|
|
}
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
}
|
|
}
|