Skip to content

Commit

Permalink
Database size on status page (#3759)
Browse files Browse the repository at this point in the history
* Database size on status page

* Cleanup

* Using the new database admin utility

* Cleanup

* Format and rounding

* Cleanup

---------

Co-authored-by: Navid <Navid200@users.noreply.github.com>
  • Loading branch information
Navid200 and Navid200 authored Nov 15, 2024
1 parent 71cb6c7 commit 11a4803
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import java.util.Set;

import static com.eveningoutpost.dexdrip.Home.startWatchUpdaterService;
import static com.eveningoutpost.dexdrip.utils.DatabaseUtil.getDataBaseSizeInBytes;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.DexcomG5;
import static com.eveningoutpost.dexdrip.xdrip.gs;

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

//@Inject
MicroStatus microStatus;
Expand Down Expand Up @@ -177,6 +179,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
sensor_status_view = (TextView) v.findViewById(R.id.sensor_status);
transmitter_status_view = (TextView) v.findViewById(R.id.transmitter_status);
current_device = (TextView) v.findViewById(R.id.remembered_device);
db_size_view = (TextView) v.findViewById(R.id.db_size);

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

Expand Down Expand Up @@ -238,6 +241,7 @@ private void set_current_values() {
setTransmitterStatus();
setNotes();
futureDataCheck();
setDbSize();

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

}

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

private void setSensorStatus() {
sensor_status_view.setText(SensorStatus.status());
Expand All @@ -285,7 +301,7 @@ private void setVersionName() {
try {
versionName = safeGetContext().getPackageManager().getPackageInfo(safeGetContext().getPackageName(), PackageManager.GET_META_DATA).versionName;
int versionNumber = safeGetContext().getPackageManager().getPackageInfo(safeGetContext().getPackageName(), PackageManager.GET_META_DATA).versionCode;
versionName += "\nCode: " + BuildConfig.buildVersion + "\nDowngradable to: " + versionNumber;
versionName += "\nCode: " + BuildConfig.buildVersion;
version_name_view.setText(versionName);
} catch (PackageManager.NameNotFoundException e) {
//e.printStackTrace();
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/res/layout/activity_system_status.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>

<LinearLayout
android:id="@+id/layout_dbsize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="10dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/database_size"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />

<TextView
android:id="@+id/db_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>

<LinearLayout
android:id="@+id/layout_device"
app:showIfTrue="@{ms.bluetooth()}"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,7 @@
<string name="progress">progress</string>
<string name="bluetooth_device">Bluetooth Device: </string>
<string name="transmitter_battery_status">Transmitter Battery: </string>
<string name="database_size">Database Size: </string>
<string name="top">Top</string>
<string name="connect_device_usb_otg">Please connect your device via USB OTG cable.</string>
<string name="connection_status">Connection Status:</string>
Expand Down

0 comments on commit 11a4803

Please sign in to comment.