17 |
18 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Programs\android-sdk\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Ad blocker detection
4 | ad blocker has been detected on your device.
6 | If you don\'t understand why you get this message, please feel free to contact us.
7 |
8 | Development of this application is supported by advertising, so please uninstall your ad blocker in order to use it.
9 |
10 | ]]>
11 | %s button to use this application without ads.
13 | ]]>
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Cüneyt Ayyıldız
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.idea/copyright/MIT.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | VERSION_NAME=1.0.0
2 | VERSION_CODE=1
3 | GROUP=com.cuneytayyildiz
4 |
5 | POM_DESCRIPTION=Many ad blockers exist on Android, this is a real problem for developers that rely on ad incomes. This project proposes an open source library that can detect most of ad blockers. Then developers can display a dialog to inform user that an ad blocker has been detected and to propose, for example, to buy an ad-free version of the application or to quit.
6 | POM_URL=https://github.com/Swisyn/AdBlockerDetector
7 | POM_SCM_URL=https://github.com/Swisyn/AdBlockerDetector
8 | POM_SCM_CONNECTION=scm:git@github.com:Swisyn/AdBlockerDetector.git
9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:Swisyn/AdBlockerDetector.git
10 | POM_LICENCE_NAME=The MIT License (MIT)
11 | POM_LICENCE_URL=https://github.com/Swisyn/AdBlockerDetector/blob/master/LICENSE
12 | POM_LICENCE_DIST=repo
13 | POM_DEVELOPER_ID=swisyn
14 | POM_DEVELOPER_NAME=Cuneyt AYYILDIZ
15 |
16 | NEXUS_USERNAME=swisyn
17 | NEXUS_PASSWORD=2819320130s
18 |
19 | SNAPSHOT_REPOSITORY_URL=https://oss.sonatype.org/content/repositories/snapshots
20 | RELEASE_REPOSITORY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2
21 |
22 | signing.keyId=8B3E18E1
23 | signing.password=2819320130
24 | signing.secretKeyRingFile=C:\\Users\\cuney\\AppData\\Roaming\\gnupg\\secring.gpg
25 |
26 | org.gradle.jvmargs=-Xmx1536m
--------------------------------------------------------------------------------
/app/src/main/java/com/cuneytayyildiz/adblockerdetector/Utils.java:
--------------------------------------------------------------------------------
1 | package com.cuneytayyildiz.adblockerdetector;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 |
7 | public class Utils {
8 |
9 | /**
10 | * Quit the current application.
11 | */
12 | public static void quitApplication() {
13 | android.os.Process.killProcess(android.os.Process.myPid());
14 | System.exit(0);
15 | }
16 |
17 | /**
18 | * Propose user to send an email with pre-filled fields.
19 | */
20 | public static void sendEMail(final Context context, final String dialogTitle, final String to, final String subject, final String body) {
21 | final Intent send = new Intent(Intent.ACTION_SENDTO);
22 | final String uriText =
23 | "mailto:" + Uri.encode(to) +
24 | "?subject=" + Uri.encode(subject) +
25 | "&body=" + Uri.encode(body);
26 | send.setData(Uri.parse(uriText));
27 | context.startActivity(Intent.createChooser(send, dialogTitle));
28 | }
29 |
30 | /**
31 | * Propose user to uninstall the given application
32 | *
33 | * @param context
34 | * @param packageName package of the application to uninstall
35 | */
36 | public static void uinstallApplication(final Context context, final String packageName) {
37 | final Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, null));
38 | context.startActivity(intent);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cuneytayyildiz/adblockerdetector/Constants.java:
--------------------------------------------------------------------------------
1 | package com.cuneytayyildiz.adblockerdetector;
2 |
3 | import android.annotation.SuppressLint;
4 |
5 | /**
6 | * Created by cuneyt on 015, 15, 08, 2016.
7 | */
8 |
9 | public class Constants {
10 | // Asynchronous callback
11 | public interface AdBlockerCallback {
12 | void onResult(boolean adBlockerFound, Info info);
13 | }
14 |
15 | // Detection method
16 | public enum Method {
17 | NONE, BY_HOSTS_FILE, BY_APP_NAME, BY_HOST_RESOLUTION, BY_LOCAL_PROXY
18 | }
19 |
20 | // Name of known ad blockers
21 |
22 | public static final String[] BLOCKERS_APP_NAMES =
23 | {
24 | "de.ub0r.android.adBlock",
25 | "org.adblockplus.android",
26 | "com.bigtincan.android.adfree",
27 | "org.adaway",
28 | "org.czzsunset.adblock",
29 | "com.pasvante.adblocker",
30 | "com.perlapps.MyInternetSecurity",
31 | "net.xdevelop.adblocker_t",
32 | "net.xdevelop.adblocker",
33 | "com.jrummy.apps.ad.blocker",
34 | "com.atejapps.advanishlite",
35 | "com.atejapps.advanish",
36 | "pl.adblocker.free",
37 | "de.resolution.blockit"
38 | };
39 |
40 |
41 | // Name of known blocked hosts
42 | public static final String[] BLOCKED_HOSTS =
43 | {
44 | "a.admob.com",
45 | "mm.admob.com",
46 | "p.admob.com",
47 | "r.admob.com",
48 | "mmv.admob.com",
49 | "aax-fe-sin.amazon-adsystem.com",
50 | "rcm-na.amazon-adsystem.com",
51 | "aax-us-east.amazon-adsystem.com",
52 | "ir-na.amazon-adsystem.com",
53 | "aax-eu.amazon-adsystem.com"
54 | };
55 |
56 | // "hosts" file possible paths
57 | @SuppressLint("SdCardPath")
58 | public static final String[] HOSTS_FILES = {"/etc/hosts", "/system/etc/hosts", "/data/data/hosts"};
59 |
60 | // Pattern to search in hosts file
61 |
62 | public static final String[] HOSTS_FILE_PATTERNS = {"admob", "amazon-adsystem"};
63 |
64 | // Give information on how ad blocker was detected
65 | public static class Info {
66 | public Method method;
67 | public String details1;
68 | public String details2;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |