Browse Source

Fixed toolbar size bug on rotation

master
Anthony Restaino 8 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; @@ -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; @@ -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 @@ -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 @@ -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 @@ -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();

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

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

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

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

Loading…
Cancel
Save