Merge pull request #8670 from Isira-Seneviratne/Update_FocusAwareCoordinator

Remove deprecated method calls in FocusAwareCoordinator.
This commit is contained in:
Stypox 2022-07-23 17:12:29 +02:00 committed by GitHub
commit 74df7fcd66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -27,6 +27,7 @@ import android.view.WindowInsets;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.WindowInsetsCompat;
import org.schabi.newpipe.R;
@ -83,23 +84,22 @@ public final class FocusAwareCoordinator extends CoordinatorLayout {
}
}
if (consumed) {
insets.consumeSystemWindowInsets();
}
return insets;
return consumed ? WindowInsetsCompat.CONSUMED.toWindowInsets() : insets;
}
/**
* Adjusts player's controls manually because fitsSystemWindows doesn't work when multiple
* Adjusts player's controls manually because onApplyWindowInsets doesn't work when multiple
* receivers adjust its bounds. So when two listeners are present (like in profile page)
* the player's controls will not receive insets. This method fixes it
*/
@Override
protected boolean fitSystemWindows(final Rect insets) {
public WindowInsets onApplyWindowInsets(final WindowInsets windowInsets) {
final var windowInsetsCompat = WindowInsetsCompat.toWindowInsetsCompat(windowInsets, this);
final var insets = windowInsetsCompat.getInsets(WindowInsetsCompat.Type.systemBars());
final ViewGroup controls = findViewById(R.id.playbackControlRoot);
if (controls != null) {
controls.setPadding(insets.left, insets.top, insets.right, insets.bottom);
}
return super.fitSystemWindows(insets);
return super.onApplyWindowInsets(windowInsets);
}
}