This repository has been archived by the owner on Dec 11, 2024. It is now read-only.
forked from ReVanced/revanced-integrations
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
607 additions
and
211 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...rc/main/java/app/revanced/integrations/music/patches/components/ShareSheetMenuFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package app.revanced.integrations.music.patches.components; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
import app.revanced.integrations.shared.patches.components.Filter; | ||
import app.revanced.integrations.shared.patches.components.StringFilterGroup; | ||
import app.revanced.integrations.music.patches.misc.ShareSheetPatch; | ||
import app.revanced.integrations.music.settings.Settings; | ||
|
||
/** | ||
* Abuse LithoFilter for {@link ShareSheetPatch}. | ||
*/ | ||
public final class ShareSheetMenuFilter extends Filter { | ||
// Must be volatile or synchronized, as litho filtering runs off main thread and this field is then access from the main thread. | ||
public static volatile boolean isShareSheetMenuVisible; | ||
|
||
public ShareSheetMenuFilter() { | ||
addIdentifierCallbacks( | ||
new StringFilterGroup( | ||
Settings.CHANGE_SHARE_SHEET, | ||
"share_sheet_container.eml" | ||
) | ||
); | ||
} | ||
|
||
@Override | ||
public boolean isFiltered(String path, @Nullable String identifier, String allValue, byte[] protobufBufferArray, | ||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) { | ||
isShareSheetMenuVisible = true; | ||
|
||
return false; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/app/revanced/integrations/music/patches/misc/ShareSheetPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package app.revanced.integrations.music.patches.misc; | ||
|
||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import app.revanced.integrations.music.patches.components.ShareSheetMenuFilter; | ||
import app.revanced.integrations.music.settings.Settings; | ||
import app.revanced.integrations.shared.utils.Logger; | ||
import app.revanced.integrations.shared.utils.Utils; | ||
|
||
@SuppressWarnings("unused") | ||
public class ShareSheetPatch { | ||
/** | ||
* Injection point. | ||
*/ | ||
public static void onShareSheetMenuCreate(final RecyclerView recyclerView) { | ||
if (!Settings.CHANGE_SHARE_SHEET.get()) | ||
return; | ||
|
||
recyclerView.getViewTreeObserver().addOnDrawListener(() -> { | ||
try { | ||
if (!ShareSheetMenuFilter.isShareSheetMenuVisible) | ||
return; | ||
if (!(recyclerView.getChildAt(0) instanceof ViewGroup shareContainer)) { | ||
return; | ||
} | ||
if (!(shareContainer.getChildAt(shareContainer.getChildCount() - 1) instanceof ViewGroup shareWithOtherAppsView)) { | ||
return; | ||
} | ||
ShareSheetMenuFilter.isShareSheetMenuVisible = false; | ||
|
||
recyclerView.setVisibility(View.GONE); | ||
Utils.clickView(shareWithOtherAppsView); | ||
} catch (Exception ex) { | ||
Logger.printException(() -> "onShareSheetMenuCreate failure", ex); | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...src/main/java/app/revanced/integrations/youtube/patches/general/DownloadActionsPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package app.revanced.integrations.youtube.patches.general; | ||
|
||
import app.revanced.integrations.shared.settings.BooleanSetting; | ||
import app.revanced.integrations.shared.utils.Logger; | ||
import app.revanced.integrations.youtube.settings.Settings; | ||
import app.revanced.integrations.youtube.utils.VideoUtils; | ||
|
||
@SuppressWarnings("unused") | ||
public final class DownloadActionsPatch extends VideoUtils { | ||
|
||
private static final BooleanSetting overrideVideoDownloadButton = | ||
Settings.OVERRIDE_VIDEO_DOWNLOAD_BUTTON; | ||
|
||
private static final BooleanSetting overridePlaylistDownloadButton = | ||
Settings.OVERRIDE_PLAYLIST_DOWNLOAD_BUTTON; | ||
|
||
/** | ||
* Injection point. | ||
* <p> | ||
* Called from the in app download hook, | ||
* for both the player action button (below the video) | ||
* and the 'Download video' flyout option for feed videos. | ||
* <p> | ||
* Appears to always be called from the main thread. | ||
*/ | ||
public static boolean inAppVideoDownloadButtonOnClick(String videoId) { | ||
try { | ||
if (!overrideVideoDownloadButton.get()) { | ||
return false; | ||
} | ||
if (videoId == null || videoId.isEmpty()) { | ||
return false; | ||
} | ||
launchVideoExternalDownloader(videoId); | ||
|
||
return true; | ||
} catch (Exception ex) { | ||
Logger.printException(() -> "inAppVideoDownloadButtonOnClick failure", ex); | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Injection point. | ||
* <p> | ||
* Called from the in app playlist download hook. | ||
* <p> | ||
* Appears to always be called from the main thread. | ||
*/ | ||
public static String inAppPlaylistDownloadButtonOnClick(String playlistId) { | ||
try { | ||
if (!overridePlaylistDownloadButton.get()) { | ||
return playlistId; | ||
} | ||
if (playlistId == null || playlistId.isEmpty()) { | ||
return playlistId; | ||
} | ||
launchPlaylistExternalDownloader(playlistId); | ||
|
||
return ""; | ||
} catch (Exception ex) { | ||
Logger.printException(() -> "inAppPlaylistDownloadButtonOnClick failure", ex); | ||
} | ||
return playlistId; | ||
} | ||
|
||
/** | ||
* Injection point. | ||
*/ | ||
public static boolean overridePlaylistDownloadButtonVisibility() { | ||
return overridePlaylistDownloadButton.get(); | ||
} | ||
|
||
} |
28 changes: 0 additions & 28 deletions
28
app/src/main/java/app/revanced/integrations/youtube/patches/misc/HookDownloadAction.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.