mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-20 13:59:14 +00:00
Added SquareFinderView for obvious reasons
This commit is contained in:
parent
2628925779
commit
1825f6719d
2 changed files with 44 additions and 10 deletions
|
@ -2,26 +2,23 @@ package me.impy.aegis;
|
|||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.util.TimeUtils;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.Result;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Time;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.dm7.barcodescanner.core.IViewFinder;
|
||||
import me.dm7.barcodescanner.zxing.ZXingScannerView;
|
||||
import me.impy.aegis.crypto.KeyInfo;
|
||||
import me.impy.aegis.crypto.TOTP;
|
||||
import me.impy.aegis.helpers.SquareFinderView;
|
||||
|
||||
public class ScannerActivity extends Activity implements ZXingScannerView.ResultHandler {
|
||||
private ZXingScannerView mScannerView;
|
||||
|
@ -29,9 +26,15 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result
|
|||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
handleDummyResult();
|
||||
//handleDummyResult();
|
||||
|
||||
mScannerView = new ZXingScannerView(this) {
|
||||
@Override
|
||||
protected IViewFinder createViewFinderView(Context context) {
|
||||
return new SquareFinderView(context);
|
||||
}
|
||||
};
|
||||
|
||||
mScannerView = new ZXingScannerView(this); // Programmatically initialize the scanner view
|
||||
setContentView(mScannerView); // Set the scanner view as the content view
|
||||
mScannerView.setFormats(getSupportedFormats());
|
||||
|
||||
|
@ -78,6 +81,7 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result
|
|||
Toast.makeText(this, rawResult.getText(), Toast.LENGTH_SHORT).show();
|
||||
|
||||
try {
|
||||
//TODO: Handle non TOTP / HOTP qr codes.
|
||||
KeyInfo info = KeyInfo.FromURL(rawResult.getText());
|
||||
KeyProfile keyProfile = new KeyProfile();
|
||||
keyProfile.KeyInfo = info;
|
||||
|
@ -93,7 +97,7 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result
|
|||
}
|
||||
|
||||
// If you would like to resume scanning, call this method below:
|
||||
//mScannerView.resumeCameraPreview(this);
|
||||
mScannerView.resumeCameraPreview(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -119,4 +123,5 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result
|
|||
|
||||
return supportedFormats;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package me.impy.aegis.helpers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import me.dm7.barcodescanner.core.ViewFinderView;
|
||||
|
||||
public class SquareFinderView extends ViewFinderView {
|
||||
|
||||
public SquareFinderView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public SquareFinderView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setSquareViewFinder(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue