Поправил много неприятных косяков
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.dinect.checker"
|
||||
android:versionCode="1"
|
||||
android:versionName="0.0.3">
|
||||
android:versionName="0.0.4">
|
||||
|
||||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
|
||||
|
||||
|
||||
@@ -55,8 +55,12 @@ import io.flutter.plugin.common.MethodChannel.Result;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.json.*;
|
||||
|
||||
import org.json.*;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import com.dinect.checker.R;
|
||||
|
||||
public class CameraActivity extends AppCompatActivity implements SurfaceHolder.Callback {
|
||||
@@ -70,7 +74,7 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
private boolean previewing = true;
|
||||
private Handler autoFocusHandler;
|
||||
private int mOffset;
|
||||
private String mToken = "19305da6610a74504f8a462411199b5de0c93979";
|
||||
private String mToken;
|
||||
|
||||
static {
|
||||
System.loadLibrary("iconv");
|
||||
@@ -108,19 +112,17 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||
}
|
||||
|
||||
mToken = getIntent().getStringExtra(MainActivity.PREF_POS_TOKEN);
|
||||
|
||||
if (mToken == null) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("item", "logout");
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
mCamera = getCameraInstance();
|
||||
mCamera.setPreviewCallback(previewCallback);
|
||||
|
||||
Camera.Parameters params = mCamera.getParameters();
|
||||
List<String> focusModes = params.getSupportedFocusModes();
|
||||
|
||||
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)) {
|
||||
params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
|
||||
}
|
||||
mCamera.setParameters(params);
|
||||
|
||||
holder.addCallback(this);
|
||||
}
|
||||
|
||||
@@ -221,13 +223,13 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
Intent intent = new Intent();
|
||||
|
||||
if (item.getItemId() == R.id.logout) {
|
||||
intent.putExtra("item", "logout");
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
LogoutDialogFragment newFragment = new LogoutDialogFragment();
|
||||
newFragment.show(getFragmentManager(), "logout");
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.faq) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("item", "faq");
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
@@ -287,9 +289,10 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
}
|
||||
if (response.code() == 200) {
|
||||
try {
|
||||
JSONArray users = new JSONArray(response.body().string());
|
||||
String s = response.body().string();
|
||||
JSONArray users = new JSONArray(s);
|
||||
Log.d("kifio", s);
|
||||
if (users.length() > 0) {
|
||||
Toast.makeText(this, "Чики-брики и в дамки", Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("user", users.get(0).toString());
|
||||
intent.putExtra("card", card);
|
||||
@@ -357,6 +360,9 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Log.d("kifio", mUrl);
|
||||
Log.d("kifio", mToken);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.addHeader("DM-Authorization", "dmapptoken 9fec83cdca38c357e6b65dbb17514cdd36bf2a08")
|
||||
.addHeader("Authorization", "dmtoken " + mToken)
|
||||
@@ -380,4 +386,30 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
mActivity = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LogoutDialogFragment extends DialogFragment {
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
// Use the Builder class for convenient dialog construction
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle("Подтверждение");
|
||||
builder.setMessage("Вы действительно хотите выйти и ввести другой номер магазина?")
|
||||
.setPositiveButton("Да", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("item", "logout");
|
||||
getActivity().setResult(RESULT_OK, intent);
|
||||
getActivity().finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Нет", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
// Create the AlertDialog object and return it
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,10 @@ 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";
|
||||
static final String PREF_POS_TOKEN = "pref_pos_token";
|
||||
|
||||
private MethodChannel mChannel;
|
||||
private SharedPreferences mPreferences;
|
||||
@@ -67,7 +67,9 @@ public class MainActivity extends FlutterActivity {
|
||||
result.success(mPreferences.getString(PREF_POS_MERCHANT_ID, null));
|
||||
break;
|
||||
case "startScanner":
|
||||
Map arguments = call.arguments();
|
||||
Intent cameraIntent = new Intent(MainActivity.this, CameraActivity.class);
|
||||
cameraIntent.putExtra(PREF_POS_TOKEN, (String) arguments.get("token"));
|
||||
startActivityForResult(cameraIntent, START_SCANNER_REQUEST_CODE);
|
||||
break;
|
||||
case "removeKeys":
|
||||
|
||||
Reference in New Issue
Block a user