diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/SystemStatusFragment.java b/app/src/main/java/com/eveningoutpost/dexdrip/SystemStatusFragment.java index e67cc9aba3..103ed8619c 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/SystemStatusFragment.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/SystemStatusFragment.java @@ -43,6 +43,7 @@ import com.eveningoutpost.dexdrip.models.UserError.Log; import com.eveningoutpost.dexdrip.services.DexCollectionService; import com.eveningoutpost.dexdrip.services.G5CollectionService; +import com.eveningoutpost.dexdrip.ui.activities.DatabaseAdmin; import com.eveningoutpost.dexdrip.utilitymodels.CollectionServiceStarter; import com.eveningoutpost.dexdrip.utilitymodels.SensorStatus; import com.eveningoutpost.dexdrip.databinding.ActivitySystemStatusBinding; @@ -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; @@ -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); @@ -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!"); @@ -274,6 +278,11 @@ private void setTransmitterStatus() { } + private void setDbSize() { + DatabaseAdmin dataBaseAdmin = new DatabaseAdmin(); + Float dbSize = dataBaseAdmin.getDbSizeFloat(); + db_size_view.setText(dbSize + "M"); + } private void setSensorStatus() { sensor_status_view.setText(SensorStatus.status()); @@ -285,7 +294,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(); diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/ui/activities/DatabaseAdmin.java b/app/src/main/java/com/eveningoutpost/dexdrip/ui/activities/DatabaseAdmin.java index 687d90ea93..de8eb0ec02 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/ui/activities/DatabaseAdmin.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/ui/activities/DatabaseAdmin.java @@ -38,6 +38,7 @@ public class DatabaseAdmin extends BaseAppCompatActivity { private final DbAdminProcessor databaseSize = new DatabaseSize(); // view model public final ObservableField console = new ObservableField<>(); + public static float dbSizeResult; // Database size @Override protected void onCreate(Bundle savedInstanceState) { @@ -57,6 +58,11 @@ public void getDbSize() { dbTask(databaseSize, "pragma database_list"); } + public float getDbSizeFloat() { + getDbSize(); + return dbSizeResult; + } + public void quickCheck() { dbTask(consoleProcessor, "pragma quick_check"); } @@ -157,6 +163,7 @@ class DatabaseSize implements DbAdminProcessor { @Override public void process(List results) { + dbSizeResult = 0; if (results.size() == 0) { console.set("Cannot locate database!!"); } else { @@ -170,7 +177,8 @@ public void process(List results) { } final File dbFile = new File(filename); if (dbFile.exists()) { - consoleAppend("Database " + insert + " size: " + JoH.roundFloat(((float) dbFile.length()) / (1024 * 1024), 2) + "M " + (dbFile.canWrite() ? "" : " CANNOT WRITE") + (dbFile.canRead() ? "" : " CANNOT READ") + "\n"); + dbSizeResult = JoH.roundFloat(((float) dbFile.length()) / (1024 * 1024), 2); + consoleAppend("Database " + insert + " size: " + dbSizeResult + "M " + (dbFile.canWrite() ? "" : " CANNOT WRITE") + (dbFile.canRead() ? "" : " CANNOT READ") + "\n"); } else { console.set("Cannot find database file! " + filename); } diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/IdempotentMigrations.java b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/IdempotentMigrations.java index 65c0c5776a..4546d7b0d9 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/IdempotentMigrations.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/IdempotentMigrations.java @@ -20,6 +20,7 @@ import com.eveningoutpost.dexdrip.models.UserNotification; import com.eveningoutpost.dexdrip.R; import com.eveningoutpost.dexdrip.SnoozeActivity; +import com.eveningoutpost.dexdrip.ui.activities.DatabaseAdmin; import java.util.ArrayList; import java.util.Iterator; @@ -60,6 +61,7 @@ public void performAll() { IncompatibleApps.notifyAboutIncompatibleApps(); CompatibleApps.notifyAboutCompatibleApps(); legacySettingsMoveLanguageFromNoToNb(); + initiateGetDbSizeFloat(); } @@ -160,4 +162,9 @@ private static void legacySettingsMoveLanguageFromNoToNb() { Pref.setString("forced_language", "nb"); } } + + private static void initiateGetDbSizeFloat() { // Get database size once so that it will return a non-zero value next + DatabaseAdmin databaseAdmin = new DatabaseAdmin(); + databaseAdmin.getDbSizeFloat(); + } } diff --git a/app/src/main/res/layout/activity_system_status.xml b/app/src/main/res/layout/activity_system_status.xml index 1d12886b85..1c07990a58 100644 --- a/app/src/main/res/layout/activity_system_status.xml +++ b/app/src/main/res/layout/activity_system_status.xml @@ -78,6 +78,27 @@ android:textAppearance="?android:attr/textAppearanceMedium" /> + + + + + + + progress Bluetooth Device: Transmitter Battery: + Database size: Top Please connect your device via USB OTG cable. Connection Status: