Browse Source

Fix bug where certain devices had different toolbar heights

master
Anthony Restaino 9 years ago
parent
commit
57d5298bec
  1. 11
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 1
      app/src/main/res/layout/toolbar.xml

11
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -250,6 +250,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -250,6 +250,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
private synchronized void initialize() {
mToolbar = (Toolbar) findViewById(R.id.toolbar);
initializeToolbarHeight(getResources().getConfiguration());
setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar();
@ -1061,15 +1062,21 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -1061,15 +1062,21 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
initializeTabHeight();
supportInvalidateOptionsMenu();
initializeToolbarHeight(newConfig);
}
private void initializeToolbarHeight(@NonNull final Configuration configuration){
// TODO externalize the dimensions
doOnLayout(mUiLayout, new Runnable() {
@Override
public void run() {
int toolbarSize;
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
// In portrait toolbar should be 56 dp tall
toolbarSize = Utils.dpToPx(56);
} else {
toolbarSize = Utils.dpToPx(48);
// In landscape toolbar should be 48 dp tall
toolbarSize = Utils.dpToPx(52);
}
mToolbar.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, toolbarSize));
mToolbar.setMinimumHeight(toolbarSize);

1
app/src/main/res/layout/toolbar.xml

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:background="?attr/colorPrimary"
android:elevation="2dp"
android:orientation="vertical">

Loading…
Cancel
Save