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 0000000..e9b669e Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_false.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_true.png b/app/src/main/res/mipmap-xhdpi/icon_true.png new file mode 100644 index 0000000..441645a Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_true.png differ diff --git a/app/src/main/res/values-en-rUS/strings.xml b/app/src/main/res/values-en-rUS/strings.xml index f01491b..b1dd009 100644 --- a/app/src/main/res/values-en-rUS/strings.xml +++ b/app/src/main/res/values-en-rUS/strings.xml @@ -34,4 +34,5 @@ network 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