11package com .tensorhub .manifold ;
22
3+ import static com .amap .api .maps .AMapUtils .calculateArea ;
34import static com .amap .api .maps .model .BitmapDescriptorFactory .getContext ;
45
56import 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