Правки по меню, по локали, добавлены Евро и Тенге
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@android:style/Theme.Black.NoTitleBar"
|
||||
android:theme="@android:style/Theme.Light.NoTitleBar"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -38,6 +37,7 @@ import android.view.Window;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.Toast;
|
||||
import android.widget.TextView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
||||
import com.dinect.checker.net.ApiClient;
|
||||
|
||||
@@ -45,6 +45,8 @@ import java.util.Queue;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
|
||||
/**
|
||||
* Created by anonymous
|
||||
@@ -297,9 +299,23 @@ public abstract class AbstractScannerActivity extends AppCompatActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
menu.findItem(R.id.settings).setIcon(getResources().getDrawable(R.drawable.settings));
|
||||
menu.findItem(R.id.faq).setIcon(getResources().getDrawable(R.drawable.help));
|
||||
menu.findItem(R.id.logout).setIcon(getResources().getDrawable(R.drawable.logout));
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.logout) {
|
||||
if (item.getItemId() == R.id.settings) {
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra("item", "settings");
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.logout) {
|
||||
logoutDialog = LogoutDialogFragment.newInstance(mColor);
|
||||
logoutDialog.show(getFragmentManager(), "logout");
|
||||
return true;
|
||||
|
||||
BIN
android/app/src/main/res/drawable-xxxhdpi/help.png
Normal file
BIN
android/app/src/main/res/drawable-xxxhdpi/help.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB |
BIN
android/app/src/main/res/drawable-xxxhdpi/ic_more_vert.png
Normal file
BIN
android/app/src/main/res/drawable-xxxhdpi/ic_more_vert.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
BIN
android/app/src/main/res/drawable-xxxhdpi/settings.png
Normal file
BIN
android/app/src/main/res/drawable-xxxhdpi/settings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
@@ -2,16 +2,27 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item android:id="@+id/faq"
|
||||
android:orderInCategory="0"
|
||||
android:title="@string/faq"
|
||||
android:icon="@drawable/help_outline"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:icon="@drawable/ic_more_vert"
|
||||
app:showAsAction="ifRoom">
|
||||
|
||||
<item android:id="@+id/logout"
|
||||
android:orderInCategory="1"
|
||||
android:title="@string/logout"
|
||||
android:icon="@drawable/logout"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<menu>
|
||||
|
||||
<group android:id="@+id/items"/>
|
||||
|
||||
<item android:id="@+id/settings"
|
||||
android:title="@string/settings"
|
||||
android:icon="@drawable/settings"/>
|
||||
|
||||
<item android:id="@+id/faq"
|
||||
android:title="@string/faq"
|
||||
android:icon="@drawable/help"/>
|
||||
|
||||
<item android:id="@+id/logout"
|
||||
android:title="@string/logout"
|
||||
android:icon="@drawable/logout"/>
|
||||
|
||||
</menu>
|
||||
</item>
|
||||
</menu>
|
||||
@@ -2,8 +2,9 @@
|
||||
<string name="app_name">AutoBonus</string>
|
||||
<string name="scanner_title">Сканер карты</string>
|
||||
<string name="scan">Сканировать</string>
|
||||
<string name="faq">FAQ</string>
|
||||
<string name="faq">Справка</string>
|
||||
<string name="logout">Выход</string>
|
||||
<string name="settings">Настройки</string>
|
||||
<string name="logout_title">Подтверждение</string>
|
||||
<string name="logout_text">Вы действительно хотите выйти и ввести другой номер магазина?</string>
|
||||
<string name="logout_yes">Да</string>
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
<string name="app_name">AutoBonus</string>
|
||||
<string name="scanner_title">Сканер карти</string>
|
||||
<string name="scan">Сканувати</string>
|
||||
<string name="faq">FAQ</string>
|
||||
<string name="faq">Допомога</string>
|
||||
<string name="logout">Вихід</string>
|
||||
<string name="settings">Налаштування</string>
|
||||
<string name="logout_title">Підтвердження</string>
|
||||
<string name="logout_text">Ви дійсно хочете вийти і ввести інший номер магазину?</string>
|
||||
<string name="logout_yes">Так</string>
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
<string name="app_name">AutoBonus</string>
|
||||
<string name="scanner_title">Card Scanner</string>
|
||||
<string name="scan">Scan</string>
|
||||
<string name="faq">FAQ</string>
|
||||
<string name="faq">Help</string>
|
||||
<string name="logout">Logout</string>
|
||||
<string name="settings">Settings</string>
|
||||
<string name="logout_title">Сonfirmation</string>
|
||||
<string name="logout_text">Do you really want to log out and enter a different store number?</string>
|
||||
<string name="logout_yes">Yes</string>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar"/>
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="android:textColorSecondary">@android:color/white</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -4,7 +4,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.3'
|
||||
classpath 'com.android.tools.build:gradle:2.3.3'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
void onOptionsItemClick(int index) {
|
||||
switch (index) {
|
||||
case 0: {
|
||||
pushRoute(context, new SettingsScreen(helper, app));
|
||||
pushRoute(context, new SettingsScreen(helper, app, false));
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
|
||||
100
lib/common.dart
100
lib/common.dart
@@ -1,6 +1,6 @@
|
||||
import 'package:checker/screens/faq.dart';
|
||||
import 'package:checker/screens/purchase.dart';
|
||||
import 'package:checker/screens/registration.dart';
|
||||
import 'package:checker/screens/settings.dart';
|
||||
import 'package:checker/screens/splash.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -65,7 +65,9 @@ forceLogout(String token , BuildContext context) async {
|
||||
helper.open().then((_) {
|
||||
helper.clear().then((_) {
|
||||
helper.close().then((_) {
|
||||
Navigator.of(context).pop();
|
||||
while (Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
pushRouteReplacement(context, new SplashScreen());
|
||||
});
|
||||
});
|
||||
@@ -78,50 +80,68 @@ forceLogout(String token , BuildContext context) async {
|
||||
/// Запуск спецефичной для каждой платформы части приложения - сканера.
|
||||
/// Может производиться с нескольких экранов (splash, finish_registration).
|
||||
startScanner(BuildContext context, String app, SqliteHelper helper) async {
|
||||
|
||||
String token = await helper.getToken();
|
||||
helper.close();
|
||||
// Канал ловит вызовы методов из "нативной" части приложения.
|
||||
// Могут быть вызваны либо logout либо faq, либо purchase.
|
||||
if (token != null) {
|
||||
platform.setMethodCallHandler((MethodCall call) async {
|
||||
|
||||
if (call.method == 'logout') {
|
||||
forceLogout(token, context);
|
||||
} else if (call.method == 'faq') {
|
||||
faq(context, true);
|
||||
} else {
|
||||
String userString = call.arguments[0];
|
||||
String card = call.arguments[1];
|
||||
var route = new MaterialPageRoute<Null>(builder: (BuildContext context) => new PurchaseScreen(userString, card));
|
||||
Navigator.of(context).pushReplacement(route);
|
||||
}
|
||||
if (helper == null) {
|
||||
helper = new SqliteHelper();
|
||||
helper.open().then((_) {
|
||||
startScanner(context, app, helper);
|
||||
});
|
||||
} else {
|
||||
String token = await helper.getToken();
|
||||
helper.close();
|
||||
// Канал ловит вызовы методов из "нативной" части приложения.
|
||||
// Могут быть вызваны либо logout либо faq, либо purchase.
|
||||
if (token != null) {
|
||||
platform.setMethodCallHandler((MethodCall call) async {
|
||||
if (call.method == 'logout') {
|
||||
forceLogout(token, context);
|
||||
} else if (call.method == 'faq') {
|
||||
faq(context, true);
|
||||
} else if(call.method == 'settings') {
|
||||
helper = new SqliteHelper();
|
||||
helper.open().then((_) {
|
||||
pushRoute(context, new SettingsScreen(helper, app, true));
|
||||
});
|
||||
} else {
|
||||
String userString = call.arguments[0];
|
||||
String card = call.arguments[1];
|
||||
var route = new MaterialPageRoute<Null>(
|
||||
builder: (BuildContext context) =>
|
||||
new PurchaseScreen(
|
||||
userString, card));
|
||||
while (Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
Navigator.of(context).pushReplacement(route);
|
||||
}
|
||||
});
|
||||
|
||||
await platform.invokeMethod('startScanner', {
|
||||
'token' : token,
|
||||
'url': url,
|
||||
'appToken': appToken,
|
||||
'color': Resources.getPrimaryColor(app).value
|
||||
});
|
||||
await platform.invokeMethod('startScanner', {
|
||||
'token': token,
|
||||
'url': url,
|
||||
'appToken': appToken,
|
||||
'color': Resources
|
||||
.getPrimaryColor(app)
|
||||
.value
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Запуск диалога с двумя кнопками
|
||||
showYesNoDialog(BuildContext context, String title, String content, VoidCallback positiveCallback) {
|
||||
showDialog(context: context, child: new AlertDialog(
|
||||
title: new Text(title),
|
||||
content: new Text(content),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.no()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.yes()),
|
||||
onPressed: positiveCallback)]));
|
||||
showDialog(context: context, child: new AlertDialog(
|
||||
title: new Text(title),
|
||||
content: new Text(content),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.no()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.yes()),
|
||||
onPressed: positiveCallback)]));
|
||||
}
|
||||
|
||||
getCurrencyTitle(int code) {
|
||||
@@ -130,7 +150,7 @@ getCurrencyTitle(int code) {
|
||||
case 840: return StringsLocalization.nominativeDollar();
|
||||
case 980: return StringsLocalization.nominativeHryvna();
|
||||
case 978: return StringsLocalization.nominativeEuro();
|
||||
case 398: return StringsLocalization.nominativeEuro();
|
||||
case 398: return StringsLocalization.nominativeTenge();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:checker/base/base_screen.dart';
|
||||
import 'package:checker/base/base_state.dart';
|
||||
import 'package:checker/common.dart';
|
||||
@@ -9,9 +11,11 @@ import 'package:flutter/material.dart';
|
||||
|
||||
class SettingsScreen extends BaseScreen {
|
||||
|
||||
SettingsScreen(helper, app) : super(helper, app);
|
||||
final bool returnToScanner;
|
||||
|
||||
@override State createState() => new SettingsState(helper, app);
|
||||
SettingsScreen(helper, app, this.returnToScanner) : super(helper, app);
|
||||
|
||||
@override State createState() => new SettingsState(helper, app, returnToScanner);
|
||||
}
|
||||
|
||||
class MenuItem {
|
||||
@@ -26,9 +30,12 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
|
||||
List<MenuItem> menuItems = [new MenuItem(StringsLocalization.currency(), '')];
|
||||
|
||||
SettingsState(SqliteHelper helper, String app) {
|
||||
bool returnToScanner;
|
||||
|
||||
SettingsState(SqliteHelper helper, String app, bool returnToScanner) {
|
||||
this.helper = helper;
|
||||
this.app = app;
|
||||
this.returnToScanner = returnToScanner;
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext ctx) {
|
||||
@@ -41,7 +48,7 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
}
|
||||
}
|
||||
});
|
||||
return getMainWidget();
|
||||
return new WillPopScope(onWillPop: onWillPop, child: getMainWidget());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -104,4 +111,12 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
String getTitle() {
|
||||
return StringsLocalization.settings();
|
||||
}
|
||||
|
||||
onWillPop() {
|
||||
if(returnToScanner) {
|
||||
return startScanner(context, app, helper);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user