二维码超时设置
This commit is contained in:
@@ -22,24 +22,6 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
signingConfigs {
|
|
||||||
release {
|
|
||||||
keyAlias 'faceid'
|
|
||||||
keyPassword '123456'
|
|
||||||
storeFile file('../faceid.jks')
|
|
||||||
storePassword '123456'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
signingConfig signingConfigs.release
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
productFlavors {
|
productFlavors {
|
||||||
|
|
||||||
product {
|
product {
|
||||||
@@ -48,8 +30,8 @@ android {
|
|||||||
*/
|
*/
|
||||||
// buildConfigField("String", "SERVER_IP", "\"120.27.209.4\"")
|
// buildConfigField("String", "SERVER_IP", "\"120.27.209.4\"")
|
||||||
// buildConfigField("String", "SERVER_PORT", "\"56792\"")
|
// buildConfigField("String", "SERVER_PORT", "\"56792\"")
|
||||||
buildConfigField("String", "SERVER_IP", "\"192.168.0.105\"")
|
buildConfigField("String", "SERVER_IP", "\"lmqhznn.goho.co\"")
|
||||||
buildConfigField("String", "SERVER_PORT", "\"56792\"")
|
buildConfigField("String", "SERVER_PORT", "\"26283\"")
|
||||||
/**
|
/**
|
||||||
* 门禁连接地址
|
* 门禁连接地址
|
||||||
*/
|
*/
|
||||||
@@ -70,7 +52,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
implementation 'com.android.support.constraint:constraint-layout:2.0.0'
|
||||||
implementation 'com.google.code.gson:gson:2.8.4'
|
implementation 'com.google.code.gson:gson:2.8.4'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:3.3.1'
|
implementation 'com.squareup.okhttp3:okhttp:3.3.1'
|
||||||
implementation 'io.netty:netty-all:4.1.10.Final'
|
implementation 'io.netty:netty-all:4.1.10.Final'
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class MainActivity extends SDBaseActivity {
|
|||||||
* 加载人脸识别信息
|
* 加载人脸识别信息
|
||||||
*/
|
*/
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void getQRResult(QRCodeEvent qrCodeEvent) {
|
public void getQRResult(QRCodeEvent qrCodeEvent) throws InterruptedException {
|
||||||
if (qrCodeEvent.getMsg().equals("不是会员")) {
|
if (qrCodeEvent.getMsg().equals("不是会员")) {
|
||||||
// 这个是非会员进入现场
|
// 这个是非会员进入现场
|
||||||
this.showStrangerDialog();
|
this.showStrangerDialog();
|
||||||
@@ -135,6 +135,10 @@ public class MainActivity extends SDBaseActivity {
|
|||||||
case QR_EVENT_ACTION_LOADING:
|
case QR_EVENT_ACTION_LOADING:
|
||||||
qrCodePbCover.setVisibility(View.VISIBLE);
|
qrCodePbCover.setVisibility(View.VISIBLE);
|
||||||
qrCodePbCover.show();
|
qrCodePbCover.show();
|
||||||
|
Thread.sleep(60000);
|
||||||
|
qrCodePbCover.setVisibility(View.GONE);
|
||||||
|
qrCodePbCover.hide();
|
||||||
|
tvTip.setText("欢迎扫码进场!");
|
||||||
break;
|
break;
|
||||||
case QR_EVENT_ACTION_OPEN_DOOR:
|
case QR_EVENT_ACTION_OPEN_DOOR:
|
||||||
case QR_EVENT_ACTION_FAILED:
|
case QR_EVENT_ACTION_FAILED:
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import android.app.Activity;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.ydd.sportfaceid.BuildConfig;
|
import com.ydd.sportfaceid.BuildConfig;
|
||||||
import com.ydd.sportfaceid.utils.SharedPreferencesUtil;
|
import com.ydd.sportfaceid.netty.config.RemoteBuildConfig;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.ydd.sportfaceid.utils.JsonMapper;
|
||||||
import io.netty.bootstrap.Bootstrap;
|
import io.netty.bootstrap.Bootstrap;
|
||||||
import io.netty.channel.ChannelFuture;
|
import io.netty.channel.ChannelFuture;
|
||||||
import io.netty.channel.ChannelFutureListener;
|
import io.netty.channel.ChannelFutureListener;
|
||||||
@@ -21,6 +21,9 @@ import io.netty.channel.ChannelOption;
|
|||||||
import io.netty.channel.EventLoopGroup;
|
import io.netty.channel.EventLoopGroup;
|
||||||
import io.netty.channel.nio.NioEventLoopGroup;
|
import io.netty.channel.nio.NioEventLoopGroup;
|
||||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,6 +57,25 @@ public class ClientThread {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static RemoteBuildConfig getRemoteConfig() {
|
||||||
|
String url = "https://lmqhznn.goho.co/getRemoteConfig";
|
||||||
|
Response response = null;
|
||||||
|
try {
|
||||||
|
response = new OkHttpClient().newCall(new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.build()).execute();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(TAG, "setConfigError: ", e);
|
||||||
|
}
|
||||||
|
String result = null;
|
||||||
|
try {
|
||||||
|
result = response.body().string();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return JsonMapper.fromJson(result,RemoteBuildConfig.class);
|
||||||
|
}
|
||||||
|
|
||||||
public ClientThread(String remoteHost, int remotePort) {
|
public ClientThread(String remoteHost, int remotePort) {
|
||||||
this.remoteHost = remoteHost;
|
this.remoteHost = remoteHost;
|
||||||
this.remotePort = remotePort;
|
this.remotePort = remotePort;
|
||||||
@@ -75,8 +97,6 @@ public class ClientThread {
|
|||||||
|
|
||||||
public void doConnect() {
|
public void doConnect() {
|
||||||
Log.d("sander","现在开始链接了");
|
Log.d("sander","现在开始链接了");
|
||||||
remoteHost = SharedPreferencesUtil.getServerIp();
|
|
||||||
remotePort = SharedPreferencesUtil.getServerPort();
|
|
||||||
Log.d("sander", "连接 = " + remoteHost + " " + remotePort);
|
Log.d("sander", "连接 = " + remoteHost + " " + remotePort);
|
||||||
future = bootstrap.connect(new InetSocketAddress(remoteHost, remotePort));
|
future = bootstrap.connect(new InetSocketAddress(remoteHost, remotePort));
|
||||||
future.addListener((ChannelFutureListener) f -> f.channel().eventLoop().schedule(() -> {
|
future.addListener((ChannelFutureListener) f -> f.channel().eventLoop().schedule(() -> {
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.ydd.sportfaceid.netty.config;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Expose;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端心跳数据包
|
||||||
|
* HeartBeat.java
|
||||||
|
*
|
||||||
|
* @author lmq
|
||||||
|
*/
|
||||||
|
public class RemoteBuildConfig implements Serializable {
|
||||||
|
|
||||||
|
@Expose
|
||||||
|
private String serverIp; //场馆号
|
||||||
|
|
||||||
|
@Expose
|
||||||
|
private String serverPort; //设备号
|
||||||
|
|
||||||
|
public String getServerIp() {
|
||||||
|
return serverIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerIp(String serverIp) {
|
||||||
|
this.serverIp = serverIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerPort() {
|
||||||
|
return serverPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerPort(String serverPort) {
|
||||||
|
this.serverPort = serverPort;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,7 +69,6 @@ public class MessageService {
|
|||||||
EventBus.getDefault().post(new QRCodeEvent(QRCodeEvent.QR_EVENT_ACTION_LOADING, message.getMessage()));
|
EventBus.getDefault().post(new QRCodeEvent(QRCodeEvent.QR_EVENT_ACTION_LOADING, message.getMessage()));
|
||||||
break;
|
break;
|
||||||
case OPEN_DOOR:
|
case OPEN_DOOR:
|
||||||
// 进入一个页面,然后显示倒计时,回到主页
|
|
||||||
Log.d(TAG, "OPEN_DOOR" + message.getMessage());
|
Log.d(TAG, "OPEN_DOOR" + message.getMessage());
|
||||||
EventBus.getDefault().post(new QRCodeEvent(QRCodeEvent.QR_EVENT_ACTION_OPEN_DOOR, message.getMessage()));
|
EventBus.getDefault().post(new QRCodeEvent(QRCodeEvent.QR_EVENT_ACTION_OPEN_DOOR, message.getMessage()));
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
package com.ydd.sportfaceid.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
|
|
||||||
import com.ydd.sportfaceid.BuildConfig;
|
|
||||||
import com.ydd.sportfaceid.StartApplication;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by hehelt on 15/12/23.
|
|
||||||
* <p/>
|
|
||||||
* 本地SharePreference存储帮助类
|
|
||||||
*/
|
|
||||||
public class SharedPreferencesUtil {
|
|
||||||
|
|
||||||
private static SharedPreferences infoShare;
|
|
||||||
|
|
||||||
private static SharedPreferences serverShare;
|
|
||||||
|
|
||||||
|
|
||||||
//初始化
|
|
||||||
private static void initInfoShare() {
|
|
||||||
if (infoShare == null) {
|
|
||||||
infoShare = StartApplication.getAppContext().getSharedPreferences("info", Context.MODE_PRIVATE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void initServerShare() {
|
|
||||||
if (serverShare == null) {
|
|
||||||
serverShare = StartApplication.getAppContext().getSharedPreferences("server", Context.MODE_PRIVATE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean setServerIpAndPort(String ip, int port) {
|
|
||||||
initServerShare();
|
|
||||||
if (getServerIp().equals(ip) && getServerPort() == port) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
serverShare.edit().putString("serverIp", ip).putInt("serverPort", port).apply();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getServerIp() {
|
|
||||||
initServerShare();
|
|
||||||
return serverShare.getString("serverIp", BuildConfig.SERVER_IP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getServerPort() {
|
|
||||||
initServerShare();
|
|
||||||
return serverShare.getInt("serverPort", Integer.parseInt(BuildConfig.SERVER_PORT));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置门禁的连接地址和端口
|
|
||||||
*
|
|
||||||
* @param ip
|
|
||||||
* @param port
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static boolean setDoorServerIpAndPort(String ip, int port) {
|
|
||||||
initServerShare();
|
|
||||||
if (getDoorServerIp().equals(ip) && getDoorServerPort() == port) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
serverShare.edit().putString("doorServerIp", ip).putInt("doorServerPort", port).apply();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDoorServerIp() {
|
|
||||||
initServerShare();
|
|
||||||
return serverShare.getString("doorServerIp", BuildConfig.DOOR_SERVER_IP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDoorServerPort() {
|
|
||||||
initServerShare();
|
|
||||||
return serverShare.getInt("doorServerPort", Integer.parseInt(BuildConfig.DOOR_SERVER_PORT));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static SharedPreferences netConfig;
|
|
||||||
|
|
||||||
public static void setIsNetConfig(boolean isSet) {
|
|
||||||
netConfig = StartApplication.getAppContext().getSharedPreferences("netConfig", Context.MODE_PRIVATE);
|
|
||||||
netConfig.edit().putBoolean("flag", isSet).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getNetConfig() {
|
|
||||||
netConfig = StartApplication.getAppContext().getSharedPreferences("netConfig", Context.MODE_PRIVATE);
|
|
||||||
return netConfig.getBoolean("flag", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void saveIp(String ip) {
|
|
||||||
if (null != ip && !"".equals(ip)) {
|
|
||||||
initLocalIp();
|
|
||||||
localIp.edit().putString("ip", ip).apply();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getLocalIp() {
|
|
||||||
initLocalIp();
|
|
||||||
String ip = localIp.getString("ip", "0.0.0.0");
|
|
||||||
return ip;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void initLocalIp() {
|
|
||||||
if (localIp == null) {
|
|
||||||
localIp = StartApplication.getAppContext().getSharedPreferences("localIp", Context.MODE_PRIVATE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SharedPreferences localIp;
|
|
||||||
|
|
||||||
}
|
|
||||||
BIN
faceid.jks
BIN
faceid.jks
Binary file not shown.
Reference in New Issue
Block a user