mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-13 07:33:57 +01:00
Merge pull request #8670 from Isira-Seneviratne/Update_FocusAwareCoordinator
Remove deprecated method calls in FocusAwareCoordinator.
This commit is contained in:
commit
74df7fcd66
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user