issue 10730

This commit is contained in:
Ivan Murashov
2018-02-13 01:06:03 +03:00
parent 36c2270f3e
commit db75d2b35f
11 changed files with 60 additions and 78 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dinect.checker" package="com.dinect.checker"
android:versionCode="5" android:versionCode="6"
android:versionName="1.1.7"> android:versionName="1.1.8">
<uses-sdk <uses-sdk
android:minSdkVersion="16" android:minSdkVersion="16"

View File

@@ -97,8 +97,6 @@ public abstract class AbstractScannerActivity extends AppCompatActivity impleme
mClient = new ApiClient(url, appToken, token); mClient = new ApiClient(url, appToken, token);
} }
/** /**
* initialize activity * initialize activity
* - removes windows title * - removes windows title
@@ -166,7 +164,8 @@ public abstract class AbstractScannerActivity extends AppCompatActivity impleme
EditText manualInput = (EditText) findViewById(R.id.manual_input); EditText manualInput = (EditText) findViewById(R.id.manual_input);
// для удобства, чтоб не вводить постоянно руками при разработке // для удобства, чтоб не вводить постоянно руками при разработке
manualInput.setText("4620011139016337050236302"); // manualInput.setText("4620011139016337050236302");
manualInput.setHint(getIntent().getStringExtra("enter_manual"));
manualInput.setOnEditorActionListener(new TextView.OnEditorActionListener() { manualInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override @Override

View File

@@ -8,7 +8,7 @@
<string name="identifier_not_found">"Identifier %s is not found"</string> <string name="identifier_not_found">"Identifier %s is not found"</string>
<string name="enter_manual">Enter the card number</string> <string name="enter_manual">Enter the card number</string>
<string name="enter_phone">Phone 79XXXXXXXXX</string> <string name="enter_phone">Phone 79XXXXXXXXX</string>
<string name="error_contact_support">You can use manual input or call the number:\n%s</string> <string name="error_contact_support">You can use manual input or call the number:%s</string>
<string name="ID_Store">Store ID</string> <string name="ID_Store">Store ID</string>
<string name="ID_not_found">Identifier %s is not found</string> <string name="ID_not_found">Identifier %s is not found</string>
<string name="app_activ">The application is activated</string> <string name="app_activ">The application is activated</string>
@@ -74,11 +74,11 @@ Store log in screen is the first thing you will see after starting the applicati
Enter the store number (ID). You can look it up in the loyalty program control panel. If you do not have access to the control panel, ask the administrator. Enter the store number (ID). You can look it up in the loyalty program control panel. If you do not have access to the control panel, ask the administrator.
Click the ""Login"" button. Click the "Login" button.
Please wait while the administrator activates your request. You can refresh your store activation status by pressing the "Update activation status" button. Please wait while the administrator activates your request. You can refresh your store activation status by pressing the "Update activation status" button.
After the administrator activates your request, click the ""Complete activation"" button. The application is ready to use. After the administrator activates your request, click the "Complete activation" button. The application is ready to use.
If you want to log in as another store, click the Menu button (upper right corner of the screen) and select "Exit". If you want to log in as another store, click the Menu button (upper right corner of the screen) and select "Exit".
</string> </string>
@@ -92,11 +92,11 @@ If the scan is successful, the customer's information will appear on the screen.
Step 2: Step 2:
Enter the purchase amount and click the ""Create a purchase"" button. Enter the purchase amount and click the "Create a purchase" button.
In a pop-up window press ""YES"" to confirm the amount and allot the points to a customer. In a pop-up window press "YES" to confirm the amount and allot the points to a customer.
If you want to correct the amount, press ""NO"" and you will return back to the purchase screen where you can adjust the amount. If you want to correct the amount, press "NO" and you will return back to the purchase screen where you can adjust the amount.
</string> </string>
<string name="support_guide"> <string name="support_guide">

View File

@@ -64,12 +64,12 @@ Store log in screen is the first thing you will see after starting the applicati
Enter the store number (DIN). You can look it up in the loyalty program control panel. If you do Enter the store number (DIN). You can look it up in the loyalty program control panel. If you do
not have access to the control panel, ask the administrator. not have access to the control panel, ask the administrator.
Click the ""Login"" button. Click the "Login" button.
Please wait while the administrator activates your request. You can refresh your store activation Please wait while the administrator activates your request. You can refresh your store activation
status by pressing the ""Update activation status"" button. status by pressing the "Update activation status" button.
After the administrator activates your request, click the ""Complete activation"" button. The After the administrator activates your request, click the "Complete activation" button. The
application is ready to use. application is ready to use.
If you want to log in as another store, click the Menu button (upper right corner of the screen) If you want to log in as another store, click the Menu button (upper right corner of the screen)
@@ -84,11 +84,11 @@ If the scan is successful, the customer's information will appear on the screen.
Step 2: Step 2:
Enter the purchase amount and click the ""Create a purchase"" button. Enter the purchase amount and click the "Create a purchase" button.
In a pop-up window press ""YES"" to confirm the amount and allot the points to a customer. In a pop-up window press "YES" to confirm the amount and allot the points to a customer.
If you want to correct the amount, press ""NO"" and you will return back to the purchase screen If you want to correct the amount, press "NO" and you will return back to the purchase screen
where you can adjust the amount. where you can adjust the amount.
</string> </string>
<string name="support_guide"> <string name="support_guide">

View File

@@ -79,7 +79,7 @@
После подтверждения запроса на активацию программы Партнером/менеджером кликните по кнопке «Завершить регистрацию», приложение готово к использованию. После подтверждения запроса на активацию программы Партнером/менеджером кликните по кнопке «Завершить регистрацию», приложение готово к использованию.
При желании изменить ID магазина, необходимо нажать на кнопку Меню (верхний правый угол экрана) и выбрать "Выход". При желании изменить ID магазина, необходимо нажать на кнопку Меню (верхний правый угол экрана) и выбрать «Выход».
</string> </string>
<string name="usage_guide"> <string name="usage_guide">
@@ -93,7 +93,7 @@
Введите сумму покупки данного покупателя и нажмите на кнопку «Проведение покупки». Введите сумму покупки данного покупателя и нажмите на кнопку «Проведение покупки».
Во всплывающем окне нажмите ""ДА"", для подтверждения суммы покупки Во всплывающем окне нажмите «ДА», для подтверждения суммы покупки
Если вы хотите поправить сумму, нажмите «НЕТ» и Вы вернетесь на экран покупки и сможете её скорректировать. Если вы хотите поправить сумму, нажмите «НЕТ» и Вы вернетесь на экран покупки и сможете её скорректировать.
</string> </string>

View File

@@ -8,7 +8,7 @@
<string name="identifier_not_found">"Ідентифікатор %s не знайден</string> <string name="identifier_not_found">"Ідентифікатор %s не знайден</string>
<string name="enter_manual">Введіть штрихкод вручну</string> <string name="enter_manual">Введіть штрихкод вручну</string>
<string name="enter_phone">Телефон 79XXXXXXXXX</string> <string name="enter_phone">Телефон 79XXXXXXXXX</string>
<string name="error_contact_support">Можете скористатися ручним введенням або зателефонувати на номер:\n%s</string> <string name="error_contact_support">Можете скористатися ручним введенням або зателефонувати на номер:%s</string>
<string name="ID_Store">ID магазину</string> <string name="ID_Store">ID магазину</string>
<string name="ID_not_found">Ідентифікатор %s не знайден</string> <string name="ID_not_found">Ідентифікатор %s не знайден</string>
<string name="app_activ">Додаток активований</string> <string name="app_activ">Додаток активований</string>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildLocationStyle</key>
<string>UseTargetSettings</string>
</dict>
</plist>

View File

@@ -1,7 +1,9 @@
import 'dart:async';
import 'package:checker/screens/faq.dart'; import 'package:checker/screens/faq.dart';
import 'package:checker/screens/purchase.dart'; import 'package:checker/screens/purchase.dart';
import 'package:checker/screens/registration.dart';
import 'package:checker/screens/settings.dart'; import 'package:checker/screens/settings.dart';
import 'package:checker/screens/splash.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
@@ -19,13 +21,18 @@ const platform = const MethodChannel('com.dinect.checker/instance_id');
pushRouteReplacement(BuildContext context, Widget widget) { pushRouteReplacement(BuildContext context, Widget widget) {
var route = var route =
new MaterialPageRoute<Null>(builder: (BuildContext context) => widget); new MaterialPageRoute<Null>(builder: (BuildContext context) => widget);
Navigator.of(context).pushReplacement(route); new Future.delayed(const Duration(milliseconds: 200), () {
Navigator.of(context).pushReplacement(route);
});
} }
pushRoute(BuildContext context, Widget widget) { pushRoute(BuildContext context, Widget widget) {
var route = var route =
new MaterialPageRoute<Null>(builder: (BuildContext context) => widget); new MaterialPageRoute<Null>(builder: (BuildContext context) => widget, fullscreenDialog: true);
Navigator.of(context).push(route); new Future.delayed(const Duration(milliseconds: 200), ()
{
Navigator.of(context).push(route);
});
} }
// Добавление route, с возможностью вернуться к предыдущему экрану. // Добавление route, с возможностью вернуться к предыдущему экрану.
@@ -37,24 +44,24 @@ faq(SqliteHelper helper, String app, BuildContext context,
// В методе отправляется запрос на удаление токена кассы, очищаются SharedPreferences приложения. // В методе отправляется запрос на удаление токена кассы, очищаются SharedPreferences приложения.
logout(BuildContext context, SqliteHelper helper) async { logout(BuildContext context, SqliteHelper helper) async {
String token = await helper.getToken(); String token = await helper.getToken();
// String locale = await helper.getLocale();
VoidCallback positiveCallback = () { VoidCallback positiveCallback = () {
if (token != null) { if (token != null) {
getDeleteTokenRequest(token).then((response) { getDeleteTokenRequest(token).then((response) {
helper.clear().then((result) { helper.clear().then((result) {
// helper.close().then((_) { platform.invokeMethod('getFlavor').then((flavor) {
// Navigator.of(context).pop(); while (Navigator.of(context).canPop()) {
// Navigator.of(context).pop(); Navigator.of(context).pop();
pushRouteReplacement(context, new SplashScreen()); // Запускаем регистрацию }
// }); pushRouteReplacement(context, new RegistrationScreen(helper, flavor));
});
}); });
}).catchError((error) { }).catchError((error) {
print(error.toString()); print(error.toString());
}); });
} else { } else {
Navigator.of(context).pop(); while (Navigator.of(context).canPop()) {
Navigator.of(context).pop(); Navigator.of(context).pop();
}
} }
}; };
@@ -62,56 +69,27 @@ logout(BuildContext context, SqliteHelper helper) async {
StringsLocalization.askChangeStore(), positiveCallback); StringsLocalization.askChangeStore(), positiveCallback);
} }
forceLogout(String token, BuildContext context) async {
getDeleteTokenRequest(token).then((response) {
SqliteHelper helper = new SqliteHelper();
helper.open().then((_) {
helper.clear().then((_) {
// helper.close().then((_) {
while (Navigator.of(context).canPop()) {
Navigator.of(context).pop();
}
pushRouteReplacement(context, new SplashScreen());
// });
});
});
}).catchError((error) {
print(error.toString());
});
}
/// Запуск спецефичной для каждой платформы части приложения - сканера. /// Запуск спецефичной для каждой платформы части приложения - сканера.
/// Может производиться с нескольких экранов (splash, finish_registration). /// Может производиться с нескольких экранов (splash, finish_registration).
startScanner(BuildContext context, String app, SqliteHelper helper) async { startScanner(BuildContext context, String app, SqliteHelper helper) async {
if (helper == null) {
helper = new SqliteHelper();
helper.open().then((_) {
startScanner(context, app, helper);
});
} else {
String token = await helper.getToken(); String token = await helper.getToken();
// Канал ловит вызовы методов из "нативной" части приложения. // Канал ловит вызовы методов из "нативной" части приложения.
// Могут быть вызваны либо exit либо faq, либо purchase. // Могут быть вызваны либо exit либо faq, либо purchase.
if (token != null) { if (token != null) {
platform.setMethodCallHandler((MethodCall call) async { platform.setMethodCallHandler((MethodCall call) async {
print('flutter handler');
print(call.method);
if (call.method == 'findUser') { if (call.method == 'findUser') {
var userResponse; var userResponse;
String cardPhone = call.arguments[0]; String cardPhone = call.arguments[0];
try { try {
switch (call.arguments[1]) { switch (call.arguments[1]) {
case 'card': case 'card':
userResponse = await getUserByCard(cardPhone,token); userResponse = await getUserByCard(cardPhone, token);
break; break;
case 'phone': case 'phone':
userResponse = await getUserByPhone(cardPhone,token); userResponse = await getUserByPhone(cardPhone, token);
break; break;
} }
} catch (error) { } catch (error) {
print(error.toString()); print(error.toString());
} }
@@ -119,7 +97,7 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async {
List<Map> users; List<Map> users;
try{ try {
users = JSON.decode(userResponse.body); users = JSON.decode(userResponse.body);
} catch (error) { } catch (error) {
print(error); print(error);
@@ -131,8 +109,6 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async {
startScanner(context, app, helper); startScanner(context, app, helper);
throw new FlutterError("Users not found"); throw new FlutterError("Users not found");
} }
} else if (call.method == 'faq') { } else if (call.method == 'faq') {
faq(helper, app, context, true); faq(helper, app, context, true);
} else if (call.method == 'settings') { } else if (call.method == 'settings') {
@@ -150,13 +126,7 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async {
String card = call.arguments[1]; String card = call.arguments[1];
print('$userString, $card'); print('$userString, $card');
var route = new MaterialPageRoute<Null>( pushRouteReplacement(context, new PurchaseScreen(helper, app, userString, card));
builder: (BuildContext context) =>
new PurchaseScreen(helper, app, userString, card));
while (Navigator.of(context).canPop()) {
Navigator.of(context).pop();
}
Navigator.of(context).pushReplacement(route);
} }
}); });
@@ -166,12 +136,14 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async {
'url': await platform.invokeMethod('getEndpoint'), 'url': await platform.invokeMethod('getEndpoint'),
'appToken': await platform.invokeMethod('getAppToken'), 'appToken': await platform.invokeMethod('getAppToken'),
'localeCode': StringsLocalization.localeCode, 'localeCode': StringsLocalization.localeCode,
'color': Resources.getPrimaryColor(app).value.toString() 'color': Resources
.getPrimaryColor(app)
.value
.toString()
}); });
platform.invokeMethod('startScanner', args); platform.invokeMethod('startScanner', args);
} }
}
} }
// Запуск диалога с двумя кнопками // Запуск диалога с двумя кнопками

View File

@@ -7,7 +7,6 @@ class Resources {
} }
static String getSplash(String app) { static String getSplash(String app) {
// app != null ? app :
return 'assets/${'pip'}_splash.png'; return 'assets/${'pip'}_splash.png';
} }

View File

@@ -45,7 +45,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
setState(() { setState(() {
requestAsyncData(user); requestAsyncData(user);
}); });
return getMainWidget(); return new WillPopScope(onWillPop: onWillPop, child: getMainWidget());
} }
bool purchaseInProgress = false; bool purchaseInProgress = false;
@@ -423,4 +423,8 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
print('kifio ' + this.loyalty); print('kifio ' + this.loyalty);
print('bonus ' + this.bonus); print('bonus ' + this.bonus);
} }
onWillPop() {
return startScanner(context, app, helper);
}
} }