Skip to content

Commit

Permalink
[SearchView] Update back arrow to be auto mirrored for RTL
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 622863529
  • Loading branch information
dsn5ft authored and imhappi committed Apr 9, 2024
1 parent 7c77d5a commit b56afa7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.graphics.drawable.DrawableCompat;

/**
* Facilitates a fade out and then a fade in of the two input drawables.
Expand All @@ -45,6 +46,10 @@ public class FadeThroughDrawable extends Drawable {
public FadeThroughDrawable(@NonNull Drawable fadeOutDrawable, @NonNull Drawable fadeInDrawable) {
this.fadeOutDrawable = fadeOutDrawable.getConstantState().newDrawable().mutate();
this.fadeInDrawable = fadeInDrawable.getConstantState().newDrawable().mutate();
DrawableCompat.setLayoutDirection(
this.fadeOutDrawable, DrawableCompat.getLayoutDirection(fadeOutDrawable));
DrawableCompat.setLayoutDirection(
this.fadeInDrawable, DrawableCompat.getLayoutDirection(fadeInDrawable));
this.fadeInDrawable.setAlpha(0);
this.alphas = new float[2];
}
Expand Down
2 changes: 2 additions & 0 deletions lib/java/com/google/android/material/search/SearchView.java
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ private void updateNavigationIconIfNeeded() {
if (toolbar.getNavigationIconTint() != null) {
DrawableCompat.setTint(navigationIconDrawable, toolbar.getNavigationIconTint());
}
DrawableCompat.setLayoutDirection(
navigationIconDrawable, ViewCompat.getLayoutDirection(this));
toolbar.setNavigationIcon(
new FadeThroughDrawable(searchBar.getNavigationIcon(), navigationIconDrawable));
updateNavigationIconProgressIfNeeded();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:viewportHeight="24.0"
android:autoMirrored="true">
<path
android:fillColor="#FF000000"
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
Expand Down

0 comments on commit b56afa7

Please sign in to comment.