Проведение покупки, проверка деактивированного токена, подтверждение логаута, функциональная маска на сканере, кнопка назад в faq
This commit is contained in:
@@ -45,6 +45,7 @@ import android.view.Surface;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import java.io.IOException;
|
||||
import java.lang.Exception;
|
||||
import java.util.List;
|
||||
import com.dinect.checker.R;
|
||||
|
||||
@@ -57,6 +58,8 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
|
||||
private boolean mBarcodeScanned = false;
|
||||
private boolean previewing = true;
|
||||
private Handler autoFocusHandler;
|
||||
private int mOffset;
|
||||
|
||||
static {
|
||||
System.loadLibrary("iconv");
|
||||
@@ -82,6 +85,10 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
mOffset = (int) (56 * getResources().getDisplayMetrics().density);
|
||||
|
||||
autoFocusHandler = new Handler();
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
|
||||
@@ -95,9 +102,7 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
|
||||
Camera.Parameters params = mCamera.getParameters();
|
||||
List<String> focusModes = params.getSupportedFocusModes();
|
||||
for (String fMode : focusModes) {
|
||||
Log.d("kifio", fMode);
|
||||
}
|
||||
|
||||
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
|
||||
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
||||
} else if (focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
||||
@@ -132,6 +137,12 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
try {
|
||||
mCamera.setPreviewDisplay(holder);
|
||||
mCamera.startPreview();
|
||||
try {
|
||||
mCamera.autoFocus(autoFocusCallback);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.d("kifio", "surfaceCreated");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -147,6 +158,7 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
Log.d("kifio", "surfaceDestroyed");
|
||||
mCamera.cancelAutoFocus();
|
||||
}
|
||||
|
||||
void setCameraDisplayOrientation(int cameraId) {
|
||||
@@ -209,24 +221,6 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
finish();
|
||||
}
|
||||
|
||||
private void initCountours() {
|
||||
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int width = displayMetrics.widthPixels;
|
||||
|
||||
Resources res = getResources();
|
||||
mContours.put("left", (int) res.getDimension(R.dimen.scanner_contour_top));
|
||||
mContours.put("top", (int) res.getDimension(R.dimen.scanner_contour_left));
|
||||
mContours.put("width", (int) res.getDimension(R.dimen.scanner_contour_height));
|
||||
mContours.put("height", width - (2 * (int) res.getDimension(R.dimen.scanner_contour_left)));
|
||||
|
||||
// Log.d("kifio", "left: " + mContours.get("left"));
|
||||
// Log.d("kifio", "top: " + mContours.get("top"));
|
||||
// Log.d("kifio", "width: " + mContours.get("width"));
|
||||
// Log.d("kifio", "height: " + mContours.get("height"));
|
||||
}
|
||||
|
||||
PreviewCallback previewCallback = new PreviewCallback() {
|
||||
public void onPreviewFrame(byte[] data, Camera camera) {
|
||||
|
||||
@@ -235,7 +229,8 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
|
||||
Image barcode = new Image(size.width, size.height, "Y800");
|
||||
barcode.setData(data);
|
||||
// barcode.setCrop(mContours.get("left"), mContours.get("top"), mContours.get("width"), mContours.get("height"));
|
||||
|
||||
barcode.setCrop((size.width / 2) - mOffset, 0, (size.width / 2) + mOffset, size.height);
|
||||
|
||||
int result = mScanner.scanImage(barcode);
|
||||
|
||||
@@ -255,4 +250,18 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private Runnable doAutoFocus = new Runnable() {
|
||||
public void run() {
|
||||
if (previewing)
|
||||
mCamera.autoFocus(autoFocusCallback);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
AutoFocusCallback autoFocusCallback = new AutoFocusCallback() {
|
||||
public void onAutoFocus(boolean success, Camera camera) {
|
||||
autoFocusHandler.postDelayed(doAutoFocus, 1000);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -15,12 +15,15 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||
import io.flutter.plugin.common.MethodChannel.Result;
|
||||
import com.google.android.gms.iid.InstanceID;
|
||||
import java.util.Map;
|
||||
import java.lang.System;
|
||||
|
||||
public class MainActivity extends FlutterActivity {
|
||||
|
||||
private static final int START_SCANNER_REQUEST_CODE = 2017;
|
||||
private static final String PREF_POS_TOKEN = "pref_pos_token";
|
||||
private static final String PREF_POS_MERCHANT_ID = "pref_pos_merchant_id";
|
||||
private static final String PREF_DOC_ID = "pref_doc_id";
|
||||
private static final String PREF_POS_ID = "pref_pos_id";
|
||||
|
||||
private MethodChannel mChannel;
|
||||
private SharedPreferences mPreferences;
|
||||
@@ -69,6 +72,28 @@ public class MainActivity extends FlutterActivity {
|
||||
case "removeKeys":
|
||||
mPreferences.edit().remove(PREF_POS_TOKEN).apply();
|
||||
mPreferences.edit().remove(PREF_POS_MERCHANT_ID).apply();
|
||||
mPreferences.edit().remove(PREF_DOC_ID).apply();
|
||||
mPreferences.edit().remove(PREF_POS_ID).apply();
|
||||
result.success(null);
|
||||
break;
|
||||
case "getDocID":
|
||||
int docId = mPreferences.getInt(PREF_DOC_ID, 0) + 1;
|
||||
mPreferences.edit().putInt(PREF_DOC_ID, docId).apply();
|
||||
result.success(String.valueOf(docId));
|
||||
break;
|
||||
case "getPosID":
|
||||
|
||||
String posId = mPreferences.getString(PREF_POS_ID, null);
|
||||
|
||||
if (posId == null) {
|
||||
posId = String.valueOf(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
Log.d("kifio", posId);
|
||||
|
||||
mPreferences.edit().putString(PREF_POS_ID, posId).apply();
|
||||
result.success(posId);
|
||||
|
||||
break;
|
||||
default:
|
||||
result.notImplemented();
|
||||
@@ -96,6 +121,10 @@ public class MainActivity extends FlutterActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void getDocID() {
|
||||
|
||||
}
|
||||
|
||||
private void removeKeys() {
|
||||
|
||||
}
|
||||
@@ -116,6 +145,10 @@ public class MainActivity extends FlutterActivity {
|
||||
|
||||
}
|
||||
|
||||
public void getPosID() {
|
||||
|
||||
}
|
||||
|
||||
public void saveMerchantID() {
|
||||
|
||||
}
|
||||
|
||||
@@ -10,38 +10,35 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<!-- <LinearLayout android:orientation="vertical"
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="?attr/actionBarSize">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<View android:layout_height="0dp"
|
||||
android:layout_weight="0.42"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_width="match_parent"
|
||||
android:background="#с0000000"/>
|
||||
|
||||
<FrameLayout android:layout_height="0dp"
|
||||
android:layout_weight="0.16"
|
||||
android:layout_width="match_parent">
|
||||
|
||||
<View android:layout_height="match_parent"
|
||||
android:layout_width="24dp"
|
||||
android:layout_gravity="left"
|
||||
android:background="#с0000000"/>
|
||||
|
||||
<View android:layout_height="match_parent"
|
||||
android:layout_width="24dp"
|
||||
android:layout_gravity="right"
|
||||
android:background="#с0000000"/>
|
||||
|
||||
</FrameLayout>
|
||||
android:background="#с0000000"
|
||||
android:layout_marginBottom="56dp"/>
|
||||
|
||||
<View android:layout_height="0dp"
|
||||
android:layout_weight="0.42"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_width="match_parent"
|
||||
android:background="#с0000000"/>
|
||||
android:background="#с0000000"
|
||||
android:layout_marginTop="56dp"/>
|
||||
|
||||
</LinearLayout> -->
|
||||
</LinearLayout>
|
||||
|
||||
<View android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="#00ff00"
|
||||
android:layout_marginBottom="56dp"/>
|
||||
|
||||
<View android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="#00ff00"
|
||||
android:layout_marginTop="56dp"/>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
||||
@@ -5,7 +5,7 @@ buildscript {
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.3'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
||||
Reference in New Issue
Block a user