Skip to content

Commit

Permalink
Merge branch 'dev_newpipe' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/build.gradle
#	app/src/main/res/values-pt-rBR/strings.xml
#	app/src/main/res/values-sv/strings.xml
#	app/src/main/res/values-vi/strings.xml
#	app/src/main/res/values/strings.xml
#	fastlane/metadata/android/de/changelogs/990.txt
#	fastlane/metadata/android/es/changelogs/810.txt
#	fastlane/metadata/android/es/changelogs/961.txt
#	fastlane/metadata/android/es/changelogs/977.txt
  • Loading branch information
polymorphicshade committed Apr 24, 2024
2 parents ad42bf9 + 9828586 commit a9ec54f
Show file tree
Hide file tree
Showing 87 changed files with 1,509 additions and 562 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {
resValue "string", "app_name", "Tubular"
minSdk 21
targetSdk 33
versionCode 996
versionName "0.26.1_r3"
versionCode 997
versionName "0.27.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down Expand Up @@ -205,7 +205,7 @@ dependencies {
// name and the commit hash with the commit hash of the (pushed) commit you want to test
// This works thanks to JitPack: https://jitpack.io/
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
implementation 'com.github.polymorphicshade:TubularExtractor:fda50817e2574ef78efa5d27c9791e7bfe508795'
implementation 'com.github.polymorphicshade:TubularExtractor:062f70db5ac461fa5fe7a8d85a3690454d9eb4ae'
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'

/** Checkstyle **/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.schabi.newpipe.database.subscription;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
Expand Down Expand Up @@ -95,11 +96,12 @@ public void setName(final String name) {
this.name = name;
}

@Nullable
public String getAvatarUrl() {
return avatarUrl;
}

public void setAvatarUrl(final String avatarUrl) {
public void setAvatarUrl(@Nullable final String avatarUrl) {
this.avatarUrl = avatarUrl;
}

Expand Down
25 changes: 12 additions & 13 deletions app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -859,20 +859,19 @@ private void prepareSelectedDownload() {
return;
}

// Check for free memory space (for api 24 and up)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
final long freeSpace = mainStorage.getFreeMemory();
if (freeSpace <= size) {
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);
if (storageSettingsIntent.resolveActivity(context.getPackageManager()) != null) {
startActivity(storageSettingsIntent);
}
return;
// Check for free storage space
final long freeSpace = mainStorage.getFreeStorageSpace();
if (freeSpace <= size) {
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);
if (storageSettingsIntent.resolveActivity(context.getPackageManager())
!= null) {
startActivity(storageSettingsIntent);
}
return;
}

// check for existing file with the same name
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/org/schabi/newpipe/error/UserAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public enum UserAction {
USER_REPORT("user report"),
UI_ERROR("ui error"),
DATABASE_IMPORT_EXPORT("database import or export"),
SUBSCRIPTION_CHANGE("subscription change"),
SUBSCRIPTION_UPDATE("subscription update"),
SUBSCRIPTION_GET("get subscription"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Queue;
import java.util.function.Supplier;

import icepick.State;
import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.disposables.CompositeDisposable;

Expand All @@ -38,7 +39,8 @@ public final class CommentRepliesFragment

public static final String TAG = CommentRepliesFragment.class.getSimpleName();

private CommentsInfoItem commentsInfoItem; // the comment to show replies of
@State
CommentsInfoItem commentsInfoItem; // the comment to show replies of
private final CompositeDisposable disposables = new CompositeDisposable();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ private void setStreamCountAndOverallDuration(final List<StreamInfoItem> list,
Localization.concatenateStrings(
Localization.localizeStreamCount(activity, streamCount),
Localization.getDurationString(playlistOverallDurationSeconds,
isDurationComplete))
isDurationComplete, true))
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class FeedUpdateInfo(
@NotificationMode
val notificationMode: Int,
val name: String,
val avatarUrl: String,
val avatarUrl: String?,
val url: String,
val serviceId: Int,
// description and subscriberCount are null if the constructor info is from the fast feed method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,8 @@ private void setStreamCountAndOverallDuration(final ArrayList<LocalItem> itemsLi
headerBinding.playlistStreamCount.setText(
Localization.concatenateStrings(
Localization.localizeStreamCount(activity, streamCount),
Localization.getDurationString(playlistOverallDurationSeconds))
Localization.getDurationString(playlistOverallDurationSeconds,
true, true))
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ class SubscriptionManager(context: Context) {
val subscriptionEntity = subscriptionTable.getSubscription(info.uid)

subscriptionEntity.name = info.name
subscriptionEntity.avatarUrl = info.avatarUrl

// some services do not provide an avatar URL
info.avatarUrl?.let { subscriptionEntity.avatarUrl = it }

// these two fields are null if the feed info was fetched using the fast feed method
info.description?.let { subscriptionEntity.description = it }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;

import com.grack.nanojson.JsonParserException;

import org.schabi.newpipe.NewPipeDatabase;
import org.schabi.newpipe.R;
import org.schabi.newpipe.error.ErrorInfo;
import org.schabi.newpipe.error.ErrorUtil;
import org.schabi.newpipe.error.UserAction;
import org.schabi.newpipe.settings.export.BackupFileLocator;
import org.schabi.newpipe.settings.export.ImportExportManager;
import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard;
import org.schabi.newpipe.streams.io.StoredFileHelper;
import org.schabi.newpipe.util.NavigationHelper;
Expand All @@ -42,7 +48,7 @@ public class BackupRestoreSettingsFragment extends BasePreferenceFragment {

private final SimpleDateFormat exportDateFormat =
new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US);
private ContentSettingsManager manager;
private ImportExportManager manager;
private String importExportDataPathKey;
private final ActivityResultLauncher<Intent> requestImportPathLauncher =
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
Expand All @@ -57,8 +63,7 @@ public void onCreatePreferences(@Nullable final Bundle savedInstanceState,
@Nullable final String rootKey) {
final File homeDir = ContextCompat.getDataDir(requireContext());
Objects.requireNonNull(homeDir);
manager = new ContentSettingsManager(new NewPipeFileLocator(homeDir));
manager.deleteSettingsFile();
manager = new ImportExportManager(new BackupFileLocator(homeDir));

importExportDataPathKey = getString(R.string.import_export_data_path);

Expand Down Expand Up @@ -165,7 +170,7 @@ private void exportDatabase(final StoredFileHelper file, final Uri exportDataUri
Toast.makeText(requireContext(), R.string.export_complete_toast, Toast.LENGTH_SHORT)
.show();
} catch (final Exception e) {
ErrorUtil.showUiErrorSnackbar(this, "Exporting database", e);
showErrorSnackbar(e, "Exporting database and settings");
}
}

Expand All @@ -182,16 +187,21 @@ private void importDatabase(final StoredFileHelper file, final Uri importDataUri
throw new IOException("Could not create databases dir");
}

// replace the current database
if (!manager.extractDb(file)) {
Toast.makeText(requireContext(), R.string.could_not_import_all_files,
Toast.LENGTH_LONG)
.show();
}

// if settings file exist, ask if it should be imported.
if (manager.extractSettings(file)) {
final boolean hasJsonPrefs = manager.exportHasJsonPrefs(file);
if (hasJsonPrefs || manager.exportHasSerializedPrefs(file)) {
new androidx.appcompat.app.AlertDialog.Builder(requireContext())
.setTitle(R.string.import_settings)
.setMessage(hasJsonPrefs ? null : requireContext()
.getString(R.string.import_settings_vulnerable_format))
.setOnDismissListener(dialog -> finishImport(importDataUri))
.setNegativeButton(R.string.cancel, (dialog, which) -> {
dialog.dismiss();
finishImport(importDataUri);
Expand All @@ -201,7 +211,16 @@ private void importDatabase(final StoredFileHelper file, final Uri importDataUri
final Context context = requireContext();
final SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(context);
manager.loadSharedPreferences(prefs);
try {
if (hasJsonPrefs) {
manager.loadJsonPrefs(file, prefs);
} else {
manager.loadSerializedPrefs(file, prefs);
}
} catch (IOException | ClassNotFoundException | JsonParserException e) {
createErrorNotification(e, "Importing preferences");
return;
}
cleanImport(context, prefs);
finishImport(importDataUri);
})
Expand All @@ -210,7 +229,7 @@ private void importDatabase(final StoredFileHelper file, final Uri importDataUri
finishImport(importDataUri);
}
} catch (final Exception e) {
ErrorUtil.showUiErrorSnackbar(this, "Importing database", e);
showErrorSnackbar(e, "Importing database and settings");
}
}

Expand Down Expand Up @@ -247,7 +266,7 @@ private void cleanImport(@NonNull final Context context,
}

/**
* Save import path and restart system.
* Save import path and restart app.
*
* @param importDataUri The import path to save
*/
Expand All @@ -268,4 +287,15 @@ private void saveLastImportExportDataUri(final Uri importExportDataUri) {
.putString(importExportDataPathKey, importExportDataUri.toString());
editor.apply();
}

private void showErrorSnackbar(final Throwable e, final String request) {
ErrorUtil.showSnackbar(this, new ErrorInfo(e, UserAction.DATABASE_IMPORT_EXPORT, request));
}

private void createErrorNotification(final Throwable e, final String request) {
ErrorUtil.createNotification(
requireContext(),
new ErrorInfo(e, UserAction.DATABASE_IMPORT_EXPORT, request)
);
}
}

This file was deleted.

Loading

0 comments on commit a9ec54f

Please sign in to comment.