Skip to content

Commit b1b36ce

Browse files
committed
frontend: debug and display calculated base font and screen width
For debugging purpose this will render the calculated increased base font size and the screen width. The screen width can vary depending on Android display size setting.
1 parent df796db commit b1b36ce

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/MainActivity.java

+6
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ public void onPageFinished(WebView view, String url) {
241241
// This size does not scale dynamically with zoom adjustments and is fixed at 1.6rem.
242242
double defaultFontSizeREM = 1.6;
243243

244+
// Set the base font-size on the html element dynamically and apply a fixed font size to the body.
245+
// Also, set a custom data attribute 'data-test' to the calculated base font size percentage for potential debugging.
246+
String cssSetup = "document.documentElement.style.fontSize = '" + baseFontSizePercentage + "%';" +
247+
"document.body.style.fontSize = '" + defaultFontSizeREM + "rem';" +
248+
"document.body.setAttribute('data-test', '" + baseFontSizePercentage + "%');";
249+
244250
// Reset the WebView's text zoom to 100% to ensure that the scaling is controlled via CSS
245251
// and not by the WebView's default scaling behavior.
246252
view.getSettings().setTextZoom(100);

frontends/web/src/components/layout/header.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const Header = ({
4646
}
4747
return false;
4848
};
49+
const test = document.body.getAttribute('data-test');
50+
const width = window.screen.width;
4951

5052
return (
5153
<div className={[style.container, sidebarStatus ? style[sidebarStatus] : ''].join(' ')}>
@@ -65,6 +67,9 @@ const Header = ({
6567
>
6668
<GuideActive />
6769
{t('guide.toggle.open')}
70+
<sup>
71+
({test} {width}px)
72+
</sup>
6873
</Button>
6974
)}
7075
</div>

0 commit comments

Comments
 (0)