Skip to content
This repository was archived by the owner on Oct 26, 2024. It is now read-only.

Commit 27d1392

Browse files
LisoUseInAIKyriosoSumAtrIX
authored andcommitted
fix(youtube): resolve duplicate preference keys (#307)
1 parent 49aedae commit 27d1392

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
public enum SettingsEnum {
1212
//Download Settings
1313
// TODO: DOWNLOAD_PATH("revanced_download_path", Environment.getExternalStorageDirectory().getPath() + "/Download", ReturnType.STRING),
14-
DOWNLOADS_BUTTON_SHOWN("revanced_downloads", true, ReturnType.BOOLEAN, true),
14+
DOWNLOADS_BUTTON_SHOWN("revanced_downloads_enabled", true, ReturnType.BOOLEAN, true),
1515
DOWNLOADS_PACKAGE_NAME("revanced_downloads_package_name", "org.schabi.newpipe" /* NewPipe */, ReturnType.STRING),
1616

1717
// Copy video URL settings
18-
COPY_VIDEO_URL_BUTTON_SHOWN("revanced_copy_video_url", true, ReturnType.BOOLEAN, true),
19-
COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN("revanced_copy_video_url_timestamp", true, ReturnType.BOOLEAN, true),
18+
COPY_VIDEO_URL_BUTTON_SHOWN("revanced_copy_video_url_enabled", true, ReturnType.BOOLEAN, true),
19+
COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN("revanced_copy_video_url_timestamp_enabled", true, ReturnType.BOOLEAN, true),
2020

2121
// Video settings
2222
OLD_STYLE_VIDEO_QUALITY_PLAYER_SETTINGS("revanced_use_old_style_quality_settings", true, ReturnType.BOOLEAN),
@@ -179,7 +179,13 @@ public enum SettingsEnum {
179179
@Deprecated
180180
DEPRECATED_BRANDING_SHOWN("revanced_branding_watermark_enabled", false, ReturnType.BOOLEAN),
181181
@Deprecated
182-
DEPRECATED_REMEMBER_VIDEO_QUALITY("revanced_remember_video_quality_selection", false, ReturnType.BOOLEAN);
182+
DEPRECATED_REMEMBER_VIDEO_QUALITY("revanced_remember_video_quality_selection", false, ReturnType.BOOLEAN),
183+
@Deprecated
184+
DEPRECATED_DOWNLOADS_BUTTON_SHOWN("revanced_downloads", true, ReturnType.BOOLEAN, true),
185+
@Deprecated
186+
DEPRECATED_COPY_VIDEO_URL_BUTTON_SHOWN("revanced_copy_video_url", true, ReturnType.BOOLEAN, true),
187+
@Deprecated
188+
DEPRECATED_COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN("revanced_copy_video_url_timestamp", true, ReturnType.BOOLEAN, true);
183189
//
184190
// end deprecated settings
185191
//
@@ -250,7 +256,7 @@ public enum SettingsEnum {
250256
}
251257

252258
//
253-
// migrate preference of prior 'default off' settings, into replacement setting with different path name but otherwise is identical
259+
// renamed settings with new path names, but otherwise the new and old settings are identical
254260
//
255261
SettingsEnum[][] renamedSettings = {
256262
{DEPRECATED_HIDE_MIX_PLAYLISTS, HIDE_MIX_PLAYLISTS},
@@ -260,16 +266,19 @@ public enum SettingsEnum {
260266
{DEPRECATED_HIDE_PLAYLIST_BUTTON, HIDE_PLAYLIST_BUTTON},
261267
{DEPRECATED_HIDE_ACTION_BUTTON, HIDE_ACTION_BUTTON},
262268
{DEPRECATED_HIDE_SHARE_BUTTON, HIDE_SHARE_BUTTON},
269+
{DEPRECATED_DOWNLOADS_BUTTON_SHOWN, DOWNLOADS_BUTTON_SHOWN},
270+
{DEPRECATED_COPY_VIDEO_URL_BUTTON_SHOWN, COPY_VIDEO_URL_BUTTON_SHOWN},
271+
{DEPRECATED_COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN, COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN},
263272
};
264273
for (SettingsEnum[] oldNewSetting : renamedSettings) {
265274
SettingsEnum oldSetting = oldNewSetting[0];
266275
SettingsEnum newSetting = oldNewSetting[1];
267276

268-
if (oldSetting.getBoolean()) {
269-
LogHelper.printInfo(() -> "Migrating enabled setting from: " + oldSetting
270-
+ " into replacement setting: " + newSetting);
271-
newSetting.saveValue(true);
272-
oldSetting.saveValue(false);
277+
if (!oldSetting.value.equals(oldSetting.defaultValue)) {
278+
LogHelper.printInfo(() -> "Migrating old setting of '" + oldSetting.value
279+
+ "' from: " + oldSetting + " into replacement setting: " + newSetting);
280+
newSetting.saveValue(oldSetting.value);
281+
oldSetting.saveValue(oldSetting.getDefaultValue()); // reset old value
273282
}
274283
}
275284
//

0 commit comments

Comments
 (0)