Skip to content

Commit

Permalink
added all server features disabler for users who doesnt have unlimite…
Browse files Browse the repository at this point in the history
…d internet
  • Loading branch information
gdlbo committed Jan 30, 2024
1 parent 3b830f5 commit 58c14fb
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import bruhcollective.itaysonlab.libvkx.ILibVkxService;
import com.vk.dto.music.MusicTrack;
import com.vk.music.common.MusicPlaybackLaunchContext;
import ru.vtosters.hooks.other.Preferences;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -33,7 +34,7 @@ public static LibVKXClientImpl getInstance() {
public static boolean isVkxInstalled() {
try {
getGlobalContext().getPackageManager().getPackageInfo("ua.itaysonlab.vkx", 0);
return isValidSignature();
return isValidSignature() && !Preferences.serverFeaturesDisable();
} catch (Exception unused) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/vk/api/audio/AudioGetLyrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public AudioGetLyrics(int lyrics_id, String audio_id, MusicTrack mt) {
public a a(@NonNull JSONObject jSONObject) {
var aVar = new a();

if (Preferences.getBoolValue("useGenius", false)) {
if (Preferences.getBoolValue("useGenius", false) && !Preferences.serverFeaturesDisable()) {
aVar.a = Genius.getTextMusic(musicTrack);
return aVar;
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/vk/music/view/x/LyricsHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void a(AudioGetLyrics.a aVar) {

@Override // com.vk.api.base.ApiCallback
public void a(VKApiExecutionException vKApiExecutionException) {
if (Preferences.getBoolValue("useGenius", false)) {
if (Preferences.getBoolValue("useGenius", false) && !Preferences.serverFeaturesDisable()) {
var text = Genius.getTextMusic(a);
var lyrics = new AudioGetLyrics.a();
lyrics.a = text;
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/ru/vtosters/hooks/MessagesHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.vk.im.ui.providers.audiomsg.ImAudioMsgPlayerProvider;
import com.vk.im.ui.providers.audiomsg.PlayerActionSources;
import com.vtosters.lite.im.ImEngineProvider;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.translators.BaseTranslator;
import ru.vtosters.lite.ui.dialogs.MessageSettings;
import ru.vtosters.lite.utils.LifecycleUtils;
Expand All @@ -20,15 +21,15 @@

public class MessagesHook {
public static String injectOwnText(String oldText) {
if (!autotranslate() || TextUtils.isEmpty(oldText))
if (!autotranslate() && !Preferences.serverFeaturesDisable() || TextUtils.isEmpty(oldText))
return oldText;
var instance = BaseTranslator.getInstance();

return replaceMentions(oldText, instance);
}

public static String injectOwnTextAll(String oldText) {
if (!autoalltranslate() || TextUtils.isEmpty(oldText)) {
if (!autoalltranslate() && !Preferences.serverFeaturesDisable() || TextUtils.isEmpty(oldText)) {
return oldText;
}
var instance = BaseTranslator.getInstance();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ru/vtosters/hooks/other/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public static boolean screenshotdetect() {

@SuppressWarnings("ConstantConditions")
public static boolean checkupdates() {
return !getBoolValue("isRoamingState", false) && isValidSignature() && BuildConfig.BUILD_TYPE.equals("release") && getBoolValue("autoupdates", true);
return !getBoolValue("isRoamingState", false) && isValidSignature() && BuildConfig.BUILD_TYPE.equals("release") && getBoolValue("autoupdates", true) && !serverFeaturesDisable();
}

public static boolean isNewBuild() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,19 +287,21 @@ public void onCreate(Bundle bundle) {

PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), AndroidUtils.getString("sett_other"));

PreferenceFragmentUtils.addMaterialSwitchPreference(
getPreferenceScreen(),
"analyticsDisabled",
AndroidUtils.getString("disable_analytics"),
AndroidUtils.getString("disable_analytics_summ"),
null,
false,
(preference, o) -> {
Preferences.getPreferences().edit().putBoolean("analyticsDisabled", (boolean) o).apply();
LifecycleUtils.restartApplicationWithTimer();
return true;
}
);
if (!Preferences.serverFeaturesDisable()) {
PreferenceFragmentUtils.addMaterialSwitchPreference(
getPreferenceScreen(),
"analyticsDisabled",
AndroidUtils.getString("disable_analytics"),
AndroidUtils.getString("disable_analytics_summ"),
null,
false,
(preference, o) -> {
Preferences.getPreferences().edit().putBoolean("analyticsDisabled", (boolean) o).apply();
LifecycleUtils.restartApplicationWithTimer();
return true;
}
);
}

PreferenceFragmentUtils.addMaterialSwitchPreference(
getPreferenceScreen(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ private void prefs() {
findPreference("lastfm_enabled").setEnabled(false);
}

findPreference("lastfm").setVisible(!Preferences.serverFeaturesDisable());

findPreference("cached_tracks").setSummary(String.format(requireContext().getString(R.string.cached_tracks_counter), MusicCacheImpl.getTracksCount()));
findPreference("cached_tracks").setOnPreferenceClickListener(preference -> {
if (MusicCacheImpl.isEmpty()) {
Expand All @@ -118,6 +120,8 @@ private void prefs() {
return true;
});

findPreference("useGenius").setVisible(!Preferences.serverFeaturesDisable());

findPreference("audio_download").setOnPreferenceClickListener(preference -> {
dlaudio(requireContext());
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ private void prefs() {

findPreference("autotranslate").setEnabled(!Preferences.autoalltranslate());

findPreference("translators").setVisible(!Preferences.serverFeaturesDisable());

findPreference("lang_service").setOnPreferenceClickListener(preference -> {
List<ImagineArrayAdapter.ImagineArrayAdapterItem> items = Arrays.asList(
new ImagineArrayAdapter.ImagineArrayAdapterItem(R.drawable.ic_yandex_translate_icon, "Yandex Translate"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public void onCreate(Bundle bundle) {
}
);

if (Preferences.isValidSignature() && !BuildConfig.BUILD_TYPE.equals("dev")) {
if (Preferences.isValidSignature() && !BuildConfig.BUILD_TYPE.equals("dev") && !Preferences.serverFeaturesDisable()) {
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), requireContext().getString(R.string.updates));

PreferenceFragmentUtils.addPreference(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vtosters.lite.R;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.hooks.other.ThemesUtils;
import ru.vtosters.lite.tgs.TGPref;
import ru.vtosters.lite.ui.adapters.StickerPackAdapter;
Expand Down Expand Up @@ -70,13 +71,15 @@ private static void resetToken(Context ctx) {

@Override
protected void onCreateMenu(Menu menu) {
menu.add(0, 0, 0, "")
.setIcon(ThemesUtils.recolorDrawable(requireContext().getDrawable(R.drawable.ic_add_outline_28)))
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(0, 1, 0, "")
.setIcon(ThemesUtils.recolorDrawable(requireContext().getDrawable(R.drawable.ic_refresh_outline_28)))
.setTitle(AndroidUtils.getString("tgs_token_reset_menu"))
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
if (!Preferences.serverFeaturesDisable()) {
menu.add(0, 0, 0, "")
.setIcon(ThemesUtils.recolorDrawable(requireContext().getDrawable(R.drawable.ic_add_outline_28)))
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(0, 1, 0, "")
.setIcon(ThemesUtils.recolorDrawable(requireContext().getDrawable(R.drawable.ic_refresh_outline_28)))
.setTitle(AndroidUtils.getString("tgs_token_reset_menu"))
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
super.onCreateMenu(menu);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.HashMap;

public class AnalyticsHelper {
private static final boolean analyticsDisabled = Preferences.getBoolValue("analyticsDisabled", false);
private static final boolean analyticsDisabled = Preferences.getBoolValue("analyticsDisabled", false) || Preferences.serverFeaturesDisable();

private static final String key = BuildConfig.APPCENTER_KEY;

Expand Down
2 changes: 1 addition & 1 deletion smali/res/values-be/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7053,7 +7053,7 @@

<string name="update_latest">У вас ўстаноўлена АПОШНЯЯ версія прыкладання</string>
<string name="update_err">Памылка праверкі абнаўлення</string>
<string name="serverFeaturesDisable">Адключыць усю працу з серверам</string>
<string name="serverFeaturesDisable">Адключыць усе знешнія падлучэння</string>
<string name="serverFeaturesDisable_summ">Адключае верыфікацыі і ўсе дадатковыя функцыі звязаныя з атрыманнем дадзеных з сервера ВТостерс</string>

<string name="tgs_token_missing">Токен адсутнічае</string>
Expand Down
4 changes: 2 additions & 2 deletions smali/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6436,8 +6436,8 @@

<string name="update_latest">У вас установлена последняя версия приложения</string>
<string name="update_err">Ошибка проверки обновления</string>
<string name="serverFeaturesDisable">Отключить всю работу с сервером</string>
<string name="serverFeaturesDisable_summ">Отключает галочки и все дополнительные функции связанные с получением данных с сервера ВТостерс</string>
<string name="serverFeaturesDisable">Отключить все внешние подключения</string>
<string name="serverFeaturesDisable_summ">Отключает галочки и все дополнительные функции связанные с получением данных с сервера ВТостерс.\n\nАктульно для тех у кого безлимитный интернет на ВКонтакте</string>

<string name="tgs_token_missing">Токен отсутствует</string>
<string name="tgs_token_reset_dialog">Сбросить токен бота?</string>
Expand Down
2 changes: 1 addition & 1 deletion smali/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6361,7 +6361,7 @@

<string name="update_latest">Вас встановлена остання версія програми</string>
<string name="update_err">Помилка перевірки оновлення</string>
<string name="serverFeaturesDisable">Відключити всю роботу з сервером</string>
<string name="serverFeaturesDisable">Відключити всі зовнішні підключення</string>
<string name="serverFeaturesDisable_summ">Відключає галочки і всі додаткові функції, пов\'язані з отриманням даних з сервера ВТостерс</string>

<string name="tgs_token_missing">Токен відсутній</string>
Expand Down
2 changes: 1 addition & 1 deletion smali/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6573,7 +6573,7 @@ May look like a fake leaving the online"</string>
<string name="sett_autoupdates_summ">Receive notification when a new version of the application is released</string>
<string name="update_latest">You have the latest version of the app installed</string>
<string name="update_err">Error checking for updates</string>
<string name="serverFeaturesDisable">Disable all server processing</string>
<string name="serverFeaturesDisable">Disable all external connections</string>
<string name="serverFeaturesDisable_summ">Disables verifications and all additional functions related to receiving data from the VTosters server</string>

<string name="tgs_token_missing">Token is missing</string>
Expand Down
2 changes: 1 addition & 1 deletion smali/res/xml/preferences_media.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
android:key="audio_download"
android:title="@string/audio_download_title"/>
</PreferenceCategory>
<PreferenceCategory android:title="Last.fm">
<PreferenceCategory android:title="Last.fm" android:key="lastfm">
<Preference
android:key="lastfm_auth"
android:summary="@string/lastfm_auth_summ"
Expand Down
2 changes: 1 addition & 1 deletion smali/res/xml/preferences_messages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
android:key="wbios"
android:title="@string/writebar_ios_title"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/translator_title">
<PreferenceCategory android:title="@string/translator_title" android:key="translators">
<com.vtosters.lite.ui.SummaryListPreference
android:defaultValue="system"
android:dialogTitle="@string/translator_choose_language"
Expand Down

0 comments on commit 58c14fb

Please sign in to comment.