Skip to content

Conversation

AndrianaBilali
Copy link
Contributor

@AndrianaBilali AndrianaBilali commented Jun 8, 2025

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

Adds two new options to the Backup & Restore settings screen:

  • "Export subscriptions": saves current subscriptions as a .json file
  • "Import subscriptions": restores subscriptions from a previously exported .json file

Reuses existing import/export logic via SubscriptionsImportService and SubscriptionsExportService. These are 2 .json files created for testing the feature:

Before/After Screenshots/Screen Record

Before After
Before After

Fixes the following issue(s)

Due diligence

@github-actions github-actions bot added the size/medium PRs with less than 250 changed lines label Jun 8, 2025
@ShareASmile ShareASmile added feature request Issue is related to a feature in the app import/export anything related to Import/export of data, subscriptions labels Jun 12, 2025
Copy link

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is a very nice addition to avoid user confusion!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code you added in this class should be deduplicated with respect to the code in SubscriptionFragment.kt. You could create a few utils functions in a new file SubscriptionsImportExportHelper.kt under app/src/main/java/org/schabi/newpipe/local/subscription/services, and call them both from here and from SubscriptionFragment.kt. Obviously the ActivityResultLauncher cannot be deduplicated, but the rest of the code should be.

private final ActivityResultLauncher<Intent> requestExportSubsLauncher =
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
this::requestExportSubsResult);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +28 to +29
android:title="Export subscriptions"
android:summary="Export your subscriptions to a .json file"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add new strings under strings.xml for these, otherwise they can't be translated

Comment on lines +35 to +36
android:title="Import subscriptions"
android:summary="Import subscriptions from a previous .json export"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

requireContext(), SubscriptionsExportService.class);
intent.putExtra(SubscriptionsExportService.KEY_FILE_PATH, fileUri);
requireContext().startService(intent);
Toast.makeText(requireContext(), R.string.exporting, Toast.LENGTH_SHORT).show();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of showing a Toast I would do the same as in SubscriptionFragment and show an ImportConfirmationDialog. This will come naturally after deduplicating the code.

);
intent.putExtra(SubscriptionsImportService.KEY_VALUE, fileUri);
requireContext().startService(intent);
Toast.makeText(requireContext(), R.string.importing, Toast.LENGTH_SHORT).show();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Toast is redundant with showToast(R.string.export_ongoing); in SubscriptionsExportService line 112, and should be removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issue is related to a feature in the app import/export anything related to Import/export of data, subscriptions size/medium PRs with less than 250 changed lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Subscription "Imports/Exports" to Settings/"Backup and restore" menu
3 participants