Browse Source

Fixed toolbar size bug on rotation

master
Anthony Restaino 9 years ago
parent
commit
71a6c93551
  1. 21
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 15
      app/src/main/res/layout/toolbar.xml
  3. 2
      app/src/main/res/layout/toolbar_content.xml

21
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.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.res.Configuration;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
@ -75,6 +76,7 @@ import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener; import android.widget.TextView.OnEditorActionListener;
@ -154,6 +156,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
// Toolbar Views // Toolbar Views
private Toolbar mToolbar;
private AutoCompleteTextView mSearch; private AutoCompleteTextView mSearch;
private ImageView mArrowImage; private ImageView mArrowImage;
@ -252,8 +255,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
private synchronized void initialize() { private synchronized void initialize() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
//TODO make sure dark theme flag gets set correctly //TODO make sure dark theme flag gets set correctly
@ -1024,6 +1027,20 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
return true; 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() { public void closeBrowser() {
mBrowserFrame.setBackgroundColor(mBackgroundColor); mBrowserFrame.setBackgroundColor(mBackgroundColor);
performExitCleanUp(); performExitCleanUp();

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

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_layout" android:id="@+id/toolbar_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
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:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
@ -9,20 +10,20 @@
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout <FrameLayout
android:id="@+id/tabs_toolbar_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="30dp" android:layout_height="30dp"/>
android:id="@+id/tabs_toolbar_container"/>
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:paddingBottom="0dp"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:paddingRight="0dp" android:paddingRight="0dp"
android:paddingTop="2dp" android:paddingTop="2dp"
android:paddingBottom="0dp"
custom:contentInsetEnd="0dp" custom:contentInsetEnd="0dp"
custom:contentInsetStart="0dp" /> custom:contentInsetStart="0dp"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -35,7 +36,7 @@
android:layout_height="2dp" android:layout_height="2dp"
custom:backgroundColor="#00000000" custom:backgroundColor="#00000000"
custom:bidirectionalAnimate="false" custom:bidirectionalAnimate="false"
custom:progressColor="?attr/colorAccent" /> custom:progressColor="?attr/colorAccent"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

2
app/src/main/res/layout/toolbar_content.xml

@ -7,7 +7,7 @@
<FrameLayout <FrameLayout
android:id="@+id/arrow_button" android:id="@+id/arrow_button"
android:layout_width="?attr/actionBarSize" android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize" android:layout_height="match_parent"
android:background="?attr/actionBarItemBackground" android:background="?attr/actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:gravity="center" > android:gravity="center" >

Loading…
Cancel
Save