From 38edb74d4cc612c63aa902d0d9313053d217fd7f Mon Sep 17 00:00:00 2001
From: wangh <123456>
Date: Mon, 3 Jun 2024 13:29:47 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AF=BB=E5=8F=96app=20=E5=87=86=E5=A4=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/src/main/AndroidManifest.xml | 25 ++++----
.../example/jinyu_rfid/AppLoginActivity.java | 3 +-
.../com/example/jinyu_rfid/MainActivity.java | 32 +++++-----
.../com/example/jinyu_rfid/ReadActivity.java | 21 +++++--
.../example/jinyu_rfid/WriteUserActivity.java | 4 +-
.../example/jinyu_rfid/base/BaseActivity.java | 5 +-
.../example/jinyu_rfid/dialog/TipDialog.java | 35 +++++++++++
app/src/main/res/drawable/dialog_bg.xml | 6 ++
app/src/main/res/layout/dialog_layout.xml | 55 ++++++++++++++++++
app/src/main/res/mipmap-xhdpi/icon_false.png | Bin 0 -> 1155 bytes
app/src/main/res/mipmap-xhdpi/icon_true.png | Bin 0 -> 1232 bytes
app/src/main/res/values-en-rUS/strings.xml | 1 +
app/src/main/res/values-vi-rVN/strings.xml | 1 +
app/src/main/res/values/strings.xml | 3 +-
app/src/main/res/values/themes.xml | 14 +++++
15 files changed, 165 insertions(+), 40 deletions(-)
create mode 100644 app/src/main/java/com/example/jinyu_rfid/dialog/TipDialog.java
create mode 100644 app/src/main/res/drawable/dialog_bg.xml
create mode 100644 app/src/main/res/layout/dialog_layout.xml
create mode 100644 app/src/main/res/mipmap-xhdpi/icon_false.png
create mode 100644 app/src/main/res/mipmap-xhdpi/icon_true.png
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 145d662..4a4e16b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -30,11 +30,10 @@
-
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
diff --git a/app/src/main/java/com/example/jinyu_rfid/AppLoginActivity.java b/app/src/main/java/com/example/jinyu_rfid/AppLoginActivity.java
index 0c8a41e..b2bc081 100644
--- a/app/src/main/java/com/example/jinyu_rfid/AppLoginActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/AppLoginActivity.java
@@ -50,10 +50,11 @@ public class AppLoginActivity extends AppCompatActivity {
SharedPreferencesUtils.putstring("language", s);
getLocaleStringXML(s);
resources.updateConfiguration(config, resources.getDisplayMetrics());
- //
var intent = new Intent(this, ReadActivity.class);
Log.e("TAG", "appLoginClick:" + value);
intent.putExtra("work",value);
+ SharedPreferencesUtils.putstring("languageIndex", index + "");
+ intent.putExtra("appType",true);
startActivity(intent);
finish();
}
diff --git a/app/src/main/java/com/example/jinyu_rfid/MainActivity.java b/app/src/main/java/com/example/jinyu_rfid/MainActivity.java
index 7aa224b..359e391 100644
--- a/app/src/main/java/com/example/jinyu_rfid/MainActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/MainActivity.java
@@ -39,6 +39,7 @@ public class MainActivity extends BaseActivity {
private Resources resources;
private Configuration config;
private int index;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -49,7 +50,7 @@ public class MainActivity extends BaseActivity {
resources.updateConfiguration(config, resources.getDisplayMetrics());
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
binding.mainLanguage.setSelection(index);
- loginVm = new LoginVm();
+ loginVm = new LoginVm();
boolean isRemember = SharedPreferencesUtils.getboolean("isRemember", false);
if (isRemember) {
loginVm.setUsername(SharedPreferencesUtils.getstring("user", ""));
@@ -62,17 +63,16 @@ public class MainActivity extends BaseActivity {
}
-
- private void getLocaleStringXML(String languageString){
- if (languageString.equals("中文")){
- config.locale = Locale.CHINA;
- index=0;
- }else if (languageString.equals("English")){
- config.locale = Locale.ENGLISH;
- index=1;
- }else {
- config.locale =new Locale("vi","VN");
- index=2;
+ private void getLocaleStringXML(String languageString) {
+ if (languageString.equals("中文")) {
+ config.locale = Locale.CHINA;
+ index = 0;
+ } else if (languageString.equals("English")) {
+ config.locale = Locale.ENGLISH;
+ index = 1;
+ } else {
+ config.locale = new Locale("vi", "VN");
+ index = 2;
}
}
@@ -90,7 +90,7 @@ public class MainActivity extends BaseActivity {
map.put("UserID", name);
map.put("UserPass", pass);
map.put("token", "123456");
- map.put("Language", index+"");
+ map.put("Language", index + "");
if (pass == null || name == null || pass.isEmpty() || name.isEmpty()) return;
OkGo.post(url + "/login")
.upRequestBody(RequestBody.create(JSON, gson.toJson(map)))
@@ -109,13 +109,13 @@ public class MainActivity extends BaseActivity {
SharedPreferencesUtils.putstring("pass", pass);
}
SharedPreferencesUtils.putstring("language", selectLanguage);
- SharedPreferencesUtils.putstring("languageIndex", index+"");
+ SharedPreferencesUtils.putstring("languageIndex", index + "");
resources.updateConfiguration(config, resources.getDisplayMetrics());
List list = LitePal.findAll(ConfigurationTable.class);
Intent intent;
- if (list==null||list.isEmpty()){
+ if (list == null || list.isEmpty()) {
intent = new Intent(MainActivity.this, ConfigurationTableActivity.class);
- }else {
+ } else {
intent = new Intent(MainActivity.this, WriteUserActivity.class);
}
startActivity(intent);
diff --git a/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java b/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java
index 90da8e8..f7cb468 100644
--- a/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java
@@ -50,7 +50,14 @@ public class ReadActivity extends BaseActivity implements DataReturnCall {
binding.setType(workmode == 1);
// 名称
stringArray = getResources().getStringArray(R.array.project_list);
- rfidModel = new C5106Device(this);
+ var appType = getIntent().getBooleanExtra("appType", false);
+ if (appType) {
+ // tl-gx4
+
+ } else {
+ rfidModel = new C5106Device(this);
+ }
+
}
@@ -61,6 +68,7 @@ public class ReadActivity extends BaseActivity implements DataReturnCall {
public void readEPCInfo(View view) {
rfidModel.sanEpc(6);
}
+
@SuppressLint("NotifyDataSetChanged")
@Override
public void readEpcCodeInfo(String info, boolean state, String stateInfo) {
@@ -71,7 +79,7 @@ public class ReadActivity extends BaseActivity implements DataReturnCall {
Map map = new HashMap<>();
map.put("EpcCode", info);
map.put("token", "123456");
- map.put("Language", SharedPreferencesUtils.getstring("languageIndex","0"));
+ map.put("Language", SharedPreferencesUtils.getstring("languageIndex", "0"));
OkGo.post(url + "/readEPCCode")
.upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) {
@Override
@@ -79,7 +87,8 @@ public class ReadActivity extends BaseActivity implements DataReturnCall {
super.onSuccess(response);
var body = response.body();
if (body.getResultFlag().equals("1")) {
- list.addAll(gson.fromJson(body.getJson(),new TypeToken>(){}.getType()));
+ list.addAll(gson.fromJson(body.getJson(), new TypeToken>() {
+ }.getType()));
adapter.notifyDataSetChanged();
} else {
Toast.makeText(ReadActivity.this, body.getJson(), Toast.LENGTH_SHORT).show();
@@ -89,7 +98,7 @@ public class ReadActivity extends BaseActivity implements DataReturnCall {
}
});
- }else {
+ } else {
binding.readText.setText(null);
}
}
@@ -107,10 +116,12 @@ public class ReadActivity extends BaseActivity implements DataReturnCall {
for (int i = 0; i < 12; i++) {
list.add(new ReadTyreNoResult(i, stringArray[i], infos[i]));
}
- }else {
+ } else {
binding.readText.setText(null);
}
adapter.notifyDataSetChanged();
}
+//
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java b/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java
index 158dcca..b9aed68 100644
--- a/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java
@@ -125,7 +125,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
writeUserState = true;
return;
}
- Toast.makeText(WriteUserActivity.this, body.getSaveMessage(), Toast.LENGTH_SHORT).show();
+ tipDialog.shouDialog(false, body.getSaveMessage());
}
});
@@ -133,7 +133,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
if (writeUserState){
Log.e("TAG", "写入");
var writeState = rfidModel.writeUser(validateDataLength(user), epcStr);
- Toast.makeText(context, getString(writeState ? R.string.write_success : R.string.write_failed), Toast.LENGTH_SHORT).show();
+ tipDialog.shouDialog(writeState,getString(writeState ? R.string.write_success : R.string.write_failed));
if (writeState) {
list.clear();
adapter.notifyDataSetChanged();
diff --git a/app/src/main/java/com/example/jinyu_rfid/base/BaseActivity.java b/app/src/main/java/com/example/jinyu_rfid/base/BaseActivity.java
index 520bfea..e7643bc 100644
--- a/app/src/main/java/com/example/jinyu_rfid/base/BaseActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/base/BaseActivity.java
@@ -25,6 +25,7 @@ import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import com.example.jinyu_rfid.R;
+import com.example.jinyu_rfid.dialog.TipDialog;
import com.google.gson.Gson;
import java.io.ByteArrayOutputStream;
@@ -48,6 +49,7 @@ public class BaseActivity extends AppCompatActivity {
private MyReceiver myReceiver;
public MediaPlayer music;
public Context context;
+ public TipDialog tipDialog;
@SuppressLint("SimpleDateFormat")
public SimpleDateFormat format= new SimpleDateFormat( "yyyyMMdd_HHmmss");
@Override
@@ -57,10 +59,8 @@ public class BaseActivity extends AppCompatActivity {
gson = new Gson();
this.context=this;
initDialog();
-
music = MediaPlayer.create(this, R.raw.msg);
-
}
public class MyReceiver extends BroadcastReceiver {
@@ -78,6 +78,7 @@ public class BaseActivity extends AppCompatActivity {
dialog.setCanceledOnTouchOutside(false);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setMessage("loading...");
+ tipDialog=new TipDialog(this);
}
private void initSan() {
diff --git a/app/src/main/java/com/example/jinyu_rfid/dialog/TipDialog.java b/app/src/main/java/com/example/jinyu_rfid/dialog/TipDialog.java
new file mode 100644
index 0000000..0cabd8b
--- /dev/null
+++ b/app/src/main/java/com/example/jinyu_rfid/dialog/TipDialog.java
@@ -0,0 +1,35 @@
+package com.example.jinyu_rfid.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+
+import androidx.annotation.NonNull;
+import androidx.databinding.DataBindingUtil;
+
+import com.example.jinyu_rfid.R;
+import com.example.jinyu_rfid.databinding.DialogLayoutBinding;
+
+/**
+ * @author wanghao
+ * @date 2024/6/3 9:17
+ */
+public class TipDialog extends Dialog {
+
+ private DialogLayoutBinding binding;
+
+ public TipDialog(@NonNull Context context) {
+ super(context, R.style.dialog);
+ binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.dialog_layout, null, false);
+ setContentView(binding.getRoot());
+ binding.dialogButton.setOnClickListener(v -> dismiss());
+ }
+
+ public void shouDialog(boolean state,String text){
+ binding.setState(state);
+ binding.setTipText(text);
+ show();
+ }
+
+}
diff --git a/app/src/main/res/drawable/dialog_bg.xml b/app/src/main/res/drawable/dialog_bg.xml
new file mode 100644
index 0000000..eebd08e
--- /dev/null
+++ b/app/src/main/res/drawable/dialog_bg.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/dialog_layout.xml b/app/src/main/res/layout/dialog_layout.xml
new file mode 100644
index 0000000..5c3a995
--- /dev/null
+++ b/app/src/main/res/layout/dialog_layout.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-xhdpi/icon_false.png b/app/src/main/res/mipmap-xhdpi/icon_false.png
new file mode 100644
index 0000000000000000000000000000000000000000..e9b669eb9e2778257eb2da9de31a438bc9328235
GIT binary patch
literal 1155
zcmV-}1bq96P)Px(JxN4CRCr$9o7r*OFc3f&9Or{ISeek3Sac(iDv?!*ltwJN5;GII27Xu(G5|=4
z2M8>2EIH9nGBl6H+XIWmf6mU)6W5Eatpn6%o`VZO!N&sQM(zo-g3r^iL
zK>$?i)fyN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Mi!Pq)PiZ)3m<{88f=JfO|kCzms3}
z%F#@@8n!t@a{v{c>h7E*8lFT5HN=W6P;9!CSFv;59c4D6o4YptWh^$9Q|2S
z=?rB6GOwoQiH7I-%mcSDKpZ|?T?pJ0jmDr!Fhb!@y-Gkx1E6--(&yg=h;J1akoHm4
zYsYtF!$Jx`_xj_U)}igFQlOw8X*UQ1h|%&qPErtr0Ax0%O9Z1lZzOT<$2wUMNswRw
z>5Zu!gqwv-oC*Qw#srlQ$BG3&Q`jt!VB0e_LY=^MKmrpUauf
zW$)sI2O07KOc!_pXveJ21IU^hJprUQr|Y~9+i<^ULUaLWhiY#kJB0eWdQsnn4B9>T
ziq@;UpzGn~0vCX!$NtvsS#<02Rh!_&&u`G;-Zlh+D;L-RB)#bI5>His|NR5qc>5Fr
z0O@so*jgOf03>FzUhrK{IL>3KycCX@WBex$)XS<7SC{iAONorkO_y##jDBz
z)c#w!SGr!p!I{7*C@6#|#9NCXTOmaMP;oyX3n3Em
z4*R(j3E+*JxnJZhQD!0JclIPZ0cv~S
zdjSagAgf1^{$<+mvOTL$a0oa%NKmy1dL>pl07qU3@@1IJ1*gYIeIFoP2S7$=`C2TJ
z1Su2ip*X-RER2}~qg)6jw2~_xiUYjpwpnetwork mode
"standalone mode "
scanning area
+ I see
\ No newline at end of file
diff --git a/app/src/main/res/values-vi-rVN/strings.xml b/app/src/main/res/values-vi-rVN/strings.xml
index 7922b5e..11b8208 100644
--- a/app/src/main/res/values-vi-rVN/strings.xml
+++ b/app/src/main/res/values-vi-rVN/strings.xml
@@ -35,4 +35,5 @@
Chế độ mạng
Chế độ đơn
Khu vực quét
+ Tôi biết rồi
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9768b24..18214a5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -33,5 +33,6 @@
工作模式
网络模式
单机模式
- 扫描区域>
+ 扫描区域
+ 我知道了>
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 17f7c55..8db5f96 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -16,4 +16,18 @@
- center
- 17sp
+
+
\ No newline at end of file