This commit is contained in:
gdlbo
2022-06-16 09:12:39 +03:00
parent a7c85a24f2
commit 92f43acb80
3 changed files with 31 additions and 28 deletions
@@ -21,11 +21,11 @@ import static ru.vtosters.lite.utils.Preferences.ads;
import static ru.vtosters.lite.utils.Preferences.devmenu;
import static ru.vtosters.lite.utils.Preferences.disableSettingsSumms;
import static ru.vtosters.lite.utils.Preferences.hasSpecialVerif;
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
import static ru.vtosters.lite.utils.Preferences.navbar;
import static ru.vtosters.lite.utils.Preferences.offline;
import static ru.vtosters.lite.utils.Preferences.shortinfo;
import static ru.vtosters.lite.utils.Preferences.vkme;
import static ru.vtosters.lite.utils.SignatureChecker.validateAppSignature;
import static ru.vtosters.lite.utils.Themes.applyTheme;
import static ru.vtosters.lite.utils.Themes.getDarkTheme;
import static ru.vtosters.lite.utils.Themes.getImDarkTheme;
@@ -35,7 +35,6 @@ import static ru.vtosters.lite.utils.Themes.setTheme;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -57,8 +56,6 @@ import com.vtosters.lite.fragments.SettingsGeneralFragment;
import com.vtosters.lite.fragments.k.BlacklistFragment;
import com.vtosters.lite.fragments.money.music.control.subscription.MusicSubscriptionControlFragment;
import java.security.NoSuchAlgorithmException;
import ru.vtosters.lite.ui.PreferencesUtil;
import ru.vtosters.lite.ui.dialogs.OTADialog;
import ru.vtosters.lite.ui.fragments.dockbar.DockBarFragment;
@@ -260,12 +257,13 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
PreferencesUtil.addPreference(this, "", getString("vtlmusic"), musicsumm, "ic_music_24", preference -> {
Context context = getContext();
Intent a2 = new Navigator(MusicFragment.class).a(context);
context.startActivity(a2);
return false;
});
if (isValidSignature())
PreferencesUtil.addPreference(this, "", getString("vtlmusic"), musicsumm, "ic_music_24", preference -> {
Context context = getContext();
Intent a2 = new Navigator(MusicFragment.class).a(context);
context.startActivity(a2);
return false;
});
}
PreferencesUtil.addPreference(this, "", getString("vtlmessages"), msgsumm, "ic_message_24", preference -> {
@@ -341,25 +339,21 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
try {
if (validateAppSignature()) {
PreferencesUtil.addPreferenceCategory(this, getString("updates"));
if (isValidSignature()) {
PreferencesUtil.addPreferenceCategory(this, getString("updates"));
PreferencesUtil.addPreference(this, "", getString("checkforupdates"), "", "ic_download_24", preference -> {
OTADialog.checkUpdates(p());
return false;
});
PreferencesUtil.addPreference(this, "", getString("checkforupdates"), "", "ic_download_24", preference -> {
OTADialog.checkUpdates(p());
return false;
});
PreferencesUtil.addMaterialSwitchPreference(this, "checkupdates", getString("checkupdates"), "", "ic_recent_24", true, (preference, o) -> {
boolean value = (boolean) o;
PreferencesUtil.addMaterialSwitchPreference(this, "checkupdates", getString("checkupdates"), "", "ic_recent_24", true, (preference, o) -> {
boolean value = (boolean) o;
edit().putBoolean("checkupdates", value).commit();
edit().putBoolean("checkupdates", value).commit();
return true;
});
}
} catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) {
e.printStackTrace();
return true;
});
}
}
@@ -364,14 +364,23 @@ public class Preferences {
return getBoolValue("roundedmsgs", false);
}
public static boolean checkupdates() throws PackageManager.NameNotFoundException, NoSuchAlgorithmException{
return getBoolValue("checkupdates", true) && validateAppSignature();
public static boolean checkupdates() {
return getBoolValue("checkupdates", true) && isValidSignature();
}
public static boolean disableanimstickers() {
return getBoolValue("disableanimstickers", true);
}
public static boolean isValidSignature() {
try {
return validateAppSignature();
} catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) {
e.printStackTrace();
}
return false;
}
public static boolean disableSettingsSumms() {
return getBoolValue("disableSettingsSumms", false);
}
@@ -43,5 +43,5 @@ public class SignatureChecker {
return decode(APP_SIGNATURE).equals(sha1);
}
return false;
}
} // Sig check to detect actions builds and etc
}