mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Merge pull request #4710 from TacoTheDank/more-cleanup
More miscellaneous little fixes and improvements
This commit is contained in:
commit
1500ce7490
@ -12,8 +12,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
@ -95,8 +94,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
// Create the adapter that will return a fragment for each of the three
|
||||
// primary sections of the activity.
|
||||
mSectionsPagerAdapter =
|
||||
new SectionsPagerAdapter(getSupportFragmentManager(), getLifecycle());
|
||||
mSectionsPagerAdapter = new SectionsPagerAdapter(this);
|
||||
|
||||
// Set up the ViewPager with the sections adapter.
|
||||
mViewPager = findViewById(R.id.container);
|
||||
@ -179,8 +177,8 @@ public class AboutActivity extends AppCompatActivity {
|
||||
* one of the sections/tabs/pages.
|
||||
*/
|
||||
public static class SectionsPagerAdapter extends FragmentStateAdapter {
|
||||
public SectionsPagerAdapter(final FragmentManager fm, final Lifecycle lifecycle) {
|
||||
super(fm, lifecycle);
|
||||
public SectionsPagerAdapter(final FragmentActivity fa) {
|
||||
super(fa);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -646,7 +646,7 @@ public class DownloadDialog extends DialogFragment
|
||||
mainStorage = mainStorageVideo; // subtitle & video files go together
|
||||
format = subtitleStreamsAdapter.getItem(selectedSubtitleIndex).getFormat();
|
||||
mime = format.mimeType;
|
||||
filename += format == MediaFormat.TTML ? MediaFormat.SRT.suffix : format.suffix;
|
||||
filename += (format == MediaFormat.TTML ? MediaFormat.SRT : format).suffix;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("No stream selected");
|
||||
|
@ -1246,9 +1246,9 @@ public class VideoDetailFragment
|
||||
final DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||
|
||||
if (getView() != null) {
|
||||
final int height = isInMultiWindow()
|
||||
? requireView().getHeight()
|
||||
: activity.getWindow().getDecorView().getHeight();
|
||||
final int height = (isInMultiWindow()
|
||||
? requireView()
|
||||
: activity.getWindow().getDecorView()).getHeight();
|
||||
setHeightThumbnail(height, metrics);
|
||||
getView().getViewTreeObserver().removeOnPreDrawListener(preDrawListener);
|
||||
}
|
||||
@ -1269,9 +1269,9 @@ public class VideoDetailFragment
|
||||
requireView().getViewTreeObserver().removeOnPreDrawListener(preDrawListener);
|
||||
|
||||
if (player != null && player.isFullscreen()) {
|
||||
final int height = isInMultiWindow()
|
||||
? requireView().getHeight()
|
||||
: activity.getWindow().getDecorView().getHeight();
|
||||
final int height = (isInMultiWindow()
|
||||
? requireView()
|
||||
: activity.getWindow().getDecorView()).getHeight();
|
||||
// Height is zero when the view is not yet displayed like after orientation change
|
||||
if (height != 0) {
|
||||
setHeightThumbnail(height, metrics);
|
||||
@ -1279,9 +1279,9 @@ public class VideoDetailFragment
|
||||
requireView().getViewTreeObserver().addOnPreDrawListener(preDrawListener);
|
||||
}
|
||||
} else {
|
||||
final int height = isPortrait
|
||||
? (int) (metrics.widthPixels / (16.0f / 9.0f))
|
||||
: (int) (metrics.heightPixels / 2.0f);
|
||||
final int height = (int) (isPortrait
|
||||
? metrics.widthPixels / (16.0f / 9.0f)
|
||||
: metrics.heightPixels / 2.0f);
|
||||
setHeightThumbnail(height, metrics);
|
||||
}
|
||||
}
|
||||
|
@ -378,11 +378,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
|
||||
final ActionBar supportActionBar = activity.getSupportActionBar();
|
||||
if (supportActionBar != null) {
|
||||
supportActionBar.setDisplayShowTitleEnabled(true);
|
||||
if (useAsFrontPage) {
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(false);
|
||||
} else {
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(!useAsFrontPage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class FeedDatabaseManager(context: Context) {
|
||||
|
||||
return streams.map<List<StreamInfoItem>> {
|
||||
val items = ArrayList<StreamInfoItem>(it.size)
|
||||
for (streamEntity in it) items.add(streamEntity.toStreamInfoItem())
|
||||
it.mapTo(items) { it.toStreamInfoItem() }
|
||||
return@map items
|
||||
}
|
||||
}
|
||||
|
@ -161,8 +161,8 @@ class FeedLoadService : Service() {
|
||||
companion object {
|
||||
fun wrapList(subscriptionId: Long, info: ListInfo<StreamInfoItem>): List<Throwable> {
|
||||
val toReturn = ArrayList<Throwable>(info.errors.size)
|
||||
for (error in info.errors) {
|
||||
toReturn.add(RequestException(subscriptionId, info.serviceId.toString() + ":" + info.url, error))
|
||||
info.errors.mapTo(toReturn) {
|
||||
RequestException(subscriptionId, info.serviceId.toString() + ":" + info.url, it)
|
||||
}
|
||||
return toReturn
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ class FeedGroupDialogViewModel(
|
||||
BiFunction { t1: String, t2: Boolean -> Filter(t1, t2) }
|
||||
)
|
||||
.distinctUntilChanged()
|
||||
.switchMap { filter ->
|
||||
subscriptionManager.getSubscriptions(groupId, filter.query, filter.showOnlyUngrouped)
|
||||
.switchMap { (query, showOnlyUngrouped) ->
|
||||
subscriptionManager.getSubscriptions(groupId, query, showOnlyUngrouped)
|
||||
}.map { list -> list.map { PickerSubscriptionItem(it) } }
|
||||
|
||||
private val mutableGroupLiveData = MutableLiveData<FeedGroupEntity>()
|
||||
|
@ -225,9 +225,9 @@ public final class MainPlayer extends Service {
|
||||
// DisplayMetrics from activity context knows about MultiWindow feature
|
||||
// while DisplayMetrics from app context doesn't
|
||||
final DisplayMetrics metrics = (playerImpl != null
|
||||
&& playerImpl.getParentActivity() != null)
|
||||
? playerImpl.getParentActivity().getResources().getDisplayMetrics()
|
||||
: getResources().getDisplayMetrics();
|
||||
&& playerImpl.getParentActivity() != null
|
||||
? playerImpl.getParentActivity().getResources()
|
||||
: getResources()).getDisplayMetrics();
|
||||
return metrics.heightPixels < metrics.widthPixels;
|
||||
}
|
||||
|
||||
|
@ -748,11 +748,10 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
||||
|
||||
//2) Icon change accordingly to current App Theme
|
||||
// using rootView.getContext() because getApplicationContext() didn't work
|
||||
item.setIcon(player.isMuted()
|
||||
? ThemeHelper.resolveResourceIdFromAttr(rootView.getContext(),
|
||||
R.attr.ic_volume_off)
|
||||
: ThemeHelper.resolveResourceIdFromAttr(rootView.getContext(),
|
||||
R.attr.ic_volume_up));
|
||||
item.setIcon(ThemeHelper.resolveResourceIdFromAttr(rootView.getContext(),
|
||||
player.isMuted()
|
||||
? R.attr.ic_volume_off
|
||||
: R.attr.ic_volume_up));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,12 +84,12 @@ public final class PlayerHelper {
|
||||
final int days = (milliSeconds % (86400000 * 7)) / 86400000;
|
||||
|
||||
STRING_BUILDER.setLength(0);
|
||||
return days > 0
|
||||
return (days > 0
|
||||
? STRING_FORMATTER.format("%d:%02d:%02d:%02d", days, hours, minutes, seconds)
|
||||
.toString()
|
||||
: hours > 0
|
||||
? STRING_FORMATTER.format("%d:%02d:%02d", hours, minutes, seconds).toString()
|
||||
: STRING_FORMATTER.format("%02d:%02d", minutes, seconds).toString();
|
||||
? STRING_FORMATTER.format("%d:%02d:%02d", hours, minutes, seconds)
|
||||
: STRING_FORMATTER.format("%02d:%02d", minutes, seconds)
|
||||
).toString();
|
||||
}
|
||||
|
||||
public static String formatSpeed(final double speed) {
|
||||
|
@ -186,7 +186,7 @@ public final class Localization {
|
||||
}
|
||||
|
||||
public static String shortCount(final Context context, final long count) {
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
return CompactDecimalFormat.getInstance(getAppLocale(context),
|
||||
CompactDecimalFormat.CompactStyle.SHORT).format(count);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package org.schabi.newpipe.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build.VERSION;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.SurfaceView;
|
||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||
@ -47,7 +46,8 @@ public class ExpandableSurfaceView extends SurfaceView {
|
||||
|
||||
if (resizeMode == RESIZE_MODE_FIT
|
||||
// KitKat doesn't work well when a view has a scale like needed for ZOOM
|
||||
|| (resizeMode == RESIZE_MODE_ZOOM && VERSION.SDK_INT < VERSION_CODES.LOLLIPOP)) {
|
||||
|| (resizeMode == RESIZE_MODE_ZOOM
|
||||
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)) {
|
||||
if (aspectDeformation > 0) {
|
||||
height = (int) (width / videoAspectRatio);
|
||||
} else {
|
||||
|
@ -270,7 +270,7 @@ public final class FocusOverlayView extends Drawable implements
|
||||
clearFocusObstacles((ViewGroup) decor);
|
||||
}
|
||||
|
||||
@RequiresApi(api = 26)
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
private static void clearFocusObstacles(final ViewGroup viewGroup) {
|
||||
viewGroup.setTouchscreenBlocksFocus(false);
|
||||
|
||||
|
@ -212,7 +212,7 @@ public class StoredDirectoryHelper {
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return docTree == null ? Uri.fromFile(ioTree).toString() : docTree.getUri().toString();
|
||||
return (docTree == null ? Uri.fromFile(ioTree) : docTree.getUri()).toString();
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,7 +29,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
@ -121,7 +120,7 @@ public class MissionAdapter extends Adapter<ViewHolder> implements Handler.Callb
|
||||
mContext = context;
|
||||
mDownloadManager = downloadManager;
|
||||
|
||||
mInflater = ContextCompat.getSystemService(mContext, LayoutInflater.class);
|
||||
mInflater = LayoutInflater.from(mContext);
|
||||
mLayout = R.layout.mission_item;
|
||||
|
||||
mHandler = new Handler(context.getMainLooper());
|
||||
|
@ -224,9 +224,10 @@ public class MissionsFragment extends Fragment {
|
||||
mList.setAdapter(mAdapter);
|
||||
|
||||
if (mSwitch != null) {
|
||||
mSwitch.setIcon(mLinear
|
||||
? ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_grid)
|
||||
: ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_list));
|
||||
mSwitch.setIcon(ThemeHelper.resolveResourceIdFromAttr(
|
||||
requireContext(), mLinear
|
||||
? R.attr.ic_grid
|
||||
: R.attr.ic_list));
|
||||
mSwitch.setTitle(mLinear ? R.string.grid : R.string.list);
|
||||
mPrefs.edit().putBoolean("linear", mLinear).apply();
|
||||
}
|
||||
|
@ -105,7 +105,8 @@
|
||||
|
||||
<PreferenceCategory
|
||||
android:layout="@layout/settings_category_header_layout"
|
||||
android:title="@string/settings_category_feed_title">
|
||||
android:title="@string/settings_category_feed_title"
|
||||
app:iconSpaceReserved="false">
|
||||
|
||||
<org.schabi.newpipe.settings.custom.DurationListPreference
|
||||
android:defaultValue="@string/feed_update_threshold_default_value"
|
||||
|
@ -1,18 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/settings_category_notification_title">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/settings_category_notification_title">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="@string/scale_to_square_image_in_notifications_key"
|
||||
android:summary="@string/notification_scale_to_square_image_summary"
|
||||
android:title="@string/notification_scale_to_square_image_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
android:defaultValue="false"
|
||||
android:key="@string/scale_to_square_image_in_notifications_key"
|
||||
android:summary="@string/notification_scale_to_square_image_summary"
|
||||
android:title="@string/notification_scale_to_square_image_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:layout="@layout/settings_category_header_layout"
|
||||
app:iconSpaceReserved="false">
|
||||
|
||||
<PreferenceCategory android:layout="@layout/settings_category_header_layout">
|
||||
<org.schabi.newpipe.settings.custom.NotificationActionsPreference />
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@ -84,7 +84,8 @@
|
||||
|
||||
<PreferenceCategory
|
||||
android:layout="@layout/settings_category_header_layout"
|
||||
android:title="@string/settings_category_player_behavior_title">
|
||||
android:title="@string/settings_category_player_behavior_title"
|
||||
app:iconSpaceReserved="false">
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@string/preferred_open_action_default"
|
||||
|
Loading…
Reference in New Issue
Block a user