Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Fotoapparat dependency to 2.2.0 #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependencies {
compile 'com.google.zxing:core:3.3.0'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'io.fotoapparat.fotoapparat:library:1.4.1'
compile 'io.fotoapparat.fotoapparat:library:2.2.0'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
}
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/java/org/fedorahosted/freeotp/add/ScanActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@
import com.squareup.picasso.Picasso;
import io.fotoapparat.Fotoapparat;
import io.fotoapparat.parameter.ScaleType;
import io.fotoapparat.parameter.selector.FocusModeSelectors;
import io.fotoapparat.view.CameraView;
import static io.fotoapparat.parameter.selector.FocusModeSelectors.autoFocus;
import static io.fotoapparat.parameter.selector.FocusModeSelectors.fixed;
import static io.fotoapparat.parameter.selector.LensPositionSelectors.back;
import static io.fotoapparat.parameter.selector.Selectors.firstAvailable;
import static io.fotoapparat.parameter.selector.SizeSelectors.biggestSize;

import static io.fotoapparat.selector.FocusModeSelectorsKt.autoFocus;
import static io.fotoapparat.selector.FocusModeSelectorsKt.continuousFocusPicture;
import static io.fotoapparat.selector.FocusModeSelectorsKt.fixed;
import static io.fotoapparat.selector.LensPositionSelectorsKt.back;
import static io.fotoapparat.selector.ResolutionSelectorsKt.highestResolution;
import static io.fotoapparat.selector.SelectorsKt.firstAvailable;

public class ScanActivity extends Activity {
private Fotoapparat fotoapparat;
Expand Down Expand Up @@ -136,11 +137,10 @@ protected void onCreate(Bundle savedInstanceState) {
fotoapparat = Fotoapparat
.with(this)
.into(cameraView)
.previewScaleType(ScaleType.CENTER_CROP)
.photoSize(biggestSize())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to see what this can be, we have photoResolution and previewResolution available separately now, and values taken is highestResolution

.previewScaleType(ScaleType.CenterCrop)
.lensPosition(back())
.focusMode(firstAvailable(
FocusModeSelectors.continuousFocus(),
continuousFocusPicture(),
autoFocus(),
fixed()
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@ public ScanFrameProcessor(Context context) {
}

@Override
public void processFrame(final Frame frame) {
public void process(final Frame frame) {
MAIN_THREAD_HANDLER.post(new Runnable() {
@Override
public void run() {
try {
reader = new QRCodeReader();
byte[] image = frame.getImage();
int width = frame.getSize().width;
int height = frame.getSize().height;
LuminanceSource ls = new PlanarYUVLuminanceSource(
frame.image, frame.size.width, frame.size.height,
0, 0, frame.size.width, frame.size.height, false);
image, width, height,
0, 0, width, height, false);
Result r = reader.decode(new BinaryBitmap(new HybridBinarizer(ls)));
sendTextToActivity(r.getText());
}
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildscript {

allprojects {
repositories {
google()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but I couldn't compile without this, it tried to include "com.android.support" by default and couldn't find it.

jcenter()
maven { url 'https://jitpack.io' }
}
Expand Down