fixed cringe build update detection v2
This commit is contained in:
@@ -8,7 +8,6 @@ import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.concurrent.VTExecutors;
|
||||
import ru.vtosters.lite.downloaders.notifications.NotificationChannels;
|
||||
import ru.vtosters.lite.hooks.ui.SystemThemeChangerHook;
|
||||
import ru.vtosters.lite.ssfs.UsersList;
|
||||
import ru.vtosters.lite.themes.ThemesManager;
|
||||
import ru.vtosters.lite.ui.dialogs.DisableBattery;
|
||||
@@ -39,7 +38,8 @@ public class MainActivityInjector {
|
||||
NotificationChannels.createChannels();
|
||||
}
|
||||
|
||||
if (AndroidUtils.isInstallFromUpdate(activity) && !ThemesUtils.isMonetTheme() && ThemesManager.canApplyCustomAccent()) {
|
||||
if (Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && ThemesManager.canApplyCustomAccent()) {
|
||||
Preferences.updateBuildNumber();
|
||||
updateBinsAndTmpArchive(activity);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ThemesManager {
|
||||
initPaths(app);
|
||||
validateModApk();
|
||||
|
||||
if (!AndroidUtils.isInstallFromUpdate(app) && !ThemesUtils.isMonetTheme() && canApplyCustomAccent()) {
|
||||
if (!Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && canApplyCustomAccent()) {
|
||||
ResourcesLoader.init(app);
|
||||
ResourcesLoader.load(app, modApk.getAbsolutePath(), false);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class Start {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
activity.requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 228);
|
||||
}
|
||||
if (getBoolValue("showAlert", true))
|
||||
if (getBoolValue("showAlert", true) && AndroidUtils.isFirstInstall(activity))
|
||||
new VkAlertDialog.Builder(activity)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(getWelcome())
|
||||
|
||||
@@ -201,14 +201,14 @@ public class AndroidUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isInstallFromUpdate(Context context) {
|
||||
public static boolean isFirstInstall(Context context) {
|
||||
try {
|
||||
long firstInstallTime = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).firstInstallTime;
|
||||
long lastUpdateTime = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).lastUpdateTime;
|
||||
return firstInstallTime != lastUpdateTime;
|
||||
return firstInstallTime == lastUpdateTime;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
import static java.lang.Long.MAX_VALUE;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.setProxy;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPackageName;
|
||||
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters;
|
||||
import static ru.vtosters.lite.utils.SignatureChecker.validateAppSignature;
|
||||
import static ru.vtosters.lite.utils.VTVerifications.isPrometheus;
|
||||
@@ -289,6 +290,24 @@ public class Preferences {
|
||||
public static boolean checkupdates() {
|
||||
return !getBoolValue("isRoamingState", false) && isValidSignature() && BuildConfig.BUILD_TYPE.equals("release");
|
||||
}
|
||||
|
||||
public static boolean isNewBuild() {
|
||||
try {
|
||||
return getPreferences().getLong("setupTime", 0L) != AndroidUtils.getGlobalContext().getPackageManager().getPackageInfo(getPackageName(), 0).lastUpdateTime;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateBuildNumber() {
|
||||
try {
|
||||
getPreferences().edit().putLong("setupTime", AndroidUtils.getGlobalContext().getPackageManager().getPackageInfo(getPackageName(), 0).lastUpdateTime).apply();
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isValidSignature() {
|
||||
try {
|
||||
return validateAppSignature();
|
||||
|
||||
Reference in New Issue
Block a user