diff --git a/.gradle/7.0.2/executionHistory/executionHistory.bin b/.gradle/7.0.2/executionHistory/executionHistory.bin
index ef5b485..9721288 100644
Binary files a/.gradle/7.0.2/executionHistory/executionHistory.bin and b/.gradle/7.0.2/executionHistory/executionHistory.bin differ
diff --git a/.gradle/7.0.2/executionHistory/executionHistory.lock b/.gradle/7.0.2/executionHistory/executionHistory.lock
index e560697..f606e34 100644
Binary files a/.gradle/7.0.2/executionHistory/executionHistory.lock and b/.gradle/7.0.2/executionHistory/executionHistory.lock differ
diff --git a/.gradle/7.0.2/fileHashes/fileHashes.bin b/.gradle/7.0.2/fileHashes/fileHashes.bin
index a6c61b5..afac2b9 100644
Binary files a/.gradle/7.0.2/fileHashes/fileHashes.bin and b/.gradle/7.0.2/fileHashes/fileHashes.bin differ
diff --git a/.gradle/7.0.2/fileHashes/fileHashes.lock b/.gradle/7.0.2/fileHashes/fileHashes.lock
index c226d71..4dcb2d0 100644
Binary files a/.gradle/7.0.2/fileHashes/fileHashes.lock and b/.gradle/7.0.2/fileHashes/fileHashes.lock differ
diff --git a/.gradle/7.0.2/fileHashes/resourceHashesCache.bin b/.gradle/7.0.2/fileHashes/resourceHashesCache.bin
index f605a9d..1f06b49 100644
Binary files a/.gradle/7.0.2/fileHashes/resourceHashesCache.bin and b/.gradle/7.0.2/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/7.0.2/javaCompile/classAnalysis.bin b/.gradle/7.0.2/javaCompile/classAnalysis.bin
index 5048b60..f951d82 100644
Binary files a/.gradle/7.0.2/javaCompile/classAnalysis.bin and b/.gradle/7.0.2/javaCompile/classAnalysis.bin differ
diff --git a/.gradle/7.0.2/javaCompile/jarAnalysis.bin b/.gradle/7.0.2/javaCompile/jarAnalysis.bin
index 62f7be9..4cb8b5d 100644
Binary files a/.gradle/7.0.2/javaCompile/jarAnalysis.bin and b/.gradle/7.0.2/javaCompile/jarAnalysis.bin differ
diff --git a/.gradle/7.0.2/javaCompile/javaCompile.lock b/.gradle/7.0.2/javaCompile/javaCompile.lock
index 2f6b11d..b49d43c 100644
Binary files a/.gradle/7.0.2/javaCompile/javaCompile.lock and b/.gradle/7.0.2/javaCompile/javaCompile.lock differ
diff --git a/.gradle/7.0.2/javaCompile/taskHistory.bin b/.gradle/7.0.2/javaCompile/taskHistory.bin
index 425ad59..2132383 100644
Binary files a/.gradle/7.0.2/javaCompile/taskHistory.bin and b/.gradle/7.0.2/javaCompile/taskHistory.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index 898a84e..ddad465 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
index c61c39d..fca84de 100644
Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/.gradle/checksums/checksums.lock b/.gradle/checksums/checksums.lock
index ba8d5b5..ad7482d 100644
Binary files a/.gradle/checksums/checksums.lock and b/.gradle/checksums/checksums.lock differ
diff --git a/.gradle/checksums/sha1-checksums.bin b/.gradle/checksums/sha1-checksums.bin
index 2735d5b..c098377 100644
Binary files a/.gradle/checksums/sha1-checksums.bin and b/.gradle/checksums/sha1-checksums.bin differ
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index d3cc770..089dfde 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -4,8 +4,11 @@
diff --git a/app/build.gradle b/app/build.gradle
index fac3ca4..7ba260c 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -9,8 +9,8 @@ android {
applicationId "UTSSG.ZQDesigned.Namecode"
minSdk 25
targetSdk 31
- versionCode 22050218
- versionName "RELEASE-1.3.0"
+ versionCode 22050221
+ versionName "RELEASE-1.3.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -32,4 +32,5 @@ dependencies {
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'junit:junit:4.13.2'
}
\ No newline at end of file
diff --git a/app/src/androidTest/java/UTSSG/ZQDesigned/Namecode/ExampleInstrumentedTest.java b/app/src/androidTest/java/UTSSG/ZQDesigned/Namecode/ExampleInstrumentedTest.java
index 26d8246..729c663 100644
--- a/app/src/androidTest/java/UTSSG/ZQDesigned/Namecode/ExampleInstrumentedTest.java
+++ b/app/src/androidTest/java/UTSSG/ZQDesigned/Namecode/ExampleInstrumentedTest.java
@@ -1,6 +1,7 @@
package UTSSG.ZQDesigned.Namecode;
import android.content.Context;
+
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
diff --git a/app/src/main/java/UTSSG/ZQDesigned/Namecode/MainActivity.java b/app/src/main/java/UTSSG/ZQDesigned/Namecode/MainActivity.java
index 9ec1c66..1feb232 100644
--- a/app/src/main/java/UTSSG/ZQDesigned/Namecode/MainActivity.java
+++ b/app/src/main/java/UTSSG/ZQDesigned/Namecode/MainActivity.java
@@ -1,16 +1,15 @@
package UTSSG.ZQDesigned.Namecode;
import android.annotation.SuppressLint;
-import android.content.DialogInterface;
import android.content.Intent;
-import android.util.Log;
+import android.os.Bundle;
+import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
-import android.os.Bundle;
import java.io.UnsupportedEncodingException;
@@ -25,22 +24,26 @@ protected void onCreate(Bundle savedInstanceState) {
@SuppressLint("SetTextI18n")
public void button2_Onclick(View view) throws UnsupportedEncodingException {
EditText name = findViewById(R.id.name);
- TextView result = findViewById(R.id.output);
String nameStr = name.getText().toString();
- byte[] codeBit = nameStr.getBytes("gb2312");// 获取汉字的字节数组
- if(codeBit.length==0) {//判断
+
+ if(TextUtils.isEmpty(nameStr)) {//判断
Toast.makeText(this, "请输入内容!", Toast.LENGTH_SHORT).show();
new AlertDialog.Builder(MainActivity.this).setTitle("提示")//设置对话框标题
.setMessage("请输入内容!")//设置显示的内容
- .setNegativeButton("返回", (dialog, which) -> {
- })
+ .setNegativeButton("返回", null)
.setIcon(android.R.drawable.ic_dialog_alert)//设置图标
.show();//在按键响应事件中显示此对话框
- } else if(codeBit.length%2==0) {//判断
+ return;
+ }
+
+ TextView result = findViewById(R.id.output);
+ byte[] codeBit = nameStr.getBytes("gb2312");// 获取汉字的字节数组
+ if(codeBit.length%2==0) {//判断
StringBuilder sb = new StringBuilder();
for (byte codeBit_tmp:codeBit) {
- byte tmp= (byte) (codeBit_tmp-160);
- if (tmp < 0) {
+ codeBit_tmp -= 160;
+
+ if (codeBit_tmp < 0) {
Toast.makeText(this, "您输入的内容不合法!", Toast.LENGTH_SHORT).show();
new AlertDialog.Builder(MainActivity.this).setTitle("提示")//设置对话框标题
.setMessage("您输入的内容不合法!")//设置显示的内容
@@ -48,27 +51,25 @@ public void button2_Onclick(View view) throws UnsupportedEncodingException {
})
.setIcon(android.R.drawable.ic_dialog_alert)//设置对话框图标
.show();//在按键响应事件中显示此对话框
- }
- else if (tmp <= 10) {
+ return;
+ } else if (codeBit_tmp <= 10) {
sb.append(0);
}
- sb.append(tmp);
+ sb.append(codeBit_tmp);
}
Toast.makeText(this, "正在查询......", Toast.LENGTH_SHORT).show();
- result.setText(nameStr+"\n"+"↓↓转换结果↓↓"+"\n"+sb.toString().replaceAll(".{4}", "$0 "));
+ result.setText(nameStr+"\n↓↓转换结果↓↓\n"+(sb.toString().replaceAll(".{4}", "$0 ")));
}else{
Toast.makeText(this, "您输入的内容不合法!", Toast.LENGTH_SHORT).show();
new AlertDialog.Builder(MainActivity.this).setTitle("提示")//设置对话框标题
.setMessage("您输入的内容不合法!")//设置显示的内容
- .setNegativeButton("返回", (dialog, which) -> {
- })
+ .setNegativeButton("返回", null)
.setIcon(android.R.drawable.ic_dialog_alert)//设置对话框图标
.show();//在按键响应事件中显示此对话框
}
}
public void button1_Onclick(View view) {
- Intent intent=new Intent(MainActivity.this,DonateActivity.class);
- startActivity(intent);
+ startActivity(new Intent(MainActivity.this,DonateActivity.class));
}
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 6c63a0d..4b975f4 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -92,7 +92,7 @@
app:layout_constraintEnd_toEndOf="parent"
android:onClick="button1_Onclick"/>