From 71a6c935510b42e3c15c197fbf3de5845519423a Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Fri, 12 Feb 2016 21:38:16 -0500 Subject: [PATCH] Fixed toolbar size bug on rotation --- .../lightning/activity/BrowserActivity.java | 21 +++++++++++++++++-- app/src/main/res/layout/toolbar.xml | 15 ++++++------- app/src/main/res/layout/toolbar_content.xml | 2 +- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java index 13ffd7f..c779fd3 100644 --- a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java @@ -15,6 +15,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.Configuration; import android.database.sqlite.SQLiteException; import android.graphics.Bitmap; import android.graphics.Color; @@ -75,6 +76,7 @@ import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; @@ -154,6 +156,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements // Toolbar Views + private Toolbar mToolbar; private AutoCompleteTextView mSearch; private ImageView mArrowImage; @@ -252,8 +255,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements } private synchronized void initialize() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); + mToolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(mToolbar); ActionBar actionBar = getSupportActionBar(); //TODO make sure dark theme flag gets set correctly @@ -1024,6 +1027,20 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements return true; } + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + int toolbarSize; + if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { + toolbarSize = Utils.dpToPx(56); + } else { + toolbarSize = Utils.dpToPx(48); + } + mToolbar.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, toolbarSize)); + mToolbar.setMinimumHeight(toolbarSize); + mToolbar.requestLayout(); + } + public void closeBrowser() { mBrowserFrame.setBackgroundColor(mBackgroundColor); performExitCleanUp(); diff --git a/app/src/main/res/layout/toolbar.xml b/app/src/main/res/layout/toolbar.xml index cc0fbcb..8c2a0c4 100644 --- a/app/src/main/res/layout/toolbar.xml +++ b/app/src/main/res/layout/toolbar.xml @@ -1,7 +1,8 @@ - + android:layout_height="30dp"/> + custom:contentInsetStart="0dp"/> + custom:progressColor="?attr/colorAccent"/> \ No newline at end of file diff --git a/app/src/main/res/layout/toolbar_content.xml b/app/src/main/res/layout/toolbar_content.xml index 06789f5..e7368c3 100644 --- a/app/src/main/res/layout/toolbar_content.xml +++ b/app/src/main/res/layout/toolbar_content.xml @@ -7,7 +7,7 @@