Settings: Improve RAM summary for devices >12GB of RAM
* settings: Improve RAM summary formatting to show one decimal place * settings: Update RAM formatting to use gigabytes with no decimal places + base 10 units for closer accuracy to advertised RAM sizes
This commit is contained in:
@@ -49,31 +49,16 @@ public class TotalRAMPreferenceController extends BasePreferenceController {
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
ActivityManager actManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
|
||||
actManager.getMemoryInfo(memInfo);
|
||||
ActivityManager actManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
|
||||
actManager.getMemoryInfo(memInfo);
|
||||
|
||||
long totRam = memInfo.totalMem;
|
||||
double gb = (double) totRam / 1073741824.0;
|
||||
|
||||
String aproxRam;
|
||||
if (gb > 0 && gb <= 2) {
|
||||
aproxRam = "2";
|
||||
} else if (gb <= 3) {
|
||||
aproxRam = "3";
|
||||
} else if (gb <= 4) {
|
||||
aproxRam = "4";
|
||||
} else if (gb <= 6) {
|
||||
aproxRam = "6";
|
||||
} else if (gb <= 8) {
|
||||
aproxRam = "8";
|
||||
} else if (gb <= 12) {
|
||||
aproxRam = "12";
|
||||
} else {
|
||||
aproxRam = "12+";
|
||||
long totRam = memInfo.totalMem;
|
||||
double gb = (double) totRam / 1000000000.0;
|
||||
|
||||
DecimalFormat df = new DecimalFormat("#");
|
||||
String formattedRam = df.format(gb);
|
||||
|
||||
return formattedRam + " GB";
|
||||
}
|
||||
|
||||
String actualRam = aproxRam.concat(" GB");
|
||||
return actualRam;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user