Commit 0e641094 authored by Mia Glaese's avatar Mia Glaese Committed by Commit Bot

[StartSurface] Remove Logo if screen too narrow.

Screen width of some devices does not have enough space for the logo.
See screenshot here:
https://drive.google.com/drive/folders/1-ZYyD0KSYr2wLEzBHZ9UFIP-K7D79tDV?usp=sharing

This CL removes the logo if there is not enough space at the first layout.

Known issues:
If device is rotates, screen width may change.

Bug: 1025296, 1027324
Change-Id: Ib5e17a8b49bd70c304d8e38e95d5de4123cf4ea2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1976311Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Commit-Queue: Mia Glaese <glamia@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729936}
parent 0c9be3ee
......@@ -29,7 +29,10 @@
android:layout_height="32dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:scaleType="centerInside"
android:adjustViewBounds="true"
app:srcCompat="@drawable/google_logo"
android:visibility="gone"
android:contentDescription="@null"/>
......
......@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.toolbar.top;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Rect;
import android.support.v7.content.res.AppCompatResources;
import android.util.AttributeSet;
import android.view.View;
......@@ -30,6 +31,9 @@ class StartSurfaceToolbarView extends RelativeLayout {
private ColorStateList mLightIconTint;
private ColorStateList mDarkIconTint;
private Rect mLogoRect = new Rect();
private Rect mViewRect = new Rect();
public StartSurfaceToolbarView(Context context, AttributeSet attrs) {
super(context, attrs);
}
......@@ -45,6 +49,26 @@ class StartSurfaceToolbarView extends RelativeLayout {
updatePrimaryColorAndTint(false);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO(https://crbug.com/1040526)
super.onLayout(changed, l, t, r, b);
if (mLogo.getVisibility() == View.GONE) return;
mLogoRect.set(mLogo.getLeft(), mLogo.getTop(), mLogo.getRight(), mLogo.getBottom());
for (int viewIndex = 0; viewIndex < getChildCount(); viewIndex++) {
View view = getChildAt(viewIndex);
if (view == mLogo) continue;
mViewRect.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
if (Rect.intersects(mLogoRect, mViewRect)) {
mLogo.setVisibility(View.GONE);
break;
}
}
}
/**
* @param appMenuButtonHelper The {@link AppMenuButtonHelper} for managing menu button
* interactions.
......@@ -64,7 +88,8 @@ class StartSurfaceToolbarView extends RelativeLayout {
}
/**
* @param isVisible Whether the Logo is visible.
* Sets the Logo visibility. Logo will not show if screen is not wide enough.
* @param isVisible Whether the Logo should be visible.
*/
void setLogoVisibility(boolean isVisible) {
mLogo.setVisibility(isVisible ? View.VISIBLE : View.GONE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment