电量记录表里添加换行显示功能。

This commit is contained in:
ZhanGSKen
2025-09-03 20:54:48 +08:00
parent 80201e8370
commit 7e476894a7
4 changed files with 51 additions and 9 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Sun Aug 31 06:21:48 CST 2025 #Wed Sep 03 12:53:17 GMT 2025
stageCount=12 stageCount=12
libraryProject= libraryProject=
baseVersion=15.4 baseVersion=15.4
publishVersion=15.4.11 publishVersion=15.4.11
buildCount=0 buildCount=11
baseBetaVersion=15.4.12 baseBetaVersion=15.4.12

View File

@@ -16,6 +16,7 @@ import cc.winboll.studio.powerbell.receivers.ControlCenterServiceReceiver;
import cc.winboll.studio.powerbell.utils.AppCacheUtils; import cc.winboll.studio.powerbell.utils.AppCacheUtils;
import cc.winboll.studio.powerbell.utils.StringUtils; import cc.winboll.studio.powerbell.utils.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import android.widget.Switch;
public class ClearRecordActivity extends Activity { public class ClearRecordActivity extends Activity {
@@ -24,6 +25,7 @@ public class ClearRecordActivity extends Activity {
AToolbar mAToolbar; AToolbar mAToolbar;
TextView mtvRecordText; TextView mtvRecordText;
App mApplication; App mApplication;
boolean mIsShowRecordWithEnter = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@@ -47,7 +49,7 @@ public class ClearRecordActivity extends Activity {
finish(); finish();
} }
}); });
// 设置滑动清理控件 // 设置滑动清理控件
// //
// 初始化发送拉动控件 // 初始化发送拉动控件
@@ -79,7 +81,18 @@ public class ClearRecordActivity extends Activity {
void initRecordText() { void initRecordText() {
ArrayList<BatteryInfoBean> listBatteryInfo = AppCacheUtils.getInstance(this).getArrayListBatteryInfo(); ArrayList<BatteryInfoBean> listBatteryInfo = AppCacheUtils.getInstance(this).getArrayListBatteryInfo();
String szRecordText = StringUtils.formatPCMListString(listBatteryInfo); if (mIsShowRecordWithEnter) {
mtvRecordText.setText(szRecordText); String szRecordText = StringUtils.formatPCMListStringWithEnter(listBatteryInfo);
mtvRecordText.setText(szRecordText);
} else {
String szRecordText = StringUtils.formatPCMListString(listBatteryInfo);
mtvRecordText.setText(szRecordText);
}
} }
public void onShowRecordWithEnter(View view) {
Switch swShowRecordWithEnter = (Switch)view;
mIsShowRecordWithEnter = swShowRecordWithEnter.isChecked();
initRecordText();
}
} }

View File

@@ -37,6 +37,15 @@ public class StringUtils {
} }
return sz; return sz;
} }
public static String formatPCMListStringWithEnter(ArrayList<BatteryInfoBean> arrayListBatteryInfo) {
String sz = "";
for (int i = 0; i < arrayListBatteryInfo.size() - 1; i++) {
//LogUtils.d(TAG, "arrayListBatteryInfo.get(i).getBattetyValue() is "+ Integer.toString(arrayListBatteryInfo.get(i).getBattetyValue()));
sz = "\n" + arrayListBatteryInfo.get(i).getBattetyValue() + "%\n " + getTimespanDifference(arrayListBatteryInfo.get(i).getTimeStamp(), arrayListBatteryInfo.get(i + 1).getTimeStamp()) + " " + sz;
}
return sz;
}
// 获取时间之间的时间跨度字符串。 // 获取时间之间的时间跨度字符串。
// Get timespan string between times. // Get timespan string between times.

View File

@@ -47,12 +47,32 @@
android:layout_weight="1.0" android:layout_weight="1.0"
android:background="@drawable/bg_frame"> android:background="@drawable/bg_frame">
<TextView <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Record Text" android:gravity="center_horizontal">
android:textStyle="bold"
android:gravity="center_horizontal"/> <TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Record Text"
android:textStyle="bold"
android:gravity="center_horizontal"
android:layout_weight="1.0"
android:layout_marginLeft="10dp"
android:background="#FFD5D5D5"/>
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="&lt;↲&gt;"
android:id="@+id/activityclearrecordSwitch1"
android:onClick="onShowRecordWithEnter"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"/>
</LinearLayout>
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"