Skip to content

Commit

Permalink
moved to internal function
Browse files Browse the repository at this point in the history
  • Loading branch information
WeslleyNasRocha committed Mar 18, 2019
1 parent fac417c commit 9776edb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 37 deletions.
15 changes: 1 addition & 14 deletions DocumentScanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import {
NativeModules,
requireNativeComponent,
View,
TouchableOpacity
} from 'react-native';

import Styles from './styles';

var iface = {
name: 'DocumentScanner',
propTypes: {
Expand All @@ -34,7 +31,6 @@ class Scanner extends PureComponent{
static defaultProps = {
onPictureTaken: ()=>{},
onProcessing: ()=>{},
style: Styles.fill,
}

componentWillMount(){
Expand All @@ -53,17 +49,8 @@ class Scanner extends PureComponent{
CameraManager.capture();
}

focus = ()=>{
CameraManager.focus();
}

render() {
return (
<View style={this.props.style}>
<DocumentScanner {...this.props} />
<TouchableOpacity activeOpacity={1} style={Styles.focusOverlay} onPressOut={() => this.focus()} />
</View>
);
return <DocumentScanner {...this.props} />;
}
}

Expand Down
2 changes: 1 addition & 1 deletion android/openCVLibrary310/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
android:versionCode="3100"
android:versionName="3.1.0">

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" />
<!--<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" />-->
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,4 @@ public void capture(){
MainView view = MainView.getInstance();
view.capture();
}

@ReactMethod
public void focus(){
MainView view = MainView.getInstance();
view.focus();
}
}
18 changes: 17 additions & 1 deletion android/src/main/java/com/documentscanner/views/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import android.app.Activity;
import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.widget.FrameLayout;

import com.documentscanner.R;
Expand Down Expand Up @@ -44,6 +46,20 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
}
}

@Override
public boolean onTouchEvent(MotionEvent event) {

int action = MotionEventCompat.getActionMasked(event);

switch (action) {
case (MotionEvent.ACTION_UP):
this.focus();
return true;
default:
return super.onTouchEvent(event);
}
}

public void setDocumentAnimation(boolean animate){
view.setDocumentAnimation(animate);
}
Expand Down Expand Up @@ -92,7 +108,7 @@ public void capture() {
view.capture();
}

public void focus() {
private void focus() {
view.focus();
}
}
15 changes: 0 additions & 15 deletions styles.js

This file was deleted.

0 comments on commit 9776edb

Please sign in to comment.