diff --git a/app/src/main/java/com/fogplix/anime/activities/MainActivity.java b/app/src/main/java/com/fogplix/anime/activities/MainActivity.java index 21b912b..2e66cdb 100644 --- a/app/src/main/java/com/fogplix/anime/activities/MainActivity.java +++ b/app/src/main/java/com/fogplix/anime/activities/MainActivity.java @@ -3,6 +3,7 @@ import android.Manifest; import android.annotation.SuppressLint; import android.content.Intent; +import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.graphics.PorterDuff; import android.net.Uri; @@ -26,6 +27,7 @@ import androidx.core.view.GravityCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.FragmentManager; +import androidx.preference.PreferenceManager; import androidx.viewpager2.widget.ViewPager2; import com.fogplix.anime.BuildConfig; @@ -87,9 +89,15 @@ protected void onCreate(Bundle savedInstanceState) { CustomMethods.checkNewNotice(this, importantNoticeTV); CustomMethods.checkPlayableServersStatus(this); + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); + AdBlockerDetector.detectAdBlocker(isAdBlockerDetected -> { - if (isAdBlockerDetected){ - Toast.makeText(this, "Ad blocker detected! Don't worry, it's ads free.", Toast.LENGTH_LONG).show(); + if (isAdBlockerDetected) { + if (preferences.getBoolean("use_proxy", false)) { + CustomMethods.warningAlert(MainActivity.this, "Warning", getString(R.string.adblock_detected), "Ignore", false); + } else { + Toast.makeText(this, "Ad-blocker detected! Don't worry, it's ads free.", Toast.LENGTH_SHORT).show(); + } } }); diff --git a/app/src/main/java/com/fogplix/anime/helpers/CustomMethods.java b/app/src/main/java/com/fogplix/anime/helpers/CustomMethods.java index eb2f960..5ef3841 100644 --- a/app/src/main/java/com/fogplix/anime/helpers/CustomMethods.java +++ b/app/src/main/java/com/fogplix/anime/helpers/CustomMethods.java @@ -101,12 +101,11 @@ public static boolean isInternetOn(Context context) { //-------------------------------------------------------------------------------------------------- public static void errorAlert(Activity activity, String errorTitle, String errorBody, String actionButton, boolean shouldGoBack) { - if (!activity.isFinishing()) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(errorTitle); builder.setMessage(errorBody); - builder.setIcon(R.drawable.warning); + builder.setIcon(R.drawable.error_outline_24); builder.setPositiveButton(actionButton, (dialogInterface, i) -> { if (shouldGoBack) { activity.finish(); @@ -123,6 +122,24 @@ public static void errorAlert(Activity activity, String errorTitle, String error } } + public static void warningAlert(Activity activity, String warningTitle, String warningBody, String actionButton, boolean shouldGoBack) { + if (!activity.isFinishing()) { + AlertDialog.Builder builder = new AlertDialog.Builder(activity); + builder.setTitle(warningTitle); + builder.setMessage(warningBody); + builder.setIcon(R.drawable.warning); + builder.setPositiveButton(actionButton, (dialogInterface, i) -> { + if (shouldGoBack) { + activity.finish(); + } else { + dialogInterface.dismiss(); + } + }); + AlertDialog dialog = builder.create(); + dialog.show(); + } + } + //-------------------------------------------------------------------------------------------------- public static boolean isAppInstalledOrNot(Context context, String packageName) { diff --git a/app/src/main/res/drawable/error_outline_24.xml b/app/src/main/res/drawable/error_outline_24.xml new file mode 100644 index 0000000..598f21e --- /dev/null +++ b/app/src/main/res/drawable/error_outline_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/warning.xml b/app/src/main/res/drawable/warning.xml index f0b8588..efe46e3 100644 --- a/app/src/main/res/drawable/warning.xml +++ b/app/src/main/res/drawable/warning.xml @@ -4,6 +4,6 @@ android:viewportWidth="48" android:viewportHeight="48"> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1db4f93..b7c47ee 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -34,6 +34,7 @@ Oops! Maybe your ISP has blocked our server. Please try using any VPN or enable proxy from settings page. May be it can help. Please take a screenshot and report this error to us. + As you\'re using an ad-blocker, it might block our proxy server and cause issues. To fix this, either turn off the proxy in settings or disable the ad-blocker. hiddenpirates@outlook.com Failed to play this episode. Please take a screenshot and report it to us. Now try to play on the web player. Just click on the below button \n