Skip to content

Commit 5f855c2

Browse files
refactor(UI): 全面优化UI/UX并修复多个关键Bug
1 parent e9acb17 commit 5f855c2

9 files changed

Lines changed: 291 additions & 181 deletions

File tree

app/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ android {
1919
val amapApiKey: String? = project.findProperty("amap.api.key") as String?
2020
manifestPlaceholders["AMAP_API_KEY"] = amapApiKey ?: "PLEASE_SET_YOUR_OWN_KEY"
2121
ndk {
22-
abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a"))
22+
abiFilters.addAll(listOf("arm64-v8a"))
2323
}
2424
}
2525
buildTypes {
@@ -45,7 +45,6 @@ android {
4545

4646
dependencies {
4747
implementation("com.squareup.okhttp3:okhttp:4.10.0")
48-
implementation ("androidx.appcompat:appcompat:1.6.1")
4948
// ✅ 高德地图 SDK
5049
implementation("com.amap.api:3dmap:9.8.3")
5150
// ✅ Google 官方库

app/release/app-release.apk

-8.84 MB
Binary file not shown.
0 Bytes
Binary file not shown.
1 Byte
Binary file not shown.

app/src/main/java/com/tensorhub/manifold/MainActivity.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.tensorhub.manifold;
22

3+
import static com.amap.api.maps.AMapUtils.calculateArea;
34
import static com.amap.api.maps.model.BitmapDescriptorFactory.getContext;
45

56
import android.Manifest;
@@ -189,6 +190,7 @@ private String aesEncrypt(String plaintext, String key) throws Exception {
189190
private float minDistance = 2.0f;
190191
private int stepCounter = 0;
191192
private MaterialTextView realStepCountTextView;
193+
private LinearLayout summaryContainer;
192194
private TextInputEditText stepInput; // 配合 XML 中的 TextInputLayout 使用
193195
private MaterialTextView areaTextView, timeTextView, stepCountTextView;
194196
private boolean isDarkTheme = false;
@@ -364,6 +366,7 @@ protected void onCreate(Bundle savedInstanceState) {
364366
timeTextView = findViewById(R.id.timeResult);
365367
stepCountTextView = findViewById(R.id.stepCountText);
366368
realStepCountTextView = findViewById(R.id.realStepCountText);
369+
summaryContainer = findViewById(R.id.summaryContainer);
367370

368371
// Location and Map settings
369372
MyLocationStyle myLocationStyle = new MyLocationStyle();
@@ -377,7 +380,9 @@ protected void onCreate(Bundle savedInstanceState) {
377380
// Bottom sheet behavior
378381
View bottomSheet = findViewById(R.id.cardView);
379382
BottomSheetBehavior<View> bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
380-
bottomSheetBehavior.setPeekHeight(780);
383+
int peekHeightInDp = 218;
384+
int peekHeightInPx = (int) (peekHeightInDp * getResources().getDisplayMetrics().density);
385+
bottomSheetBehavior.setPeekHeight(peekHeightInPx);
381386
bottomSheetBehavior.setHideable(false);
382387

383388
// Start button click listener
@@ -416,25 +421,29 @@ protected void onCreate(Bundle savedInstanceState) {
416421
// Stop button click listener
417422
findViewById(R.id.stopBtn).setOnClickListener(v -> {
418423
if (startTimeMillis == 0) {
419-
showMessage("请先点击“开始记录坐标(GPS)”再结束记录");
424+
showMessage("请先点击“开始记录坐标”再结束记录");
420425
return;
421426
}
422427
endTimeMillis = System.currentTimeMillis();
423428
stopLocationUpdates();
424429
drawClosedPolygon();
425-
426430
double area = calculateArea(pointList);
427431
double perimeter = calculatePerimeter(pointList);
428432
String duration = getDuration();
429433

430-
areaTextView.setText(String.format("面积:%.2f㎡\n周长:%.2fm", area, perimeter));
431-
timeTextView.setText(String.format("开始:%s\n结束:%s\n用时:%s",
434+
areaTextView.setText(String.format(java.util.Locale.US, "%.2f m² · %.2f m", area, perimeter));
435+
436+
timeTextView.setText(String.format("%s / %s / %s",
432437
formatTime(startTimeMillis), formatTime(endTimeMillis), duration));
433438

434-
stepCountTextView.setText("步长数:" + stepCounter);
435-
runOnUiThread(() -> realStepCountTextView.setText("真实步数:" + realSteps));
439+
stepCountTextView.setText(String.valueOf(stepCounter));
440+
runOnUiThread(() -> realStepCountTextView.setText(String.valueOf(realSteps)));
441+
436442
saveToHistory(area, perimeter, stepCounter);
437443

444+
// 显示统计信息容器
445+
summaryContainer.setVisibility(View.VISIBLE);
446+
438447
if (pointList.size() >= 3) {
439448
double gap = euclideanDistance(pointList.get(0), pointList.get(pointList.size() - 1));
440449
if (gap > 10) showMessage("路径可能未闭合(起终点向量差距大)");
@@ -450,7 +459,7 @@ protected void onCreate(Bundle savedInstanceState) {
450459
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(lastLatLng, 18));
451460
showMessage("已定位到当前位置");
452461
} else {
453-
showMessage("尚未获取定位,请先点击“开始记录坐标(GPS)”并允许使用确切的位置信息");
462+
showMessage("尚未获取定位,请先点击“开始记录坐标”并允许使用确切的位置信息");
454463
}
455464
});
456465

@@ -710,9 +719,16 @@ private void showLeJianAccountSelector(
710719
accountsMap.remove(phone);
711720

712721
StringBuilder sb = new StringBuilder();
722+
int i = 0;
713723
for (java.util.Map.Entry<String, String> acc : accountsMap.entrySet()) {
714-
sb.append(acc.getKey()).append(":").append(acc.getValue()).append("\n");
724+
if (i > 0) {
725+
// 只有在不是第一个元素的时候,才在前面加上换行符
726+
sb.append("\n");
727+
}
728+
sb.append(acc.getKey()).append(":").append(acc.getValue());
729+
i++;
715730
}
731+
716732
sp.edit().putString("accounts", sb.toString()).apply();
717733

718734
container.removeView(card);

0 commit comments

Comments
 (0)