Skip to content

Commit

Permalink
核心代码修复
Browse files Browse the repository at this point in the history
修复不能检测非文本内容的问题,优化核心代码
  • Loading branch information
ZQDesigned committed May 2, 2022
1 parent 9e30b74 commit 206017a
Show file tree
Hide file tree
Showing 19 changed files with 28 additions and 41 deletions.
Binary file modified .gradle/7.0.2/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.0.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.0.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.0.2/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/7.0.2/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/7.0.2/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file modified .gradle/7.0.2/javaCompile/jarAnalysis.bin
Binary file not shown.
Binary file modified .gradle/7.0.2/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified .gradle/7.0.2/javaCompile/taskHistory.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified .gradle/checksums/checksums.lock
Binary file not shown.
Binary file modified .gradle/checksums/sha1-checksums.bin
Binary file not shown.
3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions .idea/modules/app/姓名代码查询器.app.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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'
}
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
39 changes: 20 additions & 19 deletions app/src/main/java/UTSSG/ZQDesigned/Namecode/MainActivity.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -25,50 +24,52 @@ 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("您输入的内容不合法!")//设置显示的内容
.setNegativeButton("返回", (dialog, which) -> {
})
.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));
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
app:layout_constraintEnd_toEndOf="parent"
android:onClick="button1_Onclick"/>
<TextView
android:text="特别鸣谢:by:Han | 情非得已c(极客软件:搞机客 开发者)提供多字高效转换思路及Demo"
android:text="特别鸣谢:by:Han | 情非得已c(极客软件:搞机客 开发者)提供多字高效转换思路及Demo,并优化核心代码"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/textView4"
tools:layout_editor_absoluteX="0dp" app:layout_constraintBottom_toBottomOf="parent"
Expand Down

0 comments on commit 206017a

Please sign in to comment.