diff --git a/app/src/main/java/nethical/digipaws/data/BlockerData.java b/app/src/main/java/nethical/digipaws/data/BlockerData.java index 28c8d14..b3c0ee9 100644 --- a/app/src/main/java/nethical/digipaws/data/BlockerData.java +++ b/app/src/main/java/nethical/digipaws/data/BlockerData.java @@ -1,218 +1,219 @@ package nethical.digipaws.data; + +import java.util.HashMap; import nethical.digipaws.utils.DigiConstants; public class BlockerData { - + + public static final String[] shortsViewIds = { - "com.google.android.youtube" + DigiConstants.VIEWID_SEPERATOR + "reel_recycler", - "app.revanced.android.youtube"+ DigiConstants.VIEWID_SEPERATOR +"reel_recycler", - "com.instagram.android" + DigiConstants.VIEWID_SEPERATOR + "root_clips_layout" + "com.google.android.youtube" + DigiConstants.VIEWID_SEPERATOR + "reel_recycler", + "app.revanced.android.youtube"+ DigiConstants.VIEWID_SEPERATOR +"reel_recycler", + "com.instagram.android" + DigiConstants.VIEWID_SEPERATOR + "root_clips_layout" }; - - // This list consists applications solely made for the purpose of doom scrolling - public static final String[] shortsApplications = { - "com.ss.android.ugc", //tiktok asia - "com.zhiliaoapp.musically", //tiktok global - "com.instagram.lite" // has no unnique ids on reels tab, hence just blocked the entire app lmao - }; - + + public static final HashMap shortsApplications = new HashMap() {{ + put("com.ss.android.ugc", null); // TikTok Asia + put("com.zhiliaoapp.musically", null); // TikTok Global + put("com.instagram.lite", null); // Blocked entire app + }}; + public static final String[] engagementPanelViewIds = { - "com.google.android.youtube" + DigiConstants.VIEWID_SEPERATOR + "engagement_panel_content", - "app.revanced.android.youtube"+ DigiConstants.VIEWID_SEPERATOR +"engagement_panel_content", - "com.instagram.android" + DigiConstants.VIEWID_SEPERATOR + "comment_composer_parent", - "com.ss.android.ugc" + DigiConstants.VIEWID_SEPERATOR + "c5g", //tiktok asia - "com.zhiliaoapp.musically" + DigiConstants.VIEWID_SEPERATOR + "c5g" //tiktok global + "com.google.android.youtube" + DigiConstants.VIEWID_SEPERATOR + "engagement_panel_content", + "app.revanced.android.youtube"+ DigiConstants.VIEWID_SEPERATOR +"engagement_panel_content", + "com.instagram.android" + DigiConstants.VIEWID_SEPERATOR + "comment_composer_parent", + "com.ss.android.ugc" + DigiConstants.VIEWID_SEPERATOR + "c5g", //tiktok asia + "com.zhiliaoapp.musically" + DigiConstants.VIEWID_SEPERATOR + "c5g" //tiktok global }; - + public static final String[] rebootViewIds = { - "oppo" + DigiConstants.VIEWID_SEPERATOR + "oppo_power_shutdown_tv_id", - "androidhwext"+ DigiConstants.VIEWID_SEPERATOR +"hw_new_global_actions_view" + "oppo" + DigiConstants.VIEWID_SEPERATOR + "oppo_power_shutdown_tv_id", + "androidhwext"+ DigiConstants.VIEWID_SEPERATOR +"hw_new_global_actions_view" }; - - - public static final String[] nonBlockedPackages = { - "com.google.android.dialer", // Google Dialer - "com.google.android.apps.messaging", - "nethical.digipaws", // DigiPaws - "com.google.android.deskclock", // Google Clock - "com.android.systemui", // Android System UI - "com.android.phone", // Android Phone - // Launchers - "com.google.android.apps.nexuslauncher", // Google Pixel Launcher - "com.microsoft.launcher", // Microsoft Launcher - "com.teslacoilsw.launcher", // Nova Launcher - "net.oneplus.launcher", // OnePlus Launcher - "com.sec.android.app.launcher", // Samsung One UI Home - "com.actionlauncher.playstore", // Action Launcher - "com.laucher.smart", // Smart Launcher - "ginlemon.flowerfree", // Smart Launcher 5 - "com.tsf.shell", // TSF Launcher - // Productive apps - "com.google.android.keep", // Google Keep - "com.microsoft.todos", // Microsoft To Do - "com.evernote", // Evernote - "com.todoist", // Todoist - "com.ticktick.task", // TickTick - "com.google.android.apps.docs", // Google Docs - "com.google.android.apps.sheets", // Google Sheets - "com.google.android.apps.slides", // Google Slides - "com.google.android.calendar", // Google Calendar - "com.microsoft.office.officehubrow", // Microsoft Office - "com.google.android.apps.tasks", // Google Tasks - "com.asana.app", // Asana - "com.trello", // Trello - "com.nutomic.syncthingandroid", // Syncthing - "com.slack", // Slack - "com.google.android.gm", // Gmail - "com.pushbullet.android", // Pushbullet - "com.teams.microsoft", // Microsoft Teams - "com.dropbox.android", // Dropbox - "com.box.android", // Box - "com.google.android.apps.meetings", // Google Meet - "com.zoho.crm", // Zoho CRM - "com.todoist", // Todoist - "com.anydo", // Any.do - "com.notion.id", // Notion - "com.mindjet.mindmanager", // MindManager - "com.miro.miro", // Miro - "com.moodle.moodlemobile", // Moodle - "com.zoom.us", // Zoom - "com.basecamp.bc3", // Basecamp - "com.campmobile.snow", // Snow - "com.gs.android", // GTasks - "com.habitrpg.android.habitica", // Habitica - "com.ticktick.task", // TickTick -}; - - public static final String[] pornKeywords = - { - "adult", - "porn", - "sex", - "xxx", - "nude", - "naked", - "erotic", - "lust", - "sensual", - "intimate", - "sexy", - "breast", - "boobs", - "vagina", - "penis", - "dick", - "cock", - "pussy", - "fuck", - "ass", - "butt", - "orgasm", - "masturbation", - "anal", - "bondage", - "fetish", - "kinky", - "swinger", - "orgy", - "cum", - "ejaculate", - "sperm", - "prostitute", - "escort", - "stripper", - "nudity", - "sexual", - "erogenous", - "seduce", - "seduction", - "lustful", - "erect", - "threesome", - "gangbang", - "hooker", - "milf", - "cougar", - "hardcore", - "softcore", - "pleasure", - "desire", - "intimacy", - "romance", - "love", - "bedroom", - "bed", - "undress", - "bikini", - "lingerie", - "condom", - "blowjob", - "cunnilingus", - "fellatio", - "handjob", - "rimming", - "strap-on", - "vibrator", - "dildo", - "playboy", - "playgirl", - "playmate", - "topless", - "bottomless", - "horny", - "naughty", - "dirty", - "kiss", - "foreplay", - "suck", - "lick", - "swallow", - "squirt", - "tits", - "clitoris", - "labia", - "scrotum", - "testicles", - "wet", - "moist", - "ejaculation", - "stimulate", - "stimulation", - "erectile", - "orgasmic", - "libido", - "pubic", - "genital", - "sexualized", - "lewd", - "obscene", - "pervert", - "orgiastic", - "busty", - "groping", - "kink", - "peep", - "voyeur", - "underwear", - "arousal", - "nipple", - "masturbate", - "prostitution", - "sodomy", - "incest", - "bareback", - "bestiality", - "exhibitionism", - "fornication", - "obscenity", - "promiscuous", - "rapist", - "sadism", - "masochism", - "swinging", - "unprotected"}; - + public static final HashMap nonBlockedPackages = new HashMap() {{ + put("com.google.android.dialer", null); // Google Dialer + put("com.google.android.apps.messaging", null); + put("nethical.digipaws", null); // DigiPaws + put("com.google.android.deskclock", null); // Google Clock + put("com.android.systemui", null); // Android System UI + put("com.android.phone", null); // Android Phone + + // Launchers + put("com.google.android.apps.nexuslauncher", null); // Google Pixel Launcher + put("com.microsoft.launcher", null); // Microsoft Launcher + put("com.teslacoilsw.launcher", null); // Nova Launcher + put("net.oneplus.launcher", null); // OnePlus Launcher + put("com.sec.android.app.launcher", null); // Samsung One UI Home + put("com.actionlauncher.playstore", null); // Action Launcher + put("com.laucher.smart", null); // Smart Launcher + put("ginlemon.flowerfree", null); // Smart Launcher 5 + put("com.tsf.shell", null); // TSF Launcher + + // Productive apps + put("com.google.android.keep", null); // Google Keep + put("com.microsoft.todos", null); // Microsoft To Do + put("com.evernote", null); // Evernote + put("com.todoist", null); // Todoist + put("com.ticktick.task", null); // TickTick + put("com.google.android.apps.docs", null); // Google Docs + put("com.google.android.apps.sheets", null); // Google Sheets + put("com.google.android.apps.slides", null); // Google Slides + put("com.google.android.calendar", null); // Google Calendar + put("com.microsoft.office.officehubrow", null); // Microsoft Office + put("com.google.android.apps.tasks", null); // Google Tasks + put("com.asana.app", null); // Asana + put("com.trello", null); // Trello + put("com.nutomic.syncthingandroid", null); // Syncthing + put("com.slack", null); // Slack + put("com.google.android.gm", null); // Gmail + put("com.pushbullet.android", null); // Pushbullet + put("com.teams.microsoft", null); // Microsoft Teams + put("com.dropbox.android", null); // Dropbox + put("com.box.android", null); // Box + put("com.google.android.apps.meetings", null); // Google Meet + put("com.zoho.crm", null); // Zoho CRM + put("com.anydo", null); // Any.do + put("com.notion.id", null); // Notion + put("com.mindjet.mindmanager", null); // MindManager + put("com.miro.miro", null); // Miro + put("com.moodle.moodlemobile", null); // Moodle + put("com.zoom.us", null); // Zoom + put("com.basecamp.bc3", null); // Basecamp + put("com.campmobile.snow", null); // Snow + put("com.gs.android", null); // GTasks + put("com.habitrpg.android.habitica", null); // Habitica + put("com.ticktick.task", null); // TickTick + }}; + + public static final HashMap pornKeywords = new HashMap() {{ + put("adult", null); + put("porn", null); + put("sex", null); + put("xxx", null); + put("nude", null); + put("naked", null); + put("erotic", null); + put("lust", null); + put("sensual", null); + put("intimate", null); + put("sexy", null); + put("breast", null); + put("boobs", null); + put("vagina", null); + put("penis", null); + put("dick", null); + put("cock", null); + put("pussy", null); + put("fuck", null); + put("ass", null); + put("butt", null); + put("orgasm", null); + put("masturbation", null); + put("anal", null); + put("bondage", null); + put("fetish", null); + put("kinky", null); + put("swinger", null); + put("orgy", null); + put("cum", null); + put("ejaculate", null); + put("sperm", null); + put("prostitute", null); + put("escort", null); + put("stripper", null); + put("nudity", null); + put("sexual", null); + put("erogenous", null); + put("seduce", null); + put("seduction", null); + put("lustful", null); + put("erect", null); + put("threesome", null); + put("gangbang", null); + put("hooker", null); + put("milf", null); + put("cougar", null); + put("hardcore", null); + put("softcore", null); + put("pleasure", null); + put("desire", null); + put("intimacy", null); + put("romance", null); + put("love", null); + put("bedroom", null); + put("bed", null); + put("undress", null); + put("bikini", null); + put("lingerie", null); + put("condom", null); + put("blowjob", null); + put("cunnilingus", null); + put("fellatio", null); + put("handjob", null); + put("rimming", null); + put("strap-on", null); + put("vibrator", null); + put("dildo", null); + put("playboy", null); + put("playgirl", null); + put("playmate", null); + put("topless", null); + put("bottomless", null); + put("horny", null); + put("naughty", null); + put("dirty", null); + put("kiss", null); + put("foreplay", null); + put("suck", null); + put("lick", null); + put("swallow", null); + put("squirt", null); + put("tits", null); + put("clitoris", null); + put("labia", null); + put("scrotum", null); + put("testicles", null); + put("wet", null); + put("moist", null); + put("ejaculation", null); + put("stimulate", null); + put("stimulation", null); + put("erectile", null); + put("orgasmic", null); + put("libido", null); + put("pubic", null); + put("genital", null); + put("sexualized", null); + put("lewd", null); + put("obscene", null); + put("pervert", null); + put("orgiastic", null); + put("busty", null); + put("groping", null); + put("kink", null); + put("peep", null); + put("voyeur", null); + put("underwear", null); + put("arousal", null); + put("nipple", null); + put("masturbate", null); + put("prostitution", null); + put("sodomy", null); + put("incest", null); + put("bareback", null); + put("bestiality", null); + put("exhibitionism", null); + put("fornication", null); + put("obscenity", null); + put("promiscuous", null); + put("rapist", null); + put("sadism", null); + put("masochism", null); + put("swinging", null); + put("unprotected", null); + }}; } + diff --git a/app/src/main/java/nethical/digipaws/itemblockers/AppBlocker.java b/app/src/main/java/nethical/digipaws/itemblockers/AppBlocker.java index 4984054..d83d76a 100644 --- a/app/src/main/java/nethical/digipaws/itemblockers/AppBlocker.java +++ b/app/src/main/java/nethical/digipaws/itemblockers/AppBlocker.java @@ -35,12 +35,9 @@ public void performAction(ServiceData data){ if(SurvivalModeManager.isSurvivalModeActive(data.getService())){ - for (String blockedPackageName : BlockerData.nonBlockedPackages) { - if(!blockedPackageName.equals(data.getPackageName())){ - pressHome(); + if(BlockerData.nonBlockedPackages.containsKey(data.getPackageName())) + pressHome(); return; - } - } } @@ -52,14 +49,10 @@ public void performAction(ServiceData data){ } if(data.isReelsBlocked()){ - for (String blockedPackageName : BlockerData.shortsApplications) { - // using contains instead of equals cuz tikok has multiple package names :sad: - if(data.getPackageName().contains(blockedPackageName)){ - punish(); - break; + if(BlockerData.shortsApplications.containsKey(data.getPackageName())){ + punish(); } - } - } + } } diff --git a/app/src/main/java/nethical/digipaws/itemblockers/KeywordBlocker.java b/app/src/main/java/nethical/digipaws/itemblockers/KeywordBlocker.java index 5d8a032..da0dbea 100644 --- a/app/src/main/java/nethical/digipaws/itemblockers/KeywordBlocker.java +++ b/app/src/main/java/nethical/digipaws/itemblockers/KeywordBlocker.java @@ -72,12 +72,14 @@ public void traverseNodesForKeywords( } } - private static boolean containsKeyword(String text) { + private boolean containsKeyword(String text) { String lowerCaseText = text.toLowerCase().trim(); - for (String keyword : BlockerData.pornKeywords) { - String trimmedKeyword = keyword.trim().toLowerCase(); - if (lowerCaseText.matches(".*\\b" + Pattern.quote(trimmedKeyword) + "\\b.*")) { + // Split text into words and check each word against the HashMap + String[] words = lowerCaseText.split("\\W+"); // Split by non-word characters + + for (String word : words) { + if (BlockerData.pornKeywords.containsKey(word)) { return true; } } diff --git a/app/src/main/java/nethical/digipaws/utils/LoadAppList.java b/app/src/main/java/nethical/digipaws/utils/LoadAppList.java index 38e8fed..a32afda 100644 --- a/app/src/main/java/nethical/digipaws/utils/LoadAppList.java +++ b/app/src/main/java/nethical/digipaws/utils/LoadAppList.java @@ -73,7 +73,7 @@ public static boolean isSystemPackage(ApplicationInfo pkgInfo) { private static List removeIgnoredPackages(Context context,List packages) { - for (String value : BlockerData.nonBlockedPackages) { + for (String value : BlockerData.nonBlockedPackages.keySet()) { packages.remove(value); }