Skip to content
Closed
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
8 changes: 3 additions & 5 deletions app/src/main/java/org/schabi/newpipe/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -121,7 +120,7 @@ public void onCreate() {
ServiceHelper.initServices(this);

// Initialize image loader
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
final var prefs = PreferenceManager.getDefaultSharedPreferences(this);
PicassoHelper.init(this);
ImageStrategy.setPreferredImageQuality(PreferredImageQuality.fromPreferenceKey(this,
prefs.getString(getString(R.string.image_quality_key),
Expand All @@ -147,8 +146,7 @@ protected Downloader getDownloader() {
}

protected void setCookiesToDownloader(final DownloaderImpl downloader) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(
getApplicationContext());
final var prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
final String key = getApplicationContext().getString(R.string.recaptcha_cookies_key);
downloader.setCookie(ReCaptchaActivity.RECAPTCHA_COOKIES_KEY, prefs.getString(key, null));
downloader.updateYoutubeRestrictedModeCookies(getApplicationContext());
Expand Down Expand Up @@ -178,7 +176,7 @@ public void accept(@NonNull final Throwable throwable) {
errors = List.of(actualThrowable);
}

for (final Throwable error : errors) {
for (final var error : errors) {
if (isThrowableIgnored(error)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/schabi/newpipe/ExitActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class ExitActivity extends Activity {

public static void exitAndRemoveFromRecentApps(final Activity activity) {
final Intent intent = new Intent(activity, ExitActivity.class);
final var intent = new Intent(activity, ExitActivity.class);

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,14 @@ private void showServices() {
}

private void enhancePeertubeMenu(final MenuItem menuItem) {
final PeertubeInstance currentInstance = PeertubeHelper.getCurrentInstance();
final var currentInstance = PeertubeHelper.getCurrentInstance();
menuItem.setTitle(currentInstance.getName());
final Spinner spinner = InstanceSpinnerLayoutBinding.inflate(LayoutInflater.from(this))
.getRoot();
final List<PeertubeInstance> instances = PeertubeHelper.getInstanceList(this);
final List<String> items = new ArrayList<>();
int defaultSelect = 0;
for (final PeertubeInstance instance : instances) {
for (final var instance : instances) {
items.add(instance.getName());
if (instance.getUrl().equals(currentInstance.getUrl())) {
defaultSelect = items.size() - 1;
Expand Down Expand Up @@ -895,7 +895,7 @@ public void onReceive(final Context context, final Intent intent) {
}
}
};
final IntentFilter intentFilter = new IntentFilter();
final var intentFilter = new IntentFilter();
intentFilter.addAction(VideoDetailFragment.ACTION_PLAYER_STARTED);
ContextCompat.registerReceiver(this, broadcastReceiver, intentFilter,
ContextCompat.RECEIVER_EXPORTED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

/*
Expand Down Expand Up @@ -30,7 +29,7 @@ public class PanicResponderActivity extends Activity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Intent intent = getIntent();
final var intent = getIntent();
if (intent != null && PANIC_TRIGGER_ACTION.equals(intent.getAction())) {
// TODO: Explicitly clear the search results
// once they are restored when the app restarts
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ public static void openPopupMenu(final PlayQueue playQueue,
final boolean hideDetails,
final FragmentManager fragmentManager,
final Context context) {
final ContextThemeWrapper themeWrapper =
new ContextThemeWrapper(context, R.style.DarkPopupMenu);

final PopupMenu popupMenu = new PopupMenu(themeWrapper, view);
final var themeWrapper = new ContextThemeWrapper(context, R.style.DarkPopupMenu);
final var popupMenu = new PopupMenu(themeWrapper, view);
popupMenu.inflate(R.menu.menu_play_queue_item);

if (hideDetails) {
Expand Down
28 changes: 12 additions & 16 deletions app/src/main/java/org/schabi/newpipe/RouterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -263,7 +262,7 @@ private static void handleError(final Context context, final ErrorInfo errorInfo
if (errorInfo.getRecaptchaUrl() != null) {
Toast.makeText(context, R.string.recaptcha_request_toast, Toast.LENGTH_LONG).show();
// Starting ReCaptcha Challenge Activity
final Intent intent = new Intent(context, ReCaptchaActivity.class);
final var intent = new Intent(context, ReCaptchaActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(ReCaptchaActivity.RECAPTCHA_URL_EXTRA, errorInfo.getRecaptchaUrl());
context.startActivity(intent);
Expand All @@ -281,7 +280,7 @@ private static void handleError(final Context context, final ErrorInfo errorInfo
}

protected void showUnsupportedUrlDialog(final String url) {
final Context context = getThemeWrapperContext();
final var context = getThemeWrapperContext();
new AlertDialog.Builder(context)
.setTitle(R.string.unsupported_url)
.setMessage(R.string.unsupported_url_dialog_message)
Expand All @@ -296,10 +295,9 @@ protected void showUnsupportedUrlDialog(final String url) {
}

protected void onSuccess() {
final SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(this);
final var preferences = PreferenceManager.getDefaultSharedPreferences(this);

final ChoiceAvailabilityChecker choiceChecker = new ChoiceAvailabilityChecker(
final var choiceChecker = new ChoiceAvailabilityChecker(
getChoicesForService(currentService, currentLinkType),
preferences.getString(getString(R.string.preferred_open_action_key),
getString(R.string.preferred_open_action_default)));
Expand Down Expand Up @@ -411,7 +409,7 @@ public boolean isAvailableAndSelected(@StringRes final int wantedKey) {
}

private void showDialog(final List<AdapterChoiceItem> choices) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final var preferences = PreferenceManager.getDefaultSharedPreferences(this);

final Context themeWrapperContext = getThemeWrapperContext();
final LayoutInflater layoutInflater = LayoutInflater.from(themeWrapperContext);
Expand Down Expand Up @@ -564,8 +562,7 @@ private List<AdapterChoiceItem> getChoicesForService(final StreamingService serv
} else {
// LinkType.NONE is never present because it's filtered out before
// channels and playlist can be played as they contain a list of videos
final SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(this);
final var preferences = PreferenceManager.getDefaultSharedPreferences(this);
final boolean isExtVideoEnabled = preferences.getBoolean(
getString(R.string.use_external_video_player_key), false);
final boolean isExtAudioEnabled = preferences.getBoolean(
Expand Down Expand Up @@ -602,7 +599,7 @@ private void setDialogButtonsState(final AlertDialog dialog, final boolean state
private void handleText() {
final String searchString = getIntent().getStringExtra(Intent.EXTRA_TEXT);
final int serviceId = getIntent().getIntExtra(Constants.KEY_SERVICE_ID, 0);
final Intent intent = new Intent(getThemeWrapperContext(), MainActivity.class);
final var intent = new Intent(getThemeWrapperContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
NavigationHelper.openSearch(getThemeWrapperContext(), serviceId, searchString);
Expand Down Expand Up @@ -657,8 +654,8 @@ private void handleChoice(final String selectedChoiceKey) {
return;
}

final Intent intent = new Intent(this, FetcherService.class);
final Choice choice = new Choice(currentService.getServiceId(), currentLinkType,
final var intent = new Intent(this, FetcherService.class);
final var choice = new Choice(currentService.getServiceId(), currentLinkType,
currentUrl, selectedChoiceKey);
intent.putExtra(FetcherService.KEY_CHOICE, choice);
startService(intent);
Expand Down Expand Up @@ -772,7 +769,7 @@ public void onResume(@NonNull final LifecycleOwner owner) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q
&& !context.isChangingConfigurations()) {
// try to bring the activity back to front if minimised
final Intent i = new Intent(context, RouterActivity.class);
final var i = new Intent(context, RouterActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(i);
}
Expand Down Expand Up @@ -946,7 +943,7 @@ protected void onHandleIntent(@Nullable final Intent intent) {
if (!(serializable instanceof Choice)) {
return;
}
final Choice playerChoice = (Choice) serializable;
final var playerChoice = (Choice) serializable;
handleChoice(playerChoice);
}

Expand Down Expand Up @@ -992,8 +989,7 @@ public Consumer<Info> getResultHandler(final Choice choice) {
final String backgroundPlayerKey = getString(R.string.background_player_key);
final String popupPlayerKey = getString(R.string.popup_player_key);

final SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(this);
final var preferences = PreferenceManager.getDefaultSharedPreferences(this);
final boolean isExtVideoEnabled = preferences.getBoolean(
getString(R.string.use_external_video_player_key), false);
final boolean isExtAudioEnabled = preferences.getBoolean(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.ViewTreeObserver;

Expand All @@ -27,7 +26,7 @@ public class DownloadActivity extends AppCompatActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
// Service
final Intent i = new Intent();
final var i = new Intent();
i.setClass(this, DownloadManagerService.class);
startService(i);

Expand Down Expand Up @@ -74,7 +73,7 @@ private void updateFragments() {
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
super.onCreateOptionsMenu(menu);
final MenuInflater inflater = getMenuInflater();
final var inflater = getMenuInflater();

inflater.inflate(R.menu.download_menu, menu);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public void onCreate(@Nullable final Bundle savedInstanceState) {
this.subtitleStreamsAdapter = new StreamItemAdapter<>(wrappedSubtitleStreams);
updateSecondaryStreams();

final Intent intent = new Intent(context, DownloadManagerService.class);
final var intent = new Intent(context, DownloadManagerService.class);
context.startService(intent);

context.bindService(intent, new ServiceConnection() {
Expand Down Expand Up @@ -248,16 +248,16 @@ public void onServiceDisconnected(final ComponentName name) {
* Update the displayed video streams based on the selected audio track.
*/
private void updateSecondaryStreams() {
final StreamInfoWrapper<AudioStream> audioStreams = getWrappedAudioStreams();
final var audioStreams = getWrappedAudioStreams();
final var secondaryStreams = new SparseArrayCompat<SecondaryStreamHelper<AudioStream>>(4);
final List<VideoStream> videoStreams = wrappedVideoStreams.getStreamsList();
final var videoStreams = wrappedVideoStreams.getStreamsList();
wrappedVideoStreams.resetInfo();

for (int i = 0; i < videoStreams.size(); i++) {
if (!videoStreams.get(i).isVideoOnly()) {
continue;
}
final AudioStream audioStream = SecondaryStreamHelper.getAudioStreamFor(
final var audioStream = SecondaryStreamHelper.getAudioStreamFor(
context, audioStreams.getStreamsList(), videoStreams.get(i));

if (audioStream != null) {
Expand Down Expand Up @@ -717,7 +717,7 @@ private int getSubtitleIndexBy(@NonNull final List<SubtitlesStream> streams) {

int candidate = 0;
for (int i = 0; i < streams.size(); i++) {
final Locale streamLocale = streams.get(i).getLocale();
final var streamLocale = streams.get(i).getLocale();

final boolean languageEquals = streamLocale.getLanguage() != null
&& preferredLocalization.getLanguageCode() != null
Expand Down Expand Up @@ -860,8 +860,7 @@ private void prepareSelectedDownload() {
Toast.makeText(context, getString(R.
string.error_insufficient_storage), Toast.LENGTH_LONG).show();
// move the user to storage setting tab
final Intent storageSettingsIntent = new Intent(Settings.
ACTION_INTERNAL_STORAGE_SETTINGS);
final var storageSettingsIntent = new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS);
if (storageSettingsIntent.resolveActivity(context.getPackageManager())
!= null) {
startActivity(storageSettingsIntent);
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.view.MenuInflater;
import android.view.MenuItem;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.IntentCompat;
Expand Down Expand Up @@ -85,11 +84,11 @@ protected void onCreate(final Bundle savedInstanceState) {
activityErrorBinding = ActivityErrorBinding.inflate(getLayoutInflater());
setContentView(activityErrorBinding.getRoot());

final Intent intent = getIntent();
final var intent = getIntent();

setSupportActionBar(activityErrorBinding.toolbarLayout.toolbar);

final ActionBar actionBar = getSupportActionBar();
final var actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(R.string.error_report_title);
Expand Down Expand Up @@ -157,7 +156,7 @@ private void openPrivacyPolicyDialog(final Context context, final String action)
context.getString(R.string.privacy_policy_url)))
.setPositiveButton(R.string.accept, (dialog, which) -> {
if (action.equals("EMAIL")) { // send on email
final Intent i = new Intent(Intent.ACTION_SENDTO)
final var i = new Intent(Intent.ACTION_SENDTO)
.setData(Uri.parse("mailto:")) // only email apps should handle this
.putExtra(Intent.EXTRA_EMAIL, new String[]{ERROR_EMAIL_ADDRESS})
.putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
Expand Down Expand Up @@ -148,7 +147,7 @@ private void saveCookiesAndFinish() {

if (!foundCookies.isEmpty()) {
// save cookies to preferences
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(
final var prefs = PreferenceManager.getDefaultSharedPreferences(
getApplicationContext());
final String key = getApplicationContext().getString(R.string.recaptcha_cookies_key);
prefs.edit().putString(key, foundCookies).apply();
Expand All @@ -161,7 +160,7 @@ private void saveCookiesAndFinish() {
// Navigate to blank page (unloads youtube to prevent background playback)
recaptchaBinding.reCaptchaWebView.loadUrl("about:blank");

final Intent intent = new Intent(this, org.schabi.newpipe.MainActivity.class);
final var intent = new Intent(this, org.schabi.newpipe.MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
NavUtils.navigateUpTo(this, intent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class EmptyFragment extends BaseFragment {
private static final String SHOW_MESSAGE = "SHOW_MESSAGE";

public static final EmptyFragment newInstance(final boolean showMessage) {
final EmptyFragment emptyFragment = new EmptyFragment();
final var emptyFragment = new EmptyFragment();
final Bundle bundle = new Bundle(1);
bundle.putBoolean(SHOW_MESSAGE, showMessage);
emptyFragment.setArguments(bundle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected void addImagesMetadataItem(final LayoutInflater inflater,
itemBinding.metadataTypeView.setText(type);

final SpannableStringBuilder urls = new SpannableStringBuilder();
for (final Image image : images) {
for (final var image : images) {
if (urls.length() != 0) {
urls.append(", ");
}
Expand Down Expand Up @@ -255,7 +255,7 @@ private void addTagsMetadataItem(final LayoutInflater inflater, final LinearLayo
final var itemBinding = ItemMetadataTagsBinding.inflate(inflater, layout, false);

tags.stream().sorted(String.CASE_INSENSITIVE_ORDER).forEach(tag -> {
final Chip chip = (Chip) inflater.inflate(R.layout.chip,
final var chip = (Chip) inflater.inflate(R.layout.chip,
itemBinding.metadataTagsChips, false);
chip.setText(tag);
chip.setOnClickListener(this::onTagClick);
Expand Down
Loading