Skip to content

Commit

Permalink
refactor(Twitter): Added toggle for Show sensitive media patch
Browse files Browse the repository at this point in the history
  • Loading branch information
swakwork committed Nov 25, 2024
1 parent b5dc850 commit a7a991c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/app/revanced/integrations/twitter/Pref.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public static float setPostFontSize() {
}
return fontSize;
}
public static boolean showSensitiveMedia() {
return Utils.getBooleanPerf(Settings.TIMELINE_SHOW_SENSITIVE_MEDIA);
}

public static boolean enableNativeDownloader() {
return Utils.getBooleanPerf(Settings.VID_NATIVE_DOWNLOADER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import com.twitter.model.json.timeline.urt.JsonTimelineEntry;
import com.twitter.model.json.timeline.urt.JsonTimelineModuleItem;
import com.twitter.model.json.core.JsonSensitiveMediaWarning;

import app.revanced.integrations.twitter.Pref;
import app.revanced.integrations.twitter.settings.SettingsStatus;

public class TimelineEntry {
private static final boolean hideAds,hideGAds,hideWTF,hideCTS,hideCTJ,hideDetailedPosts,hideRBMK,hidePinnedPosts,hidePremiumPrompt,hideMainEvent,hideSuperheroEvent,hideVideosForYou;
private static final boolean hideAds,hideGAds,hideWTF,hideCTS,hideCTJ,hideDetailedPosts,hideRBMK,hidePinnedPosts,hidePremiumPrompt,hideMainEvent,hideSuperheroEvent,hideVideosForYou,showSensitiveMedia;
static {
hideAds = (Pref.hideAds() && SettingsStatus.hideAds);
hideGAds = (Pref.hideGoogleAds() && SettingsStatus.hideGAds);
Expand All @@ -21,6 +22,7 @@ public class TimelineEntry {
hideMainEvent = (Pref.hideMainEvent() && SettingsStatus.hideMainEvent);
hideSuperheroEvent = (Pref.hideSuperheroEvent() && SettingsStatus.hideSuperheroEvent);
hideVideosForYou = (Pref.hideVideosForYou() && SettingsStatus.hideVideosForYou);
showSensitiveMedia = Pref.showSensitiveMedia();
}


Expand Down Expand Up @@ -92,5 +94,18 @@ public static JsonTimelineModuleItem checkEntry(JsonTimelineModuleItem jsonTimel
return jsonTimelineModuleItem;
}

public static JsonSensitiveMediaWarning sensitiveMedia(JsonSensitiveMediaWarning jsonSensitiveMediaWarning) {
try {
if(showSensitiveMedia){
jsonSensitiveMediaWarning.a = false;
jsonSensitiveMediaWarning.b = false;
jsonSensitiveMediaWarning.c = false;
}
} catch (Exception unused) {

}
return jsonSensitiveMediaWarning;
}

//end
}
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,15 @@ public void buildTimelineSection(boolean buildCategory){
)
);
}
if (SettingsStatus.showSensitiveMedia) {
addPreference(category,
helper.switchPreference(
strRes("piko_pref_show_sensitive_media"),
"",
Settings.TIMELINE_SHOW_SENSITIVE_MEDIA
)
);
}
}

public void buildExportSection(boolean buildCategory){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting TIMELINE_ENABLE_VID_AUTO_ADVANCE = new BooleanSetting("timeline_enable_vid_auto_advance", true);
public static final BooleanSetting TIMELINE_ENABLE_VID_FORCE_HD = new BooleanSetting("timeline_enable_vid_force_hd", true);
public static final BooleanSetting TIMELINE_HIDE_NUDGE_BUTTON = new BooleanSetting("timeline_hide_nudge_button", false);
public static final BooleanSetting TIMELINE_SHOW_SENSITIVE_MEDIA = new BooleanSetting("timeline_show_sensitive_media", true);

public static final BooleanSetting PREMIUM_READER_MODE = new BooleanSetting("premium_reader_mode", false);
public static final BooleanSetting PREMIUM_UNDO_POSTS = new BooleanSetting("premium_undo_posts", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public static void inlineBarCustomisation() {
}

public static boolean enableTimelineSection() {
return ( hideNudgeButton || disableAutoTimelineScroll || forceTranslate || hidePromoteButton || hideCommunityNote || hideLiveThreads || hideBanner || hideInlineBmk || showPollResultsEnabled || hideImmersivePlayer || enableVidAutoAdvance || enableForceHD);
return ( showSensitiveMedia || hideNudgeButton || disableAutoTimelineScroll || forceTranslate || hidePromoteButton || hideCommunityNote || hideLiveThreads || hideBanner || hideInlineBmk || showPollResultsEnabled || hideImmersivePlayer || enableVidAutoAdvance || enableForceHD);
}

public static boolean enableMiscSection() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.twitter.model.json.core;

public class JsonSensitiveMediaWarning {
public boolean a;
public boolean b;
public boolean c;
}

0 comments on commit a7a991c

Please sign in to comment.