|
|
@ -14,6 +14,7 @@ import java.util.regex.Pattern; |
|
|
|
|
|
|
|
import awais.instagrabber.BuildConfig; |
|
|
|
import awais.instagrabber.R; |
|
|
|
import awaisomereport.CrashReporterHelper; |
|
|
|
|
|
|
|
import static awais.instagrabber.utils.Utils.settingsHelper; |
|
|
|
|
|
|
@ -70,23 +71,23 @@ public final class FlavorTown { |
|
|
|
} |
|
|
|
|
|
|
|
public static void changelogCheck(@NonNull final Context context) { |
|
|
|
if (settingsHelper.getInteger(Constants.PREV_INSTALL_VERSION) < BuildConfig.VERSION_CODE) { |
|
|
|
int appUaCode = settingsHelper.getInteger(Constants.APP_UA_CODE); |
|
|
|
int browserUaCode = settingsHelper.getInteger(Constants.BROWSER_UA_CODE); |
|
|
|
if (browserUaCode == -1 || browserUaCode >= UserAgentUtils.browsers.length) { |
|
|
|
browserUaCode = ThreadLocalRandom.current().nextInt(0, UserAgentUtils.browsers.length); |
|
|
|
settingsHelper.putInteger(Constants.BROWSER_UA_CODE, browserUaCode); |
|
|
|
} |
|
|
|
if (appUaCode == -1 || appUaCode >= UserAgentUtils.devices.length) { |
|
|
|
appUaCode = ThreadLocalRandom.current().nextInt(0, UserAgentUtils.devices.length); |
|
|
|
settingsHelper.putInteger(Constants.APP_UA_CODE, appUaCode); |
|
|
|
} |
|
|
|
final String appUa = UserAgentUtils.generateAppUA(appUaCode, LocaleUtils.getCurrentLocale().getLanguage()); |
|
|
|
settingsHelper.putString(Constants.APP_UA, appUa); |
|
|
|
final String browserUa = UserAgentUtils.generateBrowserUA(browserUaCode); |
|
|
|
settingsHelper.putString(Constants.BROWSER_UA, browserUa); |
|
|
|
Toast.makeText(context, R.string.updated, Toast.LENGTH_SHORT).show(); |
|
|
|
settingsHelper.putInteger(Constants.PREV_INSTALL_VERSION, BuildConfig.VERSION_CODE); |
|
|
|
if (settingsHelper.getInteger(Constants.PREV_INSTALL_VERSION) >= BuildConfig.VERSION_CODE) return; |
|
|
|
int appUaCode = settingsHelper.getInteger(Constants.APP_UA_CODE); |
|
|
|
int browserUaCode = settingsHelper.getInteger(Constants.BROWSER_UA_CODE); |
|
|
|
if (browserUaCode == -1 || browserUaCode >= UserAgentUtils.browsers.length) { |
|
|
|
browserUaCode = ThreadLocalRandom.current().nextInt(0, UserAgentUtils.browsers.length); |
|
|
|
settingsHelper.putInteger(Constants.BROWSER_UA_CODE, browserUaCode); |
|
|
|
} |
|
|
|
if (appUaCode == -1 || appUaCode >= UserAgentUtils.devices.length) { |
|
|
|
appUaCode = ThreadLocalRandom.current().nextInt(0, UserAgentUtils.devices.length); |
|
|
|
settingsHelper.putInteger(Constants.APP_UA_CODE, appUaCode); |
|
|
|
} |
|
|
|
final String appUa = UserAgentUtils.generateAppUA(appUaCode, LocaleUtils.getCurrentLocale().getLanguage()); |
|
|
|
settingsHelper.putString(Constants.APP_UA, appUa); |
|
|
|
final String browserUa = UserAgentUtils.generateBrowserUA(browserUaCode); |
|
|
|
settingsHelper.putString(Constants.BROWSER_UA, browserUa); |
|
|
|
CrashReporterHelper.deleteAllStacktraceFiles(context); |
|
|
|
Toast.makeText(context, R.string.updated, Toast.LENGTH_SHORT).show(); |
|
|
|
settingsHelper.putInteger(Constants.PREV_INSTALL_VERSION, BuildConfig.VERSION_CODE); |
|
|
|
} |
|
|
|
} |