forked from ReVanced/revanced-patches-template
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into revanced-extended
- Loading branch information
Showing
308 changed files
with
9,566 additions
and
5,983 deletions.
There are no files selected for viewing
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
66 changes: 43 additions & 23 deletions
66
.../shared/src/main/java/app/revanced/extension/music/patches/ads/PremiumPromotionPatch.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 |
---|---|---|
@@ -1,40 +1,60 @@ | ||
package app.revanced.extension.music.patches.ads; | ||
|
||
import static app.revanced.extension.music.patches.general.GeneralPatch.disableDimBehind; | ||
import static app.revanced.extension.shared.utils.StringRef.str; | ||
|
||
import android.app.Dialog; | ||
import android.content.DialogInterface; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.LinearLayout; | ||
|
||
import app.revanced.extension.music.settings.Settings; | ||
import app.revanced.extension.shared.settings.BaseSettings; | ||
import app.revanced.extension.shared.utils.Logger; | ||
import app.revanced.extension.shared.utils.Utils; | ||
|
||
@SuppressWarnings("unused") | ||
public class PremiumPromotionPatch { | ||
private static final boolean HIDE_PREMIUM_PROMOTION = | ||
Settings.HIDE_PREMIUM_PROMOTION.get(); | ||
|
||
public static void hidePremiumPromotion(View view) { | ||
if (!Settings.HIDE_PREMIUM_PROMOTION.get()) | ||
return; | ||
|
||
view.getViewTreeObserver().addOnGlobalLayoutListener(() -> { | ||
try { | ||
if (!(view instanceof ViewGroup viewGroup)) { | ||
return; | ||
} | ||
if (!(viewGroup.getChildAt(0) instanceof ViewGroup mealBarLayoutRoot)) { | ||
return; | ||
} | ||
if (!(mealBarLayoutRoot.getChildAt(0) instanceof LinearLayout linearLayout)) { | ||
return; | ||
public static void hidePremiumPromotionBottomSheet(View view) { | ||
if (HIDE_PREMIUM_PROMOTION) { | ||
view.getViewTreeObserver().addOnGlobalLayoutListener(() -> { | ||
try { | ||
if (!(view instanceof ViewGroup viewGroup)) { | ||
return; | ||
} | ||
if (!(viewGroup.getChildAt(0) instanceof ViewGroup mealBarLayoutRoot)) { | ||
return; | ||
} | ||
if (!(mealBarLayoutRoot.getChildAt(0) instanceof LinearLayout linearLayout)) { | ||
return; | ||
} | ||
if (!(linearLayout.getChildAt(0) instanceof ImageView imageView)) { | ||
return; | ||
} | ||
if (imageView.getVisibility() == View.VISIBLE) { | ||
view.setVisibility(View.GONE); | ||
} | ||
} catch (Exception ex) { | ||
Logger.printException(() -> "hidePremiumPromotionBottomSheet failure", ex); | ||
} | ||
if (!(linearLayout.getChildAt(0) instanceof ImageView imageView)) { | ||
return; | ||
} | ||
if (imageView.getVisibility() == View.VISIBLE) { | ||
view.setVisibility(View.GONE); | ||
} | ||
} catch (Exception ex) { | ||
Logger.printException(() -> "hideGetPremium failure", ex); | ||
}); | ||
} | ||
} | ||
|
||
public static void hidePremiumPromotionDialog(Dialog dialog, View contentView) { | ||
if (HIDE_PREMIUM_PROMOTION) { | ||
disableDimBehind(dialog.getWindow()); | ||
dialog.setOnShowListener(DialogInterface::dismiss); | ||
if (BaseSettings.ENABLE_DEBUG_LOGGING.get()) { | ||
Utils.showToastShort(str("revanced_hide_premium_promotion_closed_toast")); | ||
} | ||
}); | ||
} else { | ||
dialog.setContentView(contentView); | ||
} | ||
} | ||
} |
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
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.