X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.java;h=0a61ce0a7298460c21b9a6dd334774f6dc24ece5;hp=2b15aa4c2993177cead252bab7bf8d1c4a795714;hb=df8b520d10c3fa31b603ff7c50670ab1f0728d2f;hpb=97e0d95eff56498ebae87dd90ad2299e0d1fb0cf diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 2b15aa4c..0a61ce0a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -447,6 +447,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook private ForegroundColorSpan initialGrayColorSpan; private ForegroundColorSpan finalGrayColorSpan; + // The drawer header padding variables are used in `onCreate()` and `onConfigurationChanged()`. + private int drawerHeaderPaddingLeftAndRight; + private int drawerHeaderPaddingTop; + private int drawerHeaderPaddingBottom; + // `sslErrorHandler` is used in `onCreate()`, `onSslErrorCancel()`, and `onSslErrorProceed`. private SslErrorHandler sslErrorHandler; @@ -912,11 +917,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook float screenDensity = resources.getDisplayMetrics().density; // Calculate the drawer header padding. This is used to move the text in the drawer headers below any cutouts. - int drawerHeaderPaddingLeftAndRight = (int) (15 * screenDensity); - int drawerHeaderPaddingTop = statusBarPixelSize + (int) (4 * screenDensity); - int drawerHeaderPaddingBottom = (int) (8 * screenDensity); + drawerHeaderPaddingLeftAndRight = (int) (15 * screenDensity); + drawerHeaderPaddingTop = statusBarPixelSize + (int) (4 * screenDensity); + drawerHeaderPaddingBottom = (int) (8 * screenDensity); - // The drawer listener is used to update the navigation menu. + // The drawer listener is used to update the navigation menu.` drawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() { @Override public void onDrawerSlide(@NonNull View drawerView, float slideOffset) { @@ -3170,7 +3175,19 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); - // Reload the ad for the free flavor if we not in full screen mode. + // Get the status bar pixel size. + int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); + int statusBarPixelSize = getResources().getDimensionPixelSize(statusBarResourceId); + + // Get the resource density. + float screenDensity = getResources().getDisplayMetrics().density; + + // Recalculate the drawer header padding. + drawerHeaderPaddingLeftAndRight = (int) (15 * screenDensity); + drawerHeaderPaddingTop = statusBarPixelSize + (int) (4 * screenDensity); + drawerHeaderPaddingBottom = (int) (8 * screenDensity); + + // Reload the ad for the free flavor if not in full screen mode. if (BuildConfig.FLAVOR.contentEquals("free") && !inFullScreenBrowsingMode) { // Reload the ad. The AdView is destroyed and recreated, which changes the ID, every time it is reloaded to handle possible rotations. AdHelper.loadAd(findViewById(R.id.adview), getApplicationContext(), getString(R.string.ad_unit_id));