Skip to content

Commit 11a4803

Browse files
authored
Database size on status page (#3759)
* Database size on status page * Cleanup * Using the new database admin utility * Cleanup * Format and rounding * Cleanup --------- Co-authored-by: Navid <[email protected]>
1 parent 71cb6c7 commit 11a4803

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

app/src/main/java/com/eveningoutpost/dexdrip/SystemStatusFragment.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import java.util.Set;
5858

5959
import static com.eveningoutpost.dexdrip.Home.startWatchUpdaterService;
60+
import static com.eveningoutpost.dexdrip.utils.DatabaseUtil.getDataBaseSizeInBytes;
6061
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.DexcomG5;
6162
import static com.eveningoutpost.dexdrip.xdrip.gs;
6263

@@ -80,6 +81,7 @@ public class SystemStatusFragment extends Fragment {
8081
private ActiveBluetoothDevice activeBluetoothDevice;
8182
private static final String TAG = "SystemStatus";
8283
private BroadcastReceiver serviceDataReceiver;
84+
private TextView db_size_view;
8385

8486
//@Inject
8587
MicroStatus microStatus;
@@ -177,6 +179,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
177179
sensor_status_view = (TextView) v.findViewById(R.id.sensor_status);
178180
transmitter_status_view = (TextView) v.findViewById(R.id.transmitter_status);
179181
current_device = (TextView) v.findViewById(R.id.remembered_device);
182+
db_size_view = (TextView) v.findViewById(R.id.db_size);
180183

181184
notes = (TextView) v.findViewById(R.id.other_notes);
182185

@@ -238,6 +241,7 @@ private void set_current_values() {
238241
setTransmitterStatus();
239242
setNotes();
240243
futureDataCheck();
244+
setDbSize();
241245

242246
/* if (notes.getText().length()==0) {
243247
notes.setText("Swipe for more status pages!");
@@ -274,6 +278,18 @@ private void setTransmitterStatus() {
274278

275279
}
276280

281+
private void setDbSize() {
282+
long dbSizeLengthLong = getDataBaseSizeInBytes();
283+
String dbSizeString = "0";
284+
if (dbSizeLengthLong > 0) { // If there is a database
285+
if (dbSizeLengthLong < 31457280) { // When smaller than 30M, round and show one decimal point
286+
dbSizeString = JoH.roundFloat((float) dbSizeLengthLong / (1024 * 1024), 1) + "";
287+
} else { // When greater than 30M, round and just show integer
288+
dbSizeString = (int) (JoH.roundFloat((float) dbSizeLengthLong / (1024 * 1024), 0)) + "";
289+
}
290+
db_size_view.setText(dbSizeString + "M");
291+
}
292+
}
277293

278294
private void setSensorStatus() {
279295
sensor_status_view.setText(SensorStatus.status());
@@ -285,7 +301,7 @@ private void setVersionName() {
285301
try {
286302
versionName = safeGetContext().getPackageManager().getPackageInfo(safeGetContext().getPackageName(), PackageManager.GET_META_DATA).versionName;
287303
int versionNumber = safeGetContext().getPackageManager().getPackageInfo(safeGetContext().getPackageName(), PackageManager.GET_META_DATA).versionCode;
288-
versionName += "\nCode: " + BuildConfig.buildVersion + "\nDowngradable to: " + versionNumber;
304+
versionName += "\nCode: " + BuildConfig.buildVersion;
289305
version_name_view.setText(versionName);
290306
} catch (PackageManager.NameNotFoundException e) {
291307
//e.printStackTrace();

app/src/main/res/layout/activity_system_status.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,27 @@
7878
android:textAppearance="?android:attr/textAppearanceMedium" />
7979
</LinearLayout>
8080

81+
<LinearLayout
82+
android:id="@+id/layout_dbsize"
83+
android:layout_width="match_parent"
84+
android:layout_height="wrap_content"
85+
android:orientation="horizontal"
86+
android:paddingTop="10dp">
87+
88+
<TextView
89+
android:layout_width="wrap_content"
90+
android:layout_height="wrap_content"
91+
android:text="@string/database_size"
92+
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
93+
94+
<TextView
95+
android:id="@+id/db_size"
96+
android:layout_width="wrap_content"
97+
android:layout_height="wrap_content"
98+
android:paddingLeft="5dp"
99+
android:textAppearance="?android:attr/textAppearanceMedium" />
100+
</LinearLayout>
101+
81102
<LinearLayout
82103
android:id="@+id/layout_device"
83104
app:showIfTrue="@{ms.bluetooth()}"

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,7 @@
15481548
<string name="progress">progress</string>
15491549
<string name="bluetooth_device">Bluetooth Device: </string>
15501550
<string name="transmitter_battery_status">Transmitter Battery: </string>
1551+
<string name="database_size">Database Size: </string>
15511552
<string name="top">Top</string>
15521553
<string name="connect_device_usb_otg">Please connect your device via USB OTG cable.</string>
15531554
<string name="connection_status">Connection Status:</string>

0 commit comments

Comments
 (0)