Skip to content

Commit

Permalink
Show available RAM in About Activity.
Browse files Browse the repository at this point in the history
  • Loading branch information
mh- committed Mar 27, 2022
1 parent 764ff13 commit e1b1c1b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.app.ActivityManager;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;
Expand Down Expand Up @@ -49,11 +50,21 @@ protected void onCreate(Bundle savedInstanceState) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(R.string.title_activity_about);
}

TextView versionTextView = findViewById(R.id.versionTextView);
TextView mainTextView = findViewById(R.id.explanationTextView1);

versionTextView.setText(getString(R.string.about_version,
BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.BUILD_TYPE));
ActivityManager.MemoryInfo memoryInfo = getAvailableMemory();

if (!memoryInfo.lowMemory) {
versionTextView.setText(getString(R.string.about_version,
BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.BUILD_TYPE,
memoryInfo.availMem/1024/1024));
} else {
versionTextView.setText(getString(R.string.about_version_low_mem,
BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.BUILD_TYPE,
memoryInfo.availMem/1024/1024));
}

String filename = "about_en.md";
if (Locale.getDefault().getLanguage().equals("de")) {
Expand All @@ -77,4 +88,12 @@ protected void onCreate(Bundle savedInstanceState) {
.build();
markwon.setMarkdown(mainTextView, new String(output.toByteArray(), StandardCharsets.UTF_8));
}

// Get a MemoryInfo object for the device's current memory status.
private ActivityManager.MemoryInfo getAvailableMemory() {
ActivityManager activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
return memoryInfo;
}
}
5 changes: 3 additions & 2 deletions corona-warn-companion/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="16dp"
android:fontFamily="sans-serif"
android:text="@string/about_version"
android:text="@string/about_version_low_mem"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
Expand All @@ -61,7 +62,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/versionTextView"
app:layout_constraintVertical_bias="1.0" />

</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 2 additions & 1 deletion corona-warn-companion/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
<string name="error_empty_rpis_ramble_mode">ERROR!\nFEHLER!\nKeine Begegnungen gefunden.\nHast Du Begegnungen aufgezeichnet und dann nochmal aus RaMBLE exportiert? Die exportierte Datenbank ist anscheinend noch leer.</string>
<string name="error_download">FEHLER!\nEs gab ein Problem beim Herunterladen der Diagnoseschlüssel.\nFunktioniert Deine Internetverbindung?</string>
<string name="title_activity_about">Über diese App</string>
<string name="about_version">Version\n%1$s (%2$d, %3$s)</string>
<string name="about_version">Version\n%1$s (%2$d, %3$s)\nRAM: %4$d MB verfügbar</string>
<string name="about_version_low_mem">Version\n%1$s (%2$d, %3$s)\nRAM: %4$d MB verfügbar (LOW MEMORY!)</string>
<string name="error_download_invalid_key_file_header">FEHLER!\nEine heruntergeladene Diagnoseschlüssel-Datei beginnt nicht mit der erwarteten Zeichenfolge!</string>
<string name="tx_power">Gemeldete Sendeleistung: %1$s dB</string>
<string name="menu_entry_countries_sub_menu">Länder</string>
Expand Down
3 changes: 2 additions & 1 deletion corona-warn-companion/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
<string name="error_empty_rpis_ramble_mode">ERROR!\nNo encounters found.\nDid you scan some encounters and then export a fresh RaMBLE database? The exported database is apparently empty.</string>
<string name="error_download">ERROR!\nDownload of Diagnosis Keys failed.\nIs your internet connection working?</string>
<string name="title_activity_about">About this app</string>
<string name="about_version">Version\n%1$s (%2$d, %3$s)</string>
<string name="about_version">Version\n%1$s (%2$d, %3$s)\nRAM: %4$d MB available</string>
<string name="about_version_low_mem">Version\n%1$s (%2$d, %3$s)\nRAM: %4$d MB available (LOW MEMORY!)</string>
<string name="error_download_invalid_key_file_header">ERROR!\nDownloaded Diagnosis Keys file starts with incorrect header!</string>
<string name="saved_app_mode" translatable="false">APP_MODE</string>
<string name="tx_power">TX Power reported by sender: %1$s dB</string>
Expand Down

0 comments on commit e1b1c1b

Please sign in to comment.