Skip to content

Commit

Permalink
modified
Browse files Browse the repository at this point in the history
  • Loading branch information
Benojir committed Aug 31, 2024
1 parent 4f525bc commit fe08f83
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
12 changes: 10 additions & 2 deletions app/src/main/java/com/fogplix/anime/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
}
});

Expand Down
21 changes: 19 additions & 2 deletions app/src/main/java/com/fogplix/anime/helpers/CustomMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/error_outline_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FF0000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M11,15h2v2h-2zM11,7h2v6h-2zM11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>

</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/warning.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="@color/red"
android:fillColor="@color/dark_yellow"
android:pathData="M2,42 L24,4 46,42ZM7.2,39H40.8L24,10ZM24.2,36.15Q24.85,36.15 25.275,35.725Q25.7,35.3 25.7,34.65Q25.7,34 25.275,33.575Q24.85,33.15 24.2,33.15Q23.55,33.15 23.125,33.575Q22.7,34 22.7,34.65Q22.7,35.3 23.125,35.725Q23.55,36.15 24.2,36.15ZM22.7,30.6H25.7V19.4H22.7ZM24,24.5Z"/>
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<string name="isp_blocked">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.</string>
<string name="adblock_detected">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.</string>

<string name="feedback_email">[email protected]</string>
<string name="episode_playing_failed_message">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</string>
Expand Down

0 comments on commit fe08f83

Please sign in to comment.