Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database size on status page #3759

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading