Skip to content

Commit

Permalink
add DeviceInfo in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
SlaVcE14 committed Feb 4, 2024
1 parent 843051a commit e0550ea
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions app/src/main/java/com/sjapps/logs/LogActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -91,12 +95,46 @@ private void update() {

numberOfLogs = logs.getLogs().size();

log.append(getDeviceInfo());

for (String s : logs.getLogs()){
log.append(s);
}
logTxt.setText(log.toString());
}

private String getDeviceInfo(){

String s = "";
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(
getPackageName(), PackageManager.GET_META_DATA);
s += "\n App Version Name: " + pInfo.versionName;
s += "\n App Version Code: " + pInfo.versionCode;
s += "\n";
} catch (PackageManager.NameNotFoundException ignored) {}
s += "\n OS Version: " + System.getProperty("os.version") + " ("
+ Build.VERSION.INCREMENTAL + ")";
s += "\n OS API Level: " + Build.VERSION.SDK_INT;
s += "\n Device: " + Build.DEVICE;
s += "\n Model (and Product): " + Build.MODEL + " (" + Build.PRODUCT + ")";
s += "\n Manufacturer: " + Build.MANUFACTURER;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
s += "\n screenWidth: " + getWindowManager().getCurrentWindowMetrics().getBounds().width();
s += "\n screenHeight: " + getWindowManager().getCurrentWindowMetrics().getBounds().height();
}else {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
s += "\n screenWidth: " + metrics.widthPixels;
s += "\n screenHeight: " + metrics.heightPixels;
}

s += "\n";

return s;
}

public void shareLog(View view) {

if (logTxt.getText().toString().equals("")) {
Expand Down

0 comments on commit e0550ea

Please sign in to comment.