Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Fix visual glitches on the hint fading edge (#1933)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and bluemarvin committed Oct 8, 2019
1 parent 7782c30 commit 0c9f13e
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.view.inputmethod.EditorInfo;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -234,6 +235,7 @@ public void setIsContentMode(boolean isContentMode) {
}
}
syncViews();
updateRightPadding();
}

public boolean isInBookmarkMode() {
Expand Down Expand Up @@ -446,18 +448,35 @@ public void updateHintFading() {

private void updateRightPadding() {
int padding = WidgetPlacement.convertDpToPixel(getContext(), 5);
boolean anyButtonVisible = false;
if (mMicrophoneButton.getVisibility() == View.VISIBLE) {
padding += mMicrophoneButton.getLayoutParams().width;
anyButtonVisible = true;
}
if (mUAModeButton.getVisibility() == View.VISIBLE) {
padding += mUAModeButton.getLayoutParams().width;
anyButtonVisible = true;
}
if (mBookmarkButton.getVisibility() == View.VISIBLE) {
padding += mBookmarkButton.getLayoutParams().width;
anyButtonVisible = true;
}
// Min padding of 20 if no icons are visible
padding = Math.max(padding, WidgetPlacement.convertDpToPixel(getContext(), 20));
mURL.setPadding(mURL.getPaddingLeft(), mURL.getPaddingTop(), padding, mURL.getPaddingBottom());

// Update hint fading
int margin = 0;
if (anyButtonVisible) {
mHintFading.setBackgroundResource(mIsPrivateMode ? R.drawable.url_bar_hint_fading_edge_private : R.drawable.url_bar_hint_fading_edge);
} else {
mHintFading.setBackgroundResource(mIsPrivateMode ? R.drawable.url_bar_hint_fading_edge_end_private : R.drawable.url_bar_hint_fading_edge_end);
margin = WidgetPlacement.convertDpToPixel(getContext(), 5);
}

LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)mHintFading.getLayoutParams();
params.rightMargin = margin;
mHintFading.setLayoutParams(params);
}

private void syncViews() {
Expand Down Expand Up @@ -545,7 +564,7 @@ public void setPrivateMode(boolean isEnabled) {
} else {
mMicrophoneButton.setBackgroundResource(backgroundEnd);
}

updateRightPadding();
}

@Override
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/url_bar_hint_fading_edge_end.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true">
<shape>
<corners android:bottomRightRadius="20dp" android:topRightRadius="20dp" />
<gradient
android:type="linear"
android:angle="0"
android:startColor="#00000000"
android:endColor="@color/void_color" />
</shape>
</item>
<item android:state_enabled="false">
<shape>
<corners android:bottomRightRadius="20dp" android:topRightRadius="20dp" />
<gradient
android:type="linear"
android:angle="0"
android:startColor="#00000000"
android:endColor="@color/asphalt" />
</shape>
</item>
</selector>

24 changes: 24 additions & 0 deletions app/src/main/res/drawable/url_bar_hint_fading_edge_end_private.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true">
<shape>
<corners android:bottomRightRadius="20dp" android:topRightRadius="20dp" />
<gradient
android:type="linear"
android:angle="0"
android:startColor="#00000000"
android:endColor="@color/blackberry" />
</shape>
</item>
<item android:state_enabled="false">
<shape>
<corners android:bottomRightRadius="20dp" android:topRightRadius="20dp" />
<gradient
android:type="linear"
android:angle="0"
android:startColor="#00000000"
android:endColor="@color/eggplant" />
</shape>
</item>
</selector>

24 changes: 24 additions & 0 deletions app/src/main/res/drawable/url_bar_hint_fading_edge_private.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true">
<shape>
<corners android:bottomRightRadius="20dp" android:topRightRadius="20dp" />
<gradient
android:type="linear"
android:angle="0"
android:startColor="#00000000"
android:endColor="@color/blackberry" />
</shape>
</item>
<item android:state_enabled="false">
<shape>
<corners android:bottomRightRadius="20dp" android:topRightRadius="20dp" />
<gradient
android:type="linear"
android:angle="0"
android:startColor="#00000000"
android:endColor="@color/eggplant" />
</shape>
</item>
</selector>

0 comments on commit 0c9f13e

Please sign in to comment.