Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
applicationId "InfinityLoop1309.NewPipeEnhanced"
minSdk 21
//noinspection ExpiredTargetSdkVersion
targetSdk 33
targetSdk 37
versionCode 1100
versionName "5.1.1"
multiDexEnabled true
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/org/schabi/newpipe/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public void onChanged(Integer connectionState) {

// Initialize settings first because others inits can use its values
NewPipeSettings.initSettings(this);
StatusBarHelper.init(this);

// Initialize Android Auto component state based on preference
DeviceUtils.updateAndroidAutoComponentState(this);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ protected void onCreate(final Bundle savedInstanceState) {
toolbarLayoutBinding = mainBinding.toolbarLayout;
setContentView(mainBinding.getRoot());

WindowInsetsHelper.applyStatusBarInsets(this, toolbarLayoutBinding.toolbar,
mainBinding.fragmentHolder);

if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
initFragments();
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/org/schabi/newpipe/about/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.schabi.newpipe.databinding.ActivityAboutBinding
import org.schabi.newpipe.databinding.FragmentAboutBinding
import org.schabi.newpipe.util.Localization
import org.schabi.newpipe.util.ThemeHelper
import org.schabi.newpipe.util.WindowInsetsHelper
import org.schabi.newpipe.util.external_communication.ShareUtils

class AboutActivity : AppCompatActivity() {
Expand All @@ -30,6 +31,8 @@ class AboutActivity : AppCompatActivity() {
val aboutBinding = ActivityAboutBinding.inflate(layoutInflater)
setContentView(aboutBinding.root)
setSupportActionBar(aboutBinding.aboutToolbar)

WindowInsetsHelper.applyStatusBarInsets(this, aboutBinding.aboutToolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)

// Create the adapter that will return a fragment for each of the three
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;

Comment on lines 5 to 10
import androidx.appcompat.app.ActionBar;
Expand All @@ -15,6 +16,7 @@
import org.schabi.newpipe.databinding.ActivityDownloaderBinding;
import org.schabi.newpipe.util.DeviceUtils;
import org.schabi.newpipe.util.ThemeHelper;
import org.schabi.newpipe.util.WindowInsetsHelper;
import org.schabi.newpipe.views.FocusOverlayView;

import us.shandian.giga.service.DownloadManagerService;
Expand Down Expand Up @@ -44,6 +46,8 @@ protected void onCreate(final Bundle savedInstanceState) {

setSupportActionBar(downloaderBinding.toolbarLayout.toolbar);

WindowInsetsHelper.applyStatusBarInsets(this, downloaderBinding.toolbarLayout.toolbar);

final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
Comment on lines 13 to 17
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
Expand All @@ -27,6 +28,7 @@
import org.schabi.newpipe.util.ErrorMatcher;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.ThemeHelper;
import org.schabi.newpipe.util.WindowInsetsHelper;
import org.schabi.newpipe.util.external_communication.ShareUtils;
import org.schabi.newpipe.util.utils;

Expand Down Expand Up @@ -103,6 +105,10 @@ protected void onCreate(final Bundle savedInstanceState) {

setSupportActionBar(activityErrorBinding.toolbarLayout.toolbar);

WindowInsetsHelper.applyStatusBarInsets(this,
activityErrorBinding.toolbarLayout.toolbar,
activityErrorBinding.scrollView);

final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.webkit.CookieManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
Comment on lines 8 to 14
Expand All @@ -25,6 +26,7 @@
import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R;
import org.schabi.newpipe.util.ThemeHelper;
import org.schabi.newpipe.util.WindowInsetsHelper;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
Expand Down Expand Up @@ -77,6 +79,9 @@ protected void onCreate(final Bundle savedInstanceState) {
setContentView(recaptchaBinding.getRoot());
setSupportActionBar(recaptchaBinding.toolbar);

WindowInsetsHelper.applyStatusBarInsets(this, recaptchaBinding.toolbar,
recaptchaBinding.reCaptchaWebView);

final String url = sanitizeRecaptchaUrl(getIntent().getStringExtra(RECAPTCHA_URL_EXTRA));
// set return to Cancel by default
setResult(RESULT_CANCELED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
Expand Down Expand Up @@ -222,6 +224,7 @@ private void onSharedPreferencesChanged(final SharedPreferences sharedPreference

private List<VideoStream> sortedVideoStreams;
private int selectedVideoStreamIndex = -1;
private int statusBarInset;
private BottomSheetBehavior<FrameLayout> bottomSheetBehavior;
private BroadcastReceiver broadcastReceiver;

Expand Down Expand Up @@ -805,6 +808,18 @@ protected void initListeners() {
});

setupBottomPlayer();
final View bottomSheetLayout = activity.findViewById(R.id.fragment_player_holder);
ViewCompat.setOnApplyWindowInsetsListener(bottomSheetLayout, (v, insets) -> {
final int statusBarHeight = insets.getInsets(
WindowInsetsCompat.Type.statusBars()).top;
statusBarInset = insets.getInsetsIgnoringVisibility(
WindowInsetsCompat.Type.statusBars()).top;
v.setPadding(v.getPaddingLeft(), statusBarHeight,
v.getPaddingRight(), v.getPaddingBottom());
updateBottomSheetPeekHeight();
return insets;
});
ViewCompat.requestApplyInsets(bottomSheetLayout);
if (!playerHolder.isBound()) {
setHeightThumbnail();
} else {
Expand Down Expand Up @@ -2265,6 +2280,8 @@ public void onFullscreenStateChanged(final boolean fullscreen) {
scrollToTop();

addVideoPlayerView();
final View bottomSheetLayout = requireActivity().findViewById(R.id.fragment_player_holder);
ViewCompat.requestApplyInsets(bottomSheetLayout);
}

@Override
Expand Down Expand Up @@ -2587,6 +2604,13 @@ private void manageSpaceAtTheBottom(final boolean showMore) {
newBottomPadding);
}

private void updateBottomSheetPeekHeight() {
final int peekHeight = getResources().getDimensionPixelSize(R.dimen.mini_player_height)
+ statusBarInset;
bottomSheetBehavior.setPeekHeight(bottomSheetState == BottomSheetBehavior.STATE_HIDDEN
? 0 : peekHeight);
Comment on lines +2607 to +2611
}

private void setupBottomPlayer() {
final CoordinatorLayout.LayoutParams params =
(CoordinatorLayout.LayoutParams) binding.appBarLayout.getLayoutParams();
Expand All @@ -2595,10 +2619,9 @@ private void setupBottomPlayer() {
final FrameLayout bottomSheetLayout = activity.findViewById(R.id.fragment_player_holder);
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetLayout);
bottomSheetBehavior.setState(bottomSheetState);
final int peekHeight = getResources().getDimensionPixelSize(R.dimen.mini_player_height);
if (bottomSheetState != BottomSheetBehavior.STATE_HIDDEN) {
manageSpaceAtTheBottom(false);
bottomSheetBehavior.setPeekHeight(peekHeight);
updateBottomSheetPeekHeight();
if (bottomSheetState == BottomSheetBehavior.STATE_COLLAPSED) {
binding.overlayLayout.setAlpha(MAX_OVERLAY_ALPHA);
} else if (bottomSheetState == BottomSheetBehavior.STATE_EXPANDED) {
Expand Down Expand Up @@ -2626,7 +2649,7 @@ public void onStateChanged(@NonNull final View bottomSheet, final int newState)
moveFocusToMainFragment(false);
manageSpaceAtTheBottom(false);

bottomSheetBehavior.setPeekHeight(peekHeight);
updateBottomSheetPeekHeight();
// Disable click because overlay buttons located on top of buttons
// from the player
setOverlayElementsClickable(false);
Expand All @@ -2652,7 +2675,7 @@ && isPlayerAvailable()
moveFocusToMainFragment(true);
manageSpaceAtTheBottom(false);

bottomSheetBehavior.setPeekHeight(peekHeight);
updateBottomSheetPeekHeight();

// Re-enable clicks
setOverlayElementsClickable(true);
Expand Down
36 changes: 36 additions & 0 deletions app/src/main/java/org/schabi/newpipe/player/PlayQueueActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.os.IBinder;
import android.provider.Settings;
import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -17,7 +18,11 @@

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.ItemTouchHelper;

import com.google.android.material.appbar.AppBarLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

Expand Down Expand Up @@ -76,6 +81,37 @@ protected void onCreate(final Bundle savedInstanceState) {
setContentView(queueControlBinding.getRoot());

setSupportActionBar(queueControlBinding.toolbar);

queueControlBinding.appbar.setStatusBarForeground(null);
getWindow().setStatusBarColor(android.graphics.Color.TRANSPARENT);

WindowInsetsHelper.applyStatusBarInsets(this, queueControlBinding.toolbar);

ViewCompat.setOnApplyWindowInsetsListener(queueControlBinding.getRoot(), (v, insets) -> {
final int navBarHeight = insets.getInsets(
WindowInsetsCompat.Type.navigationBars()).bottom;
final int twelveDp = (int) (12 * getResources()
.getDisplayMetrics().density + 0.5f);

if (queueControlBinding.playbackControls != null) {
final ViewGroup.MarginLayoutParams controlsParams =
(ViewGroup.MarginLayoutParams) queueControlBinding
.playbackControls.getLayoutParams();
controlsParams.bottomMargin = twelveDp + navBarHeight;
queueControlBinding.playbackControls.setLayoutParams(controlsParams);
}

if (queueControlBinding.playbackControlsBottom != null) {
queueControlBinding.playbackControlsBottom.setPadding(
queueControlBinding.playbackControlsBottom.getPaddingLeft(),
queueControlBinding.playbackControlsBottom.getPaddingTop(),
queueControlBinding.playbackControlsBottom.getPaddingRight(),
navBarHeight);
}

return insets;
});

if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.title_activity_play_queue);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ public void setupFromView(@NonNull final PlayerBinding playerBinding) {

private void initViews(@NonNull final PlayerBinding playerBinding) {
binding = playerBinding;
binding.playbackControlRoot.setFitsSystemWindows(isFullscreen);
setupSubtitleView();

binding.resizeTextView
Expand Down Expand Up @@ -4638,6 +4639,7 @@ public void toggleFullscreen() {
}

isFullscreen = !isFullscreen;
binding.playbackControlRoot.setFitsSystemWindows(isFullscreen);
if (!isFullscreen) {
// Apply window insets because Android will not do it when orientation changes
// from landscape to portrait (open vertical video to reproduce)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
Expand All @@ -23,6 +24,7 @@
import org.schabi.newpipe.R;
import org.schabi.newpipe.util.ServiceHelper;
import org.schabi.newpipe.util.ThemeHelper;
import org.schabi.newpipe.util.WindowInsetsHelper;

import java.util.ArrayList;
import java.util.HashSet;
Expand All @@ -47,7 +49,10 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_filter_list);

setSupportActionBar(findViewById(R.id.toolbar));
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

WindowInsetsHelper.applyStatusBarInsets(this, toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(getActivityTitle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
Comment on lines 9 to 13

import androidx.annotation.IdRes;
Expand All @@ -34,6 +35,7 @@
import org.schabi.newpipe.settings.preferencesearch.PreferenceSearchResultListener;
import org.schabi.newpipe.settings.preferencesearch.PreferenceSearcher;
import org.schabi.newpipe.util.DeviceUtils;
import org.schabi.newpipe.util.WindowInsetsHelper;
import org.schabi.newpipe.util.KeyboardUtil;
import org.schabi.newpipe.util.ReleaseVersionUtil;
import org.schabi.newpipe.util.ThemeHelper;
Expand Down Expand Up @@ -101,6 +103,10 @@ protected void onCreate(final Bundle savedInstanceBundle) {

setSupportActionBar(settingsLayoutBinding.settingsToolbarLayout.toolbar);

WindowInsetsHelper.applyStatusBarInsets(this,
settingsLayoutBinding.settingsToolbarLayout.toolbar,
settingsLayoutBinding.settingsFragmentHolder);

if (restored) {
// Restore state
if (this.wasSearchActive) {
Expand Down
43 changes: 43 additions & 0 deletions app/src/main/java/org/schabi/newpipe/util/StatusBarHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.schabi.newpipe.util;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;

import androidx.annotation.NonNull;

public final class StatusBarHelper {
private static int portraitHeight;
private static int landscapeHeight;

private StatusBarHelper() {
}

public static void init(@NonNull final Context context) {
final Resources resources = context.getResources();
portraitHeight = getInternalDimensionPixelSize(resources, "status_bar_height_portrait");
landscapeHeight = getInternalDimensionPixelSize(resources, "status_bar_height_landscape");

final int fallbackHeight = getInternalDimensionPixelSize(resources, "status_bar_height");
if (portraitHeight == 0) {
portraitHeight = fallbackHeight;
}
if (landscapeHeight == 0) {
landscapeHeight = fallbackHeight;
}
}

public static int get(@NonNull final Context context) {
return context.getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE ? landscapeHeight : portraitHeight;
}

private static int getInternalDimensionPixelSize(@NonNull final Resources resources,
@NonNull final String name) {
final int resourceId = resources.getIdentifier(name, "dimen", "android");
if (resourceId == 0) {
return 0;
}
return resources.getDimensionPixelSize(resourceId);
}
}
Loading