Skip to content

Commit

Permalink
Merge branch 'dev' into remember_dl_pref
Browse files Browse the repository at this point in the history
  • Loading branch information
vmazoyer authored Aug 30, 2020
2 parents 05f0788 + 8d2ec30 commit 0cdcfc9
Show file tree
Hide file tree
Showing 236 changed files with 7,725 additions and 6,651 deletions.
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ with your GitHub account.

## Code contribution

* If you want to add a feature or change one, please open an issue describing your change. This gives the team and community a chance to give feedback before you spend any time on something that could be done differently or not done at all. It also prevents two contributors from working on the same thing and one being disappointed when only one user's code can be added.
* Stick to NewPipe's style conventions: follow [checkStyle](https://github.com/checkstyle/checkstyle). It will run each time you build the project.
* Do not bring non-free software (e.g. binary blobs) into the project. Also, make sure you do not introduce Google
libraries.
Expand Down
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ assignees: ''

---

# We have fixed the decrpytion exception and a new release is on its wait. Please do not report the bug, that no videos can be played.
If you are about to report something else, please remove this and the above line. Thank you :)
<!--
Oh no, a bug! It happens. Thanks for reporting an issue with NewPipe. If this is your first bug report, read the following information before proceeding:
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ dependencies {
exclude module: 'support-annotations'
}

implementation 'com.github.TeamNewPipe:NewPipeExtractor:5ac80624a40f4c600ae493e66881b5bf008f0ddb'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:6633f26ec5a73a8e932de575b7a0643b6ad6c890'

implementation "com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751"
implementation "org.jsoup:jsoup:1.13.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import android.os.Parcel;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;

import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.schabi.newpipe.R;
Expand All @@ -21,13 +21,13 @@ public class ErrorInfoTest {

@Test
public void errorInfoTestParcelable() {
ErrorInfo info = ErrorInfo.make(UserAction.USER_REPORT, "youtube", "request",
final ErrorInfo info = ErrorInfo.make(UserAction.USER_REPORT, "youtube", "request",
R.string.general_error);
// Obtain a Parcel object and write the parcelable object to it:
Parcel parcel = Parcel.obtain();
final Parcel parcel = Parcel.obtain();
info.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
ErrorInfo infoFromParcel = ErrorInfo.CREATOR.createFromParcel(parcel);
final ErrorInfo infoFromParcel = ErrorInfo.CREATOR.createFromParcel(parcel);

assertEquals(UserAction.USER_REPORT, infoFromParcel.userAction);
assertEquals("youtube", infoFromParcel.serviceName);
Expand Down
29 changes: 10 additions & 19 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
android:logo="@mipmap/ic_launcher"
android:requestLegacyExternalStorage="true"
android:theme="@style/OpeningTheme"
android:resizeableActivity="true"
tools:ignore="AllowBackup">
<activity
android:name=".MainActivity"
Expand All @@ -43,34 +44,18 @@
</receiver>

<service
android:name=".player.BackgroundPlayer"
android:exported="false">
android:name=".player.MainPlayer"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</service>

<activity
android:name=".player.BackgroundPlayerActivity"
android:label="@string/title_activity_background_player"
android:label="@string/title_activity_play_queue"
android:launchMode="singleTask" />

<activity
android:name=".player.PopupVideoPlayerActivity"
android:label="@string/title_activity_popup_player"
android:launchMode="singleTask" />

<service
android:name=".player.PopupVideoPlayer"
android:exported="false" />

<activity
android:name=".player.MainVideoPlayer"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/VideoPlayerTheme" />

<activity
android:name=".settings.SettingsActivity"
android:label="@string/settings" />
Expand Down Expand Up @@ -334,5 +319,11 @@
<service
android:name=".RouterActivity$FetcherService"
android:exported="false" />

<!-- see https://github.com/TeamNewPipe/NewPipe/issues/3947 -->
<!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
<!-- Version >= 3.0. DeX Dual Mode support -->
<meta-data android:name="com.samsung.android.multidisplay.keep_process_alive" android:value="true"/>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public Object instantiateItem(@NonNull final ViewGroup container, final int posi
// from its saved state, where the fragment manager has already
// taken care of restoring the fragments we previously had instantiated.
if (mFragments.size() > position) {
Fragment f = mFragments.get(position);
final Fragment f = mFragments.get(position);
if (f != null) {
return f;
}
Expand All @@ -160,12 +160,12 @@ public Object instantiateItem(@NonNull final ViewGroup container, final int posi
mCurTransaction = mFragmentManager.beginTransaction();
}

Fragment fragment = getItem(position);
final Fragment fragment = getItem(position);
if (DEBUG) {
Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
}
if (mSavedState.size() > position) {
Fragment.SavedState fss = mSavedState.get(position);
final Fragment.SavedState fss = mSavedState.get(position);
if (fss != null) {
fragment.setInitialSavedState(fss);
}
Expand All @@ -191,7 +191,7 @@ public Object instantiateItem(@NonNull final ViewGroup container, final int posi
@Override
public void destroyItem(@NonNull final ViewGroup container, final int position,
@NonNull final Object object) {
Fragment fragment = (Fragment) object;
final Fragment fragment = (Fragment) object;

if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction();
Expand All @@ -217,7 +217,7 @@ public void destroyItem(@NonNull final ViewGroup container, final int position,
@SuppressWarnings({"ReferenceEquality", "deprecation"})
public void setPrimaryItem(@NonNull final ViewGroup container, final int position,
@NonNull final Object object) {
Fragment fragment = (Fragment) object;
final Fragment fragment = (Fragment) object;
if (fragment != mCurrentPrimaryItem) {
if (mCurrentPrimaryItem != null) {
mCurrentPrimaryItem.setMenuVisibility(false);
Expand Down Expand Up @@ -267,17 +267,17 @@ public Parcelable saveState() {
Bundle state = null;
if (mSavedState.size() > 0) {
state = new Bundle();
Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
final Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
mSavedState.toArray(fss);
state.putParcelableArray("states", fss);
}
for (int i = 0; i < mFragments.size(); i++) {
Fragment f = mFragments.get(i);
final Fragment f = mFragments.get(i);
if (f != null && f.isAdded()) {
if (state == null) {
state = new Bundle();
}
String key = "f" + i;
final String key = "f" + i;
mFragmentManager.putFragment(state, key, f);

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -294,21 +294,21 @@ public Parcelable saveState() {
@Override
public void restoreState(@Nullable final Parcelable state, @Nullable final ClassLoader loader) {
if (state != null) {
Bundle bundle = (Bundle) state;
final Bundle bundle = (Bundle) state;
bundle.setClassLoader(loader);
Parcelable[] fss = bundle.getParcelableArray("states");
final Parcelable[] fss = bundle.getParcelableArray("states");
mSavedState.clear();
mFragments.clear();
if (fss != null) {
for (int i = 0; i < fss.length; i++) {
mSavedState.add((Fragment.SavedState) fss[i]);
}
}
Iterable<String> keys = bundle.keySet();
for (String key: keys) {
final Iterable<String> keys = bundle.keySet();
for (final String key : keys) {
if (key.startsWith("f")) {
int index = Integer.parseInt(key.substring(1));
Fragment f = mFragmentManager.getFragment(bundle, key);
final int index = Integer.parseInt(key.substring(1));
final Fragment f = mFragmentManager.getFragment(bundle, key);
if (f != null) {
while (mFragments.size() <= index) {
mFragments.add(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.OverScroller;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import org.schabi.newpipe.R;

import java.lang.reflect.Field;

Expand All @@ -20,23 +23,25 @@ public FlingBehavior(final Context context, final AttributeSet attrs) {
super(context, attrs);
}

private boolean allowScroll = true;
private final Rect globalRect = new Rect();

@Override
public boolean onRequestChildRectangleOnScreen(
@NonNull final CoordinatorLayout coordinatorLayout, @NonNull final AppBarLayout child,
@NonNull final Rect rectangle, final boolean immediate) {

focusScrollRect.set(rectangle);

coordinatorLayout.offsetDescendantRectToMyCoords(child, focusScrollRect);

int height = coordinatorLayout.getHeight();
final int height = coordinatorLayout.getHeight();

if (focusScrollRect.top <= 0 && focusScrollRect.bottom >= height) {
// the child is too big to fit inside ourselves completely, ignore request
return false;
}

int dy;
final int dy;

if (focusScrollRect.bottom > height) {
dy = focusScrollRect.top;
Expand All @@ -48,13 +53,22 @@ public boolean onRequestChildRectangleOnScreen(
return false;
}

int consumed = scroll(coordinatorLayout, child, dy, getMaxDragOffset(child), 0);
final int consumed = scroll(coordinatorLayout, child, dy, getMaxDragOffset(child), 0);

return consumed == dy;
}

public boolean onInterceptTouchEvent(final CoordinatorLayout parent, final AppBarLayout child,
final MotionEvent ev) {
final ViewGroup playQueue = child.findViewById(R.id.playQueuePanel);
if (playQueue != null) {
final boolean visible = playQueue.getGlobalVisibleRect(globalRect);
if (visible && globalRect.contains((int) ev.getRawX(), (int) ev.getRawY())) {
allowScroll = false;
return false;
}
}
allowScroll = true;
switch (ev.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
// remove reference to old nested scrolling child
Expand All @@ -68,17 +82,37 @@ public boolean onInterceptTouchEvent(final CoordinatorLayout parent, final AppBa
return super.onInterceptTouchEvent(parent, child, ev);
}

@Override
public boolean onStartNestedScroll(@NonNull final CoordinatorLayout parent,
@NonNull final AppBarLayout child,
@NonNull final View directTargetChild,
final View target,
final int nestedScrollAxes,
final int type) {
return allowScroll && super.onStartNestedScroll(
parent, child, directTargetChild, target, nestedScrollAxes, type);
}

@Override
public boolean onNestedFling(@NonNull final CoordinatorLayout coordinatorLayout,
@NonNull final AppBarLayout child,
@NonNull final View target, final float velocityX,
final float velocityY, final boolean consumed) {
return allowScroll && super.onNestedFling(
coordinatorLayout, child, target, velocityX, velocityY, consumed);
}

@Nullable
private OverScroller getScrollerField() {
try {
Class<?> headerBehaviorType = this.getClass()
final Class<?> headerBehaviorType = this.getClass()
.getSuperclass().getSuperclass().getSuperclass();
if (headerBehaviorType != null) {
Field field = headerBehaviorType.getDeclaredField("scroller");
final Field field = headerBehaviorType.getDeclaredField("scroller");
field.setAccessible(true);
return ((OverScroller) field.get(this));
}
} catch (NoSuchFieldException | IllegalAccessException e) {
} catch (final NoSuchFieldException | IllegalAccessException e) {
// ?
}
return null;
Expand All @@ -87,34 +121,35 @@ private OverScroller getScrollerField() {
@Nullable
private Field getLastNestedScrollingChildRefField() {
try {
Class<?> headerBehaviorType = this.getClass().getSuperclass().getSuperclass();
final Class<?> headerBehaviorType = this.getClass().getSuperclass().getSuperclass();
if (headerBehaviorType != null) {
Field field = headerBehaviorType.getDeclaredField("lastNestedScrollingChildRef");
final Field field
= headerBehaviorType.getDeclaredField("lastNestedScrollingChildRef");
field.setAccessible(true);
return field;
}
} catch (NoSuchFieldException e) {
} catch (final NoSuchFieldException e) {
// ?
}
return null;
}

private void resetNestedScrollingChild() {
Field field = getLastNestedScrollingChildRefField();
final Field field = getLastNestedScrollingChildRefField();
if (field != null) {
try {
Object value = field.get(this);
final Object value = field.get(this);
if (value != null) {
field.set(this, null);
}
} catch (IllegalAccessException e) {
} catch (final IllegalAccessException e) {
// ?
}
}
}

private void stopAppBarLayoutFling() {
OverScroller scroller = getScrollerField();
final OverScroller scroller = getScrollerField();
if (scroller != null) {
scroller.forceFinished(true);
}
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/org/schabi/newpipe/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void onCreate() {
}

protected Downloader getDownloader() {
DownloaderImpl downloader = DownloaderImpl.init(null);
final DownloaderImpl downloader = DownloaderImpl.init(null);
setCookiesToDownloader(downloader);
return downloader;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ protected void initACRA() {
.setBuildConfigClass(BuildConfig.class)
.build();
ACRA.init(this, acraConfig);
} catch (ACRAConfigurationException ace) {
} catch (final ACRAConfigurationException ace) {
ace.printStackTrace();
ErrorActivity.reportError(this,
ace,
Expand All @@ -231,10 +231,10 @@ public void initNotificationChannel() {
// Keep this below DEFAULT to avoid making noise on every notification update
final int importance = NotificationManager.IMPORTANCE_LOW;

NotificationChannel mChannel = new NotificationChannel(id, name, importance);
final NotificationChannel mChannel = new NotificationChannel(id, name, importance);
mChannel.setDescription(description);

NotificationManager mNotificationManager =
final NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.createNotificationChannel(mChannel);

Expand All @@ -255,11 +255,11 @@ private void setUpUpdateNotificationChannel(final int importance) {
final String appUpdateDescription
= getString(R.string.app_update_notification_channel_description);

NotificationChannel appUpdateChannel
final NotificationChannel appUpdateChannel
= new NotificationChannel(appUpdateId, appUpdateName, importance);
appUpdateChannel.setDescription(appUpdateDescription);

NotificationManager appUpdateNotificationManager
final NotificationManager appUpdateNotificationManager
= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
appUpdateNotificationManager.createNotificationChannel(appUpdateChannel);
}
Expand Down
Loading

0 comments on commit 0cdcfc9

Please sign in to comment.