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
private synchronized void initialize() { private synchronized void initialize() {
mToolbar = (Toolbar) findViewById(R.id.toolbar); mToolbar = (Toolbar) findViewById(R.id.toolbar);
initializeToolbarHeight(getResources().getConfiguration());
setSupportActionBar(mToolbar); setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
@ -1061,15 +1062,21 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
initializeTabHeight(); initializeTabHeight();
supportInvalidateOptionsMenu(); supportInvalidateOptionsMenu();
initializeToolbarHeight(newConfig);
}
private void initializeToolbarHeight(@NonNull final Configuration configuration){
// TODO externalize the dimensions
doOnLayout(mUiLayout, new Runnable() { doOnLayout(mUiLayout, new Runnable() {
@Override @Override
public void run() { public void run() {
int toolbarSize; 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); toolbarSize = Utils.dpToPx(56);
} else { } 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.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, toolbarSize));
mToolbar.setMinimumHeight(toolbarSize); mToolbar.setMinimumHeight(toolbarSize);

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

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

Loading…
Cancel
Save