Commit cac7a74f by wjg

init

parent 84575675
......@@ -25,8 +25,8 @@
<activity
android:name=".view.LauncherActivity"
android:label="@string/app_name"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -37,6 +37,12 @@
<category android:name="android.intent.category.MONKEY" />
</intent-filter>
</activity>
<activity
android:name=".view.SettingsActivity"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="landscape" />
<receiver
android:name=".component.PushMessageReceiver"
android:exported="true">
......
......@@ -3,6 +3,7 @@ package com.ihaoin.hooloo.device;
import android.app.Application;
import com.ihaoin.hooloo.device.config.AppConfig;
import com.ihaoin.hooloo.device.network.HttpUtil;
import cn.jpush.android.api.JPushInterface;
......@@ -12,8 +13,8 @@ public class HLApplication extends Application {
public void onCreate() {
super.onCreate();
AppConfig.MACHINE_CODE = ""; // TODO 获取机器编码
AppConfig.SCREEN_NO = ""; // TODO 点单屏编码
AppConfig.MACHINE_CODE = HttpUtil.getMacAddress();
AppConfig.MACHINE_CODE = "Code001"; // TODO 获取机器编码
JPushInterface.setDebugMode(true);
JPushInterface.init(this);
......
......@@ -10,6 +10,7 @@ import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.component.SettingsQueue;
import com.ihaoin.hooloo.device.data.vo.Recommend;
import com.ihaoin.hooloo.device.data.ScrollBean;
import com.ihaoin.hooloo.device.util.Utils;
......@@ -24,6 +25,9 @@ public class RecommendAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseVi
@Override
protected void convertHead(BaseViewHolder helper, ScrollBean item) {
View layoutItem = helper.getView(R.id.layout_item);
View imgLogo = helper.getView(R.id.img_logo);
SettingsQueue settingsQueue = new SettingsQueue(mContext, imgLogo, layoutItem);
}
@Override
......
package com.ihaoin.hooloo.device.component;
import android.content.Context;
import android.view.View;
import androidx.annotation.NonNull;
import com.ihaoin.hooloo.device.util.Utils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class SettingsQueue extends ArrayList<Boolean> {
private List trigger = Arrays.asList(true, false);
// private List trigger = Arrays.asList(true, false, true, false, true, false, true);
private Context context;
private View oneView;
private View zeroView;
public SettingsQueue(@NonNull Context context, @NonNull View oneView, @NonNull View zeroView) {
super();
this.context = context;
this.oneView = oneView;
this.zeroView = zeroView;
// this.oneView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Toast.makeText(context, "1", Toast.LENGTH_SHORT).show();
// add(true);
// }
// });
// this.zeroView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Toast.makeText(context, "0", Toast.LENGTH_SHORT).show();
// add(false);
// }
// });
this.oneView.setOnClickListener(v -> add(true));
this.zeroView.setOnClickListener(v -> add(false));
}
@Override
public boolean add(Boolean o) {
if (size() >= trigger.size()) {
remove(0);
}
boolean result = super.add(o);
if (size() >= trigger.size()) {
ifMatch();
}
return result;
}
private void ifMatch() {
boolean matched = true;
for (int i = 0; i < trigger.size(); i++) {
if (trigger.get(i) != get(i)) {
matched = false;
break;
}
}
// Toast.makeText(context, String.valueOf(matched), Toast.LENGTH_SHORT).show();
if (matched) {
Utils.openAppSettings(context);
clear();
}
}
}
......@@ -3,13 +3,7 @@ package com.ihaoin.hooloo.device.config;
public class AppConfig {
public static Boolean DEBUG = true;
/**
* 机器编码
*/
/** 机器编码 */
public static String MACHINE_CODE = "";
/**
* 点单屏编码
*/
public static String SCREEN_NO = "";
}
......@@ -2,10 +2,11 @@ package com.ihaoin.hooloo.device.network;
public class BaseParams {
private static final String HOST = "http://www.baidu.com";
private static final String HOST = "http://114.115.234.81:8080";
public static final String GET_MAIN_DATA = HOST + "/mainData";
public static final String GET_ORDERS = HOST + "/confirm/order";
public static final String POST_CONFIRM_ORDER = HOST + "/confirm/order";
public static final String POST_REGISTRATION_ID = HOST + "/confirm/order";
public static final String GET_MAIN_DATA = HOST + "/application/getOrderTaking?machineCode=%s";
public static final String GET_ORDERS = HOST + "/application/getOrderInfo?machineCode=%s";
public static final String POST_CONFIRM_ORDER = HOST + "/application/saveData?machineCode=%s";
public static final String POST_REGISTRATION_ID = HOST + "/application/jgRegister?machineCode=%s&registerId=%s";
public static final String GET_CHECK_SKU = HOST + "/application/checkSku?machineCode=%s&skuId=%s";
}
......@@ -5,6 +5,9 @@ import android.os.Message;
import android.util.Log;
import java.io.IOException;
import java.net.NetworkInterface;
import java.util.Collections;
import java.util.List;
import okhttp3.Call;
import okhttp3.Callback;
......@@ -64,15 +67,47 @@ public class HttpUtil {
handler.sendMessage(msg);
}
public static void postConfirmOrder(String body, Handler handler) {
post(BaseParams.POST_CONFIRM_ORDER, body, handler);
public static void getMainDatas(String body, Handler handler) {
post(BaseParams.GET_MAIN_DATA, body, handler);
}
public static void getOrders(String body, Handler handler) {
post(BaseParams.GET_ORDERS, body, handler);
}
public static void postConfirmOrder(String body, Handler handler) {
post(BaseParams.POST_CONFIRM_ORDER, body, handler);
}
public static void postRegistrationId(String body, Handler handler) {
post(BaseParams.POST_REGISTRATION_ID, body, handler);
}
public static void checkSku(String body, Handler handler) {
post(BaseParams.GET_CHECK_SKU, body, handler);
}
public static String getMacAddress() {
try {
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface nif : all) {
if (!nif.getName().equalsIgnoreCase("wlan0")) continue;
byte[] macBytes = nif.getHardwareAddress();
if (macBytes == null) {
return null;
}
StringBuilder res1 = new StringBuilder();
for (byte b : macBytes) {
res1.append(String.format("%02X:", b));
}
if (res1.length() > 0) {
res1.deleteCharAt(res1.length() - 1);
}
return res1.toString();
}
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
}
package com.ihaoin.hooloo.device.util;
import android.content.Context;
import android.content.SharedPreferences;
public class SharedPreferencesUtils {
private final static String KEY_SEETINGS = "settings";
private final static String KEY_SCREEN_NO = "SCREEN_NO";
private final static String KEY_SHOW_MENU = "SHOW_MENU";
private final static String KEY_SHOW_LOGCAT = "SHOW_LOGCAT";
public static String getScreenNo(Context context) {
SharedPreferences sp = getSharedPreferences(context);
return sp.getString(KEY_SCREEN_NO, "A");
}
public static void setScreenNo(Context context, String val) {
SharedPreferences sp = getSharedPreferences(context);
sp.edit().putString(KEY_SCREEN_NO, val).commit();
}
public static Boolean getShowMenu(Context context) {
SharedPreferences sp = getSharedPreferences(context);
return sp.getBoolean(KEY_SHOW_MENU, false);
}
public static void setShowMenu(Context context, Boolean val) {
SharedPreferences sp = getSharedPreferences(context);
sp.edit().putBoolean(KEY_SCREEN_NO, val).commit();
}
public static Boolean getShowLogcat(Context context) {
SharedPreferences sp = getSharedPreferences(context);
return sp.getBoolean(KEY_SHOW_LOGCAT, false);
}
public static void setShowLogcat(Context context, Boolean val) {
SharedPreferences sp = getSharedPreferences(context);
sp.edit().putBoolean(KEY_SHOW_LOGCAT, val).commit();
}
public static SharedPreferences getSharedPreferences(Context context) {
return context.getSharedPreferences(KEY_SEETINGS, Context.MODE_PRIVATE);
}
}
......@@ -19,6 +19,7 @@ import com.ihaoin.hooloo.device.data.vo.Goods;
import com.ihaoin.hooloo.device.data.vo.Sku;
import com.ihaoin.hooloo.device.view.ConfirmOrderDialog;
import com.ihaoin.hooloo.device.view.GoodsDetailDialog;
import com.ihaoin.hooloo.device.view.SettingsActivity;
import com.ihaoin.hooloo.device.view.TipsDialog;
import java.util.Arrays;
......@@ -70,6 +71,16 @@ public class Utils {
dialog.show();
}
public static void openSystemSettings(Context context) {
Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
context.startActivity(intent); // 打开系统设置界面
}
public static void openAppSettings(Context context) {
Intent intent = new Intent(context, SettingsActivity.class);
context.startActivity(intent); // 打开系统设置界面
}
/**
* 获得资源 dimens (dp)
*
......
......@@ -33,6 +33,7 @@ import com.ihaoin.hooloo.device.data.vo.Goods;
import com.ihaoin.hooloo.device.data.vo.Sku;
import com.ihaoin.hooloo.device.network.HttpUtil;
import com.ihaoin.hooloo.device.util.RandomUtils;
import com.ihaoin.hooloo.device.util.SharedPreferencesUtils;
import com.ihaoin.hooloo.device.util.Utils;
import java.util.ArrayList;
......@@ -185,7 +186,7 @@ public class ConfirmOrderDialog extends Dialog {
try {
ConfirmOrder confirmOrder = new ConfirmOrder();
confirmOrder.setMachineCode(AppConfig.MACHINE_CODE);
confirmOrder.setScreenNo(AppConfig.SCREEN_NO);
confirmOrder.setScreenNo(SharedPreferencesUtils.getScreenNo(getContext()));
confirmOrder.setSeqNo(genSeqNo());
confirmOrder.setGoods(goods);
return JSON.toJSONString(confirmOrder);
......
......@@ -86,7 +86,7 @@ public class LauncherActivity extends Activity {
initCategorys();
initGoods();
this.registerdTrolleyReceiver();
registerdTrolleyReceiver();
showMenuView();
requestPermissions();
......
package com.ihaoin.hooloo.device.view;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.pm.PackageInfo;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;
import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.config.AppConfig;
import com.ihaoin.hooloo.device.util.SharedPreferencesUtils;
public class SettingsActivity extends Activity {
private View layoutSysSettings;
private TextView txtVersion;
private TextView txtMachineCode;
private View layoutScreen;
private TextView txtScreenNo;
private ToggleButton butnMenu;
private ToggleButton butnLogcat;
private View butnClose;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
initViews();
}
private void initViews() {
layoutSysSettings = findViewById(R.id.layout_sys_settings);
txtVersion = findViewById(R.id.txt_version);
txtMachineCode = findViewById(R.id.txt_machine_code);
layoutScreen = findViewById(R.id.layout_screen);
txtScreenNo = findViewById(R.id.txt_screen_no);
butnMenu = findViewById(R.id.butn_menu);
butnLogcat = findViewById(R.id.butn_logcat);
butnClose = findViewById(R.id.butn_close);
txtVersion.setText(getAppVersionName());
txtMachineCode.setText(AppConfig.MACHINE_CODE);
txtScreenNo.setText(SharedPreferencesUtils.getScreenNo(this));
butnClose.setOnClickListener(v -> finish());
layoutScreen.setOnClickListener(v -> showEditScreen());
}
private void showEditScreen() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("修改点单屏编码");
EditText editText = new EditText(getApplicationContext());
editText.setText(SharedPreferencesUtils.getScreenNo(SettingsActivity.this));
builder.setView(editText);
builder.setPositiveButton("确定", (dialog, which) -> {
SharedPreferencesUtils.setScreenNo(SettingsActivity.this, editText.getText().toString());
txtScreenNo.setText(SharedPreferencesUtils.getScreenNo(SettingsActivity.this));
});
builder.setNegativeButton("取消", null);
builder.create().show();
}
public String getAppVersionName() {
try {
PackageInfo packageInfo = getApplicationContext().getPackageManager().getPackageInfo(getPackageName(), 0);
return packageInfo.versionName;
} catch (Exception e) {
}
return null;
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:alpha="0.9"
android:tint="@color/textSecondPrimary"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/colorPrimary"
android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp"
android:height="18dp"
android:alpha="0.9"
android:tint="@color/textSecondPrimary"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/textSecondPrimary"
android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6z" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -41,4 +42,4 @@
android:id="@+id/view_trolley"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
\ No newline at end of file
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<include layout="@layout/view_header" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/layout_sys_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:text="打开系统设置"
android:textColor="@color/textPrimary"
android:textSize="16sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:src="@drawable/ic_baseline_chevron_right_24_grey" />
</LinearLayout>
<include layout="@layout/view_line" />
<LinearLayout
android:id="@+id/layout_version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:text="App版本号"
android:textColor="@color/textPrimary"
android:textSize="16sp" />
<TextView
android:id="@+id/txt_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="1.0.0"
android:textColor="@color/textDisable"
android:textSize="14sp" />
</LinearLayout>
<include layout="@layout/view_line" />
<LinearLayout
android:id="@+id/layout_machine_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:text="机器编码"
android:textColor="@color/textPrimary"
android:textSize="16sp" />
<TextView
android:id="@+id/txt_machine_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="机器编码"
android:textColor="@color/textDisable"
android:textSize="14sp" />
</LinearLayout>
<include layout="@layout/view_line" />
<LinearLayout
android:id="@+id/layout_screen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:text="点单屏编码"
android:textColor="@color/textPrimary"
android:textSize="16sp" />
<TextView
android:id="@+id/txt_screen_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="A"
android:textColor="@color/textDisable"
android:textSize="14sp" />
</LinearLayout>
<include layout="@layout/view_line" />
<LinearLayout
android:id="@+id/layout_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:text="显示菜单屏"
android:textColor="@color/textPrimary"
android:textSize="16sp" />
<ToggleButton
android:id="@+id/butn_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<include layout="@layout/view_line" />
<LinearLayout
android:id="@+id/layout_logcat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:text="logcat日志"
android:textColor="@color/textPrimary"
android:textSize="16sp" />
<ToggleButton
android:id="@+id/butn_logcat"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_item"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/img_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@mipmap/logo" />
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/butn_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:padding="10dp"
android:src="@drawable/ic_baseline_chevron_left_24" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:padding="10dp"
android:text="设置"
android:textColor="@color/textSecondPrimary"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<include
layout="@layout/view_line"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/line" />
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment