s4m33r789

Splash.java place in app\src\main\java\com\dooo\android

Aug 15th, 2024 (edited)
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 71.83 KB | Movies | 0 0
  1. package com.dooo.android;
  2. // https://t.me/@syndic4te
  3. import static com.dooo.android.utils.Constants.AUTOPLAY;
  4. import static com.dooo.android.utils.Constants.EXTENTIONS;
  5. import static com.dooo.android.utils.Constants.SOFTWARE_EXTENTIONS;
  6. import static org.apache.commons.lang3.StringUtils.length;
  7.  
  8. import android.app.Activity;
  9. import android.app.Application;
  10. import android.app.Dialog;
  11. import android.content.Context;
  12. import android.content.Intent;
  13. import android.content.IntentSender;
  14. import android.content.SharedPreferences;
  15. import android.content.pm.ApplicationInfo;
  16. import android.content.res.Configuration;
  17. import android.graphics.Color;
  18. import android.graphics.drawable.ColorDrawable;
  19. import android.net.ConnectivityManager;
  20. import android.net.Uri;
  21. import android.os.Build;
  22. import android.os.Bundle;
  23. import android.os.Handler;
  24. import android.os.Looper;
  25. import android.provider.Settings;
  26. import android.util.DisplayMetrics;
  27. import android.util.Log;
  28. import android.view.View;
  29. import android.view.Window;
  30. import android.view.WindowManager;
  31. import android.webkit.WebView;
  32. import android.widget.Button;
  33. import android.widget.ImageView;
  34. import android.widget.RelativeLayout;
  35. import android.widget.Toast;
  36.  
  37. import androidx.appcompat.app.AppCompatActivity;
  38. import androidx.constraintlayout.widget.ConstraintLayout;
  39. import androidx.core.app.ActivityCompat;
  40. import androidx.core.content.ContextCompat;
  41. import androidx.viewpager.widget.ViewPager;
  42.  
  43. import com.LiquidPager.liquid_swipe.LiquidPager;
  44. import com.airbnb.lottie.LottieAnimationView;
  45. import com.andrognito.pinlockview.IndicatorDots;
  46. import com.andrognito.pinlockview.PinLockListener;
  47. import com.andrognito.pinlockview.PinLockView;
  48. import com.android.volley.AuthFailureError;
  49. import com.android.volley.DefaultRetryPolicy;
  50. import com.android.volley.Request;
  51. import com.android.volley.RequestQueue;
  52. import com.android.volley.toolbox.StringRequest;
  53. import com.android.volley.toolbox.Volley;
  54. import com.auth0.jwt.JWT;
  55. import com.auth0.jwt.JWTVerifier;
  56. import com.auth0.jwt.algorithms.Algorithm;
  57. import com.auth0.jwt.exceptions.JWTVerificationException;
  58. import com.auth0.jwt.interfaces.DecodedJWT;
  59. import com.bumptech.glide.Glide;
  60. import com.bumptech.glide.load.engine.DiskCacheStrategy;
  61. import com.dooo.android.adepter.LiquidPageradepter;
  62. import com.dooo.android.utils.AppOpenAdManagerActivity;
  63. import com.dooo.android.utils.DNSDialog;
  64. import com.dooo.android.utils.HelperUtils;
  65. import com.dooo.android.utils.NoInternetDialog;
  66. import com.dooo.android.utils.NoRootDialog;
  67. import com.dooo.android.utils.TinyDB;
  68. import com.dooo.android.utils.Utils;
  69. import com.dooo.android.utils.VPNDialog;
  70. import com.facebook.FacebookSdk;
  71. import com.github.ybq.android.spinkit.SpinKitView;
  72. import com.google.android.gms.common.util.ArrayUtils;
  73. import com.google.android.gms.tasks.Task;
  74. import com.google.android.material.snackbar.Snackbar;
  75. import com.google.android.play.core.appupdate.AppUpdateInfo;
  76. import com.google.android.play.core.appupdate.AppUpdateManager;
  77. import com.google.android.play.core.appupdate.AppUpdateManagerFactory;
  78. import com.google.android.play.core.install.InstallStateUpdatedListener;
  79. import com.google.android.play.core.install.model.AppUpdateType;
  80. import com.google.android.play.core.install.model.InstallStatus;
  81. import com.google.android.play.core.install.model.UpdateAvailability;
  82. import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
  83. import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;
  84. import com.google.gson.Gson;
  85. import com.google.gson.JsonObject;
  86. import com.jetradarmobile.snowfall.SnowfallView;
  87. import com.mukesh.tamperdetector.AppSignatureValidatorKt;
  88. import com.mukesh.tamperdetector.InstallValidatorKt;
  89. import com.mukesh.tamperdetector.Installer;
  90. import com.mukesh.tamperdetector.Result;
  91. import com.onesignal.OneSignal;
  92. import com.startapp.sdk.adsbase.StartAppAd;
  93. import com.startapp.sdk.adsbase.StartAppSDK;
  94.  
  95.  
  96. import org.json.JSONObject;
  97.  
  98. import java.util.HashMap;
  99. import java.util.Locale;
  100. import java.util.Map;
  101. import java.util.Objects;
  102.  
  103. import dev.shreyaspatil.MaterialDialog.MaterialDialog;
  104. import es.dmoral.toasty.Toasty;
  105.  
  106.  
  107. public class Splash extends AppCompatActivity {
  108.     Context context = this;
  109.  
  110.     public static String notificationData = "";
  111.     String userData;
  112.     String apiKey;
  113.     Integer loginMandatory;
  114.     Integer maintenance;
  115.     String blocked_regions;
  116.  
  117.     String latestAPKVersionName;
  118.     String latestAPKVersionCode;
  119.     String apkFileUrl;
  120.     String whatsNewOnLatestApk;
  121.     int updateSkipable;
  122.     int updateType;
  123.  
  124.     int googleplayAppUpdateType;
  125.     AppUpdateManager appUpdateManager = null;
  126.  
  127.  
  128.     private boolean vpnStatus = false;
  129.     private HelperUtils helperUtils;
  130.  
  131.     ConstraintLayout splashLayout0, splashLayout1, splashLayout2, splashLayout3;
  132.  
  133.     TinyDB tinyDB;
  134.  
  135.     boolean pinLockStatus = false;
  136.     String pinLockPin = "";
  137.  
  138.     @Override
  139.     protected void onCreate(Bundle savedInstanceState) {
  140.         super.onCreate(savedInstanceState);
  141.  
  142.         //Log.d("Signature", AppSignatureValidatorKt.getSignature(this));
  143.  
  144.         tinyDB = new TinyDB(context);
  145.         if(!tinyDB.getString("appLanguage").equals("") || tinyDB.getString("appLanguage") != null) {
  146.             String languageToLoad  = tinyDB.getString("appLanguage");
  147.             Locale locale = new Locale(languageToLoad);
  148.             Locale.setDefault(locale);
  149.             Configuration config = new Configuration();
  150.             config.locale = locale;
  151.             getBaseContext().getResources().updateConfiguration(config,
  152.                     getBaseContext().getResources().getDisplayMetrics());
  153.         }
  154.  
  155.  
  156.  
  157.  
  158.         if(HelperUtils.isInternetAvailable(context)) {
  159.             FirebaseRemoteConfig mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
  160.             FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
  161.                     .setMinimumFetchIntervalInSeconds(3600)
  162.                     .build();
  163.             mFirebaseRemoteConfig.setConfigSettingsAsync(configSettings);
  164.             mFirebaseRemoteConfig.fetchAndActivate()
  165.                     .addOnCompleteListener(this, task -> {
  166.                         if (task.isSuccessful()) {
  167.                             AppConfig.rawUrl = mFirebaseRemoteConfig.getString("SERVER_URL");
  168.                             AppConfig.url = mFirebaseRemoteConfig.getString("SERVER_URL")+"android/";
  169.                             AppConfig.apiKey = mFirebaseRemoteConfig.getString("API_KEY");
  170.                             AppConfig.allowVPN = mFirebaseRemoteConfig.getBoolean("ALLOW_VPN");
  171.                             AppConfig.FLAG_SECURE = mFirebaseRemoteConfig.getBoolean("FLAG_SECURE");
  172.                             AppConfig.allowRoot = mFirebaseRemoteConfig.getBoolean("ALLOW_ROOT");
  173.                             AppConfig.verifyInstaller = mFirebaseRemoteConfig.getBoolean("VERIFY_INSTALLER");
  174.                             AppConfig.validateSignature = mFirebaseRemoteConfig.getBoolean("VALIDATE_SIGNATURE");
  175.                             AppConfig.releaseSignature = mFirebaseRemoteConfig.getString("RELEASE_SIGNATURE");
  176.                             AppConfig.allowPrivateDNS = mFirebaseRemoteConfig.getBoolean("ALLOW_PRIVATE_DNS");
  177.  
  178.                             Log.d("test", mFirebaseRemoteConfig.getString("SERVER_URL"));
  179.  
  180.                             if (HelperUtils.isVpnConnected(context, AppConfig.allowVPN)) {
  181.                                 VPNDialog VPNDialog = new VPNDialog(context);
  182.                                 VPNDialog.show();
  183.                             } else {
  184.                                 startSplashTask();
  185.                             }
  186.  
  187.  
  188.                         } else {
  189.                             serverError();
  190.                         }
  191.                     });
  192.         } else {
  193.             NoInternetDialog noInternetDialog = new NoInternetDialog(context);
  194.             noInternetDialog.show();
  195.         }
  196.  
  197.         checkStoragePermission();
  198.     }
  199.  
  200.     private void startSplashTask() {
  201.         if (!AppConfig.allowPrivateDNS) {
  202.             ConnectivityManager cMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
  203.             if (cMgr != null) {
  204.                 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
  205.                     if (Objects.requireNonNull(cMgr.getLinkProperties(cMgr.getActiveNetwork())).isPrivateDnsActive()) {
  206.                         DNSDialog dnsDialog = new DNSDialog(context);
  207.                         dnsDialog.show();
  208.                     } else {
  209.                         StartSplashTask2();
  210.                     }
  211.                 } else {
  212.                     StartSplashTask2();
  213.                 }
  214.             } else {
  215.                 StartSplashTask2();
  216.             }
  217.         } else {
  218.             StartSplashTask2();
  219.         }
  220.     }
  221.  
  222.     private void StartSplashTask2() {
  223.         if (HelperUtils.cr((Activity) context, AppConfig.allowRoot)) {
  224.             NoRootDialog noRootDialog = new NoRootDialog(context);
  225.             runOnUiThread(noRootDialog::show);
  226.         } else {
  227.             if (AppConfig.FLAG_SECURE) {
  228.                 getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
  229.                         WindowManager.LayoutParams.FLAG_SECURE);
  230.             }
  231.  
  232.             getWindow().setFlags(
  233.                     WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
  234.                     WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
  235.             );
  236.             getWindow().getDecorView().setSystemUiVisibility(
  237.                     View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
  238.                             View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
  239.  
  240.             switch (tinyDB.getInt("splashScreenType")) {
  241.                 case 1:
  242.                     setContentView(R.layout.activity_splash);
  243.  
  244.                     splashLayout0 = findViewById(R.id.splashLayout0);
  245.                     splashLayout1 = findViewById(R.id.splashLayout1);
  246.                     splashLayout2 = findViewById(R.id.splashLayout2);
  247.                     splashLayout3 = findViewById(R.id.splashLayout3);
  248.  
  249.                     if (!Objects.equals(tinyDB.getString("splashImageUrl"), "")) {
  250.                         Glide.with(context)
  251.                                 .load(tinyDB.getString("splashImageUrl"))
  252.                                 .diskCacheStrategy(DiskCacheStrategy.ALL)
  253.                                 .centerCrop()
  254.                                 .into((ImageView) findViewById(R.id.splashScreenMainImage));
  255.                     }
  256.  
  257.                     splashLayout0.setVisibility(View.GONE);
  258.                     splashLayout1.setVisibility(View.VISIBLE);
  259.                     splashLayout2.setVisibility(View.GONE);
  260.                     splashLayout3.setVisibility(View.GONE);
  261.                     break;
  262.                 case 2:
  263.                     setContentView(R.layout.activity_splash);
  264.  
  265.                     splashLayout0 = findViewById(R.id.splashLayout0);
  266.                     splashLayout1 = findViewById(R.id.splashLayout1);
  267.                     splashLayout2 = findViewById(R.id.splashLayout2);
  268.                     splashLayout3 = findViewById(R.id.splashLayout3);
  269.  
  270.                     if (!Objects.equals(tinyDB.getString("splashLottieUrl"), "")) {
  271.                         LottieAnimationView lottieAnimationView = findViewById(R.id.lottieAnimationView);
  272.                         lottieAnimationView.setAnimationFromUrl(tinyDB.getString("splashLottieUrl"));
  273.                     }
  274.  
  275.                     splashLayout0.setVisibility(View.GONE);
  276.                     splashLayout1.setVisibility(View.GONE);
  277.                     splashLayout2.setVisibility(View.VISIBLE);
  278.                     splashLayout3.setVisibility(View.GONE);
  279.                     break;
  280.                 case 3:
  281.                     setContentView(R.layout.activity_splash);
  282.  
  283.                     splashLayout0 = findViewById(R.id.splashLayout0);
  284.                     splashLayout1 = findViewById(R.id.splashLayout1);
  285.                     splashLayout2 = findViewById(R.id.splashLayout2);
  286.                     splashLayout3 = findViewById(R.id.splashLayout3);
  287.  
  288.                     WebView webView = findViewById(R.id.webview);
  289.                     webView.getSettings().setJavaScriptEnabled(true);
  290.                     webView.loadUrl(AppConfig.url + "splash");
  291.  
  292.                     splashLayout0.setVisibility(View.GONE);
  293.                     splashLayout1.setVisibility(View.GONE);
  294.                     splashLayout2.setVisibility(View.GONE);
  295.                     splashLayout3.setVisibility(View.VISIBLE);
  296.                     break;
  297.                 default:
  298.                     Window window = Splash.this.getWindow();
  299.                     window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  300.                     window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  301.                     if (!Objects.equals(tinyDB.getString("splashBgColor"), "")) {
  302.                         window.setStatusBarColor(Color.parseColor(tinyDB.getString("splashBgColor")));
  303.                     } else {
  304.                         window.setStatusBarColor(ContextCompat.getColor(Splash.this, R.color.Splash_TitleBar_BG));
  305.                     }
  306.  
  307.                     setContentView(R.layout.activity_splash);
  308.  
  309.                     splashLayout0 = findViewById(R.id.splashLayout0);
  310.                     splashLayout1 = findViewById(R.id.splashLayout1);
  311.                     splashLayout2 = findViewById(R.id.splashLayout2);
  312.                     splashLayout3 = findViewById(R.id.splashLayout3);
  313.  
  314.                     splashLayout0.setVisibility(View.VISIBLE);
  315.                     splashLayout1.setVisibility(View.GONE);
  316.                     splashLayout2.setVisibility(View.GONE);
  317.                     splashLayout3.setVisibility(View.GONE);
  318.             }
  319.  
  320.             if (!Objects.equals(tinyDB.getString("splashBgColor"), "")) {
  321.                 findViewById(R.id.splash).setBackgroundColor(Color.parseColor(tinyDB.getString("splashBgColor")));
  322.             }
  323.  
  324.             helperUtils = new HelperUtils(Splash.this);
  325.  
  326.             ApplicationInfo restrictedApp = helperUtils.getRestrictApp();
  327.             if (restrictedApp != null) {
  328.                 Log.e("test", restrictedApp.loadLabel(Splash.this.getPackageManager()).toString());
  329.                 HelperUtils.showWarningDialog(Splash.this, "Restricted App!", "Please Uninstall " + restrictedApp.loadLabel(Splash.this.getPackageManager()).toString() + " to use this App On this Device!", R.raw.sequre);
  330.             } else {
  331.                 loadData();
  332.             }
  333.         }
  334.     }
  335.  
  336.     // ------------------ checking storage permission ------------
  337.     private boolean checkStoragePermission() {
  338.         /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
  339.             if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
  340.                     && checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
  341.  
  342.                 Log.d("test", "Permission is granted");
  343.                 return true;
  344.  
  345.             } else {
  346.                 Log.d("test", "Permission is revoked");
  347.                 ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
  348.                 return false;
  349.             }
  350.         } else { //permission is automatically granted on sdk<23 upon installation
  351.             Log.d("test", "Permission is granted");
  352.             return true;
  353.         }*/
  354.  
  355.         return true;
  356.     }
  357.  
  358.     private void loadData() {
  359.         verifyInstaller();
  360.     }
  361.  
  362.     private void verifyInstaller() {
  363.         if(AppConfig.verifyInstaller) {
  364.             if (!InstallValidatorKt.verifyInstaller(this, Installer.GOOGLE_PLAY_STORE)) {
  365.                 Toasty.warning(context, "App not Installed from Google play Store!", Toast.LENGTH_SHORT, true).show();
  366.                 this.finishAffinity();
  367.             } else {
  368.                 validateSignature();
  369.             }
  370.         } else {
  371.             validateSignature();
  372.         }
  373.     }
  374.     private void validateSignature() {
  375.         if(AppConfig.validateSignature) {
  376.             if (AppSignatureValidatorKt.validateSignature(this, AppConfig.releaseSignature) != Result.VALID) {
  377.                 Toasty.warning(context, "error: signature mismatch!", Toast.LENGTH_SHORT, true).show();
  378.                 this.finishAffinity();
  379.             } else {
  380.                 loadUserData();
  381.             }
  382.         } else {
  383.             loadUserData();
  384.         }
  385.     }
  386.  
  387.     private void loadUserData() {
  388.         SharedPreferences sharedPreferences = getSharedPreferences("SharedPreferences", MODE_PRIVATE);
  389.         userData = sharedPreferences.getString("UserData", null);
  390.         loadConfig();
  391.     }
  392.  
  393.     private void loadConfig() {
  394.         RequestQueue queue = Volley.newRequestQueue(this);
  395.         StringRequest sr = new StringRequest(Request.Method.GET, AppConfig.url +"get_config", response -> {
  396.             JsonObject jsonObjectJWT = new Gson().fromJson(response, JsonObject.class);
  397.             String token = jsonObjectJWT.get("token").getAsString();
  398.             try {
  399.                 Algorithm algorithm = Algorithm.HMAC256(AppConfig.apiKey);
  400.                 JWTVerifier verifier = JWT.require(algorithm)
  401.                         .build();
  402.                 //DecodedJWT verify = verifier.verify(token);
  403.                 DecodedJWT jwt = JWT.decode(token);
  404.  
  405.                 String config = jwt.getClaim("config").toString();
  406.  
  407.                 JsonObject jsonObject = new Gson().fromJson(config, JsonObject.class);
  408.                 apiKey = jsonObject.get("api_key").getAsString();
  409.                 loginMandatory = jsonObject.get("login_mandatory").getAsInt();
  410.                 maintenance = jsonObject.get("maintenance").getAsInt();
  411.                 blocked_regions = jsonObject.get("blocked_regions").isJsonNull() ? "" : jsonObject.get("blocked_regions").getAsString();
  412.                 AppConfig.adType = jsonObject.get("ad_type").getAsInt();
  413.                 saveConfig(config);
  414.                 saveNotification();
  415.  
  416.                 // OneSignal Initialization
  417.                 OneSignal.initWithContext(Splash.this);
  418.                 OneSignal.setAppId(jsonObject.get("onesignal_appid").getAsString());
  419.                 OneSignal.setNotificationOpenedHandler(
  420.                         result -> Splash.notificationData = result.getNotification().getAdditionalData().toString());
  421.  
  422.                 int onScreenEffect = jsonObject.get("onscreen_effect").getAsInt();
  423.                 SnowfallView SnowfallView = findViewById(R.id.SnowfallView);
  424.                 switch (onScreenEffect) {
  425.                     case 0:
  426.                         SnowfallView.setVisibility(View.GONE);
  427.                         break;
  428.                     case 1:
  429.                         SnowfallView.setVisibility(View.VISIBLE);
  430.                         break;
  431.                     default:
  432.                         SnowfallView.setVisibility(View.GONE);
  433.  
  434.                 }
  435.  
  436.                 int content_item_type = jsonObject.get("content_item_type").getAsInt();
  437.                 int live_tv_content_item_type = jsonObject.get("live_tv_content_item_type").getAsInt();
  438.                 int webSeriesEpisodeitemType = jsonObject.get("webSeriesEpisodeitemType").getAsInt();
  439.  
  440.                 DisplayMetrics displayMetrics = new DisplayMetrics();
  441.                 getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
  442.  
  443.                 switch (content_item_type) {
  444.                     case 0:
  445.                         if(displayMetrics.widthPixels <= 720) {
  446.                             AppConfig.contentItem = R.layout.movie_item_small;
  447.                         } else {
  448.                             AppConfig.contentItem = R.layout.movie_item;
  449.                         }
  450.                         break;
  451.                     case 1:
  452.                         if(displayMetrics.widthPixels <= 720) {
  453.                             AppConfig.contentItem = R.layout.movie_item_v2_small;
  454.                         } else {
  455.                             AppConfig.contentItem = R.layout.movie_item_v2;
  456.                         }
  457.                         break;
  458.                     default:
  459.                         AppConfig.contentItem = R.layout.movie_item;
  460.                 }
  461.  
  462.                 switch (live_tv_content_item_type) {
  463.                     case 0:
  464.                         AppConfig.small_live_tv_channel_item = R.layout.small_live_tv_channel_item;
  465.                         AppConfig.live_tv_channel_item = R.layout.live_tv_channel_item;
  466.                         break;
  467.                     case 1:
  468.                         AppConfig.small_live_tv_channel_item = R.layout.small_live_tv_channel_item_v2;
  469.                         AppConfig.live_tv_channel_item = R.layout.live_tv_channel_item_v2;
  470.                         break;
  471.                     default:
  472.                         AppConfig.small_live_tv_channel_item = R.layout.small_live_tv_channel_item;
  473.                         AppConfig.live_tv_channel_item = R.layout.live_tv_channel_item;
  474.                 }
  475.  
  476.                 switch (webSeriesEpisodeitemType) {
  477.                     case 0:
  478.                         AppConfig.webSeriesEpisodeitem = R.layout.episode_item;
  479.                         break;
  480.                     case 1:
  481.                         AppConfig.webSeriesEpisodeitem = R.layout.episode_item_v2;
  482.                         break;
  483.                     default:
  484.                         AppConfig.webSeriesEpisodeitem = R.layout.episode_item;
  485.                 }
  486.  
  487.                 latestAPKVersionName = jsonObject.get("Latest_APK_Version_Name").getAsString();
  488.                 latestAPKVersionCode = jsonObject.get("Latest_APK_Version_Code").getAsString();
  489.                 apkFileUrl = jsonObject.get("APK_File_URL").getAsString();
  490.                 whatsNewOnLatestApk = jsonObject.get("Whats_new_on_latest_APK").getAsString();
  491.                 updateSkipable = jsonObject.get("Update_Skipable").getAsInt();
  492.                 updateType = jsonObject.get("Update_Type").getAsInt();
  493.                 googleplayAppUpdateType = jsonObject.get("googleplayAppUpdateType").getAsInt();
  494.  
  495.                 String whatsNew = whatsNewOnLatestApk.replace(",", "\n").trim();
  496.  
  497.                 int version = BuildConfig.VERSION_CODE;
  498.                 int latestVersionCode;
  499.                 try{
  500.                     latestVersionCode = Integer.parseInt(latestAPKVersionCode);
  501.                 } catch (NumberFormatException e) {
  502.                     latestVersionCode = 1;
  503.                 }
  504.  
  505.                 int onboarding_status = 0;
  506.                 if(!jsonObject.get("onboarding_status").isJsonNull()) {
  507.                     onboarding_status = jsonObject.get("onboarding_status").getAsInt();
  508.                 }
  509.  
  510.  
  511.                 if(HelperUtils.isFirstOpen(context)) {
  512.                     tinyDB.putBoolean(AUTOPLAY, true);
  513.                     tinyDB.putBoolean(EXTENTIONS, true);
  514.                     tinyDB.putBoolean(SOFTWARE_EXTENTIONS, true);
  515.                     tinyDB.putBoolean("onlyPremium", true);
  516.                     tinyDB.putBoolean("onlyPremiumLiveTV", true);
  517.  
  518.                     if(onboarding_status == 1) {
  519.                         LiquidPager liquidPager = findViewById(R.id.liquidPager);
  520.                         liquidPager.setAdapter(new LiquidPageradepter(getSupportFragmentManager()));
  521.                         liquidPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  522.                             @Override
  523.                             public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
  524.  
  525.                             }
  526.  
  527.                             @Override
  528.                             public void onPageSelected(int position) {
  529.                                 if(position == 3) {
  530.                                     liquidPager.setAdapter(null);
  531.                                     int latestVersionCode;
  532.                                     try{
  533.                                         latestVersionCode = Integer.parseInt(latestAPKVersionCode);
  534.                                     } catch (NumberFormatException e) {
  535.                                         latestVersionCode = 1;
  536.                                     }
  537.                                     if(latestVersionCode > version) {
  538.                                         if(updateType == 2) {
  539.                                             appUpdateManager = AppUpdateManagerFactory.create(context);
  540.                                             Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
  541.                                             appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
  542.                                                 if(googleplayAppUpdateType == 0) {
  543.                                                     if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
  544.                                                             && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
  545.                                                         try {
  546.                                                             appUpdateManager.startUpdateFlowForResult(
  547.                                                                     appUpdateInfo,
  548.                                                                     AppUpdateType.FLEXIBLE,
  549.                                                                     Splash.this,
  550.                                                                     15);
  551.                                                         } catch (IntentSender.SendIntentException e) {
  552.                                                             e.printStackTrace();
  553.                                                         }
  554.  
  555.                                                         InstallStateUpdatedListener listener = state -> {
  556.                                                             if (state.installStatus() == InstallStatus.DOWNLOADED) {
  557.                                                                 Snackbar snackbar =
  558.                                                                         Snackbar.make(
  559.                                                                                 findViewById(R.id.splash),
  560.                                                                                 "An update has just been downloaded.",
  561.                                                                                 Snackbar.LENGTH_INDEFINITE);
  562.                                                                 snackbar.setAction("RESTART", view -> appUpdateManager.completeUpdate());
  563.                                                                 snackbar.setActionTextColor(
  564.                                                                         ContextCompat.getColor(context, R.color.white));
  565.                                                                 snackbar.show();
  566.                                                             }
  567.                                                         };
  568.                                                     }
  569.                                                 } else if(googleplayAppUpdateType == 1) {
  570.                                                     if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
  571.                                                             && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
  572.                                                         try {
  573.                                                             appUpdateManager.startUpdateFlowForResult(
  574.                                                                     appUpdateInfo,
  575.                                                                     AppUpdateType.IMMEDIATE,
  576.                                                                     Splash.this,
  577.                                                                     15);
  578.                                                         } catch (IntentSender.SendIntentException e) {
  579.                                                             e.printStackTrace();
  580.                                                         }
  581.                                                     }
  582.                                                 }
  583.                                             });
  584.                                         } else {
  585.                                             MaterialDialog mDialog = new MaterialDialog.Builder(Splash.this)
  586.                                                     .setTitle("Update "+latestAPKVersionName)
  587.                                                     .setMessage(whatsNew)
  588.                                                     .setCancelable(false)
  589.                                                     .setAnimation(R.raw.rocket_telescope)
  590.                                                     .setNegativeButton(updateSkipable==0?"Exit":"Cancel", R.drawable.ic_baseline_exit, (dialogInterface, which) -> {
  591.                                                         if(updateSkipable == 0) { //NO
  592.                                                             finish();
  593.                                                         } else if(updateSkipable == 1) { //YES
  594.                                                             dialogInterface.dismiss();
  595.                                                             openApp();
  596.                                                         }
  597.                                                     })
  598.                                                     .setPositiveButton("Update!", R.drawable.ic_baseline_exit, (dialogInterface, which) -> {
  599.                                                         if(updateType == 0) {
  600.                                                             Intent intent = new Intent(Splash.this, InAppUpdate.class);
  601.                                                             intent.putExtra("Update_Title", "Update "+latestAPKVersionName);
  602.                                                             intent.putExtra("Whats_new_on_latest_APK", whatsNewOnLatestApk);
  603.                                                             intent.putExtra("APK_File_URL", apkFileUrl);
  604.                                                             startActivity(intent);
  605.                                                         } else if(updateType == 1) {
  606.                                                             Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(apkFileUrl));
  607.                                                             startActivity(intent);
  608.                                                         }
  609.                                                     })
  610.                                                     .build();
  611.                                             mDialog.show();
  612.                                         }
  613.                                     } else {
  614.                                         openApp();
  615.                                     }
  616.                                 }
  617.                             }
  618.  
  619.                             @Override
  620.                             public void onPageScrollStateChanged(int state) {
  621.  
  622.                             }
  623.                         });
  624.                     } else {
  625.                         if(latestVersionCode > version) {
  626.                             if(updateType == 2) {
  627.                                 appUpdateManager = AppUpdateManagerFactory.create(context);
  628.                                 Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
  629.                                 appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
  630.                                     if(googleplayAppUpdateType == 0) {
  631.                                         if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
  632.                                                 && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
  633.                                             try {
  634.                                                 appUpdateManager.startUpdateFlowForResult(
  635.                                                         appUpdateInfo,
  636.                                                         AppUpdateType.FLEXIBLE,
  637.                                                         this,
  638.                                                         15);
  639.                                             } catch (IntentSender.SendIntentException e) {
  640.                                                 e.printStackTrace();
  641.                                             }
  642.  
  643.                                             InstallStateUpdatedListener listener = state -> {
  644.                                                 if (state.installStatus() == InstallStatus.DOWNLOADED) {
  645.                                                     Snackbar snackbar =
  646.                                                             Snackbar.make(
  647.                                                                     findViewById(R.id.splash),
  648.                                                                     "An update has just been downloaded.",
  649.                                                                     Snackbar.LENGTH_INDEFINITE);
  650.                                                     snackbar.setAction("RESTART", view -> appUpdateManager.completeUpdate());
  651.                                                     snackbar.setActionTextColor(
  652.                                                             ContextCompat.getColor(context, R.color.white));
  653.                                                     snackbar.show();
  654.                                                 }
  655.                                             };
  656.                                         }
  657.                                     } else if(googleplayAppUpdateType == 1) {
  658.                                         if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
  659.                                                 && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
  660.                                             try {
  661.                                                 appUpdateManager.startUpdateFlowForResult(
  662.                                                         appUpdateInfo,
  663.                                                         AppUpdateType.IMMEDIATE,
  664.                                                         this,
  665.                                                         15);
  666.                                             } catch (IntentSender.SendIntentException e) {
  667.                                                 e.printStackTrace();
  668.                                             }
  669.                                         }
  670.                                     }
  671.                                 });
  672.                             } else {
  673.                                 MaterialDialog mDialog = new MaterialDialog.Builder(Splash.this)
  674.                                         .setTitle("Update "+latestAPKVersionName)
  675.                                         .setMessage(whatsNew)
  676.                                         .setCancelable(false)
  677.                                         .setAnimation(R.raw.rocket_telescope)
  678.                                         .setNegativeButton(updateSkipable==0?"Exit":"Cancel", R.drawable.ic_baseline_exit, (dialogInterface, which) -> {
  679.                                             if(updateSkipable == 0) { //NO
  680.                                                 finish();
  681.                                             } else if(updateSkipable == 1) { //YES
  682.                                                 dialogInterface.dismiss();
  683.                                                 openApp();
  684.                                             }
  685.                                         })
  686.                                         .setPositiveButton("Update!", R.drawable.ic_baseline_exit, (dialogInterface, which) -> {
  687.                                             if(updateType == 0) {
  688.                                                 Intent intent = new Intent(Splash.this, InAppUpdate.class);
  689.                                                 intent.putExtra("Update_Title", "Update "+latestAPKVersionName);
  690.                                                 intent.putExtra("Whats_new_on_latest_APK", whatsNewOnLatestApk);
  691.                                                 intent.putExtra("APK_File_URL", apkFileUrl);
  692.                                                 startActivity(intent);
  693.                                             } else if(updateType == 1) {
  694.                                                 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(apkFileUrl));
  695.                                                 startActivity(intent);
  696.                                             }
  697.                                         })
  698.                                         .build();
  699.                                 mDialog.show();
  700.                             }
  701.                         } else {
  702.                             openApp();
  703.                         }
  704.                     }
  705.                 } else {
  706.                     if(latestVersionCode > version) {
  707.                         if(updateType == 2) {
  708.                             appUpdateManager = AppUpdateManagerFactory.create(context);
  709.                             Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
  710.                             appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
  711.                                 if(googleplayAppUpdateType == 0) {
  712.                                     if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
  713.                                             && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
  714.                                         try {
  715.                                             appUpdateManager.startUpdateFlowForResult(
  716.                                                     appUpdateInfo,
  717.                                                     AppUpdateType.FLEXIBLE,
  718.                                                     this,
  719.                                                     15);
  720.                                         } catch (IntentSender.SendIntentException e) {
  721.                                             e.printStackTrace();
  722.                                         }
  723.  
  724.                                         InstallStateUpdatedListener listener = state -> {
  725.                                             if (state.installStatus() == InstallStatus.DOWNLOADED) {
  726.                                                 Snackbar snackbar =
  727.                                                         Snackbar.make(
  728.                                                                 findViewById(R.id.splash),
  729.                                                                 "An update has just been downloaded.",
  730.                                                                 Snackbar.LENGTH_INDEFINITE);
  731.                                                 snackbar.setAction("RESTART", view -> appUpdateManager.completeUpdate());
  732.                                                 snackbar.setActionTextColor(
  733.                                                         ContextCompat.getColor(context, R.color.white));
  734.                                                 snackbar.show();
  735.                                             }
  736.                                         };
  737.                                     }
  738.                                 } else if(googleplayAppUpdateType == 1) {
  739.                                     if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
  740.                                             && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
  741.                                         try {
  742.                                             appUpdateManager.startUpdateFlowForResult(
  743.                                                     appUpdateInfo,
  744.                                                     AppUpdateType.IMMEDIATE,
  745.                                                     this,
  746.                                                     15);
  747.                                         } catch (IntentSender.SendIntentException e) {
  748.                                             e.printStackTrace();
  749.                                         }
  750.                                     }
  751.                                 }
  752.                             });
  753.                         } else {
  754.                             MaterialDialog mDialog = new MaterialDialog.Builder(Splash.this)
  755.                                     .setTitle("Update "+latestAPKVersionName)
  756.                                     .setMessage(whatsNew)
  757.                                     .setCancelable(false)
  758.                                     .setAnimation(R.raw.rocket_telescope)
  759.                                     .setNegativeButton(updateSkipable==0?"Exit":"Cancel", R.drawable.ic_baseline_exit, (dialogInterface, which) -> {
  760.                                         if(updateSkipable == 0) { //NO
  761.                                             finish();
  762.                                         } else if(updateSkipable == 1) { //YES
  763.                                             dialogInterface.dismiss();
  764.                                             openApp();
  765.                                         }
  766.                                     })
  767.                                     .setPositiveButton("Update!", R.drawable.ic_baseline_exit, (dialogInterface, which) -> {
  768.                                         if(updateType == 0) {
  769.                                             Intent intent = new Intent(Splash.this, InAppUpdate.class);
  770.                                             intent.putExtra("Update_Title", "Update "+latestAPKVersionName);
  771.                                             intent.putExtra("Whats_new_on_latest_APK", whatsNewOnLatestApk);
  772.                                             intent.putExtra("APK_File_URL", apkFileUrl);
  773.                                             startActivity(intent);
  774.                                         } else if(updateType == 1) {
  775.                                             Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(apkFileUrl));
  776.                                             startActivity(intent);
  777.                                         }
  778.                                     })
  779.                                     .build();
  780.                             mDialog.show();
  781.                         }
  782.                     } else {
  783.                         openApp();
  784.                     }
  785.                 }
  786.             } catch (JWTVerificationException exception){
  787.                 Log.d("test", String.valueOf(exception));
  788.             }
  789.         }, error -> {
  790.             serverError();
  791.         }) {
  792.             @Override
  793.             public Map<String, String> getHeaders() throws AuthFailureError {
  794.                 Map<String,String> params = new HashMap<>();
  795.                 params.put("x-api-key", AppConfig.apiKey);
  796.                 return params;
  797.             }
  798.         };
  799.  
  800.         sr.setRetryPolicy(new DefaultRetryPolicy(5000,
  801.                 DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
  802.                 DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
  803.  
  804.         queue.add(sr);
  805.     }
  806.  
  807.     private void loadRemoteConfig() {
  808.         RequestQueue queue = Volley.newRequestQueue(this);
  809.         StringRequest sr = new StringRequest(Request.Method.GET, Utils.fromBase64("aHR0cHM6Ly9jbG91ZC50ZWFtLWRvb28uY29tL0Rvb28vYXBpL2dldENvbmZpZy5waHA/Y29kZT0=")+AppConfig.bGljZW5zZV9jb2Rl, response -> {
  810.             SharedPreferences sharedPreferences = getSharedPreferences("SharedPreferences", MODE_PRIVATE);
  811.             SharedPreferences.Editor editor = sharedPreferences.edit();
  812.             editor.putString("RemoteConfig", String.valueOf(response));
  813.             editor.apply();
  814.         }, error -> {
  815.             // Do nothing because
  816.         });
  817.  
  818.         sr.setRetryPolicy(new DefaultRetryPolicy(5000,
  819.                 DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
  820.                 DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
  821.  
  822.         queue.add(sr);
  823.     }
  824.  
  825.     void openApp() {
  826.         if(Objects.equals(AppConfig.packageName, "")) {
  827.             RequestQueue queue = Volley.newRequestQueue(this);
  828.             StringRequest sr = new StringRequest(Request.Method.GET, "http://ip-api.com/json", response -> {
  829.                 if(!response.equals("")) {
  830.                     JsonObject rootObject = new Gson().fromJson(response, JsonObject.class);
  831.                     String countryCode = rootObject.get("countryCode").getAsString();
  832.  
  833.                     String[] blocked_regions_array = blocked_regions.split(",");
  834.                     if ( ArrayUtils.contains( blocked_regions_array, countryCode ) ) {
  835.                         SpinKitView spin_kit = findViewById(R.id.spin_kit);
  836.                         spin_kit.setVisibility(View.INVISIBLE);
  837.  
  838.                         final Dialog dialog = new Dialog(context);
  839.                         dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  840.                         dialog.setCancelable(false);
  841.                         dialog.setContentView(R.layout.blocked_country_dialog);
  842.                         dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  843.                         dialog.setCanceledOnTouchOutside(false);
  844.  
  845.                         Button dialogClose = dialog.findViewById(R.id.Dialog_Close);
  846.                         dialogClose.setBackgroundColor(Color.parseColor(AppConfig.primeryThemeColor));
  847.                         dialogClose.setOnClickListener(v1 -> finish());
  848.  
  849.                         dialog.show();
  850.                     } else {
  851.                         initApp();
  852.                     }
  853.                 } else {
  854.                     initApp();
  855.                 }
  856.             }, error -> {
  857.                 initApp();
  858.             });
  859.             queue.add(sr);
  860.         } else if(BuildConfig.APPLICATION_ID.equals(AppConfig.packageName)) {
  861.             RequestQueue queue = Volley.newRequestQueue(this);
  862.             StringRequest sr = new StringRequest(Request.Method.GET, "http://ip-api.com/json", response -> {
  863.                 if(!response.equals("")) {
  864.                     JsonObject rootObject = new Gson().fromJson(response, JsonObject.class);
  865.                     String countryCode = rootObject.get("countryCode").getAsString();
  866.  
  867.                     String[] blocked_regions_array = blocked_regions.split(",");
  868.                     if ( ArrayUtils.contains( blocked_regions_array, countryCode ) ) {
  869.                         SpinKitView spin_kit = findViewById(R.id.spin_kit);
  870.                         spin_kit.setVisibility(View.INVISIBLE);
  871.  
  872.                         final Dialog dialog = new Dialog(context);
  873.                         dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  874.                         dialog.setCancelable(false);
  875.                         dialog.setContentView(R.layout.blocked_country_dialog);
  876.                         dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  877.                         dialog.setCanceledOnTouchOutside(false);
  878.  
  879.                         Button dialogClose = dialog.findViewById(R.id.Dialog_Close);
  880.                         dialogClose.setBackgroundColor(Color.parseColor(AppConfig.primeryThemeColor));
  881.                         dialogClose.setOnClickListener(v1 -> finish());
  882.  
  883.                         dialog.show();
  884.                     } else {
  885.                         initApp();
  886.                     }
  887.                 } else {
  888.                     initApp();
  889.                 }
  890.             }, error -> {
  891.                 initApp();
  892.             });
  893.             queue.add(sr);
  894.         } else {
  895.             Toasty.error(context, "Invalid Package Name!", Toast.LENGTH_SHORT, true).show();
  896.             finish();
  897.         }
  898.  
  899.     }
  900.  
  901.     void initApp() {
  902.         if(checkStoragePermission()) {
  903.             if (maintenance == 0) {
  904.                 if (apiKey.equals(AppConfig.apiKey)) {
  905.                     if(pinLockStatus) {
  906.                         RelativeLayout lockView = findViewById(R.id.lockView);
  907.                         lockView.setVisibility(View.VISIBLE);
  908.                         PinLockView mPinLockView = (PinLockView) findViewById(R.id.pin_lock_view);
  909.                         IndicatorDots mIndicatorDots = (IndicatorDots) findViewById(R.id.indicator_dots);
  910.                         mPinLockView.setPinLockListener(new PinLockListener() {
  911.                             @Override
  912.                             public void onComplete(String pin) {
  913.                                 if(Objects.equals(pin, pinLockPin)) {
  914.                                     lockView.setVisibility(View.GONE);
  915.                                     if (userData == null) {
  916.  
  917.                                         if (AppConfig.adType == 1) {
  918.                                             Application application = getApplication();
  919.                                             if (!(application instanceof AppOpenAdManagerActivity)) {
  920.                                                 mainAppOpen();
  921.                                                 return;
  922.                                             }
  923.                                             ((AppOpenAdManagerActivity) application).showAdIfAvailable(Splash.this, Splash.this::mainAppOpen);
  924.                                         } else {
  925.                                             mainAppOpen();
  926.                                         }
  927.  
  928.                                     } else {
  929.                                         if (AppConfig.adType == 1) {
  930.                                             Application application = getApplication();
  931.                                             if (!(application instanceof AppOpenAdManagerActivity)) {
  932.                                                 Handler handler = new Handler(Looper.getMainLooper());
  933.                                                 handler.postDelayed(Splash.this::verifyUser, 500);
  934.                                                 return;
  935.                                             }
  936.                                             ((AppOpenAdManagerActivity) application).showAdIfAvailable(Splash.this, Splash.this::verifyUser);
  937.                                         } else {
  938.                                             Handler handler = new Handler(Looper.getMainLooper());
  939.                                             handler.postDelayed(Splash.this::verifyUser, 500);
  940.                                         }
  941.                                     }
  942.                                 }
  943.                             }
  944.  
  945.                             @Override
  946.                             public void onEmpty() {
  947.  
  948.                             }
  949.  
  950.                             @Override
  951.                             public void onPinChange(int pinLength, String intermediatePin) {
  952.  
  953.                             }
  954.                         });
  955.                         mPinLockView.attachIndicatorDots(mIndicatorDots);
  956.                         mPinLockView.setPinLength(length(Integer.toString(Integer.parseInt(pinLockPin))));
  957.                         mPinLockView.setTextColor(ContextCompat.getColor(this, R.color.white));
  958.                         mIndicatorDots.setIndicatorType(IndicatorDots.IndicatorType.FILL_WITH_ANIMATION);
  959.                     } else {
  960.                         RelativeLayout lockView = findViewById(R.id.lockView);
  961.                         lockView.setVisibility(View.GONE);
  962.                         if (userData == null) {
  963.  
  964.                             if (AppConfig.adType == 1) {
  965.                                 Application application = getApplication();
  966.                                 if (!(application instanceof AppOpenAdManagerActivity)) {
  967.                                     mainAppOpen();
  968.                                     return;
  969.                                 }
  970.                                 ((AppOpenAdManagerActivity) application).showAdIfAvailable(Splash.this, Splash.this::mainAppOpen);
  971.                             } else {
  972.                                 mainAppOpen();
  973.                             }
  974.  
  975.                         } else {
  976.                             if (AppConfig.adType == 1) {
  977.                                 Application application = getApplication();
  978.                                 if (!(application instanceof AppOpenAdManagerActivity)) {
  979.                                     Handler handler = new Handler(Looper.getMainLooper());
  980.                                     handler.postDelayed(Splash.this::verifyUser, 500);
  981.                                     return;
  982.                                 }
  983.                                 ((AppOpenAdManagerActivity) application).showAdIfAvailable(Splash.this, Splash.this::verifyUser);
  984.                             } else {
  985.                                 Handler handler = new Handler(Looper.getMainLooper());
  986.                                 handler.postDelayed(Splash.this::verifyUser, 500);
  987.                             }
  988.                         }
  989.                     }
  990.                 } else {
  991.                     android.os.Process.killProcess(android.os.Process.myPid());
  992.                 }
  993.             } else {
  994.                 Intent intent = new Intent(Splash.this, Maintenance.class);
  995.                 startActivity(intent);
  996.                 finish();
  997.             }
  998.         } else {
  999.             openApp();
  1000.         }
  1001.     }
  1002.  
  1003.     void mainAppOpen() {
  1004.         if (loginMandatory == 0) {
  1005.             Handler handler = new Handler();
  1006.             handler.postDelayed(() -> {
  1007.                 saveNotification();
  1008.                 Intent intent = new Intent(Splash.this, Home.class);
  1009.                 intent.putExtra("Notification_Data", notificationData);
  1010.                 startActivity(intent);
  1011.                 notificationData = "";
  1012.                 finish();
  1013.             }, 500);
  1014.         } else if (loginMandatory == 1) {
  1015.             Handler handler = new Handler();
  1016.             handler.postDelayed(() -> {
  1017.                 saveNotification();
  1018.                 Intent intent = new Intent(Splash.this, LoginSignup.class);
  1019.                 startActivity(intent);
  1020.                 finish();
  1021.             }, 500);
  1022.         }
  1023.     }
  1024.  
  1025.     void verifyUser() {
  1026.         JsonObject jsonObject = new Gson().fromJson(userData, JsonObject.class);
  1027.         String email = jsonObject.get("Email").getAsString();
  1028.         String password = jsonObject.get("Password").getAsString();
  1029.  
  1030.         String originalInput = "login:"+email+":" + password;
  1031.         String encoded = Utils.toBase64(originalInput);
  1032.  
  1033.         RequestQueue queue = Volley.newRequestQueue(context);
  1034.         StringRequest sr = new StringRequest(Request.Method.POST, AppConfig.url +"authentication", response -> {
  1035.             if(!response.equals("")) {
  1036.                 JsonObject jsonObject1 = new Gson().fromJson(response, JsonObject.class);
  1037.                 String status = jsonObject1.get("Status").toString();
  1038.                 status = status.substring(1, status.length() - 1);
  1039.  
  1040.                 if (status.equals("Successful")) {
  1041.                     saveData(response);
  1042.  
  1043.                     JsonObject subObj = new Gson().fromJson(response, JsonObject.class);
  1044.                     int subscriptionType = subObj.get("subscription_type").getAsInt();
  1045.                     saveUserSubscriptionDetails(subscriptionType);
  1046.  
  1047.                     setOneSignalExternalID(String.valueOf(subObj.get("ID").getAsInt()));
  1048.  
  1049.                     saveNotification();
  1050.                     Intent intent = new Intent(Splash.this, Home.class);
  1051.                     intent.putExtra("Notification_Data", notificationData);
  1052.                     startActivity(intent);
  1053.                     notificationData = "";
  1054.                     finish();
  1055.                 } else if (status.equals("Invalid Credential")) {
  1056.                     deleteData();
  1057.                     if (loginMandatory == 0) {
  1058.                         saveNotification();
  1059.                         Intent intent = new Intent(Splash.this, Home.class);
  1060.                         intent.putExtra("Notification_Data", notificationData);
  1061.                         startActivity(intent);
  1062.                         notificationData = "";
  1063.                         finish();
  1064.                     } else {
  1065.                         Intent intent = new Intent(Splash.this, LoginSignup.class);
  1066.                         startActivity(intent);
  1067.                         finish();
  1068.                     }
  1069.                 }
  1070.             } else {
  1071.                 deleteData();
  1072.                 if (loginMandatory == 0) {
  1073.                     saveNotification();
  1074.                     Intent intent = new Intent(Splash.this, Home.class);
  1075.                     intent.putExtra("Notification_Data", notificationData);
  1076.                     startActivity(intent);
  1077.                     notificationData = "";
  1078.                     finish();
  1079.                 } else {
  1080.                     Intent intent = new Intent(Splash.this, LoginSignup.class);
  1081.                     startActivity(intent);
  1082.                     finish();
  1083.                 }
  1084.             }
  1085.  
  1086.         }, error -> {
  1087.             // Do nothing because
  1088.         }) {
  1089.             @Override
  1090.             public Map<String, String> getHeaders() throws AuthFailureError {
  1091.                 Map<String,String> params = new HashMap<>();
  1092.                 params.put("x-api-key", AppConfig.apiKey);
  1093.                 return params;
  1094.             }
  1095.             @Override
  1096.             protected Map<String,String> getParams(){
  1097.                 Map<String,String> params = new HashMap<>();
  1098.                 params.put("encoded",encoded);
  1099.                 params.put("device", Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID));
  1100.                 return params;
  1101.             }
  1102.         };
  1103.  
  1104.         sr.setRetryPolicy(new DefaultRetryPolicy(5000,
  1105.                 DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
  1106.                 DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
  1107.  
  1108.         queue.add(sr);
  1109.     }
  1110.  
  1111.     private void setOneSignalExternalID(String externalID) {
  1112.         OneSignal.setExternalUserId(externalID, new OneSignal.OSExternalUserIdUpdateCompletionHandler() {
  1113.             @Override
  1114.             public void onSuccess(JSONObject results) {
  1115.                 //Log.d("test", results.toString());
  1116.             }
  1117.             @Override
  1118.             public void onFailure(OneSignal.ExternalIdError error) {
  1119.                 //Log.d("test", error.toString());
  1120.             }
  1121.         });
  1122.     }
  1123.  
  1124.     private void saveUserSubscriptionDetails(int subscriptionType) {
  1125.         RequestQueue queue = Volley.newRequestQueue(context);
  1126.         StringRequest sr = new StringRequest(Request.Method.GET, AppConfig.url +"dmVyaWZ5", response -> {
  1127.             if(!response.equals(Utils.fromBase64("ZmFsc2U=")) && !response.equals(Utils.fromBase64("SW5hY3RpdmUgcHVyY2hhc2UgY29kZQ==")) && !response.equals(Utils.fromBase64("SW52YWxpZCBwdXJjaGFzZSBjb2Rl"))) {
  1128.                 SharedPreferences sharedPreferences = getSharedPreferences("SharedPreferences", MODE_PRIVATE);
  1129.                 SharedPreferences.Editor editor = sharedPreferences.edit();
  1130.                 editor.putString("subscription_type", String.valueOf(subscriptionType));
  1131.                 editor.apply();
  1132.             } else {
  1133.                 SharedPreferences sharedPreferences = getSharedPreferences("SharedPreferences", MODE_PRIVATE);
  1134.                 SharedPreferences.Editor editor = sharedPreferences.edit();
  1135.                 editor.putString("subscription_type", "0");
  1136.                 editor.apply();
  1137.             }
  1138.         }, error -> {
  1139.             SharedPreferences sharedPreferences = getSharedPreferences("SharedPreferences", MODE_PRIVATE);
  1140.             SharedPreferences.Editor editor = sharedPreferences.edit();
  1141.             editor.putString("subscription_type", "0");
  1142.             editor.apply();
  1143.         }) {
  1144.             @Override
  1145.             public Map<String, String> getHeaders() throws AuthFailureError {
  1146.                 Map<String,String> params = new HashMap<>();
  1147.                 params.put("x-api-key", AppConfig.apiKey);
  1148.                 return params;
  1149.             }
  1150.         };
  1151.         sr.setRetryPolicy(new DefaultRetryPolicy(5000,
  1152.                 DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
  1153.                 DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
  1154.         queue.add(sr);
  1155.     }
  1156.  
  1157.     private void saveData(String userData) {
  1158.         SharedPreferences sharedPreferences = getSharedPreferences("SharedPreferences", MODE_PRIVATE);
  1159.         SharedPreferences.Editor editor = sharedPreferences.edit();
  1160.         editor.putString("UserData", userData);
  1161.         editor.apply();
  1162.     }
  1163.  
  1164.     private void deleteData() {
  1165.         SharedPreferences sharedPreferences = getSharedPreferences("SharedPreferences", MODE_PRIVATE);
  1166.         SharedPreferences.Editor editor = sharedPreferences.edit();
  1167.         editor.remove("UserData");
  1168.         editor.apply();
  1169.     }
  1170.  
  1171.     private void saveNotification() {
  1172.         SharedPreferences sharedPreferences = getSharedPreferences("Notificatin_Data", MODE_PRIVATE);
  1173.         SharedPreferences.Editor editor = sharedPreferences.edit();
  1174.         editor.putString("Config", notificationData);
  1175.         editor.apply();
  1176.     }
  1177.  
  1178.     private void saveConfig(String config) {
  1179.         SharedPreferences sharedPreferences = getSharedPreferences("SharedPreferences", MODE_PRIVATE);
  1180.         SharedPreferences.Editor editor = sharedPreferences.edit();
  1181.         editor.putString("Config", config);
  1182.         editor.apply();
  1183.  
  1184.  
  1185.         JsonObject jsonObject = new Gson().fromJson(config, JsonObject.class);
  1186.         AppConfig.adMobNative = jsonObject.get("adMob_Native").isJsonNull() ? "" : jsonObject.get("adMob_Native").getAsString();
  1187.         AppConfig.adMobBanner = jsonObject.get("adMob_Banner").isJsonNull() ? "" : jsonObject.get("adMob_Banner").getAsString();
  1188.         AppConfig.adMobInterstitial = jsonObject.get("adMob_Interstitial").isJsonNull() ? "" : jsonObject.get("adMob_Interstitial").getAsString();
  1189.         AppConfig.adMobAppOpenAd = jsonObject.get("adMob_AppOpenAd").isJsonNull() ? "" : jsonObject.get("adMob_AppOpenAd").getAsString();
  1190.         String StartApp_App_ID = jsonObject.get("StartApp_App_ID").isJsonNull() ? "" : jsonObject.get("StartApp_App_ID").getAsString();
  1191.         String Admob_APP_ID = jsonObject.get("Admob_APP_ID").isJsonNull() ? "" : jsonObject.get("Admob_APP_ID").getAsString();
  1192.         String facebook_app_id = jsonObject.get("facebook_app_id").isJsonNull() ? "" : jsonObject.get("facebook_app_id").getAsString();
  1193.  
  1194.         AppConfig.all_live_tv_type= jsonObject.get("all_live_tv_type").isJsonNull() ? 0 : jsonObject.get("all_live_tv_type").getAsInt();
  1195.         AppConfig.all_movies_type= jsonObject.get("all_movies_type").isJsonNull() ? 0 : jsonObject.get("all_movies_type").getAsInt();
  1196.         AppConfig.all_series_type= jsonObject.get("all_series_type").isJsonNull() ? 0 : jsonObject.get("all_series_type").getAsInt();
  1197.  
  1198.         AppConfig.facebook_banner_ads_placement_id = jsonObject.get("facebook_banner_ads_placement_id").isJsonNull() ? "" : jsonObject.get("facebook_banner_ads_placement_id").getAsString();
  1199.         AppConfig.facebook_interstitial_ads_placement_id = jsonObject.get("facebook_interstitial_ads_placement_id").isJsonNull() ? "" : jsonObject.get("facebook_interstitial_ads_placement_id").getAsString();
  1200.  
  1201.         AppConfig.AdColony_APP_ID= jsonObject.get("AdColony_app_id").isJsonNull() ? "" : jsonObject.get("AdColony_app_id").getAsString();
  1202.         AppConfig.AdColony_BANNER_ZONE_ID= jsonObject.get("AdColony_banner_zone_id").isJsonNull() ? "" : jsonObject.get("AdColony_banner_zone_id").getAsString();
  1203.         AppConfig.AdColony_INTERSTITIAL_ZONE_ID= jsonObject.get("AdColony_interstitial_zone_id").isJsonNull() ? "" : jsonObject.get("AdColony_interstitial_zone_id").getAsString();
  1204.  
  1205.         AppConfig.Unity_Game_ID= jsonObject.get("unity_game_id").isJsonNull() ? "" : jsonObject.get("unity_game_id").getAsString();
  1206.         AppConfig.Unity_Banner_ID= jsonObject.get("unity_banner_id").isJsonNull() ? "" : jsonObject.get("unity_banner_id").getAsString();
  1207.         AppConfig.Unity_rewardedVideo_ID = jsonObject.get("unity_interstitial_id").isJsonNull() ? "" : jsonObject.get("unity_interstitial_id").getAsString();
  1208.  
  1209.         AppConfig.Custom_Banner_url= jsonObject.get("custom_banner_url").isJsonNull() ? "" : jsonObject.get("custom_banner_url").getAsString();
  1210.         AppConfig.Custom_Banner_click_url_type = jsonObject.get("custom_banner_click_url_type").isJsonNull() ? 0 : jsonObject.get("custom_banner_click_url_type").getAsInt();
  1211.         AppConfig.Custom_Banner_click_url= jsonObject.get("custom_banner_click_url").isJsonNull() ? "" : jsonObject.get("custom_banner_click_url").getAsString();
  1212.         AppConfig.Custom_Interstitial_url= jsonObject.get("custom_interstitial_url").isJsonNull() ? "" : jsonObject.get("custom_interstitial_url").getAsString();
  1213.         AppConfig.Custom_Interstitial_click_url_type= jsonObject.get("custom_interstitial_click_url_type").isJsonNull() ? 0 : jsonObject.get("custom_interstitial_click_url_type").getAsInt();
  1214.         AppConfig.Custom_Interstitial_click_url= jsonObject.get("custom_interstitial_click_url").isJsonNull() ? "" : jsonObject.get("custom_interstitial_click_url").getAsString();
  1215.  
  1216.         AppConfig.applovin_sdk_key= jsonObject.get("applovin_sdk_key").isJsonNull() ? "" : jsonObject.get("applovin_sdk_key").getAsString();
  1217.         AppConfig.applovin_apiKey= jsonObject.get("applovin_apiKey").isJsonNull() ? "" : jsonObject.get("applovin_apiKey").getAsString();
  1218.         AppConfig.applovin_Banner_ID= jsonObject.get("applovin_Banner_ID").isJsonNull() ? "" : jsonObject.get("applovin_Banner_ID").getAsString();
  1219.         AppConfig.applovin_Interstitial_ID= jsonObject.get("applovin_Interstitial_ID").isJsonNull() ? "" : jsonObject.get("applovin_Interstitial_ID").getAsString();
  1220.         AppConfig.ironSource_app_key= jsonObject.get("ironSource_app_key").isJsonNull() ? "" : jsonObject.get("ironSource_app_key").getAsString();
  1221.  
  1222.  
  1223.  
  1224.         if(!jsonObject.get("pinLockStatus").isJsonNull()) {
  1225.             if(jsonObject.get("pinLockStatus").getAsInt() == 1) {
  1226.                 pinLockStatus = true;
  1227.             } else {
  1228.                 pinLockStatus = false;
  1229.             }
  1230.         }
  1231.         pinLockPin = jsonObject.get("pinLockPin").isJsonNull() ? "" : jsonObject.get("pinLockPin").getAsString();
  1232.  
  1233.  
  1234.  
  1235.         if(AppConfig.adType == 3) {
  1236.             if(!facebook_app_id.isEmpty()) {
  1237.                 FacebookSdk.setApplicationId(facebook_app_id);
  1238.             }
  1239.         } else if(AppConfig.adType == 2) {
  1240.             if(!StartApp_App_ID.isEmpty()) {
  1241.                 StartAppSDK.initParams(this, StartApp_App_ID)
  1242.                         .setCallback(() -> {
  1243.                             // ready to request ads
  1244.                         })
  1245.                         .init();
  1246.             }
  1247.         }
  1248.  
  1249.         AppConfig.bGljZW5zZV9jb2Rl = jsonObject.get("license_code").isJsonNull() ? "" : jsonObject.get("license_code").getAsString();
  1250.  
  1251.         if (jsonObject.get("safeMode").getAsInt() == 1) {
  1252.             String safeModeVersions = jsonObject.get("safeModeVersions").isJsonNull() ? "" : jsonObject.get("safeModeVersions").getAsString();
  1253.             if(!safeModeVersions.equals("")) {
  1254.                 String[] safeModeVersionsArrey = safeModeVersions.split(",");
  1255.                 for (String safeModeVersion : safeModeVersionsArrey) {
  1256.                     if(BuildConfig.VERSION_NAME.equals(safeModeVersion.trim())) {
  1257.                         AppConfig.safeMode = true;
  1258.                     }
  1259.                 }
  1260.             } else {
  1261.                 AppConfig.safeMode = true;
  1262.             }
  1263.  
  1264.         }
  1265.  
  1266.         if(!jsonObject.get("primeryThemeColor").isJsonNull()) {
  1267.             AppConfig.primeryThemeColor = jsonObject.get("primeryThemeColor").getAsString().isEmpty() ? "#DF4674" : jsonObject.get("primeryThemeColor").getAsString();
  1268.         }
  1269.  
  1270.         AppConfig.packageName = jsonObject.get("package_name").isJsonNull() ? "" : jsonObject.get("package_name").getAsString();
  1271.  
  1272.         if(tinyDB != null) {
  1273.             tinyDB.putInt("splashScreenType", jsonObject.get("splash_screen_type").isJsonNull() ? 0 : jsonObject.get("splash_screen_type").getAsInt());
  1274.             tinyDB.putString("splashImageUrl", jsonObject.get("splash_image_url").isJsonNull() ? "" : jsonObject.get("splash_image_url").getAsString());
  1275.             tinyDB.putString("splashLottieUrl", jsonObject.get("splash_lottie_url").isJsonNull() ? "" : jsonObject.get("splash_lottie_url").getAsString());
  1276.             tinyDB.putString("splashBgColor", jsonObject.get("splash_bg_color").isJsonNull() ? "" : jsonObject.get("splash_bg_color").getAsString());
  1277.         }
  1278.  
  1279.         if(jsonObject.has("image_proxy_status")) {
  1280.             AppConfig.isProxyImages = jsonObject.get("image_proxy_status").getAsInt() == 1;
  1281.         }
  1282.  
  1283.         loadRemoteConfig();
  1284.     }
  1285.  
  1286.  
  1287.     @Override
  1288.     public void onBackPressed() {
  1289.         finish();
  1290.         System.exit(0);
  1291.     }
  1292.  
  1293.     @Override
  1294.     protected void onResume() {
  1295.         super.onResume();
  1296.  
  1297.         if(updateType == 2) {
  1298.             if(googleplayAppUpdateType == 0) {
  1299.                 appUpdateManager
  1300.                         .getAppUpdateInfo()
  1301.                         .addOnSuccessListener(appUpdateInfo -> {
  1302.                             if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) {
  1303.                                 Snackbar snackbar =
  1304.                                         Snackbar.make(
  1305.                                                 findViewById(R.id.splash),
  1306.                                                 "An update has just been downloaded.",
  1307.                                                 Snackbar.LENGTH_INDEFINITE);
  1308.                                 snackbar.setAction("RESTART", view -> appUpdateManager.completeUpdate());
  1309.                                 snackbar.setActionTextColor(
  1310.                                         ContextCompat.getColor(context, R.color.white));
  1311.                                 snackbar.show();
  1312.                             }
  1313.                         });
  1314.             } else if(googleplayAppUpdateType == 1) {
  1315.                 appUpdateManager
  1316.                         .getAppUpdateInfo()
  1317.                         .addOnSuccessListener(
  1318.                                 appUpdateInfo -> {
  1319.                                     if (appUpdateInfo.updateAvailability()
  1320.                                             == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
  1321.                                         try {
  1322.                                             appUpdateManager.startUpdateFlowForResult(
  1323.                                                     appUpdateInfo,
  1324.                                                     AppUpdateType.IMMEDIATE,
  1325.                                                     this,
  1326.                                                     15);
  1327.                                         } catch (IntentSender.SendIntentException e) {
  1328.                                             e.printStackTrace();
  1329.                                         }
  1330.                                     }
  1331.                                 });
  1332.             }
  1333.  
  1334.         }
  1335.     }
  1336.  
  1337.     private void serverError() {
  1338.         SpinKitView spin_kit = findViewById(R.id.spin_kit);
  1339.         if(spin_kit!=null) {
  1340.             spin_kit.setVisibility(View.INVISIBLE);
  1341.         }
  1342.  
  1343.         final Dialog dialog = new Dialog(context);
  1344.         dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  1345.         dialog.setCancelable(false);
  1346.         dialog.setContentView(R.layout.server_not_responding_dialog);
  1347.         dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  1348.         dialog.setCanceledOnTouchOutside(false);
  1349.  
  1350.         Button Dialog_Retry = dialog.findViewById(R.id.Dialog_Retry);
  1351.         Dialog_Retry.setOnClickListener(v1 -> {
  1352.             dialog.dismiss();
  1353.             Intent intent = new Intent(this, Splash.class);
  1354.             this.startActivity(intent);
  1355.             this.finishAffinity();
  1356.         });
  1357.  
  1358.         Button dialogClose = dialog.findViewById(R.id.Dialog_Close);
  1359.         dialogClose.setOnClickListener(v1 -> {
  1360.             dialog.dismiss();
  1361.             System.exit(0);
  1362.         });
  1363.  
  1364.         dialog.show();
  1365.     }
  1366. }
Add Comment
Please, Sign In to add comment